From 39b1f985c9037373a435a0c50e33602a06e26369 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Wed, 31 May 2017 15:55:23 +1000 Subject: Added support for variable timeout. --- src/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 4b34ec1..9f1217d 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,7 @@ void syntax(void) fprintf(stderr, "Syntax:\n" " qlprint [-p lp] -i\n" -" [-p lp] [-m margin] [-a] [-C|-D] [-W width] [-L length] [-Q] [-n num] [-t threshold] png...\n" +" [-p lp] [-m margin] [-a] [-C|-D] [-W width] [-L length] [-Q] [-n num] [-t threshold] [-x timeout] png...\n" "Where:\n" " -p lp Printer port (default /dev/usb/lp0)\n" " -i Print status information only, then exit\n" @@ -41,6 +41,7 @@ void syntax(void) " -Q Prioritise quality of speed\n" " -n num Print num copies\n" " -t threshold Threshold for black-vs-white (default 128, i.e. 0-127=black)\n" +" -x timeout Time to wait for successful print, in seconds (default 5)\n" " png... One or more png files to print\n" "\n"); @@ -57,9 +58,10 @@ int main (int argc, char *argv[]) .threshold = 0x80, .flags = 0 }; - int opt; const char *printer = "/dev/usb/lp0"; - while ((opt = getopt(argc, argv, "ip:m:an:CDW:L:Q")) != -1) + unsigned timeout = 5; + int opt; + while ((opt = getopt(argc, argv, "ip:m:an:CDW:L:Qx:")) != -1) { switch(opt) { @@ -77,6 +79,7 @@ int main (int argc, char *argv[]) case 'L': cfg.media_length = atoi(optarg); cfg.flags |= QL_PRINT_CFG_MEDIA_LENGTH; break; case 'Q': cfg.flags |= QL_PRINT_CFG_QUALITY_PRIO; break; + case 'x': timeout = atoi(optarg); break; default: syntax(); } } @@ -171,7 +174,7 @@ for(int i = 0; i < img->height; ++i) argv[i], img->width, img->height); return EXIT_FAILURE; } - alarm(5); + alarm(timeout); do { if (!ql_read_status(ctx, &status)) { -- cgit v1.2.1