summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohny Mattsson <jmattsson@dius.com.au>2017-05-31 15:55:23 +1000
committerJohny Mattsson <jmattsson@dius.com.au>2017-05-31 15:55:23 +1000
commit39b1f985c9037373a435a0c50e33602a06e26369 (patch)
treed3acdf25ee6d9513eff9a5a20c907a5a6c67939b
parent125221e7878e3188e8ce858b76c380e10886e445 (diff)
downloadqlprint-39b1f985c9037373a435a0c50e33602a06e26369.tar.gz
qlprint-39b1f985c9037373a435a0c50e33602a06e26369.tar.xz
qlprint-39b1f985c9037373a435a0c50e33602a06e26369.zip
Added support for variable timeout.
-rw-r--r--src/main.c11
1 files changed, 7 insertions, 4 deletions
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))
{