mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-05-15 00:02:56 +00:00
Move processing after argument parsing so that arguments do not have to be specified in a magic order
This commit is contained in:
parent
e00645e6c7
commit
0d83cc4f14
@ -319,7 +319,7 @@ int parse_args(int argc, char **argv)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, lines, tape_width;
|
int i, lines = 0, tape_width;
|
||||||
char *line[MAX_LINES];
|
char *line[MAX_LINES];
|
||||||
gdImage *im=NULL;
|
gdImage *im=NULL;
|
||||||
ptouch_dev ptdev=NULL;
|
ptouch_dev ptdev=NULL;
|
||||||
@ -369,10 +369,6 @@ int main(int argc, char *argv[])
|
|||||||
exit(0);
|
exit(0);
|
||||||
} else if (strcmp(&argv[i][1], "-image") == 0) {
|
} else if (strcmp(&argv[i][1], "-image") == 0) {
|
||||||
im=image_load(argv[++i]);
|
im=image_load(argv[++i]);
|
||||||
if (im != NULL) {
|
|
||||||
print_img(ptdev, im);
|
|
||||||
gdImageDestroy(im);
|
|
||||||
}
|
|
||||||
} else if (strcmp(&argv[i][1], "-text") == 0) {
|
} else if (strcmp(&argv[i][1], "-text") == 0) {
|
||||||
for (lines=0; (lines < MAX_LINES) && (i < argc); lines++) {
|
for (lines=0; (lines < MAX_LINES) && (i < argc); lines++) {
|
||||||
if ((i+1 >= argc) || (argv[i+1][0] == '-')) {
|
if ((i+1 >= argc) || (argv[i+1][0] == '-')) {
|
||||||
@ -381,26 +377,30 @@ int main(int argc, char *argv[])
|
|||||||
i++;
|
i++;
|
||||||
line[lines]=argv[i];
|
line[lines]=argv[i];
|
||||||
}
|
}
|
||||||
if ((im=render_text(font_file, line, lines, tape_width)) == NULL) {
|
|
||||||
printf(_("could not render text\n"));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (save_png != NULL) {
|
|
||||||
write_png(im, save_png);
|
|
||||||
} else {
|
|
||||||
print_img(ptdev, im);
|
|
||||||
}
|
|
||||||
gdImageDestroy(im);
|
|
||||||
} else if (strcmp(&argv[i][1], "-cutmark") == 0) {
|
} else if (strcmp(&argv[i][1], "-cutmark") == 0) {
|
||||||
ptouch_cutmark(ptdev);
|
ptouch_cutmark(ptdev);
|
||||||
} else {
|
} else {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!save_png && ptouch_eject(ptdev) != 0) {
|
|
||||||
printf(_("ptouch_eject() failed\n"));
|
if (lines) {
|
||||||
return -1;
|
if ((im=render_text(font_file, line, lines, tape_width)) == NULL) {
|
||||||
|
printf(_("could not render text\n"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (save_png) {
|
||||||
|
write_png(im, save_png);
|
||||||
|
} else {
|
||||||
|
print_img(ptdev, im);
|
||||||
|
if (ptouch_eject(ptdev) != 0) {
|
||||||
|
printf(_("ptouch_eject() failed\n"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gdImageDestroy(im);
|
||||||
ptouch_close(ptdev);
|
ptouch_close(ptdev);
|
||||||
libusb_exit(NULL);
|
libusb_exit(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user