#include #include #include #include #include #include #include #include static void usage(int argc, char **argv, char *message, ...) { if (message) { va_list args; va_start(args, message); vfprintf(stderr, message, args); fprintf(stderr, "\n"); va_end(args); } fprintf(stderr, "usage: %s device\n", argv[0]); exit(1); } int main(int argc, char **argv) { int fd, status; tabby_printer_packet_header header; uint16_t checksum; uint8_t body[TABBY_PRINTER_MAX_PACKET_SIZE]; if (argc != 2) { usage(argc, argv, "No device specified"); } if ((fd = tabby_link_open(argv[1])) < 0) { fprintf(stderr, "%s: %s: %s: %s\n", argv[0], "tabby_link_open()", argv[1], strerror(errno)); goto error_link_open; } while (1) { uint8_t value; status = tabby_printer_packet_recv(fd, &header, &body, &checksum); if (status < 0) { fprintf(stderr, "%s: %s: %s\n", argv[0], "tabby_printer_packet_recv()", strerror(errno)); continue; } } tabby_link_close(fd); return 0; error_link_send: tabby_link_close(fd); error_link_open: return 1; }