home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / protocol / nfs / 2218 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  7.0 KB

  1. Path: sparky!uunet!munnari.oz.au!mel.dit.csiro.au!yarra!melba.bby.oz.au!gnb
  2. From: gnb@duke.bby.com.au (Gregory N. Bond)
  3. Newsgroups: comp.protocols.nfs
  4. Subject: Patch to pcnfsd-92.08.21
  5. Message-ID: <1992Sep3.063937.21322@bby.com.au>
  6. Date: 3 Sep 92 06:39:37 GMT
  7. Sender: usenet@bby.com.au (news READER id)
  8. Organization: Burdett, Buckeridge & Young, Melbourne, Australia
  9. Lines: 248
  10. Nntp-Posting-Host: duke
  11.  
  12. Attached below is a patch to the pcnfsd version 2 dated 92/08/21,
  13. probably only relevant to Sun PC-NFS 4.0.  It adds an option to look
  14. at the /etc/printcap file instead of "lpc stat" to get the list of
  15. printers. This has the following advantages:
  16.  
  17. 1) You can get descriptive comments in the printer description.  This
  18. is (unfortunately!) ignored by the "net printers" command(*), but is
  19. available in the Windows printer setup dialog.
  20.  
  21. 2) Placeholder entries in the printcap don't appear in the list of
  22. printers on a PC.  (By placeholder entries, I mean ones that have no
  23. lp= or rm= fields, but contain common settings and are referenced
  24. from other printcap entries via tc=.)
  25.  
  26. The patches assume that your printcap file is in a certain (fairly
  27. loose) format;  feeding in random strings may well break!  It expects
  28. each printer definition to look something like this:
  29.  
  30. realname|alias-1|alias-2|Descriptive Name:\
  31.     :sd=...:lf=...:sf=....:\
  32.     :rm=foo:rp=fooprinter:lp=:\
  33.     :tc=ps-fmt:
  34.  
  35. ps-fmt|Formatter defs for PostScript printers:\
  36.     :df=.....:tf=......:sh:rw:
  37.  
  38. Each real printer entry contains an "official" name, zero or more
  39. aliases, and the last name is a description, (e.g. "LaserJet in Rm
  40. 2254").  Real printers either have a non-null lp= field or non-null
  41. rm= and rp= fields. Continuation lines have leading TAB (not space)
  42. characters, and lp/rm/rp entries are not recognised on the name line.
  43.  
  44. Placeholder entries have neither lp= fields nor rp= fields; they are
  45. ignored as far as the PC is concerned (e.g. ps-fmt entry above).
  46.  
  47. These patches have not been extensivly tested, but they work for us.
  48. Tested only on SunOs 4.1. Use at your own risk.  No warranty.  Worth
  49. every cent you paid for it.  Don't sleep in the subway.
  50.  
  51. Greg.
  52.  
  53. (*) Geoff: Can you please pretty please use the comment field in the
  54. net printers output if it looks like an interesting string?  Please?
  55. You are welcome to include these patches in the next distribution,
  56. should you wish to!
  57.  
  58. -- if you -- cut here -- you will void the warranty on your monitor... --
  59. *** pcnfsd_print.c.DIST    Wed Aug 19 02:53:12 1992
  60. --- pcnfsd_print.c    Thu Sep  3 15:47:05 1992
  61. ***************
  62. *** 597,603 ****
  63.   
  64.   #endif SVR4_STYLE_PR_LIST
  65.   
  66. ! #ifdef BSD_STYLE_PR_LIST
  67.   
  68.   int
  69.   build_pr_list()
  70. --- 597,603 ----
  71.   
  72.   #endif SVR4_STYLE_PR_LIST
  73.   
  74. ! #if defined(BSD_STYLE_PR_LIST) && !defined(PRINTCAP_STYLE_PR_LIST)
  75.   
  76.   int
  77.   build_pr_list()
  78. ***************
  79. *** 654,660 ****
  80.   
  81.       return(1);
  82.   }
  83. ! #endif BSD_STYLE_PR_LIST
  84.   
  85.   
  86.   
  87. --- 654,802 ----
  88.   
  89.       return(1);
  90.   }
  91. ! #endif /* defined(BSD_STYLE_PR_LIST) && !defined(PRINTCAP_STYLE_PR_LIST) */
  92. ! #ifdef PRINTCAP_STYLE_PR_LIST
  93. ! int
  94. ! build_pr_list()
  95. ! {
  96. ! pr_list last = NULL;
  97. ! pr_list curr = NULL;
  98. ! char buff[256];
  99. ! FILE *p;
  100. ! char *cp, *lcp;
  101. ! int saw_system;
  102. !     p = fopen("/etc/printcap", "r");
  103. !     if(p == NULL) {
  104. !         printers = list_virtual_printers();
  105. !         return(1);
  106. !     }
  107. !     
  108. !     while(fgets(buff, 255, p) != NULL) {
  109. ! /*
  110. !  * Assume printcap entries look like this:
  111. !  * # comments
  112. !  * realname|alias|alias|Descriptive Name:\
  113. !  *     :sd=......:\
  114. !  *     :rm=remhost:rp=remprtr:\
  115. !  *
  116. !  * We look for lines starting with an alphanumeric character.  Then we
  117. !  * take the first entry as the official name, the last as a comment.
  118. !  */
  119. !         if(isalnum(buff[0])) {
  120. !              /* 
  121. !               * Is the first line of a new printer
  122. !               * description.  If we are already processing a
  123. !               * printer, add it to the list. 
  124. !               */ 
  125. !              if (curr && !(curr->device && curr->pn)) {
  126. !               /*
  127. !                * Don't add printers with no device - they
  128. !                * are placeholder printcap entries intended
  129. !                * to be used with tc=xxxx entries.
  130. !                */
  131. !               free_pr_list_item(curr);
  132. !               curr = NULL;
  133. !              }
  134. !              if (curr) {
  135. !               /*
  136. !                * Add this printer 
  137. !                */
  138. !               if (!curr->remhost) curr->remhost = my_strdup("");
  139. !               if(last == NULL)
  140. !                    printers = curr;
  141. !               else
  142. !                    last->pr_next = curr;
  143. !               last = curr;
  144. !               curr = NULL;
  145. !              }
  146. !              /*
  147. !               * Create the new printer
  148. !               */
  149. !              curr = (struct pr_list_item *)
  150. !               grab(sizeof (struct pr_list_item));
  151. !              curr->pn = NULL;
  152. !              curr->device = NULL;
  153. !              curr->remhost = NULL;
  154. !              curr->cm = NULL;
  155. !              curr->pr_next = NULL;
  156. !              /*
  157. !               * Find the canonical name
  158. !               */
  159. !              cp = strtok(buff, "\r\n\\|:");
  160. !              if(!cp)
  161. !               continue;
  162. !              curr->pn = my_strdup(cp);
  163. !              /*
  164. !               * Now get the last name to use as a comment
  165. !               */
  166. !              lcp = cp;
  167. !              while (cp = strtok(NULL, ":|\\\r\n")) {
  168. !               if (!isalnum(*cp)) break;
  169. !               lcp = cp;
  170. !              }
  171. !              curr->cm = my_strdup(lcp);
  172. !         }
  173. !         if (buff[0] != '\t')
  174. !              continue;
  175. !         /* Is a data line */
  176. !         if ((cp = strstr(buff, "rm=")) && 
  177. !             (lcp = strchr(cp + 3, ':')) && lcp > cp + 4) {
  178. !              cp += 3;
  179. !              *lcp = '\0';
  180. !              curr->remhost = my_strdup(cp);
  181. !              *lcp = ':';
  182. !         }
  183. !         if (!curr->device &&
  184. !             (cp = strstr(buff, "rp=")) && 
  185. !             (lcp = strchr(cp + 3, ':')) && lcp > cp + 4) {
  186. !              cp += 3;
  187. !              *lcp = '\0';
  188. !              curr->device = my_strdup(cp);
  189. !              *lcp = ':';
  190. !         }
  191. !         if (!curr->device &&
  192. !             (cp = strstr(buff, "lp=")) && 
  193. !             (lcp = strchr(cp + 3, ':')) && lcp > cp + 4) {
  194. !              curr->device = my_strdup(curr->pn);
  195. !         }
  196. !         
  197. !     }
  198. !     (void) fclose(p);
  199. !         
  200. !     if (curr && !(curr->device && curr->pn)) {
  201. !          free_pr_list_item(curr);
  202. !          curr = NULL;
  203. !     }
  204. !     if (curr) {
  205. !          if (!curr->remhost) curr->remhost = my_strdup("");
  206. !          if(last == NULL)
  207. !           printers = curr;
  208. !          else
  209. !           last->pr_next = curr;
  210. !          last = curr;
  211. !          curr = NULL;
  212. !     }
  213. ! /*
  214. ! ** Now add on the virtual printers, if any
  215. ! */
  216. !     if(last == NULL)
  217. !         printers = list_virtual_printers();
  218. !     else
  219. !         last->pr_next = list_virtual_printers();
  220. !     return(1);
  221. ! }
  222. ! #endif /* PRINTCAP_STYLE_PR_LIST */
  223.   
  224.   
  225.   
  226. *** Makefile.DIST    Wed Aug 19 02:52:08 1992
  227. --- Makefile    Thu Sep  3 16:12:25 1992
  228. ***************
  229. *** 43,49 ****
  230.   #LIBS= -lrpcsvc -lsocket -lnsl
  231.   #
  232.   # SunOS 4.1[.x] for SPARC
  233. ! CFLAGS = $(BUGFLAG) -DOSVER_SUNOS41
  234.   LIBS= -lrpcsvc
  235.   #
  236.   # SunOS 4.0.3[c] for SPARC, Sun386i or Sun 3
  237. --- 43,49 ----
  238.   #LIBS= -lrpcsvc -lsocket -lnsl
  239.   #
  240.   # SunOS 4.1[.x] for SPARC
  241. ! CFLAGS = $(BUGFLAG) -DOSVER_SUNOS41 -DPRINTCAP_STYLE_PR_LIST
  242.   LIBS= -lrpcsvc
  243.   #
  244.   # SunOS 4.0.3[c] for SPARC, Sun386i or Sun 3
  245. --
  246. Gregory Bond <gnb@bby.com.au> Burdett Buckeridge & Young Ltd Melbourne Australia
  247. ``USL has never sold long distance.  You're going after the wrong men in black 
  248.   hats.  (Or, in the case of Plan 9, black space suits)'' - Tom Limoncelli
  249.