home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!mel.dit.csiro.au!yarra!melba.bby.oz.au!gnb
- From: gnb@duke.bby.com.au (Gregory N. Bond)
- Newsgroups: comp.protocols.nfs
- Subject: Patch to pcnfsd-92.08.21
- Message-ID: <1992Sep3.063937.21322@bby.com.au>
- Date: 3 Sep 92 06:39:37 GMT
- Sender: usenet@bby.com.au (news READER id)
- Organization: Burdett, Buckeridge & Young, Melbourne, Australia
- Lines: 248
- Nntp-Posting-Host: duke
-
- Attached below is a patch to the pcnfsd version 2 dated 92/08/21,
- probably only relevant to Sun PC-NFS 4.0. It adds an option to look
- at the /etc/printcap file instead of "lpc stat" to get the list of
- printers. This has the following advantages:
-
- 1) You can get descriptive comments in the printer description. This
- is (unfortunately!) ignored by the "net printers" command(*), but is
- available in the Windows printer setup dialog.
-
- 2) Placeholder entries in the printcap don't appear in the list of
- printers on a PC. (By placeholder entries, I mean ones that have no
- lp= or rm= fields, but contain common settings and are referenced
- from other printcap entries via tc=.)
-
- The patches assume that your printcap file is in a certain (fairly
- loose) format; feeding in random strings may well break! It expects
- each printer definition to look something like this:
-
- realname|alias-1|alias-2|Descriptive Name:\
- :sd=...:lf=...:sf=....:\
- :rm=foo:rp=fooprinter:lp=:\
- :tc=ps-fmt:
-
- ps-fmt|Formatter defs for PostScript printers:\
- :df=.....:tf=......:sh:rw:
-
- Each real printer entry contains an "official" name, zero or more
- aliases, and the last name is a description, (e.g. "LaserJet in Rm
- 2254"). Real printers either have a non-null lp= field or non-null
- rm= and rp= fields. Continuation lines have leading TAB (not space)
- characters, and lp/rm/rp entries are not recognised on the name line.
-
- Placeholder entries have neither lp= fields nor rp= fields; they are
- ignored as far as the PC is concerned (e.g. ps-fmt entry above).
-
- These patches have not been extensivly tested, but they work for us.
- Tested only on SunOs 4.1. Use at your own risk. No warranty. Worth
- every cent you paid for it. Don't sleep in the subway.
-
- Greg.
-
- (*) Geoff: Can you please pretty please use the comment field in the
- net printers output if it looks like an interesting string? Please?
- You are welcome to include these patches in the next distribution,
- should you wish to!
-
- -- if you -- cut here -- you will void the warranty on your monitor... --
- *** pcnfsd_print.c.DIST Wed Aug 19 02:53:12 1992
- --- pcnfsd_print.c Thu Sep 3 15:47:05 1992
- ***************
- *** 597,603 ****
-
- #endif SVR4_STYLE_PR_LIST
-
- ! #ifdef BSD_STYLE_PR_LIST
-
- int
- build_pr_list()
- --- 597,603 ----
-
- #endif SVR4_STYLE_PR_LIST
-
- ! #if defined(BSD_STYLE_PR_LIST) && !defined(PRINTCAP_STYLE_PR_LIST)
-
- int
- build_pr_list()
- ***************
- *** 654,660 ****
-
- return(1);
- }
- ! #endif BSD_STYLE_PR_LIST
-
-
-
- --- 654,802 ----
-
- return(1);
- }
- ! #endif /* defined(BSD_STYLE_PR_LIST) && !defined(PRINTCAP_STYLE_PR_LIST) */
- !
- !
- !
- ! #ifdef PRINTCAP_STYLE_PR_LIST
- !
- ! int
- ! build_pr_list()
- ! {
- ! pr_list last = NULL;
- ! pr_list curr = NULL;
- ! char buff[256];
- ! FILE *p;
- ! char *cp, *lcp;
- ! int saw_system;
- !
- ! p = fopen("/etc/printcap", "r");
- ! if(p == NULL) {
- ! printers = list_virtual_printers();
- ! return(1);
- ! }
- !
- ! while(fgets(buff, 255, p) != NULL) {
- ! /*
- ! * Assume printcap entries look like this:
- ! * # comments
- ! * realname|alias|alias|Descriptive Name:\
- ! * :sd=......:\
- ! * :rm=remhost:rp=remprtr:\
- ! *
- ! * We look for lines starting with an alphanumeric character. Then we
- ! * take the first entry as the official name, the last as a comment.
- ! */
- ! if(isalnum(buff[0])) {
- ! /*
- ! * Is the first line of a new printer
- ! * description. If we are already processing a
- ! * printer, add it to the list.
- ! */
- ! if (curr && !(curr->device && curr->pn)) {
- ! /*
- ! * Don't add printers with no device - they
- ! * are placeholder printcap entries intended
- ! * to be used with tc=xxxx entries.
- ! */
- ! free_pr_list_item(curr);
- ! curr = NULL;
- ! }
- ! if (curr) {
- ! /*
- ! * Add this printer
- ! */
- ! if (!curr->remhost) curr->remhost = my_strdup("");
- ! if(last == NULL)
- ! printers = curr;
- ! else
- ! last->pr_next = curr;
- ! last = curr;
- ! curr = NULL;
- ! }
- ! /*
- ! * Create the new printer
- ! */
- ! curr = (struct pr_list_item *)
- ! grab(sizeof (struct pr_list_item));
- !
- ! curr->pn = NULL;
- ! curr->device = NULL;
- ! curr->remhost = NULL;
- ! curr->cm = NULL;
- ! curr->pr_next = NULL;
- !
- ! /*
- ! * Find the canonical name
- ! */
- ! cp = strtok(buff, "\r\n\\|:");
- ! if(!cp)
- ! continue;
- ! curr->pn = my_strdup(cp);
- ! /*
- ! * Now get the last name to use as a comment
- ! */
- ! lcp = cp;
- ! while (cp = strtok(NULL, ":|\\\r\n")) {
- ! if (!isalnum(*cp)) break;
- ! lcp = cp;
- ! }
- ! curr->cm = my_strdup(lcp);
- ! }
- ! if (buff[0] != '\t')
- ! continue;
- !
- ! /* Is a data line */
- ! if ((cp = strstr(buff, "rm=")) &&
- ! (lcp = strchr(cp + 3, ':')) && lcp > cp + 4) {
- ! cp += 3;
- ! *lcp = '\0';
- ! curr->remhost = my_strdup(cp);
- ! *lcp = ':';
- ! }
- ! if (!curr->device &&
- ! (cp = strstr(buff, "rp=")) &&
- ! (lcp = strchr(cp + 3, ':')) && lcp > cp + 4) {
- ! cp += 3;
- ! *lcp = '\0';
- ! curr->device = my_strdup(cp);
- ! *lcp = ':';
- ! }
- ! if (!curr->device &&
- ! (cp = strstr(buff, "lp=")) &&
- ! (lcp = strchr(cp + 3, ':')) && lcp > cp + 4) {
- ! curr->device = my_strdup(curr->pn);
- ! }
- !
- !
- ! }
- ! (void) fclose(p);
- !
- ! if (curr && !(curr->device && curr->pn)) {
- ! free_pr_list_item(curr);
- ! curr = NULL;
- ! }
- ! if (curr) {
- ! if (!curr->remhost) curr->remhost = my_strdup("");
- ! if(last == NULL)
- ! printers = curr;
- ! else
- ! last->pr_next = curr;
- ! last = curr;
- ! curr = NULL;
- ! }
- !
- ! /*
- ! ** Now add on the virtual printers, if any
- ! */
- ! if(last == NULL)
- ! printers = list_virtual_printers();
- ! else
- ! last->pr_next = list_virtual_printers();
- !
- ! return(1);
- ! }
- ! #endif /* PRINTCAP_STYLE_PR_LIST */
-
-
-
- *** Makefile.DIST Wed Aug 19 02:52:08 1992
- --- Makefile Thu Sep 3 16:12:25 1992
- ***************
- *** 43,49 ****
- #LIBS= -lrpcsvc -lsocket -lnsl
- #
- # SunOS 4.1[.x] for SPARC
- ! CFLAGS = $(BUGFLAG) -DOSVER_SUNOS41
- LIBS= -lrpcsvc
- #
- # SunOS 4.0.3[c] for SPARC, Sun386i or Sun 3
- --- 43,49 ----
- #LIBS= -lrpcsvc -lsocket -lnsl
- #
- # SunOS 4.1[.x] for SPARC
- ! CFLAGS = $(BUGFLAG) -DOSVER_SUNOS41 -DPRINTCAP_STYLE_PR_LIST
- LIBS= -lrpcsvc
- #
- # SunOS 4.0.3[c] for SPARC, Sun386i or Sun 3
- --
- Gregory Bond <gnb@bby.com.au> Burdett Buckeridge & Young Ltd Melbourne Australia
- ``USL has never sold long distance. You're going after the wrong men in black
- hats. (Or, in the case of Plan 9, black space suits)'' - Tom Limoncelli
-