Index: printers.c =================================================================== --- printers.c (revision 4627) +++ printers.c (working copy) @@ -48,6 +48,9 @@ * desktop tools. * write_irix_state() - Update the status files used by IRIX printing * desktop tools. + * check_printer_state_at_load() - Check the printer state at load time. + * For now just verify that a backend exists + * to support the specified printer. */ /* @@ -66,6 +69,8 @@ static void write_irix_state(printer_t *p); #endif /* __sgi */ +static void check_printer_state_at_load(printer_t *p); + /* * 'AddPrinter()' - Add a printer to the system. @@ -876,6 +881,8 @@ { SetPrinterAttrs(p); AddPrinterHistory(p); + check_printer_state_at_load(p); + p = NULL; } else @@ -2684,5 +2691,35 @@ /* + * 'check_printer_state_at_load()' - Check the printer state at load time. + * For now just verify that a backend exists to support the specified + * printer. + */ + +static void +check_printer_state_at_load(printer_t *p) /* I - Printer to check */ +{ + char scheme[255]; /* Scheme protion of device URI */ + char command[1024]; /* Full path to backend command */ + struct stat stat_buf; /* stat buffer for receiving file status */ + + if (!p || !p->device_uri) + return; + + if (strncmp(p->device_uri, "file:", 5) != 0) + { + sscanf(p->device_uri, "%254[^:]", scheme); + snprintf(command, sizeof(command), "%s/backend/%s", ServerBin, scheme); + + if (stat(command, &stat_buf) && errno == ENOENT) + { + LogMessage(L_ERROR, "Backend \"%s\" does not exist.", command); + + StopPrinter(p, 1); + } + } +} + +/* * End of "$Id$". */