]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Now sort PPD files by make, model, and language.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 11 Feb 2000 05:04:15 +0000 (05:04 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 11 Feb 2000 05:04:15 +0000 (05:04 +0000)
Now sort devices by info, class, and uri.

Implicit classes are now handled as special printers.

The directory services now handle the location, info, and make_and_model
attributes.

Updated printer and class templates to show device URI and member names,
respectively.

The parallel backend now looks at the /proc/parport/n/autoprobe file to
get the make and model string for the parallel port, if available.

Added USB backend (needs testing!)

Added template files for form support.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@903 7a7537e8-13f0-0310-91df-b6672ffda945

22 files changed:
backend/Makefile
backend/parallel.c
backend/usb.c [new file with mode: 0644]
config.h.in
cups.list
cups.spec
filter/Makefile
filter/form-attr.c [new file with mode: 0644]
filter/form-main.c [new file with mode: 0644]
filter/form-ps.c [new file with mode: 0644]
filter/form-text.c [new file with mode: 0644]
filter/form-tree.c [new file with mode: 0644]
filter/form.h [new file with mode: 0644]
scheduler/devices.c
scheduler/dirsvc.c
scheduler/job.c
scheduler/ppds.c
scheduler/printers.c
scheduler/printers.h
templates/choose-device.tmpl
templates/classes.tmpl
templates/printers.tmpl

index 47443b042a7c71339950f05c788921cf2ee46b1a..e0ed0a0cf0cf1d70f8f53a44aa9d3d16eac41b7f 100644 (file)
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile,v 1.15 2000/02/08 20:38:41 mike Exp $"
+# "$Id: Makefile,v 1.16 2000/02/11 05:04:12 mike Exp $"
 #
 #   Backend makefile for the Common UNIX Printing System (CUPS).
 #
@@ -24,8 +24,9 @@
 
 include ../Makedefs
 
-TARGETS        =       betest ipp lpd parallel serial socket
-OBJS   =       betest.o ipp.o lpd.o parallel.o serial.o socket.o
+TARGETS        =       betest ipp lpd parallel serial socket usb
+OBJS   =       betest.o ipp.o lpd.o parallel.o serial.o socket.o usb.o
+
 
 #
 # Make all targets...
@@ -33,6 +34,7 @@ OBJS  =       betest.o ipp.o lpd.o parallel.o serial.o socket.o
 
 all:   $(TARGETS)
 
+
 #
 # Clean all object files...
 #
@@ -40,6 +42,7 @@ all:  $(TARGETS)
 clean:
        rm -f $(OBJS) $(TARGETS)
 
+
 #
 # Install all targets...
 #
@@ -49,6 +52,7 @@ install:
        $(CP) $(TARGETS) $(SERVERBIN)/backend
        -$(LN) ipp $(SERVERBIN)/backend/http
 
+
 #
 # betest
 #
@@ -59,6 +63,7 @@ betest:       betest.o ../cups/$(LIBCUPS)
 
 betest.o:      ../cups/string.h ../Makedefs
 
+
 #
 # ipp
 #
@@ -70,6 +75,7 @@ ipp:  ipp.o ../cups/$(LIBCUPS)
 
 ipp.o: ../cups/cups.h ../Makedefs
 
+
 #
 # lpd
 #
@@ -80,6 +86,7 @@ lpd:  lpd.o ../cups/$(LIBCUPS)
 
 lpd.o: ../cups/cups.h ../Makedefs
 
+
 #
 # parallel
 #
@@ -90,6 +97,7 @@ parallel:     parallel.o ../cups/$(LIBCUPS)
 
 parallel.o:    ../cups/cups.h ../Makedefs
 
+
 #
 # serial
 #
@@ -100,6 +108,7 @@ serial:     serial.o ../cups/$(LIBCUPS)
 
 serial.o:      ../cups/cups.h ../Makedefs
 
+
 #
 # socket
 #
@@ -110,6 +119,18 @@ socket:    socket.o ../cups/$(LIBCUPS)
 
 socket.o:      ../cups/cups.h ../Makedefs
 
+
+#
+# usb
+#
+
+usb:   usb.o ../cups/$(LIBCUPS)
+       echo Linking $@...
+       $(CC) $(LDFLAGS) -o usb usb.o $(LIBS)
+
+usb.o: ../cups/cups.h ../Makedefs
+
+
 #
-# End of "$Id: Makefile,v 1.15 2000/02/08 20:38:41 mike Exp $".
+# End of "$Id: Makefile,v 1.16 2000/02/11 05:04:12 mike Exp $".
 #
index cb8459b33848d108ba6a20bf357df9e7449ead37..0a191297e298b89f0cc609b58b53e6a4f244613d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: parallel.c,v 1.13 2000/02/10 00:57:52 mike Exp $"
+ * "$Id: parallel.c,v 1.14 2000/02/11 05:04:12 mike Exp $"
  *
  *   Parallel port backend for the Common UNIX Printing System (CUPS).
  *
@@ -212,27 +212,74 @@ void
 list_devices(void)
 {
 #ifdef __linux
-  int  i;              /* Looping var */
-  int  fd;             /* File descriptor */
-  char device[255];    /* Device filename */
+  int  i;                      /* Looping var */
+  int  fd;                     /* File descriptor */
+  char device[255];            /* Device filename */
+  FILE *probe;                 /* /proc/parport/n/autoprobe file */
+  char line[1024],             /* Line from file */
+       *delim,                 /* Delimiter in file */
+       make[IPP_MAX_NAME],     /* Make from file */
+       model[IPP_MAX_NAME];    /* Model from file */
 
 
   for (i = 0; i < 4; i ++)
   {
-    sprintf(device, "/dev/lp%d", i);
-    if ((fd = open(device, O_WRONLY)) >= 0)
+    sprintf(device, "/proc/parport/%d/autoprobe", i);
+    if ((probe = fopen(device, "r")) != NULL)
     {
-      close(fd);
-      printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
+      memset(make, 0, sizeof(make));
+      memset(model, 0, sizeof(model));
+      strcpy(model, "Unknown");
+
+      while (fgets(line, sizeof(line), probe) != NULL)
+      {
+       /*
+        * Strip trailing ; and/or newline.
+       */
+
+        if ((delim = strrchr(line, ';')) != NULL)
+         *delim = '\0';
+       else if ((delim = strrchr(line, '\n')) != NULL)
+         *delim = '\0';
+
+       /*
+        * Look for MODEL and MANUFACTURER lines...
+       */
+
+        if (strncmp(line, "MODEL:", 6) == 0 &&
+           strncmp(line, "MODEL:Unknown", 13) != 0)
+         strncpy(model, line + 6, sizeof(model) - 1);
+       else if (strncmp(line, "MANUFACTURER:", 13) == 0 &&
+                strncmp(line, "MANUFACTURER:Unknown", 20) != 0)
+         strncpy(make, line + 13, sizeof(make) - 1);
+      }
+
+      fclose(probe);
+
+      if (make[0])
+       printf("direct parallel:/dev/lp%d \"%s %s\" \"Parallel Port #%d\"\n",
+              i, make, model, i + 1);
+      else
+       printf("direct parallel:/dev/lp%d \"%s\" \"Parallel Port #%d\"\n",
+              i, model, i + 1);
     }
     else
     {
-      sprintf(device, "/dev/par%d", i);
+      sprintf(device, "/dev/lp%d", i);
       if ((fd = open(device, O_WRONLY)) >= 0)
       {
        close(fd);
        printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
       }
+      else
+      {
+       sprintf(device, "/dev/par%d", i);
+       if ((fd = open(device, O_WRONLY)) >= 0)
+       {
+         close(fd);
+         printf("direct parallel:%s \"Unknown\" \"Parallel Port #%d\"\n", device, i + 1);
+       }
+      }
     }
   }
 #elif defined(__sgi)
@@ -245,5 +292,5 @@ list_devices(void)
 
 
 /*
- * End of "$Id: parallel.c,v 1.13 2000/02/10 00:57:52 mike Exp $".
+ * End of "$Id: parallel.c,v 1.14 2000/02/11 05:04:12 mike Exp $".
  */
diff --git a/backend/usb.c b/backend/usb.c
new file mode 100644 (file)
index 0000000..7c2b4db
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * "$Id: usb.c,v 1.1 2000/02/11 05:04:12 mike Exp $"
+ *
+ *   USB port backend for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2000 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
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ *   main()         - Send a file to the specified USB port.
+ *   list_devices() - List all USB devices.
+ */
+
+/*
+ * Include necessary headers.
+ */
+
+#include <cups/cups.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <cups/string.h>
+
+#if defined(WIN32) || defined(__EMX__)
+#  include <io.h>
+#else
+#  include <unistd.h>
+#  include <fcntl.h>
+#  include <termios.h>
+#endif /* WIN32 || __EMX__ */
+
+
+/*
+ * Local functions...
+ */
+
+void   list_devices(void);
+
+
+/*
+ * 'main()' - Send a file to the specified USB port.
+ *
+ * Usage:
+ *
+ *    printer-uri job-id user title copies options [file]
+ */
+
+int                    /* O - Exit status */
+main(int  argc,                /* I - Number of command-line arguments (6 or 7) */
+     char *argv[])     /* I - Command-line arguments */
+{
+  char         method[255],    /* Method in URI */
+               hostname[1024], /* Hostname */
+               username[255],  /* Username info (not used) */
+               resource[1024], /* Resource info (device and options) */
+               *options;       /* Pointer to options */
+  int          port;           /* Port number (not used) */
+  FILE         *fp;            /* Print file */
+  int          copies;         /* Number of copies to print */
+  int          fd;             /* Parallel device */
+  int          error;          /* Error code (if any) */
+  size_t       nbytes,         /* Number of bytes written */
+               tbytes;         /* Total number of bytes written */
+  char         buffer[8192];   /* Output buffer */
+  struct termios opts;         /* Parallel port options */
+
+
+  if (argc == 1)
+  {
+    list_devices();
+    return (0);
+  }
+  else if (argc < 6 || argc > 7)
+  {
+    fputs("Usage: USB job-id user title copies options [file]\n", stderr);
+    return (1);
+  }
+
+ /*
+  * If we have 7 arguments, print the file named on the command-line.
+  * Otherwise, send stdin instead...
+  */
+
+  if (argc == 6)
+  {
+    fp     = stdin;
+    copies = 1;
+  }
+  else
+  {
+   /*
+    * Try to open the print file...
+    */
+
+    if ((fp = fopen(argv[6], "rb")) == NULL)
+    {
+      perror("ERROR: unable to open print file");
+      return (1);
+    }
+
+    copies = atoi(argv[4]);
+  }
+
+ /*
+  * Extract the device name and options from the URI...
+  */
+
+  httpSeparate(argv[0], method, username, hostname, &port, resource);
+
+ /*
+  * See if there are any options...
+  */
+
+  if ((options = strchr(resource, '?')) != NULL)
+  {
+   /*
+    * Yup, terminate the device name string and move to the first
+    * character of the options...
+    */
+
+    *options++ = '\0';
+  }
+
+ /*
+  * Open the USB port device...
+  */
+
+  if ((fd = open(resource, O_WRONLY)) == -1)
+  {
+    perror("ERROR: Unable to open USB port device file");
+    return (1);
+  }
+
+ /*
+  * Set any options provided...
+  */
+
+  tcgetattr(fd, &opts);
+
+  opts.c_lflag &= ~(ICANON | ECHO | ISIG);     /* Raw mode */
+
+  /**** No options supported yet ****/
+
+  tcsetattr(fd, TCSANOW, &opts);
+
+ /*
+  * Finally, send the print file...
+  */
+
+  while (copies > 0)
+  {
+    copies --;
+
+    if (fp != stdin)
+    {
+      fputs("PAGE: 1 1\n", stderr);
+      rewind(fp);
+    }
+
+    tbytes = 0;
+    while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0)
+    {
+     /*
+      * Write the print data to the printer...
+      */
+
+      if (write(fd, buffer, nbytes) < nbytes)
+      {
+       perror("ERROR: Unable to send print file to printer");
+       break;
+      }
+      else
+       tbytes += nbytes;
+
+      if (argc > 6)
+       fprintf(stderr, "INFO: Sending print file, %u bytes...\n", tbytes);
+    }
+  }
+
+ /*
+  * Close the socket connection and input file and return...
+  */
+
+  close(fd);
+  if (fp != stdin)
+    fclose(fp);
+
+  return (0);
+}
+
+
+/*
+ * 'list_devices()' - List all USB devices.
+ */
+
+void
+list_devices(void)
+{
+#ifdef __linux
+  int  i;                      /* Looping var */
+  int  is_printer;             /* Printer device? */
+  int  fd;                     /* File descriptor */
+  char device[255];            /* Device filename */
+  FILE *probe;                 /* /proc/parport/n/autoprobe file */
+  char line[1024],             /* Line from file */
+       *delim,                 /* Delimiter in file */
+       make[IPP_MAX_NAME],     /* Make from file */
+       model[IPP_MAX_NAME];    /* Model from file */
+
+
+  if ((probe = fopen("/proc/bus/usb/devices", "r")) != NULL)
+  {
+    i          = 0;
+    is_printer = 0;
+
+    memset(make, 0, sizeof(make));
+    memset(model, 0, sizeof(model));
+
+    while (fgets(line, sizeof(line), probe) != NULL)
+    {
+     /*
+      * Strip trailing newline.
+      */
+
+      if ((delim = strrchr(line, '\n')) != NULL)
+       *delim = '\0';
+
+     /*
+      * See if it is a printer device ("P: ...")
+      */
+
+      if (strncmp(line, "S:", 2) == 0 && is_printer)
+      {
+       /*
+        * String attribute...
+       */
+
+        if (strncmp(line, "S:  Manufacturer=", 17) == 0)
+         strncpy(make, line + 17, sizeof(make) - 1);
+        else if (strncmp(line, "S:  Product=", 12) == 0)
+         strncpy(model, line + 12, sizeof(model) - 1);
+      }
+      else if (is_printer)
+      {
+       /*
+        * We were processing a printer device; send the info out...
+       */
+
+       if (make[0])
+         printf("direct usb:/dev/usblp%d \"%s %s\" \"USB Printer #%d\"\n",
+                i, make, model, i + 1);
+       else if (model[0])
+         printf("direct usb:/dev/usblp%d \"%s\" \"USB Printer #%d\"\n",
+                i, model, i + 1);
+       else
+         printf("direct usb:/dev/usblp%d \"Unknown\" \"USB Printer #%d\"\n",
+                i, i + 1);
+
+        is_printer = strncmp(line, "P:", 2) == 0;
+       i ++;
+
+       memset(make, 0, sizeof(make));
+       memset(model, 0, sizeof(model));
+      }
+    }
+
+    if (is_printer)
+    {
+     /*
+      * We were processing a printer device; send the info out...
+      */
+
+      if (make[0])
+       printf("direct usb:/dev/usblp%d \"%s %s\" \"USB Printer #%d\"\n",
+              i, make, model, i + 1);
+      else if (model[0])
+       printf("direct usb:/dev/usblp%d \"%s\" \"USB Printer #%d\"\n",
+              i, model, i + 1);
+      else
+       printf("direct usb:/dev/usblp%d \"Unknown\" \"USB Printer #%d\"\n",
+              i, i + 1);
+    }
+
+    fclose(probe);
+  }
+  else
+  {
+    for (i = 0; i < 8; i ++)
+    {
+      sprintf(device, "/dev/usblp%d", i);
+      if ((fd = open(device, O_WRONLY)) >= 0)
+      {
+       close(fd);
+       printf("direct usb:%s \"Unknown\" \"USB Printer #%d\"\n", device, i + 1);
+      }
+    }
+  }
+#elif defined(__sgi)
+#elif defined(__sun)
+#elif defined(__hpux)
+#elif defined(__osf)
+#elif defined(FreeBSD) || defined(OpenBSD) || defined(NetBSD)
+#endif
+}
+
+
+/*
+ * End of "$Id: usb.c,v 1.1 2000/02/11 05:04:12 mike Exp $".
+ */
index 776efd7d93cef9b48f36e5786e6239ea2d124bb7..6be1db3df128f9153b2d133af54e62a86a96b896 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: config.h.in,v 1.17 2000/02/08 20:38:40 mike Exp $"
+ * "$Id: config.h.in,v 1.18 2000/02/11 05:04:11 mike Exp $"
  *
  *   Configuration file for the Common UNIX Printing System (CUPS).
  *
@@ -28,7 +28,7 @@
  * Version of software...
  */
 
-#define CUPS_SVERSION  "CUPS v1.1a6"
+#define CUPS_SVERSION  "CUPS v1.1a7"
 
 /*
  * Where are files stored?
 #undef HAVE_WAIT3
 
 /*
- * End of "$Id: config.h.in,v 1.17 2000/02/08 20:38:40 mike Exp $".
+ * End of "$Id: config.h.in,v 1.18 2000/02/11 05:04:11 mike Exp $".
  */
index 76ed283cec59c4c658724e715bf7551f7ab591c1..3c9248faee774d0f382639198d757a841daac0e4 100644 (file)
--- a/cups.list
+++ b/cups.list
@@ -1,5 +1,5 @@
 #
-# "$Id: cups.list,v 1.45 2000/02/10 00:57:51 mike Exp $"
+# "$Id: cups.list,v 1.46 2000/02/11 05:04:11 mike Exp $"
 #
 #   ESP Package Manager (EPM) file list for the Common UNIX Printing
 #   System (CUPS).
@@ -28,7 +28,7 @@
 %vendor Easy Software Products
 %license LICENSE.txt
 %readme README.txt
-%version 1.1a6
+%version 1.1a7
 %incompat printpro
 
 %system all
@@ -39,6 +39,7 @@ f 0555 root sys /usr/lib/cups/backend/lpd backend/lpd
 f 0555 root sys /usr/lib/cups/backend/parallel backend/parallel
 f 0555 root sys /usr/lib/cups/backend/serial backend/serial
 f 0555 root sys /usr/lib/cups/backend/socket backend/socket
+f 0555 root sys /usr/lib/cups/backend/usb backend/usb
 f 0500 root sys /usr/sbin/cupsd scheduler/cupsd
 f 0555 root sys /usr/lib/cups/cgi-bin/admin.cgi cgi-bin/admin.cgi
 f 0555 root sys /usr/lib/cups/cgi-bin/classes.cgi cgi-bin/classes.cgi
@@ -394,5 +395,5 @@ f 0444 root sys /usr/man/man5/printers.conf.5 man/printers.conf.5
 i 0555 root sys cups cups.sh
 
 #
-# End of "$Id: cups.list,v 1.45 2000/02/10 00:57:51 mike Exp $".
+# End of "$Id: cups.list,v 1.46 2000/02/11 05:04:11 mike Exp $".
 #
index f72c1d4a8251935b2622ea0fb6f22a17fb0555f0..05b4876a2967513600cfa89b9cc1dc05f4dcd524 100644 (file)
--- a/cups.spec
+++ b/cups.spec
@@ -1,5 +1,5 @@
 #
-# "$Id: cups.spec,v 1.12 2000/02/08 20:38:40 mike Exp $"
+# "$Id: cups.spec,v 1.13 2000/02/11 05:04:11 mike Exp $"
 #
 #   RPM "spec" file for the Common UNIX Printing System (CUPS).
 #
@@ -26,7 +26,7 @@
 
 Summary: Common Unix Printing System
 Name: cups
-Version: 1.1a6
+Version: 1.1a7
 Release: 0
 Copyright: GPL
 Group: System Environment/Daemons
@@ -111,5 +111,5 @@ rm -rf $RPM_BUILD_ROOT
 /usr/lib/*.a
 
 #
-# End of "$Id: cups.spec,v 1.12 2000/02/08 20:38:40 mike Exp $".
+# End of "$Id: cups.spec,v 1.13 2000/02/11 05:04:11 mike Exp $".
 #
index 642265f27f40203aef9f088b09c07bb5dcb1fcf5..53a27b00b303f2e40e19eb577443f7ea1aee094f 100644 (file)
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile,v 1.24 2000/02/08 20:38:56 mike Exp $"
+# "$Id: Makefile,v 1.25 2000/02/11 05:04:13 mike Exp $"
 #
 #   Filter makefile for the Common UNIX Printing System (CUPS).
 #
@@ -32,9 +32,11 @@ HPGLOBJS =   hpgl-attr.o hpgl-config.o hpgl-main.o hpgl-prolog.o \
 IMAGEOBJS =    image-colorspace.o image-photocd.o image-sgilib.o \
                image-tiff.o image-gif.o image-png.o image-sgi.o image-zoom.o \
                image-jpeg.o image-pnm.o image-sun.o image.o
-OBJS   =       $(HPGLOBJS) $(IMAGEOBJS) imagetops.o imagetoraster.o \
-               common.o pstops.o raster.o rastertoepson.o rastertohp.o \
-               texttops.o textcommon.o
+FORMOBJS =     form-attr.o form-main.o form-ps.o form-text.o form-tree.o
+OBJS   =       $(HPGLOBJS) $(IMAGEOBJS) $(FORMOBJS) \
+               imagetops.o imagetoraster.o common.o pstops.o raster.o \
+               rastertoepson.o rastertohp.o texttops.o textcommon.o
+
 
 #
 # Make all targets...
@@ -42,6 +44,7 @@ OBJS  =       $(HPGLOBJS) $(IMAGEOBJS) imagetops.o imagetoraster.o \
 
 all:   $(TARGETS)
 
+
 #
 # Clean all object files...
 #
@@ -49,6 +52,7 @@ all:  $(TARGETS)
 clean:
        rm -f $(OBJS) $(TARGETS) $(LIBCUPSIMAGE)
 
+
 #
 # Install all targets...
 #
@@ -65,6 +69,17 @@ install:
                $(LN) $(LIBCUPSIMAGE) `basename $(LIBCUPSIMAGE) .1`; \
        fi
 
+
+#
+# formtops
+#
+
+formtops:      $(FORMOBJS) common.o ../Makedefs ../cups/$(LIBCUPS)
+       echo Linking $@...
+       $(CC) $(LDFLAGS) -o $@ $(FORMOBJS) common.o $(LIBS) -lm
+$(FORMOBJS):   form.h
+
+
 #
 # hpgltops
 #
@@ -74,6 +89,7 @@ hpgltops:     $(HPGLOBJS) common.o ../Makedefs ../cups/$(LIBCUPS)
        $(CC) $(LDFLAGS) -o $@ $(HPGLOBJS) common.o $(LIBS) -lm
 $(HPGLOBJS):   hpgltops.h
 
+
 #
 # libcupsimage.so.1, libcupsimage.sl.1
 #
@@ -83,6 +99,7 @@ libcupsimage.so.1 libcupsimage.sl.1:  $(IMAGEOBJS) raster.o ../Makedefs
        $(DSO) $@ $(IMAGEOBJS) raster.o $(DSOLIBS) -lm
        -$(LN) $@ `basename $@ .1`
 
+
 #
 # libcupsimage.a
 #
@@ -96,6 +113,7 @@ libcupsimage.a:      $(IMAGEOBJS) raster.o ../Makedefs
 $(IMAGEOBJS):  image.h
 raster.o:      raster.h
 
+
 #
 # imagetops
 #
@@ -107,6 +125,7 @@ imagetops:  imagetops.o common.o $(LIBCUPSIMAGE) ../Makedefs \
                $(IMGLIBS) $(LIBS)
 imagetops:     common.h image.h
 
+
 #
 # imagetoraster
 #
@@ -118,6 +137,7 @@ imagetoraster:      imagetoraster.o common.o $(LIBCUPSIMAGE) ../Makedefs \
                $(IMGLIBS) $(LIBS)
 imagetoraster: common.h image.h raster.h
 
+
 #
 # pstops
 #
@@ -127,6 +147,7 @@ pstops:     pstops.o common.o ../Makedefs ../cups/$(LIBCUPS)
        $(CC) $(LDFLAGS) -o $@ pstops.o common.o $(LIBS)
 pstops.o:      common.h
 
+
 #
 # rastertoepson
 #
@@ -136,6 +157,7 @@ rastertoepson:      rastertoepson.o ../Makedefs ../cups/$(LIBCUPS)
        $(CC) $(LDFLAGS) -o $@ rastertoepson.o -L. -lcupsimage $(LIBS)
 rastertoepson.o:       raster.h
 
+
 #
 # rastertohp
 #
@@ -145,6 +167,7 @@ rastertohp: rastertohp.o ../Makedefs ../cups/$(LIBCUPS)
        $(CC) $(LDFLAGS) -o $@ rastertohp.o -L. -lcupsimage $(LIBS)
 rastertohp.o:  raster.h
 
+
 #
 # texttops
 #
@@ -157,8 +180,11 @@ texttops.o:        common.h textcommon.h
 
 common.o:      common.h
 textcommon.o:  textcommon.h common.h
+
+
 $(OBJS):       ../Makedefs ../cups/cups.h ../cups/ppd.h ../cups/language.h
 
+
 #
-# End of "$Id: Makefile,v 1.24 2000/02/08 20:38:56 mike Exp $".
+# End of "$Id: Makefile,v 1.25 2000/02/11 05:04:13 mike Exp $".
 #
diff --git a/filter/form-attr.c b/filter/form-attr.c
new file mode 100644 (file)
index 0000000..5b87133
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * "$Id: form-attr.c,v 1.1 2000/02/11 05:04:13 mike Exp $"
+ *
+ *   CUPS form attribute routines for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2000 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "form.h"
+
+
+/*
+ * End of "$Id: form-attr.c,v 1.1 2000/02/11 05:04:13 mike Exp $".
+ */
diff --git a/filter/form-main.c b/filter/form-main.c
new file mode 100644 (file)
index 0000000..0251d5f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * "$Id: form-main.c,v 1.1 2000/02/11 05:04:13 mike Exp $"
+ *
+ *   CUPS form main entry for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2000 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "form.h"
+
+
+/*
+ * End of "$Id: form-main.c,v 1.1 2000/02/11 05:04:13 mike Exp $".
+ */
diff --git a/filter/form-ps.c b/filter/form-ps.c
new file mode 100644 (file)
index 0000000..009a782
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * "$Id: form-ps.c,v 1.1 2000/02/11 05:04:13 mike Exp $"
+ *
+ *   CUPS form PostScript routines for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2000 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "form.h"
+
+
+/*
+ * End of "$Id: form-ps.c,v 1.1 2000/02/11 05:04:13 mike Exp $".
+ */
diff --git a/filter/form-text.c b/filter/form-text.c
new file mode 100644 (file)
index 0000000..6087ea4
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * "$Id: form-text.c,v 1.1 2000/02/11 05:04:13 mike Exp $"
+ *
+ *   CUPS form text routines for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2000 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "form.h"
+
+
+/*
+ * End of "$Id: form-text.c,v 1.1 2000/02/11 05:04:13 mike Exp $".
+ */
diff --git a/filter/form-tree.c b/filter/form-tree.c
new file mode 100644 (file)
index 0000000..265a256
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * "$Id: form-tree.c,v 1.1 2000/02/11 05:04:13 mike Exp $"
+ *
+ *   CUPS form document tree routines for the Common UNIX Printing
+ *   System (CUPS).
+ *
+ *   Copyright 1997-2000 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "form.h"
+
+
+/*
+ * End of "$Id: form-tree.c,v 1.1 2000/02/11 05:04:13 mike Exp $".
+ */
diff --git a/filter/form.h b/filter/form.h
new file mode 100644 (file)
index 0000000..469f82c
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * "$Id: form.h,v 1.1 2000/02/11 05:04:13 mike Exp $"
+ *
+ *   CUPS form header file for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2000 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636-3111 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "common.h"
+
+
+/*
+ * End of "$Id: form.h,v 1.1 2000/02/11 05:04:13 mike Exp $".
+ */
index 970a38e996b0b694c4771e5c822ab7189ad3b7de..3c53af5e39cac66f8c9f4bbaf11b820ab2c12c5d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: devices.c,v 1.2 2000/02/10 00:57:54 mike Exp $"
+ * "$Id: devices.c,v 1.3 2000/02/11 05:04:14 mike Exp $"
  *
  *   Device scanning routines for the Common UNIX Printing System (CUPS).
  *
@@ -51,6 +51,35 @@ typedef struct direct DIRENT;
 #endif
 
 
+/*
+ * Device information structure...
+ */
+
+typedef struct
+{
+  char device_class[128],              /* Device class */
+       device_make_and_model[128],     /* Make and model, if known */
+       device_info[128],               /* Device info/description */
+       device_uri[1024];               /* Device URI */
+} dev_info_t;
+
+
+/*
+ * Local globals...
+ */
+
+static int             num_devs,       /* Number of devices */
+                       alloc_devs;     /* Number of allocated entries */
+static dev_info_t      *devs;          /* Device info */
+
+
+/*
+ * Local functions...
+ */
+
+static int     compare_devs(const dev_info_t *p0, const dev_info_t *p1);
+
+
 /*
  * 'LoadDevices()' - Load all available devices.
  */
@@ -58,6 +87,7 @@ typedef struct direct DIRENT;
 void
 LoadDevices(const char *d)     /* I - Directory to scan */
 {
+  int          i;              /* Looping var */
   FILE         *fp;            /* Pipe to device backend */
   DIR          *dir;           /* Directory pointer */
   DIRENT       *dent;          /* Directory entry */
@@ -67,7 +97,12 @@ LoadDevices(const char *d)   /* I - Directory to scan */
                uri[1024],      /* Device URI */
                info[128],      /* Device info */
                make_model[256];/* Make and model */
+  dev_info_t   *dev;           /* Current device */
+
 
+ /*
+  * We always support the "file" device...
+  */
 
   Devices = ippNew();
 
@@ -80,6 +115,10 @@ LoadDevices(const char *d)  /* I - Directory to scan */
   ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_URI,
                "device-uri", NULL, "file");
 
+ /*
+  * Try opening the backend directory...
+  */
+
   if ((dir = opendir(d)) == NULL)
   {
     LogMessage(L_ERROR, "LoadDevices: Unable to open backend directory \"%s\": %s",
@@ -87,6 +126,18 @@ LoadDevices(const char *d)  /* I - Directory to scan */
     return;
   }
 
+ /*
+  * Setup the devices array...
+  */
+
+  alloc_devs = 0;
+  num_devs   = 0;
+  devs       = (dev_info_t *)0;
+
+ /*
+  * Loop through all of the device backends...
+  */
+
   while ((dent = readdir(dir)) != NULL)
   {
    /*
@@ -125,20 +176,43 @@ LoadDevices(const char *d)        /* I - Directory to scan */
        else
        {
         /*
-         * Add strings to attributes...
+         * Add the device to the array of available devices...
          */
 
-          ippAddSeparator(Devices);
-          ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
-                       "device-class", NULL, dclass);
-          ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                       "device-info", NULL, info);
-          ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                       "device-make-and-model", NULL, make_model);
-          ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_URI,
-                       "device-uri", NULL, uri);
-
-          LogMessage(L_DEBUG, "LoadDevices: Adding device \"%s\"...", uri);
+         if (num_devs >= alloc_devs)
+         {
+          /*
+           * Allocate (more) memory for the PPD files...
+           */
+
+           if (alloc_devs == 0)
+              dev = malloc(sizeof(dev_info_t) * 16);
+           else
+              dev = realloc(devs, sizeof(dev_info_t) * (alloc_devs + 16));
+
+           if (dev == NULL)
+           {
+              LogMessage(L_ERROR, "load_devs: Ran out of memory for %d devices!",
+                        alloc_devs + 16);
+              closedir(dir);
+             return;
+           }
+
+           devs = dev;
+           alloc_devs += 16;
+         }
+
+         dev = devs + num_devs;
+         num_devs ++;
+
+         memset(dev, 0, sizeof(dev_info_t));
+         strncpy(dev->device_class, dclass, sizeof(dev->device_class) - 1);
+         strncpy(dev->device_info, info, sizeof(dev->device_info) - 1);
+         strncpy(dev->device_make_and_model, make_model,
+                 sizeof(dev->device_make_and_model) - 1);
+         strncpy(dev->device_uri, uri, sizeof(dev->device_uri) - 1);
+
+          LogMessage(L_DEBUG, "LoadDevices: Added device \"%s\"...", uri);
        }
       }
 
@@ -150,9 +224,167 @@ LoadDevices(const char *d)        /* I - Directory to scan */
   }
 
   closedir(dir);
+
+ /*
+  * Sort the available devices...
+  */
+
+  if (num_devs > 1)
+    qsort(devs, num_devs, sizeof(dev_info_t),
+          (int (*)(const void *, const void *))compare_devs);
+
+ /*
+  * Create the list of devices...
+  */
+
+  for (i = num_devs, dev = devs; i > 0; i --, dev ++)
+  {
+   /*
+    * Add strings to attributes...
+    */
+
+    ippAddSeparator(Devices);
+    ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                 "device-class", NULL, dev->device_class);
+    ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+                 "device-info", NULL, dev->device_info);
+    ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+                 "device-make-and-model", NULL, dev->device_make_and_model);
+    ippAddString(Devices, IPP_TAG_PRINTER, IPP_TAG_URI,
+                 "device-uri", NULL, dev->device_uri);
+  }
+
+ /*
+  * Free the devices array...
+  */
+
+  if (alloc_devs)
+    free(devs);
+}
+
+
+/*
+ * 'compare_devs()' - Compare PPD file make and model names for sorting.
+ */
+
+static int                             /* O - Result of comparison */
+compare_devs(const dev_info_t *d0,     /* I - First PPD file */
+             const dev_info_t *d1)     /* I - Second PPD file */
+{
+  const char   *s,                     /* First name */
+               *t;                     /* Second name */
+  int          diff,                   /* Difference between digits */
+               digits;                 /* Number of digits */
+
+
+ /* 
+  * First compare names...
+  */
+
+  s = d0->device_info;
+  t = d1->device_info;
+
+ /*
+  * Loop through both nicknames, returning only when a difference is
+  * seen.  Also, compare whole numbers rather than just characters, too!
+  */
+
+  while (*s && *t)
+  {
+    if (isdigit(*s) && isdigit(*t))
+    {
+     /*
+      * Got a number; start by skipping leading 0's...
+      */
+
+      while (*s == '0')
+        s ++;
+      while (*t == '0')
+        t ++;
+
+     /*
+      * Skip equal digits...
+      */
+
+      while (isdigit(*s) && *s == *t)
+      {
+        s ++;
+       t ++;
+      }
+
+     /*
+      * Bounce out if *s and *t aren't both digits...
+      */
+
+      if (isdigit(*s) && !isdigit(*t))
+        return (1);
+      else if (!isdigit(*s) && isdigit(*t))
+        return (-1);
+      else if (!isdigit(*s) || !isdigit(*t))
+        continue;     
+
+      if (*s < *t)
+        diff = -1;
+      else
+        diff = 1;
+
+     /*
+      * Figure out how many more digits there are...
+      */
+
+      digits = 0;
+      s ++;
+      t ++;
+
+      while (isdigit(*s))
+      {
+        digits ++;
+       s ++;
+      }
+
+      while (isdigit(*t))
+      {
+        digits --;
+       t ++;
+      }
+
+     /*
+      * Return if the number or value of the digits is different...
+      */
+
+      if (digits < 0)
+        return (-1);
+      else if (digits > 0)
+        return (1);
+      else if (diff)
+        return (diff);
+    }
+    else if (tolower(*s) < tolower(*t))
+      return (-1);
+    else if (tolower(*s) > tolower(*t))
+      return (1);
+    else
+    {
+      s ++;
+      t ++;
+    }
+  }
+
+ /*
+  * Return the results of the final comparison...
+  */
+
+  if (*s)
+    return (1);
+  else if (*t)
+    return (-1);
+  else if ((diff = strcasecmp(d0->device_class, d1->device_class)) != 0)
+    return (diff);
+  else
+    return (strcasecmp(d0->device_uri, d1->device_uri));
 }
 
 
 /*
- * End of "$Id: devices.c,v 1.2 2000/02/10 00:57:54 mike Exp $".
+ * End of "$Id: devices.c,v 1.3 2000/02/11 05:04:14 mike Exp $".
  */
index 5e464e8fe565755270d5585e977870e172340962..2ebd9f92b6e8bb62f52a27e3097463ca8747babc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: dirsvc.c,v 1.47 2000/02/08 20:38:59 mike Exp $"
+ * "$Id: dirsvc.c,v 1.48 2000/02/11 05:04:14 mike Exp $"
  *
  *   Directory services routines for the Common UNIX Printing System (CUPS).
  *
@@ -159,7 +159,10 @@ UpdateBrowseList(void)
                method[HTTP_MAX_URI],   /* Method portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
-               resource[HTTP_MAX_URI]; /* Resource portion of URI */
+               resource[HTTP_MAX_URI], /* Resource portion of URI */
+               info[IPP_MAX_NAME],     /* Information string */
+               location[IPP_MAX_NAME], /* Location string */
+               make_model[IPP_MAX_NAME];/* Make and model string */
   int          port;                   /* Port portion of URI */
   char         name[IPP_MAX_NAME],     /* Name of printer */
                *hptr,                  /* Pointer into hostname */
@@ -208,14 +211,22 @@ UpdateBrowseList(void)
   packet[bytes] = '\0';
 #endif /* DEBUG */
 
-  if (sscanf(packet, "%x%x%1023s", &type, &state, uri) != 3)
+  location[0]   = '\0';
+  info[0]       = '\0';
+  make_model[0] = '\0';
+
+  if (sscanf(packet,
+             "%x%x%1023s%*[^\"]\"%127[^\"]%*[^\"]\"%127[^\"]%*[^\"]\"%127[^\"]",
+             &type, &state, uri, location, info, make_model) < 3)
   {
     LogMessage(L_WARN, "UpdateBrowseList: Garbled browse packet - %s",
                packet);
     return;
   }
 
-  DEBUG_printf(("type=%x, state=%x, uri=\"%s\"\n", type, state, uri));
+  DEBUG_printf(("type=%x, state=%x, uri=\"%s\"\n"
+                "location=\"%s\", info=\"%s\", make_model=\"%s\"\n",
+               type, state, uri, location, info, make_model));
 
  /*
   * Pull the URI apart to see if this is a local or remote printer...
@@ -267,6 +278,12 @@ UpdateBrowseList(void)
       strcpy(p->uri, uri);
       strcpy(p->device_uri, uri);
       strcpy(p->hostname, host);
+
+      strcpy(p->location, "Location Unknown");
+      strcpy(p->info, "No Information Available");
+      snprintf(p->make_model, sizeof(p->make_model), "Remote Class on %s",
+               host);
+
       SetPrinterAttrs(p);
     }
   }
@@ -297,6 +314,12 @@ UpdateBrowseList(void)
       strcpy(p->uri, uri);
       strcpy(p->device_uri, uri);
       strcpy(p->hostname, host);
+
+      strcpy(p->location, "Location Unknown");
+      strcpy(p->info, "No Information Available");
+      snprintf(p->make_model, sizeof(p->make_model), "Remote Printer on %s",
+               host);
+
       SetPrinterAttrs(p);
     }
   }
@@ -310,6 +333,13 @@ UpdateBrowseList(void)
   p->accepting   = state != IPP_PRINTER_STOPPED;
   p->browse_time = time(NULL);
 
+  if (location[0])
+    strcpy(p->location, location);
+  if (info[0])
+    strcpy(p->info, info);
+  if (make_model[0])
+    strcpy(p->make_model, make_model);
+
  /*
   * See if we have a default printer...  If not, make the first printer the
   * default.
@@ -354,13 +384,13 @@ UpdateBrowseList(void)
        * we have a class, and if this printer is a member...
        */
 
-        if ((pclass = FindClass(name)) == NULL)
+        if ((pclass = FindPrinter(name)) == NULL)
        {
         /*
          * Need to add the class...
          */
 
-         pclass = AddClass(name);
+         pclass = AddPrinter(name);
          pclass->type      |= CUPS_PRINTER_IMPLICIT;
          pclass->accepting = 1;
          pclass->state     = IPP_PRINTER_IDLE;
@@ -406,7 +436,8 @@ UpdateBrowseList(void)
        name[len] = '\0';
        offset    = 0;
 
-       if (FindPrinter(name) != NULL)
+       if ((pclass = FindPrinter(name)) != NULL &&
+           !(pclass->type & CUPS_PRINTER_IMPLICIT))
        {
         /*
          * Can't use same name as printer; add "Any" to the front of the
@@ -439,7 +470,7 @@ SendBrowseList(void)
   time_t               ut,     /* Minimum update time */
                        to;     /* Timeout time */
   int                  bytes;  /* Length of packet */
-  char                 packet[1540];
+  char                 packet[1453];
                                /* Browse data packet */
 
 
@@ -482,8 +513,10 @@ SendBrowseList(void)
 
       p->browse_time = time(NULL);
 
-      sprintf(packet, "%x %x %s\n", p->type | CUPS_PRINTER_REMOTE, p->state,
-              p->uri);
+      snprintf(packet, sizeof(packet), "%x %x %s \"%s\" \"%s\" \"%s\"\n",
+               p->type | CUPS_PRINTER_REMOTE, p->state, p->uri,
+              p->location, p->info, p->make_model);
+
       bytes = strlen(packet);
       DEBUG_printf(("SendBrowseList: (%d bytes) %s", bytes, packet));
 
@@ -509,5 +542,5 @@ SendBrowseList(void)
 
 
 /*
- * End of "$Id: dirsvc.c,v 1.47 2000/02/08 20:38:59 mike Exp $".
+ * End of "$Id: dirsvc.c,v 1.48 2000/02/11 05:04:14 mike Exp $".
  */
index 2fcb9c8e099c904beb9abb5cd7eaa450d7aa6037..ef9d9f19deb6d7ef69d2bdd9febf3f5b763a7658 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: job.c,v 1.53 2000/02/08 20:39:00 mike Exp $"
+ * "$Id: job.c,v 1.54 2000/02/11 05:04:14 mike Exp $"
  *
  *   Job management routines for the Common UNIX Printing System (CUPS).
  *
@@ -252,7 +252,8 @@ CheckJobs(void)
 {
   job_t                *current,       /* Current job in queue */
                *prev;          /* Previous job in queue */
-  printer_t    *printer;       /* Printer/class destination */
+  printer_t    *printer,       /* Printer destination */
+               *pclass;        /* Printer class destination */
 
 
   DEBUG_puts("CheckJobs()");
@@ -270,12 +271,22 @@ CheckJobs(void)
     {
       DEBUG_printf(("CheckJobs: current->dest = \'%s\'\n", current->dest));
 
-      if (FindClass(current->dest) != NULL)
+      if ((pclass = FindClass(current->dest)) != NULL)
         printer = FindAvailablePrinter(current->dest);
       else
         printer = FindPrinter(current->dest);
 
-      if (printer == NULL && FindClass(current->dest) == NULL)
+      if (printer != NULL && (printer->type & CUPS_PRINTER_IMPLICIT))
+      {
+       /*
+        * Handle implicit classes...
+       */
+
+        pclass  = printer;
+        printer = FindAvailablePrinter(current->dest);
+      }
+
+      if (printer == NULL && pclass == NULL)
       {
        /*
         * Whoa, the printer and/or class for this destination went away;
@@ -2164,5 +2175,5 @@ start_process(const char *command,        /* I - Full path to command */
 
 
 /*
- * End of "$Id: job.c,v 1.53 2000/02/08 20:39:00 mike Exp $".
+ * End of "$Id: job.c,v 1.54 2000/02/11 05:04:14 mike Exp $".
  */
index ed21529148cf48faaaa58743022a830a53fde896..ca4fb1804cb67ad183d0e39ca49cc58f1f8b47ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppds.c,v 1.3 2000/02/10 00:57:54 mike Exp $"
+ * "$Id: ppds.c,v 1.4 2000/02/11 05:04:14 mike Exp $"
  *
  *   PPD scanning routines for the Common UNIX Printing System (CUPS).
  *
@@ -57,10 +57,33 @@ typedef struct direct DIRENT;
 #endif
 
 
+/*
+ * PPD information structure...
+ */
+
+typedef struct
+{
+  char ppd_make[128],                  /* Manufacturer */
+       ppd_make_and_model[256],        /* Make and model */
+       ppd_name[256],                  /* PPD filename */
+       ppd_natural_language[16];       /* Natural language */
+} ppd_info_t;
+
+
+/*
+ * Local globals...
+ */
+
+static int             num_ppds,       /* Number of PPD files */
+                       alloc_ppds;     /* Number of allocated entries */
+static ppd_info_t      *ppds;          /* PPD file info */
+
+
 /*
  * Local functions...
  */
 
+static int     compare_ppds(const ppd_info_t *p0, const ppd_info_t *p1);
 static void    load_ppds(const char *d, const char *p);
 
 
@@ -71,9 +94,182 @@ static void load_ppds(const char *d, const char *p);
 void
 LoadPPDs(const char *d)                /* I - Directory to scan... */
 {
-  PPDs = ippNew();
+  int          i;              /* Looping var */
+  ppd_info_t   *ppd;           /* Current PPD file */
+
+
+ /*
+  * Load all PPDs in the specified directory and below...
+  */
+
+  num_ppds   = 0;
+  alloc_ppds = 0;
+  ppds       = (ppd_info_t *)0;
 
   load_ppds(d, "");
+
+ /*
+  * Sort the PPDs...
+  */
+
+  if (num_ppds > 1)
+    qsort(ppds, num_ppds, sizeof(ppd_info_t),
+          (int (*)(const void *, const void *))compare_ppds);
+
+ /*
+  * Create the list of PPDs...
+  */
+
+  PPDs = ippNew();
+
+  for (i = num_ppds, ppd = ppds; i > 0; i --, ppd ++)
+  {
+    if (i)
+      ippAddSeparator(PPDs);
+
+    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_NAME,
+                 "ppd-name", NULL, ppd->ppd_name);
+    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+                 "ppd-make", NULL, ppd->ppd_make);
+    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+                 "ppd-make-and-model", NULL, ppd->ppd_make_and_model);
+    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE,
+                 "ppd-natural-language", NULL, ppd->ppd_natural_language);
+  }
+
+ /*
+  * Free the memory used...
+  */
+
+  if (alloc_ppds)
+    free(ppds);
+}
+
+
+/*
+ * 'compare_ppds()' - Compare PPD file make and model names for sorting.
+ */
+
+static int                             /* O - Result of comparison */
+compare_ppds(const ppd_info_t *p0,     /* I - First PPD file */
+             const ppd_info_t *p1)     /* I - Second PPD file */
+{
+  const char   *s,                     /* First name */
+               *t;                     /* Second name */
+  int          diff,                   /* Difference between digits */
+               digits;                 /* Number of digits */
+
+
+ /*
+  * First compare manufacturers...
+  */
+
+  if ((diff = strcasecmp(p0->ppd_make, p1->ppd_make)) != 0)
+    return (diff);
+
+ /* 
+  * Then compare names...
+  */
+
+  s = p0->ppd_make_and_model;
+  t = p1->ppd_make_and_model;
+
+ /*
+  * Loop through both nicknames, returning only when a difference is
+  * seen.  Also, compare whole numbers rather than just characters, too!
+  */
+
+  while (*s && *t)
+  {
+    if (isdigit(*s) && isdigit(*t))
+    {
+     /*
+      * Got a number; start by skipping leading 0's...
+      */
+
+      while (*s == '0')
+        s ++;
+      while (*t == '0')
+        t ++;
+
+     /*
+      * Skip equal digits...
+      */
+
+      while (isdigit(*s) && *s == *t)
+      {
+        s ++;
+       t ++;
+      }
+
+     /*
+      * Bounce out if *s and *t aren't both digits...
+      */
+
+      if (isdigit(*s) && !isdigit(*t))
+        return (1);
+      else if (!isdigit(*s) && isdigit(*t))
+        return (-1);
+      else if (!isdigit(*s) || !isdigit(*t))
+        continue;     
+
+      if (*s < *t)
+        diff = -1;
+      else
+        diff = 1;
+
+     /*
+      * Figure out how many more digits there are...
+      */
+
+      digits = 0;
+      s ++;
+      t ++;
+
+      while (isdigit(*s))
+      {
+        digits ++;
+       s ++;
+      }
+
+      while (isdigit(*t))
+      {
+        digits --;
+       t ++;
+      }
+
+     /*
+      * Return if the number or value of the digits is different...
+      */
+
+      if (digits < 0)
+        return (-1);
+      else if (digits > 0)
+        return (1);
+      else if (diff)
+        return (diff);
+    }
+    else if (tolower(*s) < tolower(*t))
+      return (-1);
+    else if (tolower(*s) > tolower(*t))
+      return (1);
+    else
+    {
+      s ++;
+      t ++;
+    }
+  }
+
+ /*
+  * Return the results of the final comparison...
+  */
+
+  if (*s)
+    return (1);
+  else if (*t)
+    return (-1);
+  else
+    return (strcasecmp(p0->ppd_natural_language, p1->ppd_natural_language));
 }
 
 
@@ -100,6 +296,7 @@ load_ppds(const char *d,            /* I - Actual directory */
                language[64],           /* Device class */
                manufacturer[1024],     /* Manufacturer */
                make_model[256];        /* Make and model */
+  ppd_info_t   *ppd;                   /* New PPD file */
 
 
   if ((dir = opendir(d)) == NULL)
@@ -298,19 +495,41 @@ load_ppds(const char *d,          /* I - Actual directory */
     * Add the PPD file...
     */
 
-    if (PPDs->attrs)
-      ippAddSeparator(PPDs);
+    if (num_ppds >= alloc_ppds)
+    {
+     /*
+      * Allocate (more) memory for the PPD files...
+      */
 
-    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_NAME,
-                 "ppd-name", NULL, name);
-    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                 "ppd-make", NULL, manufacturer);
-    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                 "ppd-make-and-model", NULL, make_model);
-    ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE,
-                 "ppd-natural-language", NULL, language);
+      if (alloc_ppds == 0)
+        ppd = malloc(sizeof(ppd_info_t) * 32);
+      else
+        ppd = realloc(ppds, sizeof(ppd_info_t) * (alloc_ppds + 32));
+
+      if (ppd == NULL)
+      {
+        LogMessage(L_ERROR, "load_ppds: Ran out of memory for %d PPD files!",
+                  alloc_ppds + 32);
+        closedir(dir);
+       return;
+      }
+
+      ppds = ppd;
+      alloc_ppds += 32;
+    }
+
+    ppd = ppds + num_ppds;
+    num_ppds ++;
+
+    memset(ppd, 0, sizeof(ppd_info_t));
+    strncpy(ppd->ppd_name, name, sizeof(ppd->ppd_name) - 1);
+    strncpy(ppd->ppd_make, manufacturer, sizeof(ppd->ppd_make) - 1);
+    strncpy(ppd->ppd_make_and_model, make_model,
+            sizeof(ppd->ppd_make_and_model) - 1);
+    strncpy(ppd->ppd_natural_language, language,
+            sizeof(ppd->ppd_natural_language) - 1);
 
-    LogMessage(L_DEBUG, "LoadPPDs: Adding ppd \"%s\"...", name);
+    LogMessage(L_DEBUG, "LoadPPDs: Added ppd \"%s\"...", name);
   }
 
   closedir(dir);
@@ -318,5 +537,5 @@ load_ppds(const char *d,            /* I - Actual directory */
 
 
 /*
- * End of "$Id: ppds.c,v 1.3 2000/02/10 00:57:54 mike Exp $".
+ * End of "$Id: ppds.c,v 1.4 2000/02/11 05:04:14 mike Exp $".
  */
index dc174326a7d40bcf49fd55da7214365c9a89d029..ed7bbe78f3d7d2e67e3e3d0e4683c102aaec4f5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.c,v 1.53 2000/02/08 20:39:02 mike Exp $"
+ * "$Id: printers.c,v 1.54 2000/02/11 05:04:14 mike Exp $"
  *
  *   Printer routines for the Common UNIX Printing System (CUPS).
  *
@@ -852,14 +852,8 @@ SetPrinterAttrs(printer_t *p)              /* I - Printer to setup */
     * Tell the client this is a remote printer of some type...
     */
 
-    if (p->type & CUPS_PRINTER_CLASS)
-      snprintf(filename, sizeof(filename), "Remote Printer Class on %s",
-               p->hostname);
-    else
-      snprintf(filename, sizeof(filename), "Remote Printer on %s", p->hostname);
-
     ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                 "printer-make-and-model", NULL, filename);
+                 "printer-make-and-model", NULL, p->make_model);
   }
   else
   {
@@ -870,14 +864,18 @@ SetPrinterAttrs(printer_t *p)             /* I - Printer to setup */
 
     p->type &= ~CUPS_PRINTER_OPTIONS;
 
-    if (p->type & CUPS_PRINTER_CLASS)
+    if (p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
     {
      /*
       * Add class-specific attributes...
       */
 
-      ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                   "printer-make-and-model", NULL, "Local Printer Class");
+      if ((p->type & CUPS_PRINTER_IMPLICIT) && p->num_printers > 0)
+       ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+                     "printer-make-and-model", NULL, p->printers[0]->make_model);
+      else
+       ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+                     "printer-make-and-model", NULL, "Local Printer Class");
 
       if (p->num_printers > 0)
       {
@@ -965,6 +963,8 @@ SetPrinterAttrs(printer_t *p)               /* I - Printer to setup */
        ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
                      "printer-make-and-model", NULL, ppd->nickname);
 
+        strncpy(p->make_model, ppd->nickname, sizeof(p->make_model) - 1);
+
        /*
        * Add media options from the PPD file...
        */
@@ -1318,5 +1318,5 @@ write_printcap(void)
 
 
 /*
- * End of "$Id: printers.c,v 1.53 2000/02/08 20:39:02 mike Exp $".
+ * End of "$Id: printers.c,v 1.54 2000/02/11 05:04:14 mike Exp $".
  */
index a5c95885abe0425e1dfeb86783982cd23b944470..c0ede752364a87cabe6d4934fd74e0036f4db696 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.h,v 1.14 2000/01/04 13:46:10 mike Exp $"
+ * "$Id: printers.h,v 1.15 2000/02/11 05:04:14 mike Exp $"
  *
  *   Printer definitions for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -33,6 +33,7 @@ typedef struct printer_str
                hostname[HTTP_MAX_HOST],/* Host printer resides on */
                name[IPP_MAX_NAME],     /* Printer name */
                location[IPP_MAX_NAME], /* Location code */
+               make_model[IPP_MAX_NAME],/* Make and model */
                info[IPP_MAX_NAME],     /* Description */
                more_info[HTTP_MAX_URI];/* URL for site-specific info */
   int          accepting;              /* Accepting jobs? */
@@ -77,5 +78,5 @@ extern void           StopPrinter(printer_t *p);
 
 
 /*
- * End of "$Id: printers.h,v 1.14 2000/01/04 13:46:10 mike Exp $".
+ * End of "$Id: printers.h,v 1.15 2000/02/11 05:04:14 mike Exp $".
  */
index d4a37d9b90f56aa96d06544171d5c89f130ec209..28f005df3be579da3483e5be87283e93a507bd73 100644 (file)
@@ -18,7 +18,8 @@
        <TD ALIGN="RIGHT">Device:</TD>
        <TD>
        <SELECT NAME="DEVICE_URI">
-       {[device_uri]<OPTION VALUE="{device_uri}" {?current_device_uri={device_uri}?SELECTED:}>{device_info}
+       {[device_uri]<OPTION VALUE="{device_uri}" {?current_device_uri={device_uri}?SELECTED:}>
+       {device_info} {?device_make_and_model!Unknown?({device_make_and_model}):}
        }</SELECT>
        </TD>
 </TR>
index be6eecbbf6019e2e7b008a8f66ce3550501f5272..97c0b9726c4c23afea3904160fdf0c72963945ed 100644 (file)
@@ -19,6 +19,7 @@
        Class State: {printer_state=3?idle:{printer_state=4?processing:stopped}},
        {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}.
        {?printer_state_message=?:<BR><I>"{printer_state_message}"</I>}
+       {?member_names=?:<BR>Members: {member_names}}
        <P>
        <A HREF="/admin/?op=print-test-page&printer_name={printer_name}">
        <IMG SRC="/images/print-test-page.gif" ALT="Print Test Page" BORDER="0"></A>
index 56c7cebe4238df3d95913790caa2fc1c10368bca..0354489e77d66f55dec792d408c07061e89d7eea 100644 (file)
@@ -20,6 +20,7 @@
        Printer State: {printer_state=3?idle:{printer_state=4?processing:stopped}},
        {printer_is_accepting_jobs=0?rejecting jobs:accepting jobs}.
        {?printer_state_message=?:<BR><I>"{printer_state_message}"</I>}
+       {?device_uri=?:<BR>Device URI: {device_uri}}
        <P>
        <A HREF="/admin/?op=print-test-page&printer_name={printer_name}">
        <IMG SRC="/images/print-test-page.gif" ALT="Print Test Page" BORDER="0"></A>