You can send the control characters in C using unix system calls:
char escp_seq[BYTES_FOR_SEQUENCE];
// ...initialize the ESC/P sequence.
int printer_fd = open("/dev/lp0", O_WRONLY);
ssize_t bytes_written = write(printer_fd, escp_seq, sizeof(escp_seq));
close(printer_fd);
As for the printable data itself, you can use Core Printing.
Using this library, you can use a either
OSStatus PMPrinterPrintWithProvider (
PMPrinter printer,
PMPrintSettings settings,
PMPageFormat format,
CFStringRef mimeType,
CGDataProviderRef provider
);
which would require you to construct a CGDataProviderRef with your data.
Alternatively, you could use a file:
OSStatus PMPrinterPrintWithFile (
PMPrinter printer,
PMPrintSettings settings,
PMPageFormat format,
CFStringRef mimeType,
CFURLRef fileURL
);
I apologize for not being able to give a concrete code example, but I really am not sure how you intend to construct the data that you wish to send to the printer. This should at least provide a basis for you to start hacking around with. I am sure there is more than enough stuff in the above-provided Apple docs to accomplish your task.
Good luck!