X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=filter%2Fcommandtops.c;h=47a49072b12d2be58f7ac810c58f963e30b341e4;hb=4c4eea893b28911e593f4dd5736d0d8830c2e3c9;hp=ea7caf10dce260c8daca890ee79509ab4e490b14;hpb=650d5645ebbdc2e82fc7e9fa210db40a3e0723e7;p=thirdparty%2Fcups.git diff --git a/filter/commandtops.c b/filter/commandtops.c index ea7caf10d..47a49072b 100644 --- a/filter/commandtops.c +++ b/filter/commandtops.c @@ -3,7 +3,7 @@ * * PostScript command filter for CUPS. * - * Copyright 2008 by Apple Inc. + * Copyright 2008-2010 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -14,14 +14,21 @@ * * Contents: * + * main() - Process a CUPS command file. + * auto_configure() - Automatically configure the printer using + * PostScript query commands and/or SNMP lookups. + * begin_ps() - Send the standard PostScript prolog. + * end_ps() - Send the standard PostScript trailer. + * print_self_test_page() - Print a self-test page. + * report_levels() - Report supply levels. */ /* * Include necessary headers... */ -#include -#include +#include +#include #include @@ -30,6 +37,8 @@ */ static void auto_configure(ppd_file_t *ppd, const char *user); +static void begin_ps(ppd_file_t *ppd, const char *user); +static void end_ps(ppd_file_t *ppd); static void print_self_test_page(ppd_file_t *ppd, const char *user); static void report_levels(ppd_file_t *ppd, const char *user); @@ -60,7 +69,9 @@ main(int argc, /* I - Number of command-line arguments */ * and return. */ - fputs("ERROR: commandtops job-id user title copies options [file]\n", stderr); + _cupsLangPrintf(stderr, + _("Usage: %s job-id user title copies options file"), + argv[0]); return (1); } @@ -150,14 +161,7 @@ auto_configure(ppd_file_t *ppd, /* I - PPD file */ * Put the printer in PostScript mode... */ - if (ppd->jcl_begin) - { - fputs(ppd->jcl_begin, stdout); - fputs(ppd->jcl_ps, stdout); - } - - puts("%!"); - fflush(stdout); + begin_ps(ppd, user); /* * Then loop through every option in the PPD file and ask for the current @@ -232,8 +236,41 @@ auto_configure(ppd_file_t *ppd, /* I - PPD file */ * Finish the job... */ + end_ps(ppd); +} + + +/* + * 'begin_ps()' - Send the standard PostScript prolog. + */ + +static void +begin_ps(ppd_file_t *ppd, /* I - PPD file */ + const char *user) /* I - Username */ +{ + (void)user; + if (ppd->jcl_begin) + { fputs(ppd->jcl_begin, stdout); + fputs(ppd->jcl_ps, stdout); + } + + puts("%!"); + puts("userdict dup(\\004)cvn{}put (\\004\\004)cvn{}put\n"); + fflush(stdout); +} + + +/* + * 'end_ps()' - Send the standard PostScript trailer. + */ + +static void +end_ps(ppd_file_t *ppd) /* I - PPD file */ +{ + if (ppd->jcl_end) + fputs(ppd->jcl_end, stdout); else putchar(0x04); @@ -253,13 +290,7 @@ print_self_test_page(ppd_file_t *ppd, /* I - PPD file */ * Put the printer in PostScript mode... */ - if (ppd->jcl_begin) - { - fputs(ppd->jcl_begin, stdout); - fputs(ppd->jcl_ps, stdout); - } - - puts("%!"); + begin_ps(ppd, user); /* * Send a simple file the draws a box around the imageable area and shows @@ -282,12 +313,7 @@ print_self_test_page(ppd_file_t *ppd, /* I - PPD file */ * Finish the job... */ - if (ppd->jcl_begin) - fputs(ppd->jcl_begin, stdout); - else - putchar(0x04); - - fflush(stdout); + end_ps(ppd); } @@ -303,24 +329,18 @@ report_levels(ppd_file_t *ppd, /* I - PPD file */ * Put the printer in PostScript mode... */ - if (ppd->jcl_begin) - { - fputs(ppd->jcl_begin, stdout); - fputs(ppd->jcl_ps, stdout); - } + begin_ps(ppd, user); - puts("%!"); + /* + * Don't bother sending any additional PostScript commands, since we just + * want the backend to have enough time to collect the supply info. + */ /* * Finish the job... */ - if (ppd->jcl_begin) - fputs(ppd->jcl_begin, stdout); - else - putchar(0x04); - - fflush(stdout); + end_ps(ppd); }