[PATCH] cupsys: options parsing and job-sheet attribute to cups-lpd
Anonymous
anonymous at easysw.com
Mon Dec 20 06:45:19 PST 2004
David Decotigny wrote:
> This is a multi-part message in MIME format.
> --------------050307030003020902000907
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
>
>
> Hi,
>
> Michael Sweet wrote:
> > Probably the best thing to do is test with the current release of
> > CUPS (1.1.22) and not a two-year-old version (1.1.17). If the
> > problem persists, report it using the form at:
>
> You're right: this works fine with cups 1.1.22.
>
> But I was not totally satisfied. There was no way to tell cups-lpd:
> "hey, just print the default banners as they are set up in the CUPS server".
>
> So attached is a patch against 1.1.22 that makes this possible: you just
> launch cups-lpd in inetd with the argument "-o job-sheets=DEFAULT"
> instead of "-o job-sheets=banner_head,banner_tail". Without any
> argument, cups-lpd does not print any banner page except if the lpr
> client explicitely asks to print them (as before).
>
> Again and again: forget my previous patch (see 1st message of the
> thread) regarding options.c: this was a buggy patch for a non-buggy
> source ! Shame on me.
>
> --
> David Decotigny -- LLR -- http://polywww.in2p3.fr
>
> --------------050307030003020902000907
> Content-Type: text/x-patch;
> name="patch-cups-lpd.diff"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
> filename="patch-cups-lpd.diff"
>
> diff -ru cups-1.1.22/scheduler/cups-lpd.c MY-cups-1.1.22/scheduler/cups-lpd.c
> --- cups-1.1.22/scheduler/cups-lpd.c 2004-10-04 21:40:35.000000000 +0200
> +++ MY-cups-1.1.22/scheduler/cups-lpd.c 2004-11-10 16:20:32.000000000 +0100
> @@ -533,9 +534,6 @@
> int num_dests; /* Number of destinations */
> cups_dest_t *dests, /* Destinations */
> *destptr; /* Current destination */
> - int num_options; /* Number of options */
> - cups_option_t *options; /* Options */
> - int banner; /* Print banner? */
>
>
> status = 0;
> @@ -760,14 +758,21 @@
> status = 1;
> else
> {
> + char *banner_name; /* Banner name */
> + const char *banner_option;
> +
> /*
> * Grab the job information first...
> */
> -
> title[0] = '\0';
> user[0] = '\0';
> docname[0] = '\0';
> - banner = cupsGetOption("job-sheets", num_defaults, defaults) != NULL;
> +
> + banner_option = cupsGetOption("job-sheets", num_defaults, defaults);
> + if (banner_option != NULL)
> + banner_name = strdup(banner_option);
> + else
> + banner_name = NULL;
>
> while (smart_gets(line, sizeof(line), fp) != NULL)
> {
> @@ -790,7 +795,8 @@
> break;
>
> case 'L' : /* Print banner page */
> - banner = 1;
> + if (banner_name == NULL)
> + banner_name = strdup("DEFAULT");
> break;
> }
>
> @@ -809,6 +815,8 @@
> /*
> * Process control lines...
> */
> + int num_options; /* Number of options */
> + cups_option_t *options; /* Options */
>
> switch (line[0])
> {
> @@ -842,21 +850,37 @@
> options = NULL;
>
> for (i = 0; i < num_defaults; i ++)
> - num_options = cupsAddOption(defaults[i].name,
> - defaults[i].value,
> - num_options, &options);
> + {
> + /* Filter-out the job-sheet option (re-inserted below) */
> + if (strcmp(defaults[i].name, "job-sheets") != 0)
> + num_options = cupsAddOption(defaults[i].name,
> + defaults[i].value,
> + num_options, &options);
> + }
> for (i = 0; i < destptr->num_options; i ++)
> num_options = cupsAddOption(destptr->options[i].name,
> destptr->options[i].value,
> num_options, &options);
>
> /*
> - * Add additional options as needed...
> + * Override by default the printer's banner configuration
> + * - No banner (default) except when lpd client
> + * explicitely requests it
> + * - Set job-sheets attribute to "DEFAULT" to explicitely
> + * always ask for the server default's banners
> + * - Set job-sheets attribute to the any other banners'
> + * names to override the server's configuration
> */
> -
> - if (!banner)
> + if (banner_name == NULL)
> num_options = cupsAddOption("job-sheets", "none",
> num_options, &options);
> + else if (strcmp(banner_name, "DEFAULT") != 0)
> + num_options = cupsAddOption("job-sheets", banner_name,
> + num_options, &options);
> +
> + /*
> + * Add additional options as needed...
> + */
>
> if (line[0] == 'l')
> num_options = cupsAddOption("raw", "", num_options, &options);
> @@ -898,6 +922,8 @@
> }
>
> fclose(fp);
> + if (banner_name != NULL)
> + free(banner_name);
> }
> }
>
>
> --------------050307030003020902000907--
More information about the cups-devel
mailing list