Patch #: 196 Type: operational change Priority: none Modification: Add support for LaserWriter 8.N DSC 3 queries Modification: Update cap60/applications/lwsrv/README Modification: Minor fixes for papif Submitted: Edward Moy Submitted: David Hornsby Submitted: Aaron Wohl Submitted: Sven Dietrich Submitted: A Submitted: Maarten Carels Submitted: M Richartz Submitted: Volker Weinberger Submitted: Adrian R.D. Pepper Submitted: Dave Alden Submitted: Brad Jones Submitted: EG Keizer Modification: Fix for ADMIN_GRP use of gr_mem Modification: Add APPLICATION_MANAGER support to CopyFile() Reported: Tim Leamy Modification: Fix bug in DISTRIB_PASSWDS ChangePassword() Reported: George Hartlieb Modification: Fix for USEFCNTLLOCK on Solaris 2.N Reported: Anthony Baxter Modification: Deprecate Kernel AppleTalk for misc. hosts Reported: John Dodson Modification: Fix for CAP with UAR under Digital UNIX (OSF/1) Reported: David Hornsby Archived: munnari.OZ.AU mac/cap.patches/cap60.patch196 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch196' File: cap60/Configure File: cap60/Makefile File: cap60/lib/afp/afposlock.c File: cap60/applications/aufs/afpos.c File: cap60/applications/lwsrv/DBfile File: cap60/applications/lwsrv/list.c File: cap60/applications/lwsrv/list.h File: cap60/applications/lwsrv/lwsrv.conf File: cap60/applications/lwsrv/lwsrvconfig.c File: cap60/applications/lwsrv/packed.c File: cap60/applications/lwsrv/packed.h File: cap60/applications/lwsrv/parse.c File: cap60/applications/lwsrv/parse.h File: cap60/applications/lwsrv/parsel.l File: cap60/applications/lwsrv/parsey.y File: cap60/applications/lwsrv/query.c File: cap60/applications/lwsrv/query.h File: cap60/applications/lwsrv/query.ps File: cap60/applications/lwsrv/Makefile.m4 File: cap60/applications/lwsrv/README File: cap60/applications/lwsrv/fontlist.c File: cap60/applications/lwsrv/fontlist.h File: cap60/applications/lwsrv/lwsrv.c File: cap60/applications/lwsrv/papstream.c File: cap60/applications/lwsrv/papstream.h File: cap60/applications/lwsrv/procset.c File: cap60/applications/lwsrv/procset.h File: cap60/applications/lwsrv/simple.c File: cap60/applications/lwsrv/spmisc.c File: cap60/lib/cap/abpap.h File: cap60/lib/cap/abpaps.c File: cap60/applications/papif/papif.c File: cap60/lib/cap/abkip.c File: cap60/support/uab/proto_intf.h *** Configure.orig Sat Jul 1 00:33:08 1995 --- Configure Wed Aug 30 22:52:28 1995 *************** *** 1,7 **** #!/bin/sh ! # $Author: djh $ $Date: 1995/06/30 14:32:56 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.97 1995/06/30 14:32:56 djh Rel djh $ ! # $Revision: 2.97 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # --- 1,7 ---- #!/bin/sh ! # $Author: djh $ $Date: 1995/08/30 12:52:13 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.100 1995/08/30 12:52:13 djh Rel djh $ ! # $Revision: 2.100 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # *************** *** 429,435 **** uabsupport=1 uarsupport=1 ethersupport=1 - kernelsupport=1 ;; "solaris") uarsupport=1 --- 429,434 ---- *************** *** 437,443 **** ;; "aix") uarsupport=1 - kernelsupport=1 ;; "pyr") # later, someone should try this. --- 436,441 ---- *************** *** 1548,1553 **** --- 1546,1557 ---- [define([libafp],concat([-L],libdestdir,[ ],libafp))]) ifelse(os,[netbsd], [define([libafpc],concat([-L],libdestdir,[ ],libafpc))]) + ifelse(os,[freebsd], + [define([libcap],concat([-L],libdestdir,[ ],libcap))]) + ifelse(os,[freebsd], + [define([libafp],concat([-L],libdestdir,[ ],libafp))]) + ifelse(os,[freebsd], + [define([libafpc],concat([-L],libdestdir,[ ],libafpc))]) # any special libraries define([libspecial],[]) ifelse(os,[ultrix40],[ *************** *** 1567,1573 **** ifelse(os,[aux],[ define([libspecial],concat(libspecial,[ -lat -lbsd]))]) ifelse(os,[hpux],[ ! define([libspecial],concat(libspecial,[ -lBSD]))]) ifelse(os,[epix],[ define([libspecial],concat(libspecial,[ -lc -lsec]))]) ifelse(os,[386bsd],[ --- 1571,1577 ---- ifelse(os,[aux],[ define([libspecial],concat(libspecial,[ -lat -lbsd]))]) ifelse(os,[hpux],[ ! define([libspecial],concat(libspecial,[ -lBSD -lndbm]))]) ifelse(os,[epix],[ define([libspecial],concat(libspecial,[ -lc -lsec]))]) ifelse(os,[386bsd],[ *** Makefile.orig Sat Mar 7 21:06:45 1992 --- Makefile Mon Aug 28 07:43:04 1995 *************** *** 18,24 **** (cd lib/afp; make install) (cd lib/afpc; make install) touch libinstall ! programs: libinstall -(cd etc; make) -(cd samples; make) --- 18,24 ---- (cd lib/afp; make install) (cd lib/afpc; make install) touch libinstall ! programs: libinstall -(cd etc; make) -(cd samples; make) *** lib/afp/afposlock.c.orig Mon Oct 10 18:59:36 1994 --- lib/afp/afposlock.c Mon Aug 28 07:59:27 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/10 08:59:24 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afposlock.c,v 2.10 1994/10/10 08:59:24 djh Rel djh $ ! * $Revision: 2.10 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/08/27 21:59:04 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afposlock.c,v 2.11 1995/08/27 21:59:04 djh Rel djh $ ! * $Revision: 2.11 $ * */ *************** *** 47,52 **** --- 47,54 ---- #ifdef SOLARIS #define USEFCNTLLOCK + #include + #include #endif SOLARIS #ifndef NOLOCKF *** applications/aufs/afpos.c.orig Mon Jun 26 15:47:49 1995 --- applications/aufs/afpos.c Mon Aug 28 08:24:19 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1995/06/26 05:47:32 $ ! * $Header: /local/mulga/mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.71 1995/06/26 05:47:32 djh Rel djh $ ! * $Revision: 2.71 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/08/27 22:23:51 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.74 1995/08/27 22:23:51 djh Rel djh $ ! * $Revision: 2.74 $ * */ *************** *** 3134,3139 **** --- 3134,3152 ---- if ((err=unix_open(from,0,&sfd)) != noErr) /* open source file */ return(err); + #ifdef APPLICATION_MANAGER + { + extern int fdplist[NOFILE]; + extern struct flist *applist; + + if (applist != NULL && fdplist[sfd] == 1) { + /* we want Finder copy protection */ + (void) unix_close(sfd); + return(aeAccessDenied); + } + } + #endif APPLICATION_MANAGER + err = unix_stat(to,&dstb); /* check on destination */ if (err == noErr) { /* file is there */ if (sstb.st_dev == dstb.st_dev && sstb.st_ino == dstb.st_ino) { *************** *** 3781,3795 **** if (uam != UAM_ANON) { struct group *grps; if ((grps = getgrnam(ADMIN_GRP)) != NULL) { ! while (grps->gr_mem != NULL) { if (strcmp(p->pw_name, *grps->gr_mem) == 0) { logit(0, "User %s has admin privs, logging in as superuser.", p->pw_name); ! p->pw_gid = grps->gr_gid; ! p->pw_uid = 0; break; } ! grps->gr_mem++; } } } --- 3794,3808 ---- if (uam != UAM_ANON) { struct group *grps; if ((grps = getgrnam(ADMIN_GRP)) != NULL) { ! while (*(grps->gr_mem) != NULL) { if (strcmp(p->pw_name, *grps->gr_mem) == 0) { logit(0, "User %s has admin privs, logging in as superuser.", p->pw_name); ! usrgid = grps->gr_gid; ! usruid = 0; break; } ! *(grps->gr_mem)++; } } } *************** *** 3879,3886 **** #endif HIDE_LWSEC_FILE if( (f = fopen( fname, "w" )) != NULL ) { /* sigh. leaves race. */ ! logit(0, "writing user %s into auth-file for %s", p->pw_name, bin); ! fprintf( f, "%s\n", p->pw_name ); /* perhaps write temp */ fclose( f ); /* and rename? */ /* sigh. fchown and fchmod are BSDisms */ chmod( fname, 0644 ); /* make owned by user so they */ --- 3892,3899 ---- #endif HIDE_LWSEC_FILE if( (f = fopen( fname, "w" )) != NULL ) { /* sigh. leaves race. */ ! logit(0, "writing user %s into auth-file for %s", usrnam, bin); ! fprintf( f, "%s\n", usrnam ); /* perhaps write temp */ fclose( f ); /* and rename? */ /* sigh. fchown and fchmod are BSDisms */ chmod( fname, 0644 ); /* make owned by user so they */ *************** *** 3987,3993 **** dedes(pwdold); desdone(); /* old password OK ? */ ! if (strcmp((char *)afp->afp_password, (char *)pwdold) != 0) return(aeUserNotAuth); /* enforce password length control */ if (strlen((char *)pwdnew) < afp->afp_minmpwlen) --- 4000,4007 ---- dedes(pwdold); desdone(); /* old password OK ? */ ! if (strncmp((char *)afp->afp_password, (char *)pwdold, ! strlen((char *)afp->afp_password)) != 0) return(aeUserNotAuth); /* enforce password length control */ if (strlen((char *)pwdnew) < afp->afp_minmpwlen) *** applications/lwsrv/DBfile.orig Mon Aug 28 20:37:08 1995 --- applications/lwsrv/DBfile Mon Aug 28 20:38:52 1995 *************** *** 0 **** --- 1,316 ---- + plain300 = ( + Query ADOIsBinaryOK? True; + FeatureQuery *?Resolution 300dpi; + FeatureQuery *ColorDevice False; + FeatureQuery *FaxSupport None; + FeatureQuery *LanguageLevel '"1"'; + FeatureQuery *TTRasterizer None; + Query ADOSpooler spooler; + ); + + "COMPAQ PAGEMARQ 15" = ( + include "LaserWriter Plus"; + FeatureQuery *PSVersion '"(2012.015) 13"'; + FeatureQuery *?Resolution 400x800dpi; + FeatureQuery *ColorDevice Unknown; + FeatureQuery *FreeVM '"2397046"'; + FeatureQuery *Product '"(COMPAQ PAGEMARQ 15)"'; + FeatureQuery *FaxSupport Base; + Query ADORamSize '"10485760"'; + ); + + "Dataproducts LZR 1260" = ( + include "LaserWriter Plus"; + FeatureQuery *PSVersion '"(47.0) 0"'; + FeatureQuery *FreeVM '"2389815"'; + FeatureQuery *Product '"(Dataproducts LZR 1260)"'; + FeatureQuery *TTRasterizer Accept68K; + Query ADORamSize '"4194304"'; + ); + + LaserWriter = ( + include plain300; + font ( + Courier, + Courier-Bold, + Courier-BoldOblique, + Courier-Oblique, + Helvetica, + Helvetica-Bold, + Helvetica-BoldOblique, + Helvetica-Oblique, + Symbol, + Times-Bold, + Times-BoldItalic, + Times-Italic, + Times-Roman, + ); + FeatureQuery *PSVersion '"(23.0) 0"'; + FeatureQuery *FreeVM '"173936"'; + FeatureQuery *Product '"(LaserWriter)"'; + Query ADORamSize '"2097152"'; + ); + + "LaserWriter II NT" = ( + include "LaserWriter Plus"; + FeatureQuery *PSVersion '"(47.0) 1"'; + FeatureQuery *FreeVM '"434204"'; + FeatureQuery *Product '"(LaserWriter II NT)"'; + FeatureQuery *TTRasterizer Accept68K; + ); + + "LaserWriter II NTX" = ( + include "LaserWriter II NT"; + FeatureQuery *PSVersion '"(47.0) 1"'; + FeatureQuery *FreeVM '"433810"'; + FeatureQuery *Product '"(LaserWriter II NTX)"'; + ); + + "LaserWriter IIf" = ( + include "LaserWriter Plus"; + FeatureQuery *ColorDevice Unknown; + FeatureQuery *LanguageLevel '"2"'; + FeatureQuery *PSVersion '"(2010.113) 1"'; + FeatureQuery *FreeVM '"2381689"'; + FeatureQuery *TTRasterizer Type42; + FeatureQuery *Product '"(LaserWriter IIf)"'; + Query ADORamSize '"8388608"'; + ); + + "LaserWriter IIg" = ( + include "LaserWriter IIf"; + FeatureQuery *PSVersion '"(2010.130) 2"'; + FeatureQuery *FreeVM '"2150107"'; + FeatureQuery *Product '"(LaserWriter IIg)"'; + ); + + "LaserWriter Plus" = ( + include LaserWriter; + font ( + AvantGarde-Book, + AvantGarde-BookOblique, + AvantGarde-Demi, + AvantGarde-DemiOblique, + Bookman-Demi, + Bookman-DemiItalic, + Bookman-Light, + Bookman-LightItalic, + Courier, + Courier-Bold, + Courier-BoldOblique, + Courier-Oblique, + Helvetica, + Helvetica-Bold, + Helvetica-BoldOblique, + Helvetica-Narrow, + Helvetica-Narrow-Bold, + Helvetica-Narrow-BoldOblique, + Helvetica-Narrow-Oblique, + Helvetica-Oblique, + NewCenturySchlbk-Bold, + NewCenturySchlbk-BoldItalic, + NewCenturySchlbk-Italic, + NewCenturySchlbk-Roman, + Palatino-Bold, + Palatino-BoldItalic, + Palatino-Italic, + Palatino-Roman, + Symbol, + Times-Bold, + Times-BoldItalic, + Times-Italic, + Times-Roman, + ZapfChancery-MediumItalic, + ZapfDingbats, + ); + FeatureQuery *PSVersion '"(42.2) 3"'; + FeatureQuery *FreeVM '"172414"'; + FeatureQuery *Product '"(LaserWriter Plus)"'; + ); + + "LaserWriter Pro 630" = ( + include "LaserWriter IIg"; + FeatureQuery *PSVersion '"(2010.130) 1"'; + FeatureQuery *FreeVM '"1698253"'; + FeatureQuery *Product '"(LaserWriter Pro 630)"'; + FeatureQuery *?Resolution 600dpi; + ); + + "PrintServer 20" = ( + include "plain300"; + FeatureQuery *PSVersion '"(48.3) 19"'; + FeatureQuery *FreeVM '"964599"'; + FeatureQuery *Product '"(PrintServer 20)"'; + Query ADORamSize '"2621440"'; + font ( + AvantGarde-Book, + AvantGarde-BookOblique, + AvantGarde-Demi, + AvantGarde-DemiOblique, + Courier, + Courier-Bold, + Courier-BoldOblique, + Courier-Oblique, + Helvetica, + Helvetica-Bold, + Helvetica-BoldOblique, + Helvetica-Oblique, + LubalinGraph-Book, + LubalinGraph-BookOblique, + LubalinGraph-Demi, + LubalinGraph-DemiOblique, + NewCenturySchlbk-Bold, + NewCenturySchlbk-BoldItalic, + NewCenturySchlbk-Italic, + NewCenturySchlbk-Roman, + Souvenir-Demi, + Souvenir-DemiItalic, + Souvenir-Light, + Souvenir-LightItalic, + Symbol, + Times-Bold, + Times-BoldItalic, + Times-Italic, + Times-Roman, + ); + ); + + "QMS-PS 410" = ( + include "LaserWriter Plus"; + FeatureQuery *PSVersion '"(52.4) 94"'; + FeatureQuery *FreeVM '"336596"'; + FeatureQuery *Product '"(QMS-PS 410)"'; + font ( + AGaramond-Bold, + AGaramond-BoldItalic, + AGaramond-Italic, + AGaramond-Regular, + AGaramond-Semibold, + AGaramond-SemiboldItalic, + AvantGarde-Book, + AvantGarde-BookOblique, + AvantGarde-Demi, + AvantGarde-DemiOblique, + Bookman-Demi, + Bookman-DemiItalic, + Bookman-Light, + Bookman-LightItalic, + Courier, + Courier-Bold, + Courier-BoldOblique, + Courier-Oblique, + Helvetica, + Helvetica-Bold, + Helvetica-BoldOblique, + Helvetica-Condensed, + Helvetica-Condensed-Bold, + Helvetica-Condensed-BoldObl, + Helvetica-Condensed-Oblique, + Helvetica-Narrow, + Helvetica-Narrow-Bold, + Helvetica-Narrow-BoldOblique, + Helvetica-Narrow-Oblique, + Helvetica-Oblique, + NewCenturySchlbk-Bold, + NewCenturySchlbk-BoldItalic, + NewCenturySchlbk-Italic, + NewCenturySchlbk-Roman, + Palatino-Bold, + Palatino-BoldItalic, + Palatino-Italic, + Palatino-Roman, + Symbol, + Times-Bold, + Times-BoldItalic, + Times-Italic, + Times-Roman, + ZapfChancery-MediumItalic, + ZapfDingbats, + ); + ); + + "Silentwriter 95" = ( + include "LaserWriter IIg"; + FeatureQuery *PSVersion '"(2010.121) 1"'; + FeatureQuery *FreeVM '"251597"'; + FeatureQuery *TTRasterizer None; + FeatureQuery *Product '"(Silentwriter 95)"'; + Query ADORamSize '"2097152"'; + ); + + "Varityper" = ( + include "LaserWriter Plus"; + FeatureQuery *?Resolution 1270dpi; + FeatureQuery *PSVersion '"(52.3) 4.7"'; + FeatureQuery *FreeVM '"2298400"'; + FeatureQuery *Product '"(Varityper)"'; + FeatureQuery *ColorDevice Unknown; + Query ADORamSize '"16777212"'; + ); + + "SPARCprinter" = ( + include "LaserWriter Plus"; + FeatureQuery *PSVersion '"(3.010) 0"'; + FeatureQuery *FreeVM '"1147258"'; + FeatureQuery *Product '"(NeWS Server)"'; + Query ADORamSize '"138936320"'; + font ( + AvantGarde-Book, + AvantGarde-BookOblique, + AvantGarde-Demi, + AvantGarde-DemiOblique, + Bembo, + Bembo-Bold, + Bembo-BoldItalic, + Bembo-Italic, + Bookman-Demi, + Bookman-DemiItalic, + Bookman-Light, + Bookman-LightItalic, + Courier, + Courier-Bold, + Courier-BoldOblique, + Courier-Oblique, + GillSans, + GillSans-Bold, + GillSans-BoldItalic, + GillSans-Italic, + Helvetica, + Helvetica-Bold, + Helvetica-BoldOblique, + Helvetica-Narrow, + Helvetica-Narrow-Bold, + Helvetica-Narrow-BoldOblique, + Helvetica-Narrow-Oblique, + Helvetica-Oblique, + LucidaBright, + LucidaBright-Demi, + LucidaBright-DemiItalic, + LucidaBright-Italic, + LucidaSans, + LucidaSans-Bold, + LucidaSans-BoldItalic, + LucidaSans-Italic, + LucidaSans-Typewriter, + LucidaSans-TypewriterBold, + NewCenturySchlbk-Bold, + NewCenturySchlbk-BoldItalic, + NewCenturySchlbk-Italic, + NewCenturySchlbk-Roman, + Palatino-Bold, + Palatino-BoldItalic, + Palatino-Italic, + Palatino-Roman, + Rockwell, + Rockwell-Bold, + Rockwell-BoldItalic, + Rockwell-Italic, + Symbol, + Times-Bold, + Times-BoldItalic, + Times-Italic, + Times-Roman, + ZapfChancery-MediumItalic, + ZapfDingbats, + ); + ); *** applications/lwsrv/list.c.orig Mon Aug 28 20:37:09 1995 --- applications/lwsrv/list.c Mon Aug 28 20:38:59 1995 *************** *** 0 **** --- 1,373 ---- + static char rcsid[] = "$Author: djh $ $Date: 1995/08/28 10:38:35 $"; + static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/list.c,v 2.1 1995/08/28 10:38:35 djh Rel djh $"; + static char revision[] = "$Revision: 2.1 $"; + + /* + * list.c - general list package-simple and key-value lists + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #include + #include + #ifdef USESTRINGDOTH + #include + #else USESTRINGDOTH + #include + #endif USESTRINGDOTH + #include "list.h" + + #define FALSE 0 + #define TRUE 1 + + static int listcmp(); + static void sendKVTree(); + static int _AddToKVTree(/* KVTree **ent, void *key, void *val, + int (*keycmp)() */); + static KVTree *_DupKVTree(/* KVTree *lf */); + static void _FreeKVTree(/* KVTree *lp, int (*keyfree)(), int (*valfree)() */); + static void _ListKVTree(/* KVTree *kp, List *lp */); + static void *_SearchKVTree(/* KVTree *lp, void *key, int (*keycmp)() */); + char *malloc(); + char *realloc(); + + void + AddToKVTree(ent, key, val, keycmp) + KVTree **ent; + void *key, *val; + int (*keycmp)(); + { + _AddToKVTree(ent, key, val, keycmp); + } + + /* + * Modified from "Algorithms + Data Structures = Programs", Niklaus Wirth, + * 1976, section 4.4.7 Balanced Tree Insertion, page 220-221 (AVL). + * + */ + + #define L_EQUILIBRATED 2 + #define LEFTSLANTED 1 + #define L_REBALANCE 0 + + #define R_EQUILIBRATED 0 + #define RIGHTSLANTED 1 + #define R_REBALANCE 2 + + static int + _AddToKVTree(ent, key, val, keycmp) + register KVTree **ent; + void *key, *val; + int (*keycmp)(); + { + register KVTree *ent1, *ent2; + register int cmp; + char *malloc(); + + if (*ent == NULL) { /* not in tree, insert it */ + if ((*ent = (KVTree *)malloc(sizeof(KVTree))) == NULL) + errorexit(1, "_AddToKVTree: Out of memory\n"); + (*ent)->left = (*ent)->right = NULL; + (*ent)->bal = LEFTSLANTED; + (*ent)->key = key; + (*ent)->val = val; + return(1); + } + if ((cmp = (*keycmp)(key, (*ent)->key)) == 0) { /* match */ + (*ent)->val = val; + return(0); + } + if (cmp < 0) { + if (!_AddToKVTree(&(*ent)->left, key, val, keycmp)) + return(0); + /* left branch has grown higher */ + switch((*ent)->bal) { + case L_EQUILIBRATED: + (*ent)->bal = LEFTSLANTED; + return(0); + case LEFTSLANTED: + (*ent)->bal = L_REBALANCE; + return(1); + case L_REBALANCE: /* rebalance */ + if ((ent1 = (*ent)->left)->bal == L_REBALANCE) { + /* single LL rotation */ + (*ent)->left = ent1->right; + ent1->right = *ent; + (*ent)->bal = LEFTSLANTED; + *ent = ent1; + } else { + /* double LR rotation */ + ent2 = ent1->right; + ent1->right = ent2->left; + ent2->left = ent1; + (*ent)->left = ent2->right; + ent2->right = *ent; + (*ent)->bal = (ent2->bal == L_REBALANCE) ? L_EQUILIBRATED : LEFTSLANTED; + ent1->bal = (ent2->bal == L_EQUILIBRATED) ? L_REBALANCE : LEFTSLANTED; + *ent = ent2; + } + (*ent)->bal = LEFTSLANTED; + return(0); + } + } + if (!_AddToKVTree(&(*ent)->right, key, val, keycmp)) + return(0); + /* right branch has grown higher */ + switch((*ent)->bal) { + case R_EQUILIBRATED: + (*ent)->bal = RIGHTSLANTED; + return(0); + case RIGHTSLANTED: + (*ent)->bal = R_REBALANCE; + return(1); + case R_REBALANCE: /* rebalance */ + if ((ent1 = (*ent)->right)->bal == R_REBALANCE) { + /* single RR rotation */ + (*ent)->right = ent1->left; + ent1->left = *ent; + (*ent)->bal = RIGHTSLANTED; + *ent = ent1; + } else { + /* double RL rotation */ + ent2 = ent1->left; + ent1->left = ent2->right; + ent2->right = ent1; + (*ent)->right = ent2->left; + ent2->left = *ent; + (*ent)->bal = (ent2->bal == R_REBALANCE) ? R_EQUILIBRATED : RIGHTSLANTED; + ent1->bal = (ent2->bal == R_EQUILIBRATED) ? R_REBALANCE : RIGHTSLANTED; + *ent = ent2; + } + (*ent)->bal = RIGHTSLANTED; + return(0); + } + } + + void + AddToList(lp, item) + register List *lp; + void *item; + { + if (lp->n >= lp->lmax && (lp->list = (void **)realloc((char *)lp->list, + (lp->lmax += LISTDELTA) * sizeof(void *))) == NULL) + errorexit(1, "AddToList: Out of memory\n"); + lp->list[lp->n++] = item; + } + + KVTree ** + CreateKVTree() + { + register KVTree **kp; + + if ((kp = (KVTree **)malloc(sizeof(KVTree *))) == NULL) + errorexit(1, "AddToKVTree: Out of memory\n"); + *kp = NULL; + return(kp); + } + + void + CatList(to, from) + register List *to; + List *from; + { + register int n; + register void **vp; + + for (n = from->n, vp = from->list; n > 0; n--) + AddToList(to, *vp++); + } + + List * + CreateList() + { + register List *lp; + static char errstr[] = "CreateList: Out of memory\n"; + + if ((lp = (List *)malloc(sizeof(List))) == NULL) + errorexit(1, errstr); + if ((lp->list = (void **)malloc((lp->lmax = LISTDELTA) * sizeof(void *))) + == NULL) + errorexit(2, errstr); + lp->n = 0; + return(lp); + } + + KVTree ** + DupKVTree(lf) + register KVTree **lf; + { + register KVTree **kp; + + if ((kp = (KVTree **)malloc(sizeof(KVTree *))) == NULL) + errorexit(1, "DupKVTree: Out of memory\n"); + *kp = *lf ? _DupKVTree(*lf) : NULL; + return(kp); + } + + static KVTree * + _DupKVTree(lf) + register KVTree *lf; + { + register KVTree *lt; + + if ((lt = (KVTree *)malloc(sizeof(KVTree))) == NULL) + errorexit(1, "_DupKVTree: Out of memory\n"); + lt->bal = lf->bal; + lt->key = lf->key; + lt->val = lf->val; + lt->left = lf->left ? _DupKVTree(lf->left) : NULL; + lt->right = lf->right ? _DupKVTree(lf->right) : NULL; + return(lt); + } + + List * + DupList(lf) + register List *lf; + { + register List *lt; + register void **vp; + register int i; + + lt = CreateList(); + for (i = lf->n, vp = lf->list; i > 0; i--) + AddToList(lt, *vp++); + return(lt); + } + + void + FreeKVTree(lp, keyfree, valfree) + KVTree **lp; + int (*keyfree)(), (*valfree)(); + { + if (*lp) + _FreeKVTree(*lp, keyfree, valfree); + free((char *)lp); + } + + static void + _FreeKVTree(lp, keyfree, valfree) + register KVTree *lp; + int (*keyfree)(), (*valfree)(); + { + if (lp->left) + FreeKVTree(lp->left, keyfree, valfree); + if (lp->right) + FreeKVTree(lp->right, keyfree, valfree); + if (keyfree) + (*keyfree)(lp->key); + if (valfree) + (*valfree)(lp->val); + free((char *)lp); + } + + void + FreeList(lp, itemfree) + List *lp; + int (*itemfree)(); + { + register void **vp; + register int i; + + if (itemfree) + for (i = lp->n, vp = lp->list; i > 0; i--) + (*itemfree)(*vp++); + free((char *)lp->list); + free((char *)lp); + } + + List * + ListKVTree(kp) + KVTree **kp; + { + register List *lp; + + lp = CreateList(); + if (*kp) + _ListKVTree(*kp, lp); + return(lp); + } + + static void + _ListKVTree(kp, lp) + register KVTree *kp; + register List *lp; + { + if (kp->left) + _ListKVTree(kp->left, lp); + AddToList(lp, kp); + if (kp->right) + _ListKVTree(kp->right, lp); + } + + void * + SearchKVTree(lp, key, keycmp) + KVTree **lp; + void *key; + int (*keycmp)(); + { + return(*lp ? _SearchKVTree(*lp, key, keycmp) : NULL); + } + + static void * + _SearchKVTree(lp, key, keycmp) + KVTree *lp; + register void *key; + int (*keycmp)(); + { + register int cmp; + + if ((cmp = (*keycmp)(key, lp->key)) == 0) + return(lp->val); + if (cmp > 0) + return(lp->right ? _SearchKVTree(lp->right, key, keycmp) : NULL); + else + return(lp->left ? _SearchKVTree(lp->left, key, keycmp) : NULL); + } + + void * + SearchList(lp, item, itemcmp) + register List *lp; + register void *item; + int (*itemcmp)(); + { + register void **ip = lp->list; + register int i, low, high, cmp; + + low = 0; + high = lp->n - 1; + while (low <= high) { + i = (low + high) / 2; + if ((cmp = (*itemcmp)(ip[i], item)) == 0) + return(ip[i]); + if (cmp > 0) + high = i - 1; + else + low = i + 1; + } + return(NULL); + } + + void + SortList(lp, itemcmp) + register List *lp; + int (*itemcmp)(); + { + qsort((char *)lp->list, lp->n, sizeof(void *), itemcmp); + } + + int + StringSortItemCmp(a, b) + char **a, **b; + { + return(strcmp(*a, *b)); + } + + errorexit(status, str) + int status; + char *str; + { + fputs(str, stderr); + exit(status); + } *** applications/lwsrv/list.h.orig Mon Aug 28 20:37:09 1995 --- applications/lwsrv/list.h Mon Aug 28 20:39:05 1995 *************** *** 0 **** --- 1,49 ---- + /* "$Author: djh $ $Date: 1995/08/28 10:38:35 $" */ + /* "$Header: /mac/src/cap60/applications/lwsrv/RCS/list.h,v 2.1 1995/08/28 10:38:35 djh Rel djh $" */ + /* "$Revision: 2.1 $" */ + + /* + * list.h - general list package-simple and key-value lists + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #ifndef _LIST_H_ + #define _LIST_H_ + + #define LISTDELTA 10 + + typedef struct KVTree { + struct KVTree *left; + struct KVTree *right; + void *key; + void *val; + unsigned char bal; /* for AVL tree balancing */ + } KVTree; + typedef struct List { + int n; + int lmax; + void **list; + } List; + + #define AddrList(lp) (((List *)(lp))->list) + #define NList(lp) (((List *)(lp))->n) + + void AddToKVTree(/* KVTree **lp, void *key, void *val, int (*keycmp)() */); + void AddToList(/* List *lp, void *item */); + void CatList(/* List *to, List *from */); + KVTree **CreateKVTree(); + List *CreateList(); + KVTree **DupKVTree(/* KVTree **lf */); + List *DupList(/* List *lf */); + void FreeKVTree(/* KVTree **lp, int (*keyfree)(), int (*valfree)() */); + void FreeList(/* List *lp, int (*itemfree)() */); + List *ListKVTree(/* KVTree **kp */); + void *SearchKVTree(/* KVTree **lp, void *key, int (*keycmp)() */); + void *SearchList(/* List *lp, void *item, int (*itemcmp)() */); + void SortList(/* List *lp, int (*itemcmp)() */); + int StringSortItemCmp(/* char **a, char **b */); + + #endif /* _LIST_H_ */ *** applications/lwsrv/lwsrv.conf.orig Mon Aug 28 20:37:10 1995 --- applications/lwsrv/lwsrv.conf Mon Aug 28 20:39:11 1995 *************** *** 0 **** --- 1,13 ---- + Library = DB; + + Options = ( + DontCollect; + ProcsetDir /usr/local/lib/cap/procsets; + FontFile /usr/local/lib/cap/LW+Fonts; + + ); + + "Technical Services Spool Test" = ( + include "LaserWriter IIf"; + printerqueue lw.tsa; + ); *** applications/lwsrv/lwsrvconfig.c.orig Mon Aug 28 20:37:11 1995 --- applications/lwsrv/lwsrvconfig.c Thu Aug 31 00:47:47 1995 *************** *** 0 **** --- 1,710 ---- + static char rcsid[] = "$Author: djh $ $Date: 1995/08/30 14:47:34 $"; + static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/lwsrvconfig.c,v 2.1 1995/08/30 14:47:34 djh Rel djh $"; + static char revision[] = "$Revision: 2.1 $"; + + /* + * lwsrvconfig - auxiliary program for testing configuration files + * and creating printer description databases + * + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #include + #include + #include + #include + #include + #include + #include + #ifdef USESTRINGDOTH + # include + #else /* USESTRINGDOTH */ + # include + #endif /* USESTRINGDOTH */ + #ifdef NEEDFCNTLDOTH + # include + #endif NEEDFCNTLDOTH + #ifndef NONDBM + # include + #else NONDBM + # include + #endif NONDBM + #include "list.h" + #include "packed.h" + #include "parse.h" + + char *myname; + + #define F_GLOBAL (1 << F_GLOBAL_BIT) + #define F_GLOBAL_BIT 0 + #define F_HASARG (1 << F_HASARG_BIT) + #define F_HASARG_BIT 1 + #define hasarg(f) ((f) & F_HASARG) + #define isglobal(f) ((f) & F_GLOBAL) + #define sf(a,g) (((a) << F_HASARG_BIT) | ((g) << F_GLOBAL_BIT)) + + struct descrip { + char *name; + short flags; + }; + + static KVTree **argname; + static struct argnamebuf { + char *arg; + struct descrip d; + } argnamebuf[] = { + {"-A", {"DSC", sf(1, 0)}}, + {"-C", {"LPRCommand", sf(1, 1)}}, + #ifdef LPRARGS + {"-L", {"LPRArgument", sf(1, 0)}}, + #endif LPRARGS + {"-N", {"DontCollect", sf(0, 0)}}, + #ifdef PASS_THRU + {"-P", {"PassThru", sf(0, 0)}}, + #endif PASS_THRU + #ifdef NeXT + {"-R", {"NeXTResolution", sf(1, 0)}}, + #endif NeXT + {"-S", {"SingleFork", sf(0, 1)}}, + {"-T", {"TranScriptOption", sf(1, 0)}}, + #ifdef LWSRV_AUFS_SECURITY + {"-X", {"AUFSSecurity", sf(1, 1)}}, + #endif LWSRV_AUFS_SECURITY + #ifdef LW_TYPE + {"-Y", {"AppleTalkType", sf(1, 0)}}, + #endif LW_TYPE + {"-a", {"ProcsetDir", sf(1, 0)}}, + {"-d", {"Debug", sf(1, 1)}}, + {"-e", {"Alloweexec", sf(0, 0)}}, + {"-f", {"FontFile", sf(1, 0)}}, + {"-h", {"SuppressBanner", sf(0, 0)}}, + {"-k", {"NoChecksum", sf(0, 0)}}, + {"-l", {"LogFile", sf(1, 1)}}, + {"-p", {"PrinterQueue", sf(1, 0)}}, + {"-q", {"QueryFile", sf(1, 1)}}, + {"-r", {"KeepSpoolFile", sf(0, 0)}}, + {"-t", {"TraceFile", sf(1, 0)}}, + {"-v", {"Verbose", sf(0, 1)}}, + {NULL, NULL}, + }; + static char *createdb = NULL; + static int datafd; + long dataoffset = 0; + #ifndef NONDBM + static DBM *db; + #endif NONDBM + static char *dbname = NULL; + static KVTree **_default; + static int firstargs = 1; + static int firstprinter = 1; + static char firsttime[127]; + static char *headerstr = NULL; + static char null[] = ""; + static int oldformat = 0; + static char *printername; + static int verbose = 0; + + int doargs(); + + static void addback(/* int argc, char **argv */); + static void display(/* char *str, KVTree **kp */); + static void displaytemplates(); + static void docreatedb(); + static KVTree **initargname(); + static int getflags(/* char *str */); + static char *keyname(/* char *str */); + static char *quotestr(/* char *str */); + static void setfirsttime(/* char *str */); + static void storedata(/* char *name, int n, char *ptr, int size */); + static unshort *ushortdup(/* int i */); + static char *untab(/* char *str */); + static void usage(); + + main(argc, argv) + int argc; + char **argv; + { + register int c; + register KVTree **kp; + register List *lp; + register FILE *fp; + extern FILE *yyin; + extern char *optarg; + extern int optind; + + if (myname = rindex(*argv, '/')) + myname++; + else + myname = *argv; + while ((c = getopt(argc, argv, "c:l:ov?")) != EOF) { + switch(c) { + case 'c': + createdb = optarg; + break; + case 'l': + dbname = optarg; + break; + case 'o': + oldformat++; + break; + case 'v': + verbose++; + break; + case '?': + default: + usage(); + } + } + if (createdb && dbname) + usage(); + if (optind < argc) { + if ((argc - optind) > 1) + usage(); + if ((fp = fopen(argv[optind], "r")) == NULL) { + fprintf(stderr, "%s: Can't open %s\n", myname, argv[optind]); + exit(1); + } + } else + fp = stdin; + yyin = fp; /* set for flex(1) */ + argname = initargname(); + initkeyword(fp); + umask(0133); + if (yyparse()) + exit(1); + if (!dbname && libraryfile) + dbname = libraryfile; + if (createdb) + docreatedb(); + else { + _default = thequery = CreateKVTree(); + setfirsttime(specialOpts); + configargs(dbname); + } + exit(0); + } + + static void + addback(argc, argv) + register int argc; + register char **argv; + { + register void *n; + register List *lp; + register int f; + + while (argc-- > 0) { + f = getflags(*argv); + if (hasarg(f)) { + n = (void *)*argv++; + if (isSpecialOpt(n)) { + if (firsttime[Option(n)]) { + firsttime[Option(n)] = 0; + if (lp = (List *)SearchKVTree(thequery, n, strcmp)) { + if (thequery == _default) { + AddToList(lp, (void *)*argv); + } else { + lp = DupList(lp); + AddToList(lp, (void *)*argv); + AddToKVTree(thequery, n, (void *)lp, strcmp); + } + } else { + lp = CreateList(); + AddToList(lp, (void *)*argv); + AddToKVTree(thequery, n, (void *)lp, strcmp); + } + } else { + lp = (List *)SearchKVTree(thequery, n, strcmp); + AddToList(lp, (void *)*argv); + } + } else + AddToKVTree(thequery, n, (void *)*argv, strcmp); + argv++; + argc--; + } else + AddToKVTree(thequery, (void *)*argv++, NULL, strcmp); + } + } + + /* + * doargs would normally set the arguments in lwsrv. We intercept this + * to do our printing. + */ + doargs(argc, argv) + int argc; + char **argv; + { + register int n, i, f; + register char **a; + + argc--; + argv++; + if (firstargs && strcmp(*argv, "-n") != 0) { /* options */ + firstargs = 0; + if (verbose) { + addback(argc, argv); + display("Options", thequery); + } else { + n = argc; + a = argv; + i = 0; + while (n-- > 0) { + f = getflags(*a); + if (isglobal(f)) + i++; + if (hasarg(f)) { + a++; + n--; + } + a++; + } + if (i > 0) { + printf("Options = %s", i > 1 ? "(\n" : null); + n = argc; + a = argv; + while (n-- > 0) { + f = getflags(*a); + if (isglobal(f)) { + printf("%s%s", i > 1 ? "\t" : null, keyname(*a)); + if (hasarg(f)) { + printf(" %s;\n", quotestr(*++a)); + n--; + } else + fputs(";\n", stdout); + if (i == 1) + break; + } else { + if (hasarg(f)) { + a++; + n--; + } + } + a++; + } + if (i > 1) + fputs(");\n\n", stdout); + else + putchar('\n'); + } + addback(argc, argv); + } + } else if (strcmp(*argv, "-n") == 0) { + /* setup thequery so setargs will insert the queries in the right one */ + firstargs = 0; + if (thequery != _default) + FreeKVTree(thequery, NULL, NULL); + thequery = DupKVTree(_default); + if (verbose && firstprinter) { /* print the templates */ + firstprinter = 0; + displaytemplates(); + } + setfirsttime(specialOpts); + printername = *++argv; + } else { /* actually do the printer */ + addback(argc, argv); + display(printername, thequery); + } + } + + static void + docreatedb() + { + register KVTree **keys; + register PackedChar *ckeys; + register PackedChar *pc; + register PackedShort *ps; + register void **v2, **v3, **vp; + register int i, j, k; + register unshort *sp, *sp2; + register char *name; + char buf[BUFSIZ]; + + if (verbose) + printf("Creating database %s\n", createdb); + strcpy(buf, createdb); + strcat(buf, ".dir"); + unlink(buf); + strcpy(buf, createdb); + strcat(buf, ".pag"); + unlink(buf); + #ifndef NONDBM + if ((db = dbm_open(createdb, O_RDWR | O_CREAT, 0755)) == NULL) { + fprintf(stderr, "%s: Can't create database %s\n", myname, createdb); + exit(1); + } + #else NONDBM + if ((i = creat(buf, 0755)) < 0) { + fprintf(stderr, "%s: Can't create %s\n", myname, buf); + exit(1); + } + if ((i = creat(buf, 0755)) < 0) { + fprintf(stderr, "%s: Can't create %s\n", myname, buf); + exit(1); + } + if (dbminit(creatdb) < 0) { + fprintf(stderr, "%s: Can't open database %s\n", myname, createdb); + exit(1); + } + #endif NONDBM + strcpy(buf, createdb); + strcat(buf, datasuffix); + unlink(buf); + if ((datafd = open(buf, O_WRONLY | O_CREAT, 0755)) < 0) { + fprintf(stderr, "%s: Can't create %s\n", myname, buf); + exit(1); + } + keys = CreateKVTree(); + ckeys = CreatePackedChar(); + for (i = NList(printerlist), vp = AddrList(printerlist); i > 0; i -= 2) { + name = (char *)*vp++; + if (verbose) + printf("\tCreating template %s\n", name); + pc = CreatePackedChar(); + /* + * Since a zero means the a string value is null, we "use up" + * the zero so that it can never occur in our data (except to mean + * that the string is NULL + */ + AddToPackedChar(pc, null); + ps = CreatePackedShort(); + AddToPackedShort(ps, (j = NList(*vp) / 2)); + sp = AllocatePackedShort(ps, 2 * j); + for (v2 = AddrList(*vp); j > 0; j--) { + if (verbose) + printf("\t\tAdding keyword %s\n", untab((char *)*v2)); + if ((sp2 = (unshort *)SearchKVTree(keys, *v2, strcmp)) == NULL) { + k = AddToPackedChar(ckeys, (char *)*v2); + sp2 = ushortdup(k); + AddToKVTree(keys, *v2, (void *)sp2, strcmp); + } + *sp++ = *sp2; + if (StringVal(*v2)) { + v2++; + *sp++ = *v2 ? AddToPackedChar(pc, (char *)*v2) : 0; + } else { + v2++; + k = NList(*v2); + *sp++ = AddToPackedShort(ps, k); + for (v3 = AddrList(*v2); k > 0; k--) + AddToPackedShort(ps, AddToPackedChar(pc, (char *)*v3++)); + } + v2++; + } + j = (NPackedShort(ps) + 1) * sizeof(unshort); + k = NPackedChar(pc) * sizeof(char); + if ((sp = (unshort *)malloc(j + k)) == NULL) + errorexit(1, "docreatedb: Out of memory\n"); + *sp = j; + bcopy((char *)AddrPackedShort(ps), (char *)(sp + 1), + NPackedShort(ps) * sizeof(unshort)); + bcopy((char *)AddrPackedChar(pc), (char *)sp + j, k); + storedata(name, strlen(name), (char *)sp, j + k); + vp++; + } + if (verbose) + printf("Adding keywords to database %s\n", createdb); + storedata(keywords_key, KEYWORDSKEYSIZE, AddrPackedChar(ckeys), + NPackedChar(ckeys) * sizeof(char), db); + #ifndef NONDBM + dbm_close(db); + if (verbose) + printf("Closing database %s\n", createdb); + #else NONDBM + /* + * There does not seem to be a way to close the old dbm file! + */ + #endif NONDBM + } + + static void + storedata(name, n, ptr, size) + char *name; + register int n; + register char *ptr; + register int size; + { + register char *cp; + datum key, data; + Location loc; + + key.dptr = name; + key.dsize = n; + loc.magic = MagicNumber; /* to identify a real lwsrvconfig database */ + loc.offset = dataoffset; + loc.size = size; + data.dptr = (char *)&loc; + data.dsize = sizeof(Location); + #ifndef NONDBM + if (dbm_store(db, key, data, DBM_REPLACE) < 0) { + fprintf(stderr, "%s: Failed to insert %s into database %s \n", myname, + name, createdb); + exit(1); + } + #else NONDBM + if (store(key, data) < 0) { + fprintf(stderr, "%s: Failed to insert %s into database %s \n", myname, + name, createdb); + exit(1); + } + #endif NONDBM + dataoffset += size; + while (size > 0) { + if ((n = write(datafd, ptr, size)) <= 0) { + fprintf(stderr, "%s: write error on %d%s\n", myname, createdb, + datasuffix); + exit(1); + } + size -= n; + ptr += n; + } + } + + static void + display(name, kp) + char *name; + register KVTree **kp; + { + register List *lp; + register char **cp; + register int n, i; + + lp = ListKVTree(kp); + if (headerstr) { + fputs(headerstr, stdout); + headerstr = NULL; + } + printf("%s = ", quotestr(name)); + kp = (KVTree **)AddrList(lp); + if ((n = NList(lp)) == 1) { + fputs(untab((char *)(*kp)->key), stdout); + if (ListVal((*kp)->key)) { + cp = (char **)AddrList((*kp)->val); + if ((i = NList((*kp)->val)) == 1) + printf(" %s;\n", quotestr(*cp)); + else if (isSpecialOpt((*kp)->key)) { + printf(" %s;\n", quotestr(*cp)); + while (--i > 0) { + fputs(untab((char *)(*kp)->key), stdout); + printf(" %s;\n", quotestr(*++cp)); + } + } else { + fputs(" (\n", stdout); + while (i--) { + printf("\t%s,\n", quotestr(*cp)); + cp++; + } + fputs(");\n", stdout); + } + } else { + if ((*kp)->val) + printf(" %s;\n", quotestr((char *)(*kp)->val)); + else + fputs(";\n", stdout); + } + } else { + fputs("(\n", stdout); + for (;n-- > 0; kp++) { + printf("\t%s", untab((char *)(*kp)->key)); + if (ListVal((*kp)->key)) { + cp = (char **)AddrList((*kp)->val); + if ((i = NList((*kp)->val)) == 1) + printf(" %s;\n", quotestr(*cp)); + else if (isSpecialOpt((*kp)->key)) { + printf(" %s;\n", quotestr(*cp)); + while (--i > 0) { + printf("\t%s", untab((char *)(*kp)->key)); + printf(" %s;\n", quotestr(*++cp)); + } + } else { + fputs(" (\n", stdout); + while (i--) { + printf("\t\t%s,\n", quotestr(*cp)); + cp++; + } + fputs("\t);\n", stdout); + } + } else { + if ((*kp)->val) + printf(" %s;\n", quotestr((char *)(*kp)->val)); + else + fputs(";\n", stdout); + } + } + fputs(");\n", stdout); + } + } + + static void + displaytemplates() + { + register List *lp; + register KVTree **kp; + register int n; + + lp = ListKVTree(_printers); + headerstr = "\nTemplates:\n"; + for (kp = (KVTree **)AddrList(lp), n = NList(lp); n > 0; kp++, n--) { + if (SearchKVTree((*kp)->val, "-p", strcmp) == NULL) + display((*kp)->key, (*kp)->val, 0); + } + headerstr = "\nPrinters:\n"; + FreeList(lp, NULL); + } + + static KVTree ** + initargname() + { + register KVTree **kp; + register struct argnamebuf *ap; + + kp = CreateKVTree(); + for (ap = argnamebuf; ap->arg; ap++) + AddToKVTree(kp, (void *)ap->arg, (void *)&ap->d, strcmp); + return(kp); + } + + static int + getflags(str) + char *str; + { + register struct descrip *sp; + + if ((sp = (struct descrip *)SearchKVTree(argname, str, strcmp)) == NULL) { + fprintf(stderr, "%s: Unknown lwsrv argument %s\n", myname, str); + exit(1); + } + return(sp->flags); + } + + static char * + keyname(str) + char *str; + { + register struct descrip *sp; + + if (strcmp(str, includename) == 0) + return("Include"); + if (oldformat) + return(str); + return((sp = (struct descrip *)SearchKVTree(argname, str, strcmp)) ? + sp->name : str); + } + + #define DQUOTE (1 << 0) + #define SQUOTE (1 << 1) + + static char * + quotestr(str) + register char *str; + { + static char buf[256]; + register char *fp, *tp, *bp; + register int quote; + + if (!str) + return(""); + quote = 0; + if (index(str, '"')) + quote |= DQUOTE; + if (index(str, '\'')) + quote |= SQUOTE; + if (!quote && !index(str, ' ') && !index(str, '\t')) { + bp = str; + if (index(bp, '\n')) { + strcpy(bp = buf, str); + if (fp = index(bp, '\n')) + *fp = 0; + } + if (strlen(bp) == 2 && *bp == '-' && isalpha(bp[1])) { + sprintf(buf, "\"-%c\"", bp[1]); + bp = buf; + } + return(bp); + } + switch(quote) { + case 0: + case (DQUOTE | SQUOTE): + quote = '"'; + break; + default: + quote = (quote & SQUOTE) ? '"' : '\''; + break; + } + fp = str; + tp = buf; + *tp++ = quote; + while (*fp) { + if (*fp == '\n') { + fp++; + continue; + } + if (*fp == quote) + *tp++ = quote; + *tp++ = *fp++; + } + *tp++ = quote; + *tp = 0; + return(buf); + } + + static void + setfirsttime(str) + register char *str; + { + while (*str) + firsttime[*str++] = 1; + } + + static unshort * + ushortdup(i) + int i; + { + register unshort *sp; + + if ((sp = (unshort *)malloc(sizeof(unshort))) == NULL) + errorexit(1, "ushortdup: Out of memory\n"); + *sp = i; + return(sp); + } + + #if (!(defined(SOLARIS) || defined(bsdi) || defined(__NetBSD__))) + char * + strdup(str) + char *str; + { + register char *cp; + + if ((cp = (char *)malloc(strlen(str) + 1)) == NULL) + errorexit(1, "strdup: Out of memory\n"); + strcpy(cp, str); + return(cp); + } + #endif /* SOLARIS || bsdi || __NetBSD__ */ + + static void + usage() + { + fprintf(stderr, "Usage: %s [-l] dbname [-o] [-v] [file]\n", myname); + fprintf(stderr, " %s -c newdbname [-o] [-v] [file]\n", myname); + exit(1); + } + + static char * + untab(str) + char *str; + { + register char *cp, *bp; + register int i; + static char buf[256]; + + if (!(bp = index(str, '\t'))) + return(keyname(str)); + strncpy(buf, str, (i = bp - str)); + buf[i] = 0; + if ((cp = keyname(str)) != str) + strcpy(buf, cp); + strcat(buf, " "); + strcat(buf, quotestr(bp + 1)); + return(buf); + } *** applications/lwsrv/packed.c.orig Mon Aug 28 20:37:11 1995 --- applications/lwsrv/packed.c Mon Aug 28 20:39:22 1995 *************** *** 0 **** --- 1,118 ---- + static char rcsid[] = "$Author: djh $ $Date: 1995/08/28 10:38:35 $"; + static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/packed.c,v 2.1 1995/08/28 10:38:35 djh Rel djh $"; + static char revision[] = "$Revision: 2.1 $"; + + /* + * packed.c - create packed printer descriptions + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #include + #include + #include + #include + #include + #ifdef USESTRINGDOTH + #include + #else /* USESTRINGDOTH */ + #include + #endif /* USESTRINGDOTH */ + #include "packed.h" + + char *malloc(); + char *realloc(); + + unsigned + AddToPackedChar(pc, str) + register PackedChar *pc; + char *str; + { + register int l, n; + + l = strlen(str) + 1; + if ((n = pc->n) + l > pc->cmax && (pc->pc = realloc(pc->pc, + (pc->cmax += l + PACKEDCHARDELTA) * sizeof(char))) == NULL) + errorexit(1, "AddToPackedChar: Out of memory\n"); + strcpy(pc->pc + n, str); + /* + * This doesn't work on machines with 16 bit ints! + */ + if ((pc->n += l) > MAXPACKEDSIZE) + errorexit(2, "AddToPackedChar: PackedChar overflow\n"); + return(n); + } + + unsigned + AddToPackedShort(ps, i) + register PackedShort *ps; + unsigned i; + { + if (ps->n >= ps->smax && (ps->ps = (unshort *)realloc(ps->ps, + (ps->smax += PACKEDSHORTDELTA) * sizeof(unshort))) == NULL) + errorexit(1, "AddToPackedShort: Out of memory\n"); + ps->ps[ps->n] = i; + return(ps->n++); + } + + unshort * + AllocatePackedShort(ps, nshort) + register PackedShort *ps; + int nshort; + { + register int n; + + if ((n = ps->n) + nshort > ps->smax && (ps->ps = (unshort *)realloc(ps->ps, + (ps->smax += nshort + PACKEDSHORTDELTA) * sizeof(unshort))) == NULL) + errorexit(1, "AllocatePackedShort: Out of memory\n"); + ps->n += nshort; + return(ps->ps + n); + } + + PackedChar * + CreatePackedChar() + { + register PackedChar *pc; + static char errstr[] = "CreatePackedChar: Out of memory\n"; + + if ((pc = (PackedChar *)malloc(sizeof(PackedChar))) == NULL) + errorexit(1, errstr); + if ((pc->pc = malloc((pc->cmax = PACKEDCHARDELTA) * sizeof(char))) + == NULL) + errorexit(2, errstr); + pc->n = 0; + return(pc); + } + + PackedShort * + CreatePackedShort() + { + register PackedShort *ps; + static char errstr[] = "CreatePackedChar: Out of memory\n"; + + if ((ps = (PackedShort *)malloc(sizeof(PackedShort))) == NULL) + errorexit(1, errstr); + if ((ps->ps = (unshort *)malloc((ps->smax = PACKEDCHARDELTA) * sizeof(unshort))) + == NULL) + errorexit(2, errstr); + ps->n = 0; + return(ps); + } + + void + FreePackedChar(pc) + register PackedChar *pc; + { + free(pc->pc); + free((char *)pc); + } + + void + FreePackedShort(ps) + register PackedShort *ps; + { + free((char *)ps->ps); + free((char *)ps); + } *** applications/lwsrv/packed.h.orig Mon Aug 28 20:37:12 1995 --- applications/lwsrv/packed.h Mon Aug 28 20:39:27 1995 *************** *** 0 **** --- 1,46 ---- + /* "$Author: djh $ $Date: 1995/08/28 10:38:35 $" */ + /* "$Header: /mac/src/cap60/applications/lwsrv/RCS/packed.h,v 2.1 1995/08/28 10:38:35 djh Rel djh $" */ + /* "$Revision: 2.1 $" */ + + /* + * packed.h - create packed printer descriptions + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #ifndef _PACKED_H_ + #define _PACKED_H_ + + #define MAXPACKEDSIZE ((unsigned)0xffff) + #define PACKEDCHARDELTA 256 + #define PACKEDSHORTDELTA 128 + + typedef unsigned short unshort; + + typedef struct PackedChar { + unsigned n; + unsigned cmax; + char *pc; + } PackedChar; + typedef struct PackedShort { + unsigned n; + unsigned smax; + unshort *ps; + } PackedShort; + + #define AddrPackedChar(p) ((p)->pc) + #define AddrPackedShort(p) ((p)->ps) + #define NPackedChar(p) ((p)->n) + #define NPackedShort(p) ((p)->n) + + unsigned AddToPackedChar(/* PackedChar *pc, char *str */); + unsigned AddToPackedShort(/* PackedShort *ps, unsigned i */); + unshort *AllocatePackedShort(/* PackedShort *ps, int nshort */); + PackedChar *CreatePackedChar(); + PackedShort *CreatePackedShort(); + void FreePackedChar(/* PackedChar *pc */); + void FreePackedShort(/* PackedShort *ps */); + + #endif /* _PACKED_H_ */ *** applications/lwsrv/parse.c.orig Mon Aug 28 20:37:12 1995 --- applications/lwsrv/parse.c Mon Aug 28 20:39:32 1995 *************** *** 0 **** --- 1,402 ---- + static char rcsid[] = "$Author: djh $ $Date: 1995/08/28 10:38:35 $"; + static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/parse.c,v 2.1 1995/08/28 10:38:35 djh Rel djh $"; + static char revision[] = "$Revision: 2.1 $"; + + /* + * parse.c - read a configuration file and parse the information + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #include + #include + #include + #include + #include + #ifdef USESTRINGDOTH + #include + #else /* USESTRINGDOTH */ + #include + #endif /* USESTRINGDOTH */ + #ifdef NEEDFCNTLDOTH + #include + #endif /* NEEDFCNTLDOTH */ + #ifndef NONDBM + # include + #else /* NONDBM */ + # include + #endif /* NONDBM */ + #include "list.h" + #include "parse.h" + + typedef unsigned short unshort; + + char datasuffix[] = ".dat"; + char includename[] = "-"; + char keywords_key[] = "keywords\0001.0.0"; + KVTree **_printers; + char specialOpts[] = "LT"; + KVTree **thequery; + + extern char *myname; + extern List *optionlist; + extern List *printerlist; + + static char *keywords = NULL; + static KVTree **pass1; + #ifndef NONDBM + static DBM *printerdb; + #endif NONDBM + static int printerfd; + + char *malloc(); + + static void Construct(); + static char *FetchData(); + static void Include(); + static void _Include(); + static List *UnpackList(); + static List *Unpackdb(); + static void _configargs(); + static void setargs(); + + static void + Construct(name, kp, lp) + char *name; + register KVTree **kp; + List *lp; + { + register void **vp; + register int i; + register void *np; + + for (vp = (void **)AddrList(lp), i = NList(lp); i > 0; i -= 2) { + if (strcmp((char *)*vp, includename) == 0) { /* include */ + Include(name, (char *)*++vp, kp); + vp++; + continue; + } + np = *vp++; + if (isOption(np) && isSpecialOpt(np)) { + if ((lp = (List *)SearchKVTree(kp, np, strcmp)) == NULL) { + lp = CreateList(); + AddToKVTree(kp, np, lp, strcmp); + } + AddToList(lp, *vp++); + } else + AddToKVTree(kp, np, *vp++, strcmp); + } + } + + static char * + FetchData(name, n) + char *name; + register int n; + { + register char *ptr, *cp; + register int size; + datum key, data; + Location loc; + + key.dptr = name; + key.dsize = n; + #ifndef NONDBM + data = dbm_fetch(printerdb, key); + #else NONDBM + data = fetch(key); + #endif NONDBM + if (!data.dptr) + return(NULL); + if (data.dsize != sizeof(Location)) { + fprintf(stderr, "%s: location data for %s is wrong size\n", + myname, name); + exit(1); + } + bcopy((char *)data.dptr, (char *)&loc, sizeof(Location)); + if (loc.magic != MagicNumber || (size = loc.size) <= 0) { + fprintf(stderr, "%s: location data mismatch for %s\n", myname, name); + exit(1); + } + if (lseek(printerfd, loc.offset, L_SET) < 0) { + fprintf(stderr, "%s: unable to position in data file for %s\n", + myname, name); + exit(1); + } + if ((cp = ptr = malloc(size)) == NULL) { + fprintf(stderr, "%s: out of memory for %s\n", myname, name); + exit(1); + } + while (size > 0) { + if ((n = read(printerfd, cp, size)) < 0) { + fprintf(stderr, "%s: read error on %s\n", myname, name); + exit(1); + } + if (n == 0) { + fprintf(stderr, " %s: premature end of file on %s\n", myname, name); + exit(1); + } + size -= n; + cp += n; + } + return(ptr); + } + + static void + Include(name, cp, kp) + char *name, *cp; + KVTree **kp; + { + register KVTree **ip; + register List *lp; + register char *dp; + + if (ip = (KVTree **)SearchKVTree(_printers, (void *)cp, strcmp)) { + _Include(kp, *ip); + return; + } + /* not in printer list, so try pass1 */ + if (lp = (List *)SearchKVTree(pass1, (void *)cp, strcmp)) { + ip = CreateKVTree(); + /* + * We add the new (empty) tree into master printer tree before + * constructing it so as to prevent infinite include loops. + */ + AddToKVTree(_printers, (void *)cp, ip, strcmp); + Construct(cp, ip, lp); + if (*ip) + _Include(kp, *ip); + NList(lp) = 0; /* mark the list as already processed */ + return; + } + /* not in pass1, so try database */ + if (keywords && (dp = FetchData(cp, strlen(cp)))) { + lp = Unpackdb(dp); + ip = CreateKVTree(); + /* + * We add the new (empty) tree into master printer tree before + * constructing it so as to prevent infinite include loops. + */ + AddToKVTree(_printers, cp, ip, strcmp); + Construct(cp, ip, lp); + if (*ip) + _Include(kp, *ip); + return; + } + fprintf(stderr, "%s: %s: Can't include %s\n", myname, name, cp); + exit(1); + } + + static void + _Include(kp, ip) + KVTree **kp; + register KVTree *ip; + { + register List *lp; + + if (ip == NULL) + return; + if (isOption(ip->key) && isSpecialOpt(ip->key) && + (lp = (List *)SearchKVTree(kp, ip->key, strcmp))) { + CatList(lp, (List *)ip->val); + } else + AddToKVTree(kp, ip->key, ip->val, strcmp); + if (ip->left) + _Include(kp, ip->left); + if (ip->right) + _Include(kp, ip->right); + } + + static List * + UnpackList(sp, c) + register unshort *sp; + register char *c; + { + register List *lp; + register int n; + + lp = CreateList(); + for (n = *sp++; n > 0; n--) + AddToList(lp, c + *sp++); + return(lp); + } + + static List * + Unpackdb(c) + register char *c; + { + register unshort *sp, *s; + register char *cp; + register List *lp; + register int n; + + lp = CreateList(); + s = (unshort *)c; + /* + * The first unshort is offset to string section. s is now pointing to + * beginning of packed ushorts + */ + c += *s++; + /* + * The first unshort is the number of pairs in the list. Then each following + * pair of ushorts points to a name string and the value, which may be another + * string or another list. + */ + sp = s; + for (n = *sp++; n > 0; n--) { + AddToList(lp, cp = keywords + *sp++); + if (StringVal(cp)) /* value is just a string */ + AddToList(lp, *sp == 0 ? NULL : c + *sp); + else /* value is another list */ + AddToList(lp, UnpackList(s + *sp, c)); + sp++; + } + return(lp); + } + + void + configargs(dbname) + char *dbname; + { + register KVTree **kp; + register List *lp; + register void **vp; + register int i; + register char *cp; + KVTree **_default; + char buf[BUFSIZ]; + + if (dbname) { + #ifndef NONDBM + if ((printerdb = dbm_open(dbname, O_RDONLY, 0)) == NULL) { + fprintf(stderr, "%s: Can't open dbm %s\n", myname, dbname); + exit(1); + } + #else NONDBM + if (dbminit(dbname) < 0) { + fprintf(stderr, "%s: Can't open dbm %s\n", myname, dbname); + exit(1); + } + #endif NONDBM + strcpy(buf, dbname); + strcat(buf, datasuffix); + if ((printerfd = open(buf, O_RDONLY, 0)) < 0) { + fprintf(stderr, "%s: Can't open data file %s%s\n", myname, dbname, + datasuffix); + exit(1); + } + if ((keywords = FetchData(keywords_key, KEYWORDSKEYSIZE)) == NULL) { + fprintf(stderr, "%s: %s does not contain printer templates\n", + myname, dbname); + exit(1); + } + } + if (optionlist) { + _default = CreateKVTree(); + Construct("Default", _default, optionlist); + if (NList(optionlist) > 0) + setargs(NULL, _default); + FreeKVTree(_default, NULL, NULL); + } + _printers = CreateKVTree(); + /* Pass 1 */ + pass1 = CreateKVTree(); + for (vp = AddrList(printerlist), i = NList(printerlist); i > 0; i -= 2){ + cp = (char *)*vp++; + AddToKVTree(pass1, (void *)cp, *vp++, strcmp); + } + /* Pass 2 */ + for (vp = AddrList(printerlist), i = NList(printerlist); i > 0; vp++, i -= 2) { + if (NList(*vp) <= 0) /* already processed */ + continue; + kp = CreateKVTree(); + cp = (char *)*vp++; + /* + * We add the new (empty) tree into master printer tree before + * constructing it so as to prevent infinite include loops. + */ + AddToKVTree(_printers, (void *)cp, kp, strcmp); + Construct(cp, kp, (List *)*vp); + } + if (*_printers) + _configargs(*_printers); + + #ifndef NONDBM + if (printerdb) + dbm_close(printerdb); + #else NONDBM + /* + * There does not seem to be a way to close the old dbm file! + */ + #endif NONDBM + } + + static void + _configargs(kp) + register KVTree *kp; + { + if (kp == NULL) + return; + if (kp->left) + _configargs(kp->left); + if (SearchKVTree(kp->val, "-p", strcmp)) + setargs(kp->key, kp->val); + if (kp->right) + _configargs(kp->right); + } + + static void + setargs(name, kp) + char *name; + register KVTree **kp; + { + register int i, j; + register List *lp, *lk; + register void **vp; + extern int optind; + + lp = CreateList(); + AddToList(lp, myname); /* simulating argc, argv, so this is argv[0] */ + if (name) { + /* + * Just do "-n name" to force thequery to be set to the correct value. + */ + AddToList(lp, "-n"); + AddToList(lp, name); + AddToList(lp, NULL); /* Just in case */ + optind = 1; + doargs(NList(lp) - 1, AddrList(lp)); + FreeList(lp, NULL); + lp = CreateList(); + AddToList(lp, myname); + } + lk = ListKVTree(kp); + for (kp = (KVTree **)AddrList(lk), i = NList(lk); i > 0; kp++, i--) { + if (!isOption((*kp)->key)) + break; + if (isSpecialOpt((*kp)->key)) { + for (j = NList((*kp)->val), vp = AddrList((*kp)->val); j > 0; j--) { + AddToList(lp, (*kp)->key); + AddToList(lp, *vp++); + } + } else { + AddToList(lp, (*kp)->key); + if ((*kp)->val) + AddToList(lp, (*kp)->val); + } + } + if (i > 0) { + while (i-- > 0) { + AddToKVTree(thequery, (*kp)->key, (*kp)->val, strcmp); + kp++; + } + } + FreeList(lk, NULL); + if (NList(lp) > 1) { + AddToList(lp, NULL); /* Just in case */ + optind = 1; + doargs(NList(lp) - 1, AddrList(lp)); + } + FreeList(lp, NULL); + } *** applications/lwsrv/parse.h.orig Mon Aug 28 20:37:12 1995 --- applications/lwsrv/parse.h Wed Aug 30 10:53:38 1995 *************** *** 0 **** --- 1,45 ---- + /* "$Author: djh $ $Date: 1995/08/30 00:53:28 $" */ + /* "$Header: /local/mulga/mac/src/cap60/applications/lwsrv/RCS/parse.h,v 2.1 1995/08/30 00:53:28 djh Rel djh $" */ + /* "$Revision: 2.1 $" */ + + /* + * parse.h - read a configuration file and parse the information + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #ifndef _PARSE_H_ + #define _PARSE_H_ + + typedef struct Location { + int magic; + int offset; + int size; + } Location; + + #define KEYWORDSKEYSIZE 14 + #define OPTIONCHAR '-' + + #define MagicNumber 0x4c77436f /* 'LwCo' */ + #define StringVal(a) (isOption(a) && !isSpecialOpt(a)) + #define ListVal(a) (!isOption(a) || isSpecialOpt(a)) + #define isOption(a) (*(char *)(a) == OPTIONCHAR) + #define isSpecialOpt(a) (Option(a) && index(specialOpts, Option(a))) + #define Option(a) (((char *)(a))[1]) + + extern char datasuffix[]; + extern char includename[]; + extern char keywords_key[]; + extern char *libraryfile; + extern List *optionlist; + extern List *printerlist; + extern KVTree **_printers; + extern char specialOpts[]; + extern KVTree **thequery; + + void configargs(/* char *dbname */); + void initkeyword(/* FILE *fp */); + + #endif /* _PARSE_H_ */ *** applications/lwsrv/parsel.l.orig Mon Aug 28 20:37:13 1995 --- applications/lwsrv/parsel.l Wed Aug 30 00:22:34 1995 *************** *** 0 **** --- 1,226 ---- + %% + \"[^"]*\" { + register int c; + + #ifdef __cplusplus + unput(c = yyinput()); + #else + unput(c = input()); + #endif + yytext[--yyleng] = 0; + if (c != '"') { + yylval.string = strdup(yytext + 1); + return(STRING); + } + yymore(); + } + '[^']*' { + register int c; + + #ifdef __cplusplus + unput(c = yyinput()); + #else + unput(c = input()); + #endif + yytext[--yyleng] = 0; + if (c != '\'') { + yylval.string = strdup(yytext + 1); + return(STRING); + } + yymore(); + } + "," { + return(COMMA); + } + ";" { + return(EOS); + } + "=" { + return(EQUAL); + } + [{(] { + return(LPAREN); + } + [})] { + return(RPAREN); + } + [ \t\n]+ { + /* just ignore whitespace */ + } + "#"[^\n]*\n { + /* just ignore comments */ + } + [^ \t\n,;=(){}"'#]+ { + static int searchkeywords(); + return(searchkeywords(yytext, &yylval.string)); + } + %% + #undef input + #undef unput + + static unsigned char backbuf[256]; + static unsigned char *backp = backbuf; + static FILE *infp; + static List *keylist; + static struct keywordbuf { + char *key; + char *sval; + int ival; + } keywordbuf[] = { + {"-A", "-A", DSC}, + {"-C", "-C", LPRCMD}, + #ifdef LPRARGS + {"-L", "-L", LPRARGUMENT}, + #endif LPRARGS + {"-N", "-N", NOCOLLECT}, + #ifdef PASS_THRU + {"-P", "-P", PASSTHRU}, + #endif PASS_THRU + #ifdef NeXT + {"-R", "-R", NEXT}, + #endif NeXT + {"-S", "-S", SINGLEFORK}, + {"-T", "-T", TRANSCRIPT}, + #ifdef LWSRV_AUFS_SECURITY + {"-X", "-X", AUFSSECURITY}, + #endif LWSRV_AUFS_SECURITY + #ifdef LW_TYPE + {"-Y", "-Y", ATTYPE}, + #endif LW_TYPE + {"-a", "-a", DIRDICT}, + {"-d", "-d", DEBUG}, + {"-e", "-e", EEXEC}, + {"-f", "-f", FONTFILE}, + {"-h", "-h", BANNER}, + {"-k", "-k", CHECKSUM}, + {"-l", "-l", LOGFILE}, + {"-p", "-p", PRINTERQUEUE}, + {"-q", "-q", QUERYFILE}, + {"-r", "-r", KEEPFILE}, + {"-t", "-t", TRACEFILE}, + {"-v", "-v", VERBOSE}, + {"alloweexec", "-e", EEXEC}, + #ifdef LW_TYPE + {"appletalktype", "-Y", ATTYPE}, + #endif LW_TYPE + #ifdef LWSRV_AUFS_SECURITY + {"aufssecurity", "-X", AUFSSECURITY}, + #endif LWSRV_AUFS_SECURITY + {"debug", "-d", DEBUG}, + {"deniedmessage", "DeniedMessage", DENIEDMESSAGE}, + {"dontcollect", "-N", NOCOLLECT}, + {"dsc", "-A", DSC}, + {"encoding", "encoding", ENCODING}, + {"featurequery", "FeatureQuery", FEATUREQUERY}, + {"file", "file", FILERES}, + {"font", "font", FONT}, + {"fontfile", "-f", FONTFILE}, + {"form", "form", FORM}, + {"include", "-", INCLUDE}, + {"keepspoolfile", "-r", KEEPFILE}, + {"library", NULL, LIBRARY}, + {"logfile", "-l", LOGFILE}, + #ifdef LPRARGS + {"lprargument", "-L", LPRARGUMENT}, + #endif LPRARGS + {"lprcommand", "-C", LPRCMD}, + #ifdef NeXT + {"nextresolution", "-R", NEXT}, + #endif NeXT + {"nochecksum", "-k", CHECKSUM}, + {"options", NULL, OPTIONS}, + #ifdef PASS_THRU + {"passthru", "-P", PASSTHRU}, + #endif PASS_THRU + {"pattern", "pattern", PATTERN}, + {"printerquery", "PrinterQuery", PRINTERQUERY}, + {"printerqueue", "-p", PRINTERQUEUE}, + {"procsetdir", "-a", DIRDICT}, + {"query", "Query", QUERY}, + {"queryfile", "-q", QUERYFILE}, + {"singlefork", "-S", SINGLEFORK}, + {"suppressbanner", "-h", BANNER}, + {"tracefile", "-t", TRACEFILE}, + {"transcriptoption", "-T", TRANSCRIPT}, + {"verbose", "-v", VERBOSE}, + {"vmstatus", "VMStatus", VMSTATUS}, + {NULL, NULL, 0}, + }; + + void + initkeyword(fp) + FILE *fp; + { + register List *lp; + register struct keywordbuf *kp; + + lp = CreateList(); + for (kp = keywordbuf; kp->key; kp++) + AddToList(lp, (void *)kp); + keylist = lp; + infp = fp; + } + + static unsigned char input_linebuf[BUFSIZ] = ""; + static unsigned char *input_lineptr = input_linebuf; + + #ifndef YY_INPUT + static int + input() + { + register int c; + + if (backp > backbuf) + return(*--backp); + if (*input_lineptr) { + /* putc(*input_lineptr, stderr); /* DEBUG */ + return(*input_lineptr++); + } + if (fgets((char *)input_linebuf, BUFSIZ, infp) == NULL) + return(0); + linenum++; + input_lineptr = input_linebuf; + /* putc(*input_lineptr, stderr); /* DEBUG */ + return(*input_lineptr++); + } + #endif + + static int + keycmp(kp, cp) + struct keywordbuf *kp; + char *cp; + { + return(strcmp(kp->key, cp)); + } + + static int + searchkeywords(str, outstr) + char *str, **outstr; + { + register struct keywordbuf *kp; + register char *cp; + char buf[BUFSIZ]; + static int keycmp(); + + if (*str != '-') { + strcpy(buf, str); + for (cp = buf; *cp; cp++) + if (isupper(*cp)) + *cp = tolower(*cp); + cp = buf; + } else + cp = str; + if (kp = (struct keywordbuf *)SearchList(keylist, cp, keycmp)) { + *outstr = kp->sval; + return(kp->ival); + } + *outstr = strdup(str); + return(STRING); + } + + static int + unput(c) + int c; + { + *backp++ = c; + } *** applications/lwsrv/parsey.y.orig Mon Aug 28 20:37:13 1995 --- applications/lwsrv/parsey.y Mon Aug 28 20:39:46 1995 *************** *** 0 **** --- 1,478 ---- + %{ + /* + * parsey - UNIX AppleTalk spooling program: act as a laserwriter + * yacc configuration file parser + * + */ + #include + #include + #include + #include "list.h" + #include "parse.h" + + typedef struct NameVal { + char *name; + void *val; + } NameVal; + + /* + * Globals + */ + + char *libraryfile = 0; + List *optionlist = 0; + List *printerlist = 0; + + /* + * Function typecasts + */ + + static char *addnl(); + static NameVal *CreateNameVal(); + + int strcmp(); + char *strdup(); + + %} + %union { + char *string; + List *list; + NameVal *nameval; + } + %token ATTYPE AUFSSECURITY BANNER CHECKSUM COMMA DEBUG DENIEDMESSAGE DIRDICT + %token DSC EEXEC ENCODING EOS EQUAL FEATUREQUERY FILERES FONT FONTFILE FORM + %token INCLUDE KEEPFILE LIBRARY LOGFILE LPAREN LPRARGUMENT LPRCMD NEXT + %token NOCOLLECT OPTIONS PASSTHRU PATTERN PRINTERQUERY PRINTERQUEUE QUERY + %token QUERYFILE RPAREN SINGLEFORK STRING TRACEFILE TRANSCRIPT VERBOSE VMSTATUS + + %type ATTYPE AUFSSECURITY BANNER CHECKSUM DEBUG DENIEDMESSAGE DIRDICT + %type DSC EEXEC ENCODING FEATUREQUERY FILERES FONT FONTFILE FORM + %type INCLUDE KEEPFILE LOGFILE LPRARGUMENT LPRCMD NEXT NOCOLLECT + %type PASSTHRU PATTERN PRINTERQUERY PRINTERQUEUE QUERY QUERYFILE + %type SINGLEFORK STRING TRACEFILE TRANSCRIPT VERBOSE VMSTATUS + %type lwsrvnoarg lwsrvwitharg optnoarg optwitharg queryargtype + %type querynoargtype querytype shortresource special + %type block clause list optionblock optionclause optlist stringcomma + %type stringlist stringnlcomma stringnllist stringnlset stringset + %type aprinter include lwsrvoption optstatement printeroption + %type printerqueue query resource specialstrings statement + + %start configuration + %% + configuration : library options printers + ; + + library : /* empty */ + | LIBRARY EQUAL STRING EOS + { + libraryfile = $3; + } + + options : /* empty */ + | OPTIONS EQUAL optionblock + { + optionlist = $3; + } + ; + + optionblock : optstatement + { + register List *lp; + + lp = CreateList(); + AddToList(lp, (void *)$1->name); + AddToList(lp, (void *)$1->val); + free((char *)$1); + $$ = lp; + } + | optionclause EOS + ; + + optionclause : LPAREN optlist RPAREN + { + $$ = $2; + } + ; + + optlist : optstatement + { + register List *lp; + + lp = CreateList(); + AddToList(lp, (void *)$1->name); + AddToList(lp, (void *)$1->val); + free((char *)$1); + $$ = lp; + } + | optlist optstatement + { + AddToList($1, (void *)$2->name); + AddToList($1, (void *)$2->val); + free((char *)$2); + $$ = $1; + } + ; + + optstatement : lwsrvoption EOS + | printeroption EOS + | query EOS + | resource EOS + | specialstrings EOS + ; + + lwsrvoption : lwsrvwitharg STRING + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + | lwsrvnoarg + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = NULL; + $$ = np; + } + ; + + lwsrvwitharg : LOGFILE + | DEBUG + | AUFSSECURITY + | LPRCMD + | QUERYFILE + ; + + lwsrvnoarg : VERBOSE + | SINGLEFORK + ; + + printers : aprinter + { + printerlist = CreateList(); + AddToList(printerlist, (void *)$1->name); + AddToList(printerlist, (void *)$1->val); + free((char *)$1); + } + | printers aprinter + { + AddToList(printerlist, (void *)$2->name); + AddToList(printerlist, (void *)$2->val); + free((char *)$2); + } + ; + + aprinter : STRING EQUAL block + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$3; + $$ = np; + } + ; + + block : statement + { + register List *lp; + + lp = CreateList(); + AddToList(lp, (void *)$1->name); + AddToList(lp, (void *)$1->val); + free((char *)$1); + $$ = lp; + } + | clause EOS + ; + + clause : LPAREN list RPAREN + { + $$ = $2; + } + ; + + list : statement + { + register List *lp; + + lp = CreateList(); + AddToList(lp, (void *)$1->name); + AddToList(lp, (void *)$1->val); + free((char *)$1); + $$ = lp; + } + | list statement + { + AddToList($1, (void *)$2->name); + AddToList($1, (void *)$2->val); + free((char *)$2); + $$ = $1; + } + ; + + statement : printerqueue EOS + | printeroption EOS + | include EOS + | query EOS + | resource EOS + | specialstrings EOS + ; + + printerqueue : PRINTERQUEUE STRING + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + ; + + printeroption : optwitharg STRING + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + | optnoarg + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = NULL; + $$ = np; + } + ; + + optwitharg : DIRDICT + | FONTFILE + | DSC + | TRANSCRIPT + | NEXT + | ATTYPE + | LPRARGUMENT + | TRACEFILE + ; + + optnoarg : EEXEC + | BANNER + | CHECKSUM + | NOCOLLECT + | PASSTHRU + | KEEPFILE + ; + + include : INCLUDE STRING + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + ; + + query : querytype stringnlset + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + ; + + querytype : queryargtype STRING + { + register char *cp; + + if((cp = (char *)malloc(strlen($1) + strlen($2) + 2)) + == NULL) + errorexit(1, "parse: Out of memory\n"); + sprintf(cp, "%s\t%s", $1, $2); + free($2); + $$ = cp; + } + | querynoargtype + ; + + queryargtype : FEATUREQUERY + | QUERY + ; + + querynoargtype : PRINTERQUERY + | VMSTATUS + ; + + resource : shortresource stringset + { + register NameVal *np; + + SortList($2, StringSortItemCmp); + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + ; + + shortresource : FONT + | FILERES + | PATTERN + | FORM + | ENCODING + ; + + stringnlset : STRING + { + register List *list; + + list = CreateList(); + AddToList(list, (void *)addnl($1)); + $$ = list; + } + | LPAREN stringnlcomma RPAREN + { + $$ = $2; + } + ; + + stringnlcomma : stringnllist + | stringnllist COMMA + ; + + stringnllist : STRING + { + register List *list; + + list = CreateList(); + AddToList(list, (void *)addnl($1)); + $$ = list; + } + | stringnllist COMMA STRING + { + AddToList($1, (void *)addnl($3)); + $$ = $1; + } + ; + + stringset : STRING + { + register List *list; + + list = CreateList(); + AddToList(list, (void *)$1); + $$ = list; + } + | LPAREN stringcomma RPAREN + { + $$ = $2; + } + ; + + stringcomma : stringlist + | stringlist COMMA + ; + + stringlist : STRING + { + register List *list; + + list = CreateList(); + AddToList(list, (void *)$1); + $$ = list; + } + | stringlist COMMA STRING + { + AddToList($1, (void *)$3); + $$ = $1; + } + ; + + specialstrings : special stringnlset + { + register NameVal *np; + + np = CreateNameVal(); + np->name = $1; + np->val = (void *)$2; + $$ = np; + } + ; + + special : DENIEDMESSAGE + ; + + %% + static char strbuf[256]; + int linenum = 0; + + static void _Include(/* KVTree **kp, KVTree *ip */); + + #include "lex.yy.c" + + static NameVal * + CreateNameVal() + { + register NameVal *np; + + if((np = (NameVal *)malloc(sizeof(NameVal))) == NULL) + errorexit(1, "CreateNameVal: Out of memory\n"); + return(np); + } + + static char * + addnl(str) + char *str; + { + register char *cp; + + if((cp = (char *)malloc(strlen(str) + 2)) == NULL) + errorexit(1, "addnl:Out of memory\n"); + strcpy(cp, str); + strcat(cp, "\n"); + free(str); + return(cp); + } + + yyerror(s) + char *s; + { + register int i, j; + register unsigned char *tp, *fp, *cp; + unsigned char buf[BUFSIZ]; + + i = 0; + for(tp = buf, fp = input_linebuf; fp < input_lineptr; fp++) { + if(*fp == '\t') { + i += (j = 8 - (i % 8)); + while(j-- > 0) + *tp++ = ' '; + continue; + } + *tp++ = *fp; + i++; + } + cp = tp; + while(*cp++ = *fp++); + fprintf(stderr, "*** %s in configuration file on or before line %d\n", s, + linenum); + fputs((char *)buf, stderr); + if((i = (tp - buf) - 2) < 0) + i = 0; + while(i-- > 0) + putc('-', stderr); + fputs("^\n", stderr); + } *** applications/lwsrv/query.c.orig Mon Aug 28 20:37:13 1995 --- applications/lwsrv/query.c Wed Aug 30 18:14:11 1995 *************** *** 0 **** --- 1,201 ---- + static char rcsid[] = "$Author: djh $ $Date: 1995/08/30 08:13:25 $"; + static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/query.c,v 2.2 1995/08/30 08:13:25 djh Rel djh $"; + static char revision[] = "$Revision: 2.2 $"; + + /* + * query.c - handle the LaserWriter 8 printer queries + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #include + #include + #include + #include + #ifdef USESTRINGDOTH + #include + #else /* USESTRINGDOTH */ + #include + #endif /* USESTRINGDOTH */ + #include "list.h" + #include "query.h" + #include "papstream.h" + + import char *myname; + + private char newline[] = "\n"; + private char no[] = ":No\n"; + private char star[] = "*\n"; + private char yes[] = ":Yes\n"; + + private void _SendResourceKVTree(); + private char *buildProc(); + + void + SendMatchedKVTree(pf, list, prefix, str) /* only used by procset */ + PFILE *pf; + KVTree **list; + char *prefix, *str; + { + register char *cp, *tp; + char buf[256], proc[256]; + + if (prefix == NULL) + cp = buf; + else { + strcpy(buf, prefix); + cp = buf + strlen(buf); + } + while (buildProc(&str, proc)) { + strcpy(cp, proc); + strcat(cp, SearchKVTree(list, proc, strcmp) ? yes : no); + p_write(pf,buf,strlen(buf),FALSE); + } + p_write(pf,star,strlen(star),FALSE); + } + + void + SendMatchedResources(pf, list, prefix, str) + PFILE *pf; + List *list; + char *prefix, *str; + { + register char *cp, *tp; + char buf[256]; + + if (prefix == NULL) + cp = buf; + else { + strcpy(buf, prefix); + cp = buf + strlen(buf); + } + while (tp = nextoken(&str)) { + strcpy(cp, tp); + strcat(cp, SearchList(list, tp, strcmp) ? yes : no); + p_write(pf,buf,strlen(buf),FALSE); + } + p_write(pf,star,strlen(star),FALSE); + } + + void + SendResourceKVTree(pf, list, prefix) + PFILE *pf; + KVTree **list; + char *prefix; + { + register char *cp; + char buf[256]; + + if (prefix == NULL) + cp = buf; + else { + strcpy(buf, prefix); + cp = buf + strlen(buf); + } + _SendResourceKVTree(pf, *list, buf, cp); + p_write(pf,star,strlen(star),FALSE); + } + + private void + _SendResourceKVTree(pf, lp, buf, cp) + PFILE *pf; + register KVTree *lp; + char *buf, *cp; + { + if (lp == NULL) + return; + if (lp->left) + _SendResourceKVTree(pf, lp->left, buf, cp); + strcpy(cp, (char *)lp->key); + strcat(cp, newline); + p_write(pf,buf,strlen(buf),FALSE); + if (lp->right) + _SendResourceKVTree(pf, lp->right, buf, cp); + } + + void + SendResourceList(pf, list, prefix) + PFILE *pf; + List *list; + char *prefix; + { + register int i; + register char **ip; + register char *cp; + char buf[256]; + + if (prefix == NULL) + cp = buf; + else { + strcpy(buf, prefix); + cp = buf + strlen(buf); + } + for (ip = (char **)AddrList(list), i = NList(list); i > 0; ip++, i--) { + strcpy(cp, *ip); + strcat(cp, newline); + p_write(pf,buf,strlen(buf),FALSE); + } + p_write(pf,star,strlen(star),FALSE); + } + + void + SendQueryResponse(pf, list) + PFILE *pf; + List *list; + { + register char **lp; + register int i; + + for (i = NList(list), lp = (char **)AddrList(list); i > 0; lp++, i--) + p_write(pf, *lp, strlen(*lp), FALSE); + } + + private char * + buildProc(str, buf) + char **str; + char *buf; + { + register char *tp; + + if (!(tp = nextoken(str))) + return(NULL); + strcpy(buf, tp); + if (!(tp = nextoken(str))) + return(buf); + strcat(buf, " "); + strcat(buf, tp); + if (!(tp = nextoken(str))) + return(buf); + strcat(buf, " "); + strcat(buf, tp); + return(buf); + } + + char * + nextoken(cp) + char **cp; + { + register char *bp, *ep; + + bp = *cp; + while (isspace(*bp)) + bp++; + if (*bp == 0) + return(NULL); + ep = bp + 1; + if (*bp == '"') { + while (*ep && *ep != '"') + ep++; + if (*ep) + ep++; + } else { + while (*ep && !isspace(*ep)) + ep++; + } + if (*ep) + *ep++ = 0; + *cp = ep; + return(bp); + } *** applications/lwsrv/query.h.orig Mon Aug 28 20:37:14 1995 --- applications/lwsrv/query.h Mon Aug 28 20:39:57 1995 *************** *** 0 **** --- 1,64 ---- + /* "$Author: djh $ $Date: 1995/08/28 10:38:35 $" */ + /* "$Header: /mac/src/cap60/applications/lwsrv/RCS/query.h,v 2.1 1995/08/28 10:38:35 djh Rel djh $" */ + /* "$Revision: 2.1 $" */ + + /* + * query.h - handle the LaserWriter 8 printer queries + * + * UNIX AppleTalk spooling program: act as a laserwriter + * AppleTalk package for UNIX (4.2 BSD). + * + */ + + #ifndef _QUERY_H_ + #define _QUERY_H_ + + struct printer_instance { + char *dictdir; /* dictionary directory (-a) */ + time_t lastried; /* dictdir last modified */ + KVTree **dictlist; /* dictionary list */ + int dochecksum; /* doing checksum (-k) */ + int hflag; /* print banner (-h) */ + int rflag; /* don't remove file (-r) */ + char *tracefile; /* tracefile (-t) */ + int eflag; /* maybe "eexec" in code(-e) */ + int toptions; /* Transcript options (-T) */ + int dsc2; /* DSC2 compatibility (-A) */ + #ifdef LPRARGS + List *lprargs; /* lpr arguments (-L) */ + #endif LPRARGS + #ifdef PASS_THRU + int passthru; /* pass through (-P) */ + #endif PASS_THRU + #ifdef NeXT + char* nextdpi; /* NeXT resolution (-R) */ + #endif NeXT + #ifdef LW_TYPE + char *prttype; /* AppleTalk type (-Y) */ + #endif LW_TYPE + int capture; /* capture procset (-N) */ + /* NBP and UNIX name required */ + char *prtname; /* NBP registered printername */ + char *unixpname; /* UNIX printer name */ + /* Query list */ + KVTree **querylist; + /* AppleTalk stuff */ + PAPStatusRec statbuf; + int srefnum; /* returned by SLInit */ + char nbpbuf[128]; /* registered name:type@zone */ + int rcomp; /* flag: waiting for job? */ + int cno; /* connection number of next job */ + int children; /* number of active children */ + }; + + void SendMatchedKVTree(/* PFILE *pf, KVTree **list, char *prefix, + char *str */); + void SendMatchedResources(/* PFILE *pf, List *list, char *prefix, + char *str */); + void SendQueryResponse(/* PFILE *pf, List *list */); + void SendResourceKVTree(/* PFILE *pf, KVTree **list, char *prefix */); + void SendResourceList(/* PFILE *pf, List *list, char *prefix */); + void SendQueryResponse(/* PFILE *pf, List *list */); + char *nextoken(/* char **cp */); + + #endif /* _QUERY_H_ */ *** applications/lwsrv/query.ps.orig Mon Aug 28 20:37:15 1995 --- applications/lwsrv/query.ps Mon Aug 28 20:40:03 1995 *************** *** 0 **** --- 1,201 ---- + %! + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % This file prints the responses to the standard LaserWriter 8.0 driver + % queries. (Note: the ADOSpooler query has been modified to output "spooler" + % rather than "0". This is to avoid confusion in what to enter in the + % database, since lwsrv should response with "spooler", not the default "0".) + % + % Remove the beginning part of the file, up to (but not including) the line + % beginning with "%!PS-Adobe 3.0 Query" if you want the query responses to + % be sent to the printer's standard output (and probably captured in a log + % file) rather than being printed. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + /D 6 dict def + D begin + /in {72 mul} def + /top 10.5 in def + /bottom .5 in def + /left 1 in def + /ypos top def + /lf 10 def + end + /Courier findfont 9 scalefont setfont + /Str 256 string def + /flush {showpage} def + /INITGRAPHICS {initgraphics} bind def + /initgraphics {currentpoint INITGRAPHICS moveto} def + /RESTORE {restore} bind def + /restore {D begin ypos end currentpoint 4 -1 roll RESTORE + moveto D begin /ypos exch def end} def + /newline {D begin /ypos ypos lf sub dup bottom lt {pop showpage top}if def + left ypos moveto end} def + D begin left ypos moveto end + /= {Str cvs show newline} def + /== {Str cvs show newline} def + /print {Str cvs (\n) search {show pop newline}if show} def + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %!PS-Adobe-3.0 Query + %%?BeginFeatureQuery: *LanguageLevel + (==>FeatureQuery *LanguageLevel) = + /languagelevel where + { + pop languagelevel dup 2 ge{(")print 3 string cvs print("\n)}{pop("1"\n)}ifelse + }{ + ("1"\n) + }ifelse + print + %%?EndFeatureQuery: Unknown + %%?BeginFeatureQuery: *PSVersion + (==>FeatureQuery *PSVersion) = + statusdict begin + ("\()print version print(\) )print revision 40 string cvs print("\n)print + end + %%?EndFeatureQuery: Unknown + %%?BeginQuery: ADOSpooler + (==>Query ADOSpooler) = + (spooler) == + %%?EndQuery: spooler + %%?BeginFeatureQuery: *?Resolution + (==>FeatureQuery *?Resolution) = + /mstr 40 string def + initgraphics + 72 0 dtransform + dup mul exch dup mul add sqrt .25 add round + cvi + 0 72 dtransform + dup mul exch dup mul add sqrt .25 add round + cvi 2 copy eq + { + pop + mstr cvs print + }{ + exch + mstr cvs print(x)print + mstr cvs print + }ifelse + (dpi\n)print + %%?EndFeatureQuery: Unknown + %%?BeginQuery: ADOIsBinaryOK? + (==>Query ADOIsBinaryOK?) = + (True\n) + /currentdevparams where + { + pop + [ + { + currentsystemparams/CurInputDevice get + currentdevparams + }stopped + { + cleartomark 0 dict + }{ + exch pop + }ifelse + dup/Filtering known + { + /Filtering get + /None ne + {pop(False\n)}if + }{ + pop + }ifelse + }if + print + %%?EndQuery: Unknown + %%?BeginFeatureQuery: *FreeVM + (==>FeatureQuery *FreeVM) = + (")print vmstatus exch sub 40 string cvs print("\n)print pop + %%?EndFeatureQuery: Unknown + %%?BeginFeatureQuery: *TTRasterizer + (==>FeatureQuery *TTRasterizer) = + save + true + { + systemdict/resourcestatus known{ + 42/FontType resourcestatus{pop pop false(Type42)=}{true}ifelse + }{true}ifelse + }{false}ifelse + { + statusdict begin product end dup(LaserWriter)ne exch(LaserWriter Plus)ne and + systemdict/eexec known and + systemdict/cexec known and{ + countdictstack mark + false + <1861AEDAE118A9F95F1629C0137F8FE656811DD93DFBEA65E947502E78BA12284B8A58EF0A3 + 2E272778DAA2ABEC72A84102D591E11D96BA61F57877B895A752D9BEAAC3DFD7D3220E2BDE7 + C036467464E0E836748F1DE7AB6216866F130CE7CFCEC8CE050B870C11881EE3E9D70919> + {eexec}stopped{ + cleartomark + countdictstack exch sub dup 0 gt{{end}repeat}{pop}ifelse + false + }{ + {cleartomark pop true}{cleartomark pop false}ifelse + }ifelse + }{false}ifelse{ + false + (Accept68K)= + }{true}ifelse + }{false}ifelse + { + (None)= + }if + restore + %%?EndFeatureQuery: Unknown + %%?BeginFeatureQuery: *Product + (==>FeatureQuery *Product) = + statusdict begin + ("\()print product print(\)"\n)print + end + %%?EndFeatureQuery: Unknown + %%?BeginFeatureQuery: *ColorDevice + (==>FeatureQuery *ColorDevice) = + systemdict/colorimage known + { + statusdict begin + /processcolors where + { + pop processcolors 1 eq + { + (Unknown) + }{ + (True) + }ifelse + }{ + (Unknown) + }ifelse + end + }{ + (False) + }ifelse + print(\n)print + %%?EndFeatureQuery: Unknown + %%?BeginQuery: ADORamSize + (==>Query ADORamSize) = + /languagelevel where{pop languagelevel}{1}ifelse 2 ge{ + currentsystemparams dup/RamSize known{/RamSize get}{pop -1}ifelse + }{ + statusdict/ramsize known{statusdict begin ramsize end}{-1}ifelse + }ifelse dup 0 le{ + pop vmstatus exch pop exch pop + gsave newpath matrix setmatrix clippath pathbbox grestore + mul 8 div cvi + statusdict/processcolors known{statusdict/processcolors get exec mul}if + exch pop exch pop add + cachestatus pop exch pop add exch pop add exch pop add + 524288 div ceiling cvi 524288 mul + }if(")print 40 string cvs print("\n)print + %%?EndQuery: Unknown + %%?BeginFeatureQuery: *FaxSupport + (==>FeatureQuery *FaxSupport) = + (None)/resourcestatus where{pop + /HWOptions/Category resourcestatus{pop pop + /Fax/HWOptions resourcestatus{pop pop pop(Base)}if + }if + }if print(\n)print + %%?EndFeatureQuery: Unknown + %%?BeginFontListQuery + (==>FontListQuery) = + save/scratch 100 string def FontDirectory{pop =}forall systemdict/filenameforall known{(fonts/*){(.)search {pop pop pop}{dup length 6 sub 6 exch getinterval =}ifelse}scratch filenameforall}if(*) = restore + %%?EndFontListQuery: * + flush + %%EOF *** applications/lwsrv/Makefile.m4.orig Sun Mar 8 17:35:23 1992 --- applications/lwsrv/Makefile.m4 Mon Aug 28 21:10:26 1995 *************** *** 3,34 **** LWFLAGS=lwflags() LIBCAP=libcap() I=includedir() # Valid are: -DADOBE_DSC2_CONFORMANT SIMPLEFLAGS=simpleflags() LWSRVOBJS=fontlist.o lwsrv.o papstream.o procset.o simple.o spmisc.o # for other libraries (like BSD on hpux) SLIB=libspecial() # make sure that you define point getopt to att_getopt.o if your system # doesn't have it builtin ATT_GETOPT=ifdef([needgetopt],[needgetopt]) lwsrv: ${LWSRVOBJS} ${ATT_GETOPT} ${CC} -o lwsrv ${LFLAGS} ${LWSRVOBJS} ${ATT_GETOPT} ${LIBCAP} ${SLIB} clean: ! -rm -f *.o lwsrv att_getopt.c spotless: ! -rm -f *.o *.orig lwsrv att_getopt.c Makefile makefile ! install: lwsrv ! -strip lwsrv ifdef([sysvinstall],[install -f $(DESTDIR) lwsrv], [${INSTALLER} lwsrv ${DESTDIR}]) dist: @cat todist --- 3,55 ---- LWFLAGS=lwflags() LIBCAP=libcap() I=includedir() + YACC=yacc + LEX=lex # Valid are: -DADOBE_DSC2_CONFORMANT SIMPLEFLAGS=simpleflags() LWSRVOBJS=fontlist.o lwsrv.o papstream.o procset.o simple.o spmisc.o + LWSRV8OBJS=fontlist8.o lwsrv8.o papstream8.o procset8.o simple8.o \ + spmisc.o query.o list.o parse.o y.tab.o + LWSRVCONFIGOBJS=lwsrvconfig.o list.o packed.o parse.o y.tab.o # for other libraries (like BSD on hpux) SLIB=libspecial() + # lex library + LLIB= -ll # make sure that you define point getopt to att_getopt.o if your system # doesn't have it builtin ATT_GETOPT=ifdef([needgetopt],[needgetopt]) + all: lwsrv lwsrv8 lwsrvconfig + lwsrv: ${LWSRVOBJS} ${ATT_GETOPT} ${CC} -o lwsrv ${LFLAGS} ${LWSRVOBJS} ${ATT_GETOPT} ${LIBCAP} ${SLIB} + lwsrv8: ${LWSRV8OBJS} ${ATT_GETOPT} + ${CC} -o lwsrv8 ${LFLAGS} ${LWSRV8OBJS} ${ATT_GETOPT} ${LIBCAP} \ + ${SLIB} ${LLIB} + + lwsrvconfig: ${LWSRVCONFIGOBJS} + ${CC} -o lwsrvconfig ${LFLAGS} ${LWSRVCONFIGOBJS} ${SLIB} ${LLIB} + clean: ! -rm -f *.o lwsrv lwsrv8 lwsrvconfig att_getopt.c lex.yy.c y.tab.c spotless: ! -rm -f *.o *.orig lwsrv lwsrv8 lwsrvconfig att_getopt.c \ ! lex.yy.c y.tab.c Makefile makefile ! install: lwsrv lwsrv8 lwsrvconfig ! -strip lwsrv lwsrv8 lwsrvconfig ifdef([sysvinstall],[install -f $(DESTDIR) lwsrv], [${INSTALLER} lwsrv ${DESTDIR}]) + ifdef([sysvinstall],[install -f $(DESTDIR) lwsrv8], + [${INSTALLER} lwsrv8 ${DESTDIR}]) + ifdef([sysvinstall],[install -f $(DESTDIR) lwsrvconfig], + [${INSTALLER} lwsrvconfig ${DESTDIR}]) dist: @cat todist *************** *** 42,69 **** lwsrv.o: lwsrv.c ${CC} ${CFLAGS} ${LWFLAGS} -c lwsrv.c # Dependencies lwsrv.o: lwsrv.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ ! $I/netat/compat.h papstream.h simple.o: simple.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/sysvcompat.h $I/netat/compat.h \ ! spmisc.h \ ! procset.h fontlist.h papstream.h fontlist.o: fontlist.c $I/netat/appletalk.h \ $I/netat/aberrors.h $I/netat/abqueue.h \ $I/netat/sysvcompat.h fontlist.h \ ! spmisc.h papstream.h papstream.o: papstream.c $I/netat/appletalk.h \ $I/netat/aberrors.h $I/netat/abqueue.h \ $I/netat/sysvcompat.h papstream.h procset.o: procset.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/sysvcompat.h $I/netat/compat.h \ ! procset.h \ ! spmisc.h spmisc.o: spmisc.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/sysvcompat.h $I/netat/compat.h \ spmisc.h --- 63,144 ---- lwsrv.o: lwsrv.c ${CC} ${CFLAGS} ${LWFLAGS} -c lwsrv.c + simple8.o: simple.c + ${CC} -DLWSRV8 ${CFLAGS} ${SIMPLEFLAGS} -o simple8.o -c simple.c + + lwsrv8.o: lwsrv.c + ${CC} -DLWSRV8 ${CFLAGS} ${LWFLAGS} -o lwsrv8.o -c lwsrv.c + + fontlist8.o: fontlist.c + ${CC} -DLWSRV8 ${CFLAGS} ${LWFLAGS} -o fontlist8.o -c fontlist.c + + papstream8.o: papstream.c + ${CC} -DLWSRV8 ${CFLAGS} ${LWFLAGS} -o papstream8.o -c papstream.c + + procset8.o: procset.c + ${CC} -DLWSRV8 ${CFLAGS} ${LWFLAGS} -o procset8.o -c procset.c + + lwsrvconfig.o: lwsrvconfig.c + ${CC} ${CFLAGS} ${LWFLAGS} -c lwsrvconfig.c + + y.tab.o: y.tab.c lex.yy.c + ${CC} ${CFLAGS} ${LWFLAGS} -c y.tab.c + + y.tab.c: parsey.y + ${YACC} parsey.y + + lex.yy.c: parsel.l + ${LEX} parsel.l + + query.o: query.c + ${CC} ${CFLAGS} ${LWFLAGS} -c query.c + # Dependencies lwsrv.o: lwsrv.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ ! $I/netat/compat.h papstream.h ! lwsrv8.o: lwsrv.c $I/netat/appletalk.h $I/netat/aberrors.h \ ! $I/netat/abqueue.h $I/netat/sysvcompat.h \ ! $I/netat/compat.h papstream.h fontlist.h \ ! list.h query.h parse.h procset.h simple.o: simple.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/sysvcompat.h $I/netat/compat.h \ ! spmisc.h procset.h fontlist.h papstream.h ! simple8.o: simple.c $I/netat/appletalk.h $I/netat/aberrors.h \ ! $I/netat/abqueue.h $I/netat/sysvcompat.h \ ! $I/netat/sysvcompat.h $I/netat/compat.h \ ! spmisc.h procset.h fontlist.h papstream.h \ ! list.h query.h parse.h fontlist.o: fontlist.c $I/netat/appletalk.h \ $I/netat/aberrors.h $I/netat/abqueue.h \ $I/netat/sysvcompat.h fontlist.h \ ! spmisc.h papstream.h ! fontlist8.o: fontlist.c $I/netat/appletalk.h \ ! $I/netat/aberrors.h $I/netat/abqueue.h \ ! $I/netat/sysvcompat.h fontlist.h \ ! spmisc.h papstream.h list.h query.h parse.h papstream.o: papstream.c $I/netat/appletalk.h \ $I/netat/aberrors.h $I/netat/abqueue.h \ $I/netat/sysvcompat.h papstream.h + papstream8.o: papstream.c $I/netat/appletalk.h \ + $I/netat/aberrors.h $I/netat/abqueue.h \ + $I/netat/sysvcompat.h papstream.h procset.o: procset.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/sysvcompat.h $I/netat/compat.h \ ! procset.h spmisc.h ! procset8.o: procset.c $I/netat/appletalk.h $I/netat/aberrors.h \ ! $I/netat/abqueue.h $I/netat/sysvcompat.h \ ! $I/netat/sysvcompat.h $I/netat/compat.h \ ! procset.h spmisc.h list.h query.h spmisc.o: spmisc.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/sysvcompat.h $I/netat/compat.h \ spmisc.h + query.o: query.c $I/netat/appletalk.h list.h query.h parse.h \ + papstream.h + y.tab.c: parsey.y list.h parse.h + lwsrvconfig.o: lwsrvconfig.c list.h parse.h packed.h + parse.o: parse.c list.h parse.h + packed.o: packed.c packed.h *** applications/lwsrv/README.orig Thu Feb 28 23:44:14 1991 --- applications/lwsrv/README Mon Aug 28 21:10:30 1995 *************** *** 1,103 **** ! LWSRV - the simple version ! -------------------------- ! Defines are best set by changing m4.setup and reconfiguring your ! makefiles. See [simpleflags] and [lwflags] in m4.setup. ! The previous version of lwsrv ran in a single fork and only allowed a ! single job at a time. The new version of lwsrv runs in multiple forks ! allowing multiple jobs to be spooled concurrently. You can get the ! old behavior by running lwsrv with the "-S" switch. A problem that ! comes up because lwsrv runs muliforking now is that status messages do ! not get updated properly and the mac sees "Starting job" until the job ! is submitted. ! ! Some spoolers, like transcript will have problems spooling files with ! characters with the 8th bit on. You can make lwsrv quote these chars ! by using the "-T quote8bit" option. This differs from the previous ! behavior. In addition, some Transcript filters like psrev only allow ! line feed as the line terminator instead of both line feed and the ! standard on the Macintosh: carriage return. You can use the "-T ! crtolf" option to force lwsrv to map carriage return to linefeed. ! (This could potentially cause problems with binary data, strings, etc). ! ! If all the "client" programs that spool to lwsrv conform to the Adobe ! Systems Document Structuring Conventions, Version 2.0, you can define ! "ADOBE_DSC2_CONFORMANT" (SIMPLEFLAGS). Actually, all this does right ! now is include the procset at a different point in the file. Turning ! this on can cause problems if the client doesn't follow the ! conventions correctly. Note: you can also use the "-A on|off" flag to ! turn this on and off. The define simply sets the default. ! ! The font list files distributed define the font coordination entries ! appropriate for a LaserWriter or LaserWriter Plus. Under old ! LaserPreps, there was a "lsf" function defined to return these values. ! Under the newer LaserPrep, the code is encapsulated in a query that ! can be retrieved by running lwsrv with tracing on. The approriate ! code is framed with a "%%?BeginFontListQuery", "%%?EndFontListQuery: ! (*)" pair and the last item is indicated with a "*". ! ! Unlike lsrv, lwsrv will prepend an AppleDict (from the LaserPrep). ! This allows different users with conflicting LaserPreps on their Macs ! to print on the same LaserWriter. However, we do not supply these ! files because they contain Apple copyrighted material that it would be ! inappropriate to distribute without permission from Apple. ! ! However, it isn't hard to pick out the information. First some ! terminology. The LaserPrep contains what Apple calls an AppleDict. ! The AppleDict is really known as a ProcSet under the Postscript ! document struction conventions. ! ! For newer versions of LaserPrep following version 2.0 of the Adobe ! PostScript document structuring conventions, unknown ProcSets are ! automatically captured (with the ExitServer code stripped). ! ! The Procset is recorded into a file called "FoundProcSet.