]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/dirsvc.c
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / dirsvc.c
index f2a0b0f628a1ebc508d7de45bb32002eba114e26..8b59c68e2fac6930b0805efbdc631dc8ab2996d3 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: dirsvc.c 5059 2006-02-02 23:17:16Z mike $"
+ * "$Id: dirsvc.c 5117 2006-02-16 14:10:43Z mike $"
  *
  *   Directory services routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2005 by Easy Software Products, all rights reserved.
+ *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Easy Software Products and are protected by Federal
@@ -124,7 +124,14 @@ cupsdLoadRemoteCache(void)
   int                  linenum;        /* Current line number */
   char                 line[1024],     /* Line from file */
                        *value,         /* Pointer to value */
-                       *valueptr;      /* Pointer into value */
+                       *valueptr,      /* Pointer into value */
+                       scheme[32],     /* Scheme portion of URI */
+                       username[64],   /* Username portion of URI */
+                       host[HTTP_MAX_HOST],
+                                       /* Hostname portion of URI */
+                       resource[HTTP_MAX_URI];
+                                       /* Resource portion of URI */
+  int                  port;           /* Port number */
   cupsd_printer_t      *p;             /* Current printer */
   time_t               now;            /* Current time */
 
@@ -167,7 +174,21 @@ cupsdLoadRemoteCache(void)
         cupsdLogMessage(CUPSD_LOG_DEBUG,
                        "cupsdLoadRemoteCache: Loading printer %s...", value);
 
-        p = cupsdAddPrinter(value);
+        if ((p = cupsdFindDest(value)) != NULL)
+       {
+         if (p->type & CUPS_PRINTER_CLASS)
+         {
+           cupsdLogMessage(CUPSD_LOG_WARN,
+                           "Cached remote printer \"%s\" conflicts with "
+                           "existing class!",
+                           value);
+           p = NULL;
+           continue;
+         }
+       }
+       else
+          p = cupsdAddPrinter(value);
+
        p->accepting   = 1;
        p->state       = IPP_PRINTER_IDLE;
        p->type        |= CUPS_PRINTER_REMOTE;
@@ -203,7 +224,11 @@ cupsdLoadRemoteCache(void)
         cupsdLogMessage(CUPSD_LOG_DEBUG,
                        "cupsdLoadRemoteCache: Loading class %s...", value);
 
-        p = cupsdAddClass(value);
+        if ((p = cupsdFindDest(value)) != NULL)
+         p->type = CUPS_PRINTER_CLASS;
+       else
+          p = cupsdAddClass(value);
+
        p->accepting   = 1;
        p->state       = IPP_PRINTER_IDLE;
        p->type        |= CUPS_PRINTER_REMOTE;
@@ -268,6 +293,11 @@ cupsdLoadRemoteCache(void)
     {
       if (value)
       {
+       httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme),
+                       username, sizeof(username), host, sizeof(host), &port,
+                       resource, sizeof(resource));
+
+       cupsdSetString(&p->hostname, host);
        cupsdSetString(&p->uri, value);
        cupsdSetString(&p->device_uri, value);
       }
@@ -2717,5 +2747,5 @@ slp_url_callback(
 
 
 /*
- * End of "$Id: dirsvc.c 5059 2006-02-02 23:17:16Z mike $".
+ * End of "$Id: dirsvc.c 5117 2006-02-16 14:10:43Z mike $".
  */