Hi ! I have a patch for print_svid.c, that enhances the usage of the "printcap=lpstat" option under System V. It not only gets the names of the printers via lpstat, but also the comments from the unix printing system. It works under Solaris, and should also work with SCO. I haven't access to other System V based systems. I don't know if this list is the appropriate place to post patches; if it is not, please let me know. Bye, N. Pueschel -------------- next part -------------- --- print_svid.c.orig Thu Jan 29 20:43:59 1998 +++ print_svid.c Mon Mar 30 07:41:19 1998 @@ -23,12 +23,11 @@ * printer information on a SVID or XPG4 compliant system. It does this * through the use of the SVID/XPG4 command "lpstat(1)". * - * The expectations is that execution of the command "lpstat -v" will + * The expectations is that execution of the command "lpstat -p -D" will * generate responses in the form of: * - * device for serial: /dev/term/b - * system for fax: server - * system for color: server (as printer chroma) + * printer HPLaser is idle. enabled since Freitag, 27. M?rz 1998, 13:35:47 Uhr MET. available. + * Description: HP Laser Printer */ @@ -41,6 +40,7 @@ typedef struct printer { char *name; + char *comment; struct printer *next; } printer_t; static printer_t *printers = NULL; @@ -49,27 +49,42 @@ { FILE *fp; - if ((fp = popen("/usr/bin/lpstat -v", "r")) != NULL) { + if ((fp = popen("/usr/bin/lpstat -p -D", "r")) != NULL) { char buf[BUFSIZ]; + char buf2[BUFSIZ]; while (fgets(buf, sizeof (buf), fp) != NULL) { printer_t *ptmp; - char *name, *tmp; + char *name, *comment, *tmp; - /* eat "system/device for " */ - if (((tmp = strchr(buf, ' ')) == NULL) || - ((tmp = strchr(++tmp, ' ')) == NULL)) - continue; + /* eat "printer" at start of first line */ + if (((tmp = strchr(buf, ' ')) == NULL)) + break; name = ++tmp; - /* truncate the ": ..." */ - if ((tmp = strchr(name, ':')) != NULL) + /* truncate the " is idle ..." */ + if ((tmp = strchr(name, ' ')) != NULL) + *tmp = '\0'; + else + break; + + /* get 2nd line of description */ + if (fgets(buf2, sizeof (buf2), fp) == NULL) + break; + + /* skip until after first ":" */ + if (((tmp = strchr(buf2, ' ')) == NULL)) + break; + comment = ++tmp; + + if ((tmp = strchr(comment, '\n')) != NULL) *tmp = '\0'; /* add it to the cache */ if ((ptmp = malloc(sizeof (*ptmp))) != NULL) { memset(ptmp, '\0', sizeof (*ptmp)); ptmp->name = strdup(name); + ptmp->comment = strdup(comment); ptmp->next = printers; printers = ptmp; } @@ -95,7 +110,7 @@ if (printers == NULL) populate_printers(); for (tmp = printers; tmp != NULL; tmp = tmp->next) - (fn)(tmp->name, ""); + (fn)(tmp->name, tmp->comment); }