Re: [Utopia] [patch] HAL backend for CUPS



On Wed, 2004-06-16 at 15:47 -0400, John (J5) Palmieri wrote:
> Here is a little patch to this that fixes the hal backend so that it
> uses the first argument (argv[0]) as the URI.  There is also a fix that
> outputs a dummy printer when no printers are found.  This is needed
> because when cups starts up it enumerates the backends by executing them
> without arguments and parses their output.  If no printers are plugged
> in and hal does not output a dummy printer you will not be able to use
> lpadmin to add a hal device since it will assume there is no hal
> backend.  In other words the hal:// URI will be filtered out as an
> invalid URI.

Ugh.  I really don't like the idea of having an "Unknown" entry in the
HAL backend.  This was part of the reason why I was doing it in the
first place, because the USB backend has so many unknown ones that it's
really ugly (and exposes device nodes to the user...)

Does CUPS ever query the backends except initially at startup?  I
thought it didn't (my own experiments with USB indicated this), and if
so the "Unknown" HAL entry probably isn't necessary at all.

I'm not totally sure, but to me the cleaner way to address the whole
issue of zero-devices vs. backend-error would be for the code which
spawns the backends to check the return code of the backend.  If it's 0,
then there are no backends, otherwise some error happened.

The argv[0] thing is weird but it seems fine.

Joe
> --- cups-1.1.20/backend/hal.c.hal       2004-06-11 16:00:35.000000000 -0400
> +++ cups-1.1.20/backend/hal.c   2004-06-16 14:16:59.000000000 -0400
> @@ -66,6 +66,8 @@
>  
>         printer_list = hal_find_device_by_capability (hal_ctx, "printer",
>                                                       &num_printers);
> +       if (num_printers == 0)
> +               printf("direct hal \"Unknown\" \"Hal printing backend\"\n"); 
>  
>         for (i = 0; i < num_printers; i++) {
>                 const char *vendor, *product, *description;
> @@ -169,7 +171,6 @@
>    unsigned char        status;         /* Port status (off-line, out-of-paper, etc.) */
>  #endif /* __linux */
>  
> -
>   /*
>    * Make sure status messages are not buffered...
>    */
> @@ -201,7 +202,7 @@
>    }
>    else if (argc < 6 || argc > 7)
>    {
> -    fputs("Usage: hal URI job-id user title copies options [file]\n", stderr);
> +    fputs("Usage: URI job-id user title copies options [file]\n", stderr);
>      return (1);
>    }
>  
> @@ -230,11 +231,11 @@
>      copies = atoi(argv[4]);
>    }
>  
> -  device_file = get_device_file (argv[1]);
> +  device_file = get_device_file (argv[0]);
>  
>    if (device_file == NULL) {
>           fprintf (stderr, "ERROR: Unable to open HAL device \"%s\"\n",
> -                  argv[1]);
> +                  argv[0]);
>           return 1;
>    }
>           




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]