home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / ease / part02 < prev    next >
Encoding:
Internet Message Format  |  1987-07-09  |  56.7 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i052:  Ease translator repost, Part02/04
  5. Message-ID: <620@uunet.UU.NET>
  6. Date: 10 Jul 87 11:22:46 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 2107
  9. Approved: rs@uunet.UU.NET
  10.  
  11. Submitted-by: Wombat <rsk@j.cc.purdue.edu>
  12. Posting-number: Volume 10, Issue 52
  13. Archive-name: ease/Part02
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 2 (of 4)."
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'config-files/FINIS/pucc-j.mc' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'config-files/FINIS/pucc-j.mc'\"
  25. else
  26. echo shar: Extracting \"'config-files/FINIS/pucc-j.mc'\" \(3004 characters\)
  27. sed "s/^X//" >'config-files/FINIS/pucc-j.mc' <<'END_OF_FILE'
  28. X/***********************************************************
  29. X ***********************************************************
  30. X ****
  31. X ****    SENDMAIL CONFIGURATION FILE
  32. X ****
  33. X ****    For PUCC-J
  34. X ****
  35. X ****    $Id: pucc-j.mc,v 1.2 86/04/04 14:20:57 kcs Exp $
  36. X ****
  37. X ***********************************************************
  38. X ***********************************************************/
  39. X
  40. X
  41. X
  42. X/***********************************************************
  43. X **    local info
  44. X ***********************************************************/
  45. X
  46. Xmacro
  47. X    m_sitename = "j.cc.purdue.edu";     /* internet hostname */
  48. X    arpa_name  = "asc";            /* our arpanet name */
  49. X
  50. Xclass
  51. X    m_sitename = { "j.cc.purdue.edu", pucc-j, puccj, j, pucc, purdue-asc, 
  52. X                purdue-205-gw, purdue-asc-tn, asc, "asc.purdue.edu", 
  53. X               "asc.cc.purdue.edu", 205-gw, asc-tn };
  54. X
  55. X    arpa_name = { "asc.purdue.edu", "asc.cc.purdue.edu", asc, purdue-asc,
  56. X               purdue-205-gw };
  57. X
  58. X#include "phonenethosts.cpp"
  59. X
  60. X#include "puccbase.cpp"
  61. X
  62. X#include "zerobase.cpp"
  63. X
  64. X/**********************************************
  65. X **  Machine dependent part of ruleset zero  **
  66. X **********************************************/
  67. X
  68. X    /* send berknet names through relay */
  69. X
  70. X    if ( < @berkhost > : path )
  71. X        resolve ( mailer ( pcl ),
  72. X              host ( $relay_host ),
  73. X              user ( $2<@$1> ) );        /* @berkhost: ... */
  74. X
  75. X    if ( anypath < @anypath berkhost > anypath )
  76. X        resolve ( mailer ( pcl ),
  77. X              host ( $relay_host ),
  78. X              user ( $1<@$2$3>$4 ) );    /* user@berknethost */
  79. X
  80. X    /* resolve campus names */
  81. X
  82. X    if ( anypath < @anypath campushost > anypath )
  83. X        resolve ( mailer ( pcl ),
  84. X              host ( $3 ),
  85. X              user ( $1<@$2$3>$4 ) );    /* user@campushost */
  86. X
  87. X    /* send csnet names through relay */
  88. X
  89. X    if ( anypath < @phonehost > anypath )
  90. X        resolve ( mailer ( tcp ),
  91. X              host ( "CSNet-Relay" ),
  92. X              user ( $1%$2<@"CSNet-Relay">$3 ) );
  93. X
  94. X    if ( anypath < @phonehost ".ARPA" > anypath )
  95. X        resolve ( mailer ( tcp ),
  96. X              host ( "CSNet-Relay" ),
  97. X              user ( $1%$2<@"CSNet-Relay">$3 ) );
  98. X
  99. X    if ( anypath < @path ".CSNET" > anypath )
  100. X        resolve ( mailer ( tcp ),
  101. X              host ( "CSNet-Relay" ),
  102. X              user ( $1%$2<@"CSNet-Relay">$3 ) );
  103. X
  104. X    /* we don't do uucp */
  105. X
  106. X    if ( anypath < @anypath ".UUCP" > anypath )
  107. X        resolve ( mailer ( error ),
  108. X              user ( "Non-Local UUCP Mail Unavailable" ) );
  109. X
  110. X    /* we don't do bitnet (yet) */
  111. X
  112. X    if ( anypath < @anypath ".BITNET" > anypath )
  113. X            resolve ( mailer ( error ),
  114. X                  user ( "Bitnet Mail Unavailable At This Time" ) );
  115. X
  116. X    /* other non-local names to the arpanet */
  117. X
  118. X    if ( anypath < @anypath > anypath )
  119. X        resolve ( mailer ( tcp ),
  120. X              host ( $2 ),
  121. X              user ( $1<@$2>$3 ) );        /* user@arpahost */
  122. X
  123. X    /* remaining names must be local */
  124. X
  125. X    if ( path )
  126. X        resolve ( mailer ( local ),
  127. X              user ( $1 ) );        /* everything else */
  128. X
  129. X/**************************************
  130. X **  Host dependent address cleanup  **
  131. X **************************************/
  132. X
  133. Xruleset HOSTDEP_RW {
  134. X
  135. X    if ( anypath uucphost!usr@hostpath )
  136. X        retry ( $3@$4 );            /* drop uucp forward */
  137. X
  138. X}
  139. X
  140. X#include "pclm.cpp"
  141. X#include "tcpm.cpp"
  142. END_OF_FILE
  143. if test 3004 -ne `wc -c <'config-files/FINIS/pucc-j.mc'`; then
  144.     echo shar: \"'config-files/FINIS/pucc-j.mc'\" unpacked with wrong size!
  145. fi
  146. # end of 'config-files/FINIS/pucc-j.mc'
  147. fi
  148. if test -f 'maketd/Manual/maketd.1l' -a "${1}" != "-c" ; then 
  149.   echo shar: Will not clobber existing file \"'maketd/Manual/maketd.1l'\"
  150. else
  151. echo shar: Extracting \"'maketd/Manual/maketd.1l'\" \(4509 characters\)
  152. sed "s/^X//" >'maketd/Manual/maketd.1l' <<'END_OF_FILE'
  153. X.TH MAKETD 1L "11 November 1985"
  154. X.if n \{.de Q
  155. X"\\$1"\\$2
  156. X.\}
  157. X.if t \{.de Q
  158. X``\\$1''\\$2
  159. X.\}
  160. X..
  161. X.SH NAME
  162. Xmaketd \- make transitive dependencies
  163. X.SH SYNOPSIS
  164. X.B maketd
  165. X[
  166. X.I option(s)
  167. X] 
  168. X.I file(s)
  169. X.SH DESCRIPTION
  170. X.I Maketd
  171. Xcomputes dependencies for makefiles from sources introduced through
  172. Xinclude files.
  173. XIt generates lines like
  174. X.Q "xx.o: e.h struct.h ../h/const.h ..." .
  175. XIt makes xx.o not only dependent on all files it includes,
  176. Xbut also recursively on all files other files include.
  177. XThis is achieved by passing the source through the C preprocessor.
  178. X.PP
  179. XThe directories used in the search for include files
  180. Xare identical to the ones used by the C compiler, because the
  181. XC preprocessor is used.
  182. XThis also means that `#define's, `#ifdef's, etc. are evaluated.
  183. XIt may therefore be necessary to recompute the dependencies if
  184. Xany source has been changed, including the associated Makefile.
  185. X.PP
  186. XA typical application in a Makefile goes as follows:
  187. X.nf
  188. X
  189. X    INCL= \-I../include  \-I../h
  190. X    CFLAGS= \-DPUCC \-DBSD4_2 ${INCL}
  191. X    SRC= a.c b.c c.c
  192. X
  193. X    maketd: ${SRC}
  194. X        maketd \-a ${CFLAGS} ${SRC}
  195. X
  196. X    # DO NOT DELETE THIS LINE \- make depend DEPENDS ON IT
  197. X
  198. X.fi
  199. XThe generated dependencies will be inserted after the `# DO NOT DELETE...'
  200. Xline.
  201. XEverything after this line will go away through the editing
  202. Xprocess of the Makefile.
  203. XIf no such line exists, a line of the expected form will be emitted,
  204. Xfollowed by the dependencies.
  205. XThe default filename for the Makefile is `makefile'.
  206. XIf `makefile' does not exist, `Makefile' is used.
  207. XThe \-m and \-d options override this default action.
  208. XBefore it is edited, the Makefile will be saved in `Makefile.bak',
  209. Xoverwritting any existing `Makefile.bak'.
  210. X.PP
  211. XSeveral options apply.
  212. XIf an option takes any arguments, all arguments follow the option
  213. Xdirectly, with no spaces.
  214. XIf spaces are required inside an argument to an option, then
  215. Xquotes must be used to prevent the shell from breaking up the
  216. Xargument.
  217. X.TP
  218. X.BI \-a
  219. XNormally, dependencies on files in `/usr/include' are
  220. Xnot included \- this option also includes dependencies on those files.
  221. X.TP
  222. X.BI \-b
  223. XGenerate dependencies for binaries rather than object files.
  224. XThis is equivelent to specifying a null suffix.
  225. XThe `.o' is stripped from the filename.
  226. X.TP
  227. X.BI \-d
  228. XInstead of editing the Makefile, dependencies are written to standard
  229. Xoutput.
  230. XThe standard header and trailer, `# DO NOT...' are not emitted.
  231. X.TP
  232. X.BI \-f
  233. XForce printing of header and trailer.
  234. XNormally, these are suppresed when the output file is the standard
  235. Xoutput.
  236. X.TP
  237. X.BI \-h
  238. XPrint a set of oneline descriptions to the terminal and exit.
  239. X.TP
  240. X.BI \-m file
  241. XInstead of editing `makefile' or `Makefile', the file named
  242. X.I file
  243. Xis edited.
  244. X.TP
  245. X.BI \-nonlocalo
  246. XGenerate dependency paths that match the source paths given.
  247. X.TP
  248. X.BI \-o directory
  249. XNormally dependencies are of the form
  250. X.Q "a.o: ....." .
  251. XThis option generates dependencies of the form
  252. X.Q "\fIdirectory\fP/a.o:...." ,
  253. Xwhich is useful for Makefiles which store the objects in
  254. Xa separate subdirectory.
  255. XThe name of the directory must not be empty.
  256. X.TP
  257. X.BI \-r
  258. XCauses the dependencies for a single source file to be generated and
  259. Xreplaced in the edited Makefile.
  260. X.TP
  261. X.BI \-s suffix
  262. XSupply a suffix for the target.
  263. XThe suffix should start with a `.'.
  264. XThe target file name should have a suffix of some sort that
  265. Xis delimited by a `.' that is replaced by this suffix.
  266. X.TP
  267. X.BI \-t target
  268. XSupply a new basename for the target.
  269. X.TP
  270. X.BI \-x
  271. XDon't shorten include files.
  272. XThe default action is to replace various strings with abbreviations.
  273. XThe Makefile is scanned to see which single letter uppercase
  274. Xvariables are set.
  275. XThese definitions are remembered.
  276. XThe pathnames `/usr/include' and `/usr/include/sys', along with any
  277. Xpathnames specified with \-I options are also used in abbreviations.
  278. XUnused uppercase single letters are defined, printed to the Makefile,
  279. Xand used.
  280. X.TP
  281. X.BI \-v
  282. XBe verbose.
  283. XExtra output is directed to
  284. X.I stderr.
  285. X.TP
  286. X.BI \-I...
  287. XSpecify a directory to search for include files.
  288. XThis option is passed to /lib/cpp, and thus behaves identically to
  289. Xthe same option to `cc'.
  290. X.TP
  291. X.BI \-D...
  292. XSpecify a definition.
  293. XThis option is passed to /lib/cpp, and thus behaves identically to
  294. Xthe same option to `cc'.
  295. X.TP
  296. X.BI \-U....
  297. XSpecify that a variable that should not be defined.
  298. XThis option is passed to /lib/cpp, and thus behaves identically to
  299. Xthe same option to `cc'.
  300. X.IR cc (1).
  301. X.SH "AUTHOR"
  302. XStephan v. Bechtolsheim (the shell script) (Purdue CS)
  303. X.br
  304. XStephen Uitti (the C version) (PUCC)
  305. X.SH "SEE ALSO"
  306. Xmake(1), cc(1)
  307. END_OF_FILE
  308. if test 4509 -ne `wc -c <'maketd/Manual/maketd.1l'`; then
  309.     echo shar: \"'maketd/Manual/maketd.1l'\" unpacked with wrong size!
  310. fi
  311. # end of 'maketd/Manual/maketd.1l'
  312. fi
  313. if test -f 'maketd/Manual/nshpopen.3l' -a "${1}" != "-c" ; then 
  314.   echo shar: Will not clobber existing file \"'maketd/Manual/nshpopen.3l'\"
  315. else
  316. echo shar: Extracting \"'maketd/Manual/nshpopen.3l'\" \(2367 characters\)
  317. sed "s/^X//" >'maketd/Manual/nshpopen.3l' <<'END_OF_FILE'
  318. X.TH NSHPOPEN 3 "local"
  319. X.SH NAME
  320. Xnshpopen, nshpclose \- initiate I/O to/from a process
  321. X.SH SYNOPSIS
  322. X.B #include <stdio.h>
  323. X.PP
  324. X.SM
  325. X.B FILE
  326. X.B *nshpopen(command, type)
  327. X.br
  328. X.B char *command, *type;
  329. X.PP
  330. X.B nshpclose(stream)
  331. X.br
  332. X.SM
  333. X.B FILE
  334. X.B *stream;
  335. X.SH DESCRIPTION
  336. XThe arguments to 
  337. X.I nshpopen
  338. Xare pointers to null-terminated strings containing respectively
  339. Xa shell command line and an I/O mode, either "r" for reading or
  340. X"w" for writing.
  341. XIt creates a pipe between the calling process and the command
  342. Xto be executed.
  343. XThe value returned is a stream pointer that can be used (as
  344. Xappropriate) to write to the standard input of the command or
  345. Xread from its standard output.
  346. X.PP
  347. XA stream opened by
  348. X.I nshpopen
  349. Xshould be closed by
  350. X.IR nshpclose ,
  351. Xwhich waits for the associated process to terminate
  352. Xand returns the exit status of the command.
  353. X.PP
  354. XBecause open files are shared, a type "r" command may be used
  355. Xas an input filter, and a type "w" as an output filter.
  356. X.PP
  357. X.I Nshpopen
  358. Xbreaks up the
  359. X.I command
  360. Xargument string at spaces and tabs for the child process.
  361. XHowever, it does not invoke a shell, and does not
  362. Xattempt any shell shell meta character parsing.
  363. XIn particular, quoted white space will still cause argument seperation.
  364. XBy avoiding calling a shell, pipe creation is a great deal quicker.
  365. XAlso, by avoiding the (rather complicated) shell meta character
  366. Xparsing, some types of bugs may be avoided.
  367. XThis is important where the security of setuid programs is involved.
  368. X.SH "SEE ALSO"
  369. Xpipe(2),
  370. Xpopen(3),
  371. Xfopen(3S),
  372. Xfclose(3S),
  373. Xsystem(3),
  374. Xwait(2),
  375. Xsh(1)
  376. X.SH DIAGNOSTICS
  377. X.I Nshpopen
  378. Xreturns a null pointer if files or processes cannot be created,
  379. Xor the shell cannot be accessed.
  380. X.PP
  381. X.I Nshpclose
  382. Xreturns \-1 if
  383. X.I stream
  384. Xis not associated with an `nshpopened' command.
  385. X.SH BUGS
  386. XBuffered reading before opening an input filter
  387. Xmay leave the standard input of that filter mispositioned.
  388. XSimilar problems with an output filter may be
  389. Xforestalled by careful buffer flushing, for instance, with
  390. X.I fflush,
  391. Xsee
  392. X.IR fclose (3).
  393. X.LP
  394. X.I Nshpopen
  395. Xdoes not call a shell to do it's work.
  396. XIt does not attempt to process shell meta characters.
  397. XThus, it does not treat quotes, I/O redirects, or file
  398. Xname wildcard characters specially.
  399. XThis is it's incompatibility with
  400. X.I popen(3).
  401. X.LP
  402. XThis type of function should have been included with
  403. X.I popen(3)
  404. Xin the standard I/O library.
  405. END_OF_FILE
  406. if test 2367 -ne `wc -c <'maketd/Manual/nshpopen.3l'`; then
  407.     echo shar: \"'maketd/Manual/nshpopen.3l'\" unpacked with wrong size!
  408. fi
  409. # end of 'maketd/Manual/nshpopen.3l'
  410. fi
  411. if test -f 'maketd/Manual/srtunq.3l' -a "${1}" != "-c" ; then 
  412.   echo shar: Will not clobber existing file \"'maketd/Manual/srtunq.3l'\"
  413. else
  414. echo shar: Extracting \"'maketd/Manual/srtunq.3l'\" \(3745 characters\)
  415. sed "s/^X//" >'maketd/Manual/srtunq.3l' <<'END_OF_FILE'
  416. X.TH SRTUNQ 1L PUCC
  417. X.SH NAME
  418. Xsrtinit, srtin, srtgti, srtgets, srtfree, srtdtree
  419. X.SH SYNOPSIS
  420. X.B #include <stdio.h>
  421. X.br
  422. X.B #include <local/srtunq.h>
  423. X.sp
  424. Xcc file.c
  425. X.B \-lsrtunq
  426. X.SH DESCRIPTION
  427. X.I Libsrtunq.a
  428. Xis a set of sorting routines for a particular purpose.
  429. XIt's use is extracting unique items from a possibly long list,
  430. Xwhere items are likely to be replicated numerously.
  431. XThe list of unique items will be small enough to
  432. Xfit in main memory.
  433. XHigh speed is desired.
  434. X.PP
  435. XThe caller has control over the database through the use of a
  436. X.I struct srtent
  437. Xvariable.
  438. XThe subroutines provide for data entry and retrieval,
  439. Xmemory allocation and deallocation.
  440. X.SH ROUTINES
  441. X.TP
  442. X.ft B
  443. Xvoid srtinit(ent) struct srtent *ent;
  444. X.ft
  445. XThis subroutine must be called before the first time
  446. Xany data is entered or retrieved
  447. Xfrom a database tree whose tag is pointed to by
  448. X.B ent.
  449. XIt assumes that the database tag has not been used
  450. Xto store a tree, and therefore does not attempt to free
  451. Xany such data.
  452. X.TP
  453. X.ft B
  454. Xchar *srtin(ent, string, compar) struct srtent *ent; char *string; int (*compar)();
  455. X.ft
  456. XThe existing data tree is searched.
  457. XIf the string is found in the tree then nothing is done.
  458. XOtherwise, space is allocated for the string and pointer structure via
  459. X.I malloc(3).
  460. XThe string is copied to this new space.
  461. XThe structure is linked into the tree.
  462. XIf space cannot be obtained, the operation is aborted, and
  463. Xa pointer to an error string is returned.
  464. XThe data structure remains consistent, but the string is not placed in it.
  465. XIf the operation is successful, NULL is returned.
  466. XThe strings are compared and sorted with the subroutine pointed to by
  467. X.I compar.
  468. XThis subroutine takes two string pointers as arguments.
  469. XIt returns zero if the strings are the same,
  470. Xless than zero if the first string should precede the second, and
  471. Xgreater than zero if the second string should precede the first.
  472. XIf the subroutine pointer is NULL, then a simple string compare is used, which
  473. Xsorts in ascending ASCII order, and strings of different length comparing
  474. Xas unequal.
  475. X.TP
  476. X.ft B
  477. Xvoid srtgti(ent); struct srtent *ent;
  478. X.ft
  479. XThis subroutine initializes the database tag pointed to by
  480. X.B ent
  481. Xso that a tree transversal can be made via
  482. X.I srtgets.
  483. X.TP
  484. X.ft B
  485. Xchar *srtgets(ent); struct srtent *ent;
  486. X.ft
  487. XThis routine extracts the next string from the data structure.
  488. XThe strings are returned in increasing order.
  489. XWhen the list is exhausted, NULL is returned.
  490. X.TP
  491. X.ft B
  492. Xvoid srtfree(ent) struct srtent *ent;
  493. X.ft
  494. XThis subroutine deletes a database, and re-initializes the
  495. Xdatabase tag.
  496. XIt assumes that the database tag was initialized at one time via
  497. X.I srtinit
  498. X(other routines will probably also have been called).
  499. XThe space formally occupied by string data and pointer structures is
  500. Xdeallocated via
  501. X.I free(3).
  502. X.TP
  503. X.ft B
  504. Xvoid srtdtree(ent, tbl) struct srtent *ent; struct srtbl *tbl;
  505. X.ft
  506. XThis subroutine recursively deletes a database subtree.
  507. XThe space formally occupied by the string data and pointer structures is
  508. Xdeallocated via
  509. X.I free(3).
  510. XThis routine is most likely only of use internally.
  511. X.SH EXAMPLE
  512. X.nf
  513. Xmain()
  514. X{
  515. X    char buf[80], *p;
  516. X    struct srtent d;
  517. X    srtinit(&d);
  518. X    while (fgets(buf, stdin, 79) != NULL)
  519. X        if ((p = srtin(&d, "foo")) != NULL)
  520. X            printf("test: %s\n", p);  /* warning message */
  521. X    srtgti(&d);
  522. X    while ((p = srtgets(&d)) != NULL)
  523. X        puts(p);
  524. X    srtfree(&d);
  525. X}
  526. X.fi
  527. X.SH DIAGNOSTICS
  528. XThere are no messages printed by these routines.
  529. XCatchable errors are returned as strings.
  530. XCompiled in errors such as the use of strings that
  531. Xare not null terminated tend to result in core files.
  532. X.SH FILES
  533. X/usr/local/lib/libsrtunq.a
  534. X.br
  535. X/usr/include/local/srtunq.h
  536. X.SH SEE ALSO
  537. Xmalloc(3), qsort(3)
  538. X.SH AUTHOR
  539. XStephen Uitti, PUCC
  540. X.SH BUGS
  541. XLikely.
  542. END_OF_FILE
  543. if test 3745 -ne `wc -c <'maketd/Manual/srtunq.3l'`; then
  544.     echo shar: \"'maketd/Manual/srtunq.3l'\" unpacked with wrong size!
  545. fi
  546. # end of 'maketd/Manual/srtunq.3l'
  547. fi
  548. if test -f 'maketd/breakargs.c' -a "${1}" != "-c" ; then 
  549.   echo shar: Will not clobber existing file \"'maketd/breakargs.c'\"
  550. else
  551. echo shar: Extracting \"'maketd/breakargs.c'\" \(2529 characters\)
  552. sed "s/^X//" >'maketd/breakargs.c' <<'END_OF_FILE'
  553. X/* breakargs - break a string into a string vector for execv.
  554. X * Returns NULL if can't malloc space for vector, else vector.
  555. X * Note, when done with the vector, mearly "free" the vector.
  556. X * Written by Stephen Uitti, PUCC, Nov '85 for the new version
  557. X * of "popen" - "nshpopen", that doesn't use a shell.
  558. X * (used here for the as filters, a newer option).
  559. X *
  560. X * breakargs is copyright (C) Purdue University, 1985
  561. X *
  562. X * put in a fix for cmds lines with "string string" in them
  563. X * Mon Aug 25 13:34:27 EST 1986 (ksb)
  564. X *
  565. X * Permission is hereby given for its free reproduction and
  566. X * modification for non-commercial purposes, provided that this
  567. X * notice and all embedded copyright notices be retained.
  568. X * Commercial organisations may give away copies as part of their
  569. X * systems provided that they do so without charge, and that they
  570. X * acknowledge the source of the software.
  571. X */
  572. X#ifdef BSD2_9
  573. X#include <sys/types.h>
  574. X#endif
  575. X#include <stdio.h>            /* for nothing, really */
  576. X#define SPC '\040'            /* ascii space */
  577. X
  578. Xchar *
  579. Xmynext(pch)
  580. Xregister char *pch;
  581. X{
  582. X    register int fQuote;
  583. X
  584. X    for (fQuote = 0; (*pch != '\000' && *pch != SPC && *pch != '\t')||fQuote; ++pch) {
  585. X        if ('\\' == *pch) {
  586. X            continue;
  587. X        }
  588. X        switch (fQuote) {
  589. X        default:
  590. X        case 0:
  591. X            if ('"' == *pch) {
  592. X                fQuote = 1;
  593. X            } else if ('\'' == *pch) {
  594. X                fQuote = 2;
  595. X            }
  596. X            break;
  597. X        case 1:
  598. X            if ('"' == *pch)
  599. X                fQuote = 0;
  600. X            break;
  601. X        case 2:
  602. X            if ('\'' == *pch)
  603. X                fQuote = 0;
  604. X            break;
  605. X        }
  606. X    }
  607. X    return pch;
  608. X}
  609. X
  610. Xchar **
  611. Xbreakargs(cmd)
  612. Xchar *cmd;
  613. X{
  614. X    register char *p;        /* tmp                */
  615. X    register char **v;        /* vector of commands returned    */
  616. X    register unsigned sum;        /* bytes for malloc        */
  617. X    register int i;            /* number of args        */
  618. X    register char *s;        /* save old position        */
  619. X    char *malloc(), *strcpy();
  620. X
  621. X    p = cmd;
  622. X    while (*p == SPC || *p == '\t')
  623. X        p++;
  624. X    cmd = p;            /* no leading spaces        */
  625. X    sum = sizeof(char *);
  626. X    i = 0;
  627. X    while (*p != '\0') {        /* space for argv[];        */
  628. X        ++i;
  629. X        s = p;
  630. X        p = mynext(p);
  631. X        sum += sizeof(char *) + 1 + (unsigned)(p - s);
  632. X        while (*p == SPC || *p == '\t')
  633. X            p++;
  634. X    }
  635. X    ++i;
  636. X    /* vector starts at v, copy of string follows NULL pointer */
  637. X    v = (char **)malloc(sum+1);
  638. X    if (v == NULL)
  639. X        return (char **)NULL;
  640. X    p = (char *)v + i * sizeof(char *); /* after NULL pointer */
  641. X    i = 0;                /* word count, vector index */
  642. X    while (*cmd != '\0') {
  643. X        v[i++] = p;
  644. X        s = cmd;
  645. X        cmd = mynext(cmd);
  646. X        if (*cmd != '\0')
  647. X            *cmd++ = '\0';
  648. X        strcpy(p, s);
  649. X        p += strlen(p);
  650. X        ++p;
  651. X        while (*cmd == SPC || *cmd == '\t')
  652. X            ++cmd;
  653. X    }
  654. X    v[i] = (char *)NULL;
  655. X    return v;
  656. X}
  657. END_OF_FILE
  658. if test 2529 -ne `wc -c <'maketd/breakargs.c'`; then
  659.     echo shar: \"'maketd/breakargs.c'\" unpacked with wrong size!
  660. fi
  661. # end of 'maketd/breakargs.c'
  662. fi
  663. if test -f 'maketd/maketd.sh' -a "${1}" != "-c" ; then 
  664.   echo shar: Will not clobber existing file \"'maketd/maketd.sh'\"
  665. else
  666. echo shar: Extracting \"'maketd/maketd.sh'\" \(2941 characters\)
  667. sed "s/^X//" >'maketd/maketd.sh' <<'END_OF_FILE'
  668. X#! /bin/sh
  669. X#
  670. X# maketd - generates file dependencies for makefiles using cc -M
  671. X#
  672. XPATH=/usr/local/bin:/bin:/usr/bin:/usr/ucb
  673. Xexport PATH
  674. X
  675. Xprogname=`basename $0`
  676. X
  677. X# Name of the Makefile which will be edited to add the dependencies
  678. Xif [ $# = 0 ] ; then
  679. X    cat << EOF
  680. Xusage: $progname [-a] [-d] [-m<file>] [-o<directory>] [-D...] [-I...] [-U...]
  681. X          [<file> ...] [-T <file> ...]
  682. XEOF
  683. X    exit
  684. Xfi
  685. X
  686. XDEPFILE=/tmp/mtd3$$.tmp
  687. Xtouch $DEPFILE
  688. XEDDFILE=/tmp/mtd4$$.tmp
  689. X
  690. Xtrap 'rm -f $DEPFILE $EDDFILE ; exit ' 1 2 3 15
  691. X
  692. X# Default values for -a, -d, -m and -o options
  693. XAOPTION="-e /\/usr\/include/d"
  694. XDOPTION=0
  695. XMAKEFILE=Makefile
  696. XOBJDIR=
  697. X
  698. X# Collect in OPTIONS all options you want to pass on to the C preprocessor.
  699. X#       in SOURCES all files you want to create dependencies for
  700. Xwhile [ -n "$1" ] ; do
  701. X    case $1 in
  702. X
  703. X    -a)
  704. X        AOPTION=
  705. X    ;;
  706. X
  707. X    -d)
  708. X        DOPTION=1
  709. X    ;;
  710. X
  711. X    -m*)
  712. X        MAKEFILE=`expr $1 : '-m\(.*\)'`
  713. X    ;;
  714. X
  715. X    -nonlocalo)
  716. X        echo "$progname: -nonlocalo option obsolete"
  717. X        exit 1
  718. X    ;;
  719. X
  720. X    -o*)
  721. X        if [ "$1" = "-o" ] ; then
  722. X        echo    "$progname: -o option requires directory name"
  723. X        exit 1
  724. X        fi
  725. X        OBJDIR=`expr $1 : '-o\(.*\)'`
  726. X        if [ ! -d $OBJDIR ] ; then
  727. X        echo    "$progname: -o option: \"$OBJDIR\" is not a directory"
  728. X        exit 1
  729. X        fi
  730. X        OBJDIR="$OBJDIR/"
  731. X    ;;
  732. X
  733. X    -[D,I,U]*)
  734. X        OPTIONS="$OPTIONS $1"
  735. X    ;;
  736. X
  737. X    -T)
  738. X        shift
  739. X        TSOURCES="$*"
  740. X        set ""
  741. X    ;;
  742. X
  743. X    -*)
  744. X        echo        "$progname: option \"$1\" unknown; ignored"
  745. X    ;;
  746. X
  747. X    *)
  748. X        SOURCES="$SOURCES $1"
  749. X    ;;
  750. X    esac
  751. X    shift
  752. Xdone
  753. X
  754. X#       Run everything through the preprocessor (using cc), sort this
  755. X#    output and remove duplictate lines.  If there is no '-a' option
  756. X#    remove all dependencies of the form '/usr/include/<file>'. Cc
  757. X#    will exit quietly if there are no source files.
  758. X/bin/cc -M $OPTIONS $SOURCES | sort | uniq | \
  759. X    sed $AOPTION \
  760. X    -e "s, \./, ,g" \
  761. X    -e "s,\.\./[a-zA-Z0-9]*/\.\.,\.\.,g" \
  762. X    -e "s,^,$OBJDIR," >> $DEPFILE
  763. X
  764. X/bin/cc -M $OPTIONS $TSOURCES | sort | uniq | \
  765. X    sed $AOPTION \
  766. X    -e "s,\.o:,:," \
  767. X    -e "s, \./, ,g" \
  768. X    -e "s,\.\./[a-zA-Z0-9]*/\.\.,\.\.,g" \
  769. X    -e "s,^,$OBJDIR," >> $DEPFILE
  770. X
  771. X# If DOPTION then cat file and exit, otherwise edit Makefile
  772. Xif [ $DOPTION -eq 1 ] ; then
  773. X    cat $DEPFILE
  774. X    rm -f $DEPFILE $EDDFILE
  775. X    exit
  776. Xfi
  777. X
  778. X# Now start editing the Makefile
  779. Xif [ ! -w $MAKEFILE ] ; then
  780. X    echo        "$progname: can't edit $MAKEFILE"
  781. X    rm -f $DEPFILE $EDDFILE
  782. X    exit 1
  783. Xfi
  784. X
  785. X
  786. X# Make sure we have the "DO NOT DELETE" line in the Makefile
  787. Xcat << EOF >> $MAKEFILE
  788. X
  789. X# DO NOT DELETE THIS LINE - maketd DEPENDS ON IT
  790. XEOF
  791. X
  792. X# Build the editor script to edit the Makefile later.
  793. Xcat << EOF > $EDDFILE
  794. X/# DO NOT DELETE THIS LINE/,\$d
  795. X\$a
  796. X# DO NOT DELETE THIS LINE - maketd DEPENDS ON IT
  797. X# Dependencies generated at: `date`
  798. X
  799. XEOF
  800. Xcat $DEPFILE >> $EDDFILE
  801. Xcat << EOF >> $EDDFILE
  802. X
  803. X# DO NOT ADD ANYTHING HERE - WILL GO AWAY
  804. X.
  805. Xw
  806. Xq
  807. XEOF
  808. X
  809. X# Editor scipt done, edit makefile now.
  810. Xcp $MAKEFILE $MAKEFILE.bak
  811. Xed - $MAKEFILE < $EDDFILE
  812. X
  813. Xrm -f $DEPFILE $EDDFILE
  814. END_OF_FILE
  815. if test 2941 -ne `wc -c <'maketd/maketd.sh'`; then
  816.     echo shar: \"'maketd/maketd.sh'\" unpacked with wrong size!
  817. fi
  818. # end of 'maketd/maketd.sh'
  819. fi
  820. if test -f 'maketd/misc.c' -a "${1}" != "-c" ; then 
  821.   echo shar: Will not clobber existing file \"'maketd/misc.c'\"
  822. else
  823. echo shar: Extracting \"'maketd/misc.c'\" \(3572 characters\)
  824. sed "s/^X//" >'maketd/misc.c' <<'END_OF_FILE'
  825. X/* Written & hacked by Stephen Uitti, PUCC staff, ach@pucc-j, 1985
  826. X * maketd is copyright (C) Purdue University, 1985
  827. X *
  828. X * Permission is hereby given for its free reproduction and
  829. X * modification for non-commercial purposes, provided that this
  830. X * notice and all embedded copyright notices be retained.
  831. X * Commercial organisations may give away copies as part of their
  832. X * systems provided that they do so without charge, and that they
  833. X * acknowledge the source of the software.
  834. X */
  835. X
  836. X#ifdef BSD2_9
  837. X#include <sys/types.h>
  838. X#include <signal.h>
  839. X#endif
  840. X#ifdef BSD4_2
  841. X#include <sys/signal.h>
  842. X#endif
  843. X#include <stdio.h>
  844. X
  845. X#include "maketd.h"
  846. X
  847. X/* VARARGS */
  848. X/* print and error and exit */
  849. Xvoid
  850. Xerr(a, b, c, d)
  851. Xchar *a;                /* the format string, as printf */
  852. Xchar *b, *c, *d;            /* arguments, as printf */
  853. X{
  854. X    fprintf(stderr, "%s: ", prgnm);
  855. X    fprintf(stderr, a, b, c, d);
  856. X    fprintf(stderr, "\n");
  857. X    errrec();                /* clean up backup file, if any */
  858. X    exit(1);
  859. X}
  860. X
  861. X/* errrec - error recovery: recover temp file */
  862. Xstatic void
  863. Xerrrec()
  864. X{
  865. X    if (backedup) {
  866. X    backedup = FALSE;        /* prevent infinite error recursion */
  867. X    unlink(makename);        /* may or may not exist */
  868. X    if (link(backupfn, makename))
  869. X        err("can't link %s to %s during recovery", makename, backupfn);
  870. X    if (unlink(backupfn))
  871. X        err("can't delete %s during recovery", backupfn);
  872. X    err("edit of '%s' aborted - file unchanged.", makename);
  873. X    }
  874. X    exit(1);
  875. X}
  876. X
  877. X/* signal trap routines, one for each */
  878. Xstatic void
  879. Xerrhup()
  880. X{
  881. X    fprintf(stderr, "%s: SIGHUP recieved\n", prgnm);
  882. X    errrec();
  883. X}
  884. X
  885. Xstatic void
  886. Xerrint()
  887. X{
  888. X    fprintf(stderr, "%s: SIGINT recieved\n", prgnm);
  889. X    errrec();
  890. X}
  891. X
  892. Xstatic void
  893. Xerrill()
  894. X{
  895. X    fprintf(stderr, "%s: SIGILL recieved\n", prgnm);
  896. X    errrec();
  897. X}
  898. X
  899. Xstatic void
  900. Xerrtrap()
  901. X{
  902. X    fprintf(stderr, "%s: SIGTRAP recieved\n", prgnm);
  903. X    errrec();
  904. X}
  905. X
  906. Xstatic void
  907. Xerriot()
  908. X{
  909. X    fprintf(stderr, "%s: SIGIOT recieved\n", prgnm);
  910. X    errrec();
  911. X}
  912. X
  913. Xstatic void
  914. Xerremt()
  915. X{
  916. X    fprintf(stderr, "%s: SIGEMT recieved\n", prgnm);
  917. X    errrec();
  918. X}
  919. X
  920. Xstatic void
  921. Xerrfpe()
  922. X{
  923. X    fprintf(stderr, "%s: SIGFPE recieved\n", prgnm);
  924. X    errrec();
  925. X}
  926. X
  927. Xstatic void
  928. Xerrbus()
  929. X{
  930. X    fprintf(stderr, "%s: SIGBUS recieved\n", prgnm);
  931. X    errrec();
  932. X}
  933. X
  934. Xstatic void
  935. Xerrsegv()
  936. X{
  937. X    fprintf(stderr, "%s: SIGSEGV recieved\n", prgnm);
  938. X    errrec();
  939. X}
  940. X
  941. Xstatic void
  942. Xerrsys()
  943. X{
  944. X    fprintf(stderr, "%s: SIGSYS recieved\n", prgnm);
  945. X    errrec();
  946. X}
  947. X
  948. Xstatic void
  949. Xerrpipe()
  950. X{
  951. X    fprintf(stderr, "%s: SIGPIPE recieved\n", prgnm);
  952. X    errrec();
  953. X}
  954. X
  955. Xstatic void
  956. Xerralrm()
  957. X{
  958. X    fprintf(stderr, "%s: SIGALRM recieved\n", prgnm);
  959. X    errrec();
  960. X}
  961. X
  962. Xstatic void
  963. Xerrterm()
  964. X{
  965. X    fprintf(stderr, "%s: SIGTERM recieved\n", prgnm);
  966. X    errrec();
  967. X}
  968. X
  969. X/* catchsig - init signal traps */
  970. Xcatchsig()
  971. X{
  972. X    signal(SIGHUP, errhup);
  973. X    signal(SIGINT, errint);
  974. X    signal(SIGILL, errill);
  975. X    signal(SIGTRAP, errtrap);
  976. X    signal(SIGIOT, erriot);
  977. X    signal(SIGEMT, erremt);
  978. X    signal(SIGFPE, errfpe);
  979. X    signal(SIGBUS, errbus);
  980. X    signal(SIGSEGV, errsegv);
  981. X    signal(SIGSYS, errsys);
  982. X    signal(SIGPIPE, errpipe);
  983. X    signal(SIGALRM, erralrm);
  984. X    signal(SIGTERM, errterm);
  985. X/* Stock 2.9BSD has all the above, but not as many as 4.2BSD:
  986. X * Want SIGQUIT to drop core.
  987. X * Not worrying about:    SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF
  988. X * cannot be caught: SIGKILL, SIGSTOP
  989. X * Leaving alone: SIGURG, SIGTSTP, SIGCONT, SIGCHLD, SIGTTIN, SIGTTOU, SIGIO
  990. X */
  991. X}
  992. X
  993. X/* lastlnch - return last char before newline or NULL in string */
  994. Xchar
  995. Xlastlnch(p)
  996. Xregister char *p;
  997. X{
  998. X    register char *q;
  999. X
  1000. X    q = p;
  1001. X    while (*p != '\0' && *p != '\n')
  1002. X    q = p++;
  1003. X    return *q;
  1004. X}
  1005. END_OF_FILE
  1006. if test 3572 -ne `wc -c <'maketd/misc.c'`; then
  1007.     echo shar: \"'maketd/misc.c'\" unpacked with wrong size!
  1008. fi
  1009. # end of 'maketd/misc.c'
  1010. fi
  1011. if test -f 'maketd/srtunq.c' -a "${1}" != "-c" ; then 
  1012.   echo shar: Will not clobber existing file \"'maketd/srtunq.c'\"
  1013. else
  1014. echo shar: Extracting \"'maketd/srtunq.c'\" \(4678 characters\)
  1015. sed "s/^X//" >'maketd/srtunq.c' <<'END_OF_FILE'
  1016. X/* Sorting function that inserts strings one at a time into memory.
  1017. X * Strings are null terminated.
  1018. X * Only uniq strings are stored (no count is kept of how many)
  1019. X * Any memory used is freed on init (or re-init).
  1020. X *
  1021. X * Author: Stephen Uitti, PUCC, 1985
  1022. X * libsrtunq is copyright (C) Purdue University, 1985
  1023. X *
  1024. X * Permission is hereby given for its free reproduction and
  1025. X * modification for non-commercial purposes, provided that this
  1026. X * notice and all embedded copyright notices be retained.
  1027. X * Commercial organisations may give away copies as part of their
  1028. X * systems provided that they do so without charge, and that they
  1029. X * acknowledge the source of the software.
  1030. X */
  1031. X
  1032. X#ifndef lint
  1033. Xstatic char *rcsid =
  1034. X    "$Id: srtunq.c,v 1.4 86/08/30 21:35:36 ksb Exp Locker: ksb $";
  1035. X#endif
  1036. X
  1037. X#ifdef BSD2_9
  1038. X#include <sys/types.h>
  1039. X#endif
  1040. X#ifdef notdef            /* a comment that allows comments. */
  1041. X * use:
  1042. X * #include <local/srtunq.h>            /* defines, etc */
  1043. X * struct srtent d;                /* data structure foothold */
  1044. X * char *p;                    /* temp */
  1045. X * srtinit(&d);                    /* init the structure */
  1046. X * if ((p = srtin(&d, "foo", NULL)) != NULL) err(p);    /* add the data */
  1047. X *    ...
  1048. X * srtgti(&d);                    /* init for get */
  1049. X * p = srtgets(&d);                /* get next entry */
  1050. X *    ...
  1051. X * srtfree(&d);                    /* delete the structure */
  1052. X#endif
  1053. X
  1054. X#include <stdio.h>            /* for null */
  1055. X#include <sys/types.h>            /* for void, in V7 */
  1056. X#include "srtunq.h"            /* for srtunq structs & functions */
  1057. X/* #include <local/srtunq.h>        /* for srtunq structs & functions */
  1058. X
  1059. X/* libc functions */
  1060. Xchar   *malloc();            /* need more memory */
  1061. Xchar   *strcpy();            /* copy string */
  1062. X
  1063. X/* srtgti - init get string function */
  1064. Xvoid
  1065. Xsrtgti(ent)
  1066. Xstruct srtent *ent;
  1067. X{
  1068. X    ent->srt_next = ent->srt_top;
  1069. X    if (ent->srt_next == NULL)
  1070. X    return;
  1071. X    while (ent->srt_next->srt_less != NULL)
  1072. X    ent->srt_next = ent->srt_next->srt_less;
  1073. X}
  1074. X
  1075. X/* srtgets - get next string from sorted list, NULL if none more. */
  1076. X/* The least shall be first... and the greatest shall be last */
  1077. Xchar *
  1078. Xsrtgets(ent)
  1079. Xstruct srtent *ent;
  1080. X{
  1081. X    register struct srtbl *s;        /* tmp */
  1082. X    register char *p;            /* ret val */
  1083. X
  1084. X    if ((s = ent->srt_next) == NULL)
  1085. X    return NULL;
  1086. X    p = s->srt_str;            /* ret val */
  1087. X    if (s->srt_more != NULL) {
  1088. X    s = s->srt_more;        /* go one more */
  1089. X    while (s->srt_less != NULL)    /* then all the way less */
  1090. X        s = s->srt_less;
  1091. X    ent->srt_next = s;
  1092. X    return p;
  1093. X    }
  1094. X    while (s != ent->srt_top && s->srt_prev->srt_more == s)
  1095. X    s = s->srt_prev;        /* back down any more's */
  1096. X    if (s == ent->srt_top)
  1097. X    s = NULL;            /* no more */
  1098. X    else
  1099. X    s = s->srt_prev;
  1100. X    ent->srt_next = s;
  1101. X    return p;
  1102. X}
  1103. X
  1104. X/* srtinit - init the database tag */
  1105. Xvoid
  1106. Xsrtinit(ent)
  1107. Xstruct srtent *ent;
  1108. X{
  1109. X    ent->srt_top = NULL;        /* erase any knowledge of it */
  1110. X    ent->srt_next = NULL;        /* extractions at the begining */
  1111. X}
  1112. X
  1113. X/* srtfree - delete all the data, init the tag */
  1114. Xvoid
  1115. Xsrtfree(ent)
  1116. Xstruct srtent *ent;
  1117. X{
  1118. X    if (ent->srt_top == NULL)        /* is the structure empty? */
  1119. X    return;                /* yes - exit */
  1120. X    srtdtree(ent->srt_top);
  1121. X    free((char *)ent->srt_top);        /* clean up last struct */
  1122. X    srtinit(ent);            /* init the tag */
  1123. X}
  1124. X
  1125. X/* srtdtree - recursive tree delete
  1126. X * frees all less & more entries pointed to by the srt struct */
  1127. Xvoid
  1128. Xsrtdtree(srt)
  1129. Xregister struct srtbl *srt;
  1130. X{
  1131. X    if (srt->srt_less != NULL) {
  1132. X    srtdtree(srt->srt_less);
  1133. X    free((char *)srt->srt_less);
  1134. X    srt->srt_less = NULL;        /* for consistency */
  1135. X    }
  1136. X    if (srt->srt_more != NULL) {
  1137. X    srtdtree(srt->srt_more);
  1138. X    free((char *)srt->srt_more);
  1139. X    srt->srt_more = NULL;
  1140. X    }
  1141. X}
  1142. X
  1143. X/* srtin - insert string sorted & unique.
  1144. X * returns NULL if good, else error message string. */
  1145. Xchar *
  1146. Xsrtin(ent, str, compar)
  1147. Xstruct srtent *ent;
  1148. Xchar *str;
  1149. Xint (*compar)();            /* if NULL: use strcmp */
  1150. X{
  1151. X    register char *p;            /* temp string pointer */
  1152. X    register i;                /* string compare result */
  1153. X    register struct srtbl *s;        /* temp */
  1154. X    register struct srtbl *srtold;    /* old temp */
  1155. X
  1156. X    s = srtold = ent->srt_top;
  1157. X    while (s != NULL) {
  1158. X        if ((i = (compar == NULL ?
  1159. X        strcmp(str, s->srt_str) : (*compar)(str, s->srt_str))) == 0)
  1160. X        return NULL;        /* found: do nothing - "good" */
  1161. X    srtold = s;
  1162. X    if (i > 0)
  1163. X        s = s->srt_more;
  1164. X    else
  1165. X        s = s->srt_less;
  1166. X    }
  1167. X    if ((p = malloc((unsigned)(strlen(str) + sizeof(struct srtbl)))) == NULL)
  1168. X    return "srtin: warning - out of memory"; /* soft error - caller \n */
  1169. X    s = (struct srtbl *)p;
  1170. X    if (srtold == NULL) {        /* empty list */
  1171. X    ent->srt_top = s;
  1172. X    srtold = ent->srt_top;
  1173. X    } else {
  1174. X    if (i > 0)
  1175. X        srtold->srt_more = s;
  1176. X    else
  1177. X        srtold->srt_less = s;
  1178. X    }
  1179. X    s->srt_prev = srtold;
  1180. X    s->srt_less = NULL;
  1181. X    s->srt_more = NULL;
  1182. X    (void) strcpy(s->srt_str, str);
  1183. X    return NULL;
  1184. X}
  1185. END_OF_FILE
  1186. if test 4678 -ne `wc -c <'maketd/srtunq.c'`; then
  1187.     echo shar: \"'maketd/srtunq.c'\" unpacked with wrong size!
  1188. fi
  1189. # end of 'maketd/srtunq.c'
  1190. fi
  1191. if test -f 'src/errors.c' -a "${1}" != "-c" ; then 
  1192.   echo shar: Will not clobber existing file \"'src/errors.c'\"
  1193. else
  1194. echo shar: Extracting \"'src/errors.c'\" \(2340 characters\)
  1195. sed "s/^X//" >'src/errors.c' <<'END_OF_FILE'
  1196. X/*    $Header: /usr/src/local/etc/ease/RCS/errors.c,v 1.2 85/10/29 23:40:20 jss Exp $    */
  1197. X
  1198. X/*
  1199. X *      errors.c   -- Contains error initialization and reporting routines.
  1200. X *
  1201. X *      author     -- James S. Schoner, Purdue University Computing Center,
  1202. X *                        West Lafayette, Indiana  47907
  1203. X *
  1204. X *      date       -- July 9, 1985
  1205. X *
  1206. X *    Copyright (c) 1985 by Purdue Research Foundation
  1207. X *
  1208. X *    All rights reserved.
  1209. X *
  1210. X */
  1211. X
  1212. X#include <stdio.h>
  1213. X
  1214. Xextern int  ErrorCount;     /* error count                   */
  1215. Xextern char FNbuf[];     /* input file name              */
  1216. Xextern int  Lcount;     /* line count                    */
  1217. XFILE *DIAGf = {stderr};  /* file for diagnostic output */
  1218. X
  1219. X
  1220. X/*
  1221. X *    ErrorReport () -- Prints source file name (FNbuf), line number (Lcount),
  1222. X *              and error message (sbErr) for each invokation.
  1223. X *
  1224. X */
  1225. Xvoid
  1226. XErrorReport (sbErr)
  1227. Xchar *sbErr;
  1228. X{
  1229. X    fprintf (DIAGf, "%s, line %d: %s", FNbuf, Lcount, sbErr);
  1230. X    ErrorCount++;
  1231. X}
  1232. X
  1233. X
  1234. X/*
  1235. X *    FatalError () -- Translator fatal error routine which prints 
  1236. X *             error message (sbErr) and an argument (sbArg).
  1237. X *
  1238. X */
  1239. Xvoid
  1240. XFatalError (sbErr, sbArg)
  1241. Xchar *sbErr,
  1242. X     *sbArg;
  1243. X{
  1244. X    fprintf (DIAGf, "%s, line %d: Fatal Error In Translator: %s %s\n", 
  1245. X         FNbuf, Lcount, sbErr, sbArg);
  1246. X    exit (1);
  1247. X}
  1248. X
  1249. X
  1250. X/*
  1251. X *    yyerror () -- Prints source file name (FNbuf), line number (Lcount),
  1252. X *              and error message (sbErr) for each invokation.
  1253. X *
  1254. X */
  1255. Xvoid
  1256. Xyyerror (sbErr)
  1257. Xchar *sbErr;
  1258. X{
  1259. X    fprintf (DIAGf, "%s, line %d: %s\n", FNbuf, Lcount, sbErr);
  1260. X    ErrorCount++;
  1261. X}
  1262. X
  1263. X
  1264. X/*
  1265. X *    PrintError () -- Prints source file name (FNbuf), line number
  1266. X *             (cline), error message (sbErr), and argument
  1267. X *             (sbArg) for each invokation.
  1268. X *
  1269. X */
  1270. Xvoid
  1271. XPrintError (sbErr, sbArg)
  1272. Xchar *sbErr;
  1273. Xchar *sbArg;
  1274. X{
  1275. X    fprintf (DIAGf, "%s, line %d: %s %s.\n", FNbuf, Lcount, sbErr, sbArg);
  1276. X    ErrorCount++;
  1277. X}
  1278. X
  1279. X
  1280. X/*
  1281. X *    PrintWarning () -- Prints a warning message with source file
  1282. X *               name (FNbuf), line number (Lcount), warning
  1283. X *               (sbWarn), and a possible identifier (sbID).
  1284. X *
  1285. X */
  1286. Xvoid
  1287. XPrintWarning (sbWarn, sbID)
  1288. Xchar *sbWarn;
  1289. Xchar *sbID;
  1290. X{
  1291. X    fprintf (DIAGf, "%s, line %d: Warning: ", FNbuf, Lcount);
  1292. X    if (sbID != NULL)
  1293. X        fprintf (DIAGf, sbWarn, sbID);
  1294. X    else
  1295. X        fprintf (DIAGf, sbWarn);
  1296. X}
  1297. X
  1298. X
  1299. X/*
  1300. X *    InitError () -- Initialize line count (Lcount) to one and error count
  1301. X *                (ErrorCount) to zero.
  1302. X *
  1303. X */
  1304. Xvoid
  1305. XInitError ()
  1306. X{
  1307. X    Lcount     = 1;
  1308. X    ErrorCount = 0;
  1309. X}
  1310. END_OF_FILE
  1311. if test 2340 -ne `wc -c <'src/errors.c'`; then
  1312.     echo shar: \"'src/errors.c'\" unpacked with wrong size!
  1313. fi
  1314. # end of 'src/errors.c'
  1315. fi
  1316. if test -f 'src/idman.c' -a "${1}" != "-c" ; then 
  1317.   echo shar: Will not clobber existing file \"'src/idman.c'\"
  1318. else
  1319. echo shar: Extracting \"'src/idman.c'\" \(5550 characters\)
  1320. sed "s/^X//" >'src/idman.c' <<'END_OF_FILE'
  1321. X/*    $Header: /usr/src/local/etc/ease/RCS/idman.c,v 1.2 85/10/29 23:41:38 jss Exp $    */
  1322. X
  1323. X/*
  1324. X *      idman.c    -- Contains routines for manipulating identifiers and their
  1325. X *           symbolic associations.
  1326. X *
  1327. X *      author    -- James S. Schoner, Purdue University Computing Center,
  1328. X *                     West Lafayette, Indiana  47907
  1329. X *
  1330. X *      date    -- July 9, 1985
  1331. X *
  1332. X *    Copyright (c) 1985 by Purdue Research Foundation
  1333. X *
  1334. X *    All rights reserved.
  1335. X *
  1336. X */
  1337. X
  1338. X#include <stdio.h>
  1339. X#include "symtab.h"
  1340. X
  1341. Xextern struct he *LookupSymbol ();
  1342. Xextern void      FatalError (),
  1343. X          ErrorReport (),
  1344. X          PrintWarning (),
  1345. X          PrintError ();
  1346. X
  1347. Xshort Uchar = 'A';            /* for unique macro names */
  1348. X
  1349. X
  1350. X/*
  1351. X *    UniqMac () -- Assigns and returns a unique one-character macro
  1352. X *              name (upper-case) for an Ease macro name.
  1353. X *
  1354. X */
  1355. Xchar
  1356. XUniqMac (phe)
  1357. Xstruct he *phe;        /* symbol table entry for Ease macro */
  1358. X{
  1359. X    if ((phe->idval.idc = Uchar++) > 'Z')
  1360. X        FatalError ("Too many macro names (26 max)", (char *) NULL);
  1361. X    return (phe->idval.idc);
  1362. X}
  1363. X
  1364. X
  1365. X/*
  1366. X *    BindID () -- Binds either a ruleset or precedence identifier (phe) to
  1367. X *              an integer (vid).  The id type distinction is passed in
  1368. X *             the parameter idt.
  1369. X *
  1370. X */
  1371. Xvoid
  1372. XBindID (phe, vid, idt)
  1373. Xregister struct he *phe;    /* symbol table entry for an identifier    */
  1374. Xint vid;            /* value of the identifier           */
  1375. Xunsigned idt;            /* identifier type (ruleset or precedence) */
  1376. X{
  1377. X    if (ISTYPED(phe->idtype)) {    /* should be undefined */
  1378. X        PrintWarning ("Redeclaration of %s.\n", phe->psb);
  1379. X        phe->idtype = ID_UNTYPED;
  1380. X    }
  1381. X    phe->idtype |= idt;        /* make defined           */
  1382. X    if (ISRULESET(phe->idtype)) {
  1383. X        if (vid > VALRSNMAX) {
  1384. X            ErrorReport ("Ruleset number too large.\n");
  1385. X            return;
  1386. X        } else if (vid < 0) {
  1387. X            ErrorReport ("Ruleset number must be non-negative.\n");
  1388. X            return;
  1389. X        }
  1390. X        sprintf (phe->idval.rsn, "%d", vid);
  1391. X    } else 
  1392. X        phe->idval.prec = vid;
  1393. X}
  1394. X
  1395. X
  1396. X/*
  1397. X *    CheckRS () -- Checks validity of a ruleset identifier (phe) and 
  1398. X *              returns the ruleset string to which the identifier
  1399. X *              is bound.  If the ruleset identifier is invalid, the
  1400. X *              null string is returned.
  1401. X *
  1402. X */
  1403. Xchar *
  1404. XCheckRS (phe)
  1405. Xstruct he *phe;        /* symbol table entry for ruleset identifier */
  1406. X{
  1407. X    if (!ISRULESET(phe->idtype)) {
  1408. X        if (!ISTYPED(phe->idtype))
  1409. X            PrintError ("Ruleset identifier not bound to a number:", phe->psb);
  1410. X        else
  1411. X            PrintError ("Identifier not of ruleset type:", phe->psb);
  1412. X        return (NULL);
  1413. X    } else
  1414. X        return (phe->idval.rsn);
  1415. X}
  1416. X
  1417. X
  1418. X/*
  1419. X *    MakeMac () -- Declare a macro name (pmac) as a class and/or macro type 
  1420. X *              (targtype) and return the unique cf character assigned 
  1421. X *              to it.
  1422. X *
  1423. X */
  1424. Xchar
  1425. XMakeMac (pmac, targtype)
  1426. Xregister struct he *pmac;    /* symbol table entry for macro identifier */
  1427. Xunsigned targtype;        /* target declaration type for the macro   */
  1428. X{
  1429. X    /*
  1430. X     *    An Ease macro may be declared as both a singular macro and
  1431. X     *    a class macro.
  1432. X     *
  1433. X     */
  1434. X    if (ISMACRO(pmac->idtype) || ISCLASS(pmac->idtype)) {
  1435. X        pmac->idtype |= targtype;
  1436. X        return (pmac->idval.idc);
  1437. X    }
  1438. X    if (ISTYPED(pmac->idtype)) {    /* not a macro or class id */
  1439. X        PrintError ("Redeclaring or using as macro or class:", pmac->psb);
  1440. X        return ('\0');
  1441. X    }
  1442. X    pmac->idtype |= targtype;    /* previously untyped; declare here */
  1443. X    return (UniqMac (pmac));
  1444. X}
  1445. X    
  1446. X
  1447. X/*
  1448. X *    GetField () -- Returns a field type string given a field 
  1449. X *               identifier (fid).
  1450. X *
  1451. X */
  1452. Xchar *
  1453. XGetField (fid)
  1454. Xregister struct he *fid;    /* field identifier */
  1455. X{
  1456. X    if (!ISFIELD(fid->idtype)) {
  1457. X        PrintError ("Field type not defined for", fid->psb);
  1458. X        return (NULL);
  1459. X    } else 
  1460. X        return (fid->idval.fstring);
  1461. X}
  1462. X
  1463. X
  1464. X/*
  1465. X *    CheckMailer () -- Declares a mailer identifier (mid) as type mailer,
  1466. X *              checking that the identifier was not previously 
  1467. X *              declared a different type. 
  1468. X *
  1469. X */
  1470. Xchar *
  1471. XCheckMailer (mid)
  1472. Xregister struct he *mid;
  1473. X{
  1474. X    if (ISTYPED (mid->idtype) && !ISMAILER (mid->idtype)) {
  1475. X        PrintError ("Redeclaration as mailer:", mid->psb);
  1476. X        return (NULL);
  1477. X    }
  1478. X    mid->idtype |= ID_MAILER;
  1479. X    return (mid->psb);
  1480. X}
  1481. X
  1482. X
  1483. X/*
  1484. X *    AssignType () -- Assigns to each field identifier in fidlist the
  1485. X *             type (in string form) fidtype.  This is accomplished
  1486. X *             by making each field identifier symbol table entry
  1487. X *             "point" to the type found in fidtype.
  1488. X *
  1489. X */
  1490. Xvoid
  1491. XAssignType (fidlist, fidtype)
  1492. Xregister char *fidlist;        /* field identifier list, blank separated */
  1493. Xchar *fidtype;            /* field identifier type string          */
  1494. X{
  1495. X    register struct he *fid;    /* pointer to a field identifier  */
  1496. X    char *fres;            /* field type result string      */
  1497. X    register char *srch;        /* fidlist search pointer      */
  1498. X    char  sep;            /* fidlist separator character    */
  1499. X
  1500. X    fres = (char *) malloc (strlen (fidtype) + 1);
  1501. X    if (fres == NULL)
  1502. X        FatalError ("System out of string space in AssignType ()", (char *) NULL);
  1503. X    strcpy (fres, fidtype);        /* make clean copy of string type */
  1504. X
  1505. X    /*
  1506. X     *    Search for all field identifiers and make the type assignment. 
  1507. X      *
  1508. X     */
  1509. X    srch = fidlist;
  1510. X    while (*srch != '\0') {
  1511. X        while ((*++srch != ' ') && (*srch != '\0'))
  1512. X            /* null */ ;
  1513. X        if (*fidlist != '\0') {                /* found a field id       */
  1514. X            sep = *srch;
  1515. X            *srch = '\0';
  1516. X            fid = LookupSymbol (fidlist);    /* get symbol table entry */
  1517. X            if (ISFIELD(fid->idtype)) {
  1518. X                if (strcmp (fid->idval.fstring, fres))
  1519. X                    PrintWarning ("Redefinition of field type for %s.\n", fid->psb);
  1520. X            } else if (ISTYPED(fid->idtype)) {
  1521. X                PrintError ("Redeclaration of identifier as a field:", fid->psb);
  1522. X                return;
  1523. X            }
  1524. X            fid->idtype |= ID_FIELD;    /* type the identifier    */
  1525. X            fid->idval.fstring = fres;    /* type the field      */
  1526. X            if ((*srch = sep) != '\0')
  1527. X                fidlist = ++srch;
  1528. X        }
  1529. X    }
  1530. X}
  1531. END_OF_FILE
  1532. if test 5550 -ne `wc -c <'src/idman.c'`; then
  1533.     echo shar: \"'src/idman.c'\" unpacked with wrong size!
  1534. fi
  1535. # end of 'src/idman.c'
  1536. fi
  1537. if test -f 'src/lexan.l' -a "${1}" != "-c" ; then 
  1538.   echo shar: Will not clobber existing file \"'src/lexan.l'\"
  1539. else
  1540. echo shar: Extracting \"'src/lexan.l'\" \(5031 characters\)
  1541. sed "s/^X//" >'src/lexan.l' <<'END_OF_FILE'
  1542. X%{
  1543. X/*    $Header: /usr/src/local/etc/ease/RCS/lexan.l,v 1.2 85/10/29 23:42:40 jss Exp $    */
  1544. X
  1545. X/*
  1546. X *    lexan.l -- Lexical Analyzer for EASE.
  1547. X *
  1548. X *           Contains code for lex(1) which generates a lexical
  1549. X *           analyzer (lex.yy.c) for Ease, a high-level specification 
  1550. X *           format for sendmail configuration files.
  1551. X *
  1552. X *    author -- James S. Schoner, Purdue University Computing Center,
  1553. X *                    West Lafayette, Indiana  47907
  1554. X *
  1555. X *    date   -- July 1, 1985
  1556. X *
  1557. X *    Copyright (c) 1985 by Purdue Research Foundation
  1558. X *
  1559. X *    All rights reserved.
  1560. X *
  1561. X */
  1562. X
  1563. X#include "symtab.h"
  1564. X#include "lexdefs.h"
  1565. X
  1566. X#define  LEXnewline '\n'
  1567. X#define     LEXeof        '\0'
  1568. X#define  MaxFN        200            /* maximum file name length */
  1569. X
  1570. Xextern struct he *LookupSymbol ();
  1571. Xextern void      ErrorReport ();
  1572. X
  1573. Xint  Lcount;                /* line counter            */
  1574. Xchar FNbuf[MaxFN];            /* file name buffer        */
  1575. Xshort RMatch  = FALSE;            /* ruleset match flag          */
  1576. X
  1577. X%}
  1578. X
  1579. X/* lex-specific extensions */
  1580. X%e 1100
  1581. X%p 3700
  1582. X%n 500
  1583. X
  1584. X%%
  1585. X    int INch;            /* any input character */
  1586. X
  1587. X[ \t\f]+            ;     /* discard whitepsace  */
  1588. X[\n]                Lcount++;
  1589. X^\#[ \t]*[0-9]+[ \t]*\".*\"[ \t]*$    {
  1590. X                    sscanf (yytext, "%*c%d%s", &Lcount, FNbuf);
  1591. X                    INch = input ();
  1592. X                    }
  1593. Xmatch                return (MATCH);
  1594. Xin                return (IN);
  1595. Xbind                return (BIND);
  1596. Xdefine                return (DEFINE);
  1597. Xmacro                return (MACRO);
  1598. Xclass                return (CLASS);
  1599. Xoptions                return (OPTIONS);
  1600. Xprecedence            return (PRECEDENCE);
  1601. Xtrusted                return (TRUSTED);
  1602. Xheader                return (HEADER);
  1603. Xruleset                return (RULESET);
  1604. Xmailer                return (MAILER);
  1605. Xhost                return (HOST);
  1606. Xuser                return (USER);
  1607. Xhostnum                return (HOSTNUM);
  1608. Xif                return (IF);
  1609. Xretry                return (RETRY);
  1610. Xnext                return (NEXT);
  1611. Xreturn                return (RETURN);
  1612. Xresolve                return (RESOLVE);
  1613. Xfor                return (FOR);
  1614. Xfield                return (FIELD);
  1615. Xconcat                return (CONCAT);
  1616. Xifset                return (IFSET);
  1617. Xcanon                return (CANON);
  1618. Xreadclass            return (READCLASS);
  1619. XPath                return (MPATH);
  1620. XFlags                return (MFLAGS);
  1621. XSender                return (MSENDER);
  1622. XRecipient            return (MRECIPIENT);
  1623. XArgv                return (MARGV);
  1624. XEol                return (MEOL);
  1625. XMaxsize                return (MMAXSIZE);
  1626. Xo_alias                return (AAOPT);
  1627. Xo_ewait                return (AOPT);
  1628. Xo_bsub                return (BBOPT);
  1629. Xo_qwait                return (COPT);
  1630. Xo_delivery            return (DOPT);
  1631. Xd_interactive            return (DOPTI);
  1632. Xd_background            return (DOPTB);
  1633. Xd_queue                return (DOPTQ);
  1634. Xo_rebuild            return (DDOPT);
  1635. Xo_handling            return (EOPT);
  1636. Xh_print                return (EOPTP);
  1637. Xh_exit                return (EOPTE);
  1638. Xh_mail                return (EOPTM);
  1639. Xh_write                return (EOPTW);
  1640. Xh_mailz                return (EOPTZ);
  1641. Xo_tmode                return (FFOPT);
  1642. Xo_usave                return (FOPT);
  1643. Xo_gid                return (GOPT);
  1644. Xo_fsmtp                return (HHOPT);
  1645. Xo_skipd                return (IOPT);
  1646. Xo_slog                return (LLOPT);
  1647. Xo_rsend                return (MOPT);
  1648. Xo_dnet                return (NNOPT);
  1649. Xo_hformat            return (OOPT);
  1650. Xo_qdir                return (QQOPT);
  1651. Xo_tread                return (ROPT);
  1652. Xo_flog                return (SSOPT);
  1653. Xo_safe                return (SOPT);
  1654. Xo_qtimeout            return (TTOPT);
  1655. Xo_timezone            return (TOPT);
  1656. Xo_dmuid                return (UOPT);
  1657. Xo_verbose            return (VOPT);
  1658. Xo_wizpass            return (WWOPT);
  1659. Xo_loadq                return (XOPT);
  1660. Xo_loadnc            return (XXOPT);
  1661. Xf_ffrom                return (FFLAG);
  1662. Xf_rfrom                return (RFLAG);
  1663. Xf_noreset            return (SSFLAG);
  1664. Xf_noufrom            return (NFLAG);
  1665. Xf_locm                return (LFLAG);
  1666. Xf_strip                return (SFLAG);
  1667. Xf_mult                return (MFLAG);
  1668. Xf_from                return (FFFLAG);
  1669. Xf_date                return (DDFLAG);
  1670. Xf_mesg                return (MMFLAG);
  1671. Xf_full                return (XFLAG);
  1672. Xf_return            return (PPFLAG);
  1673. Xf_upperu            return (UFLAG);
  1674. Xf_upperh            return (HFLAG);
  1675. Xf_arpa                return (AAFLAG);
  1676. Xf_ufrom                return (UUFLAG);
  1677. Xf_expensive            return (EFLAG);
  1678. Xf_dot                return (XXFLAG);
  1679. Xf_llimit            return (LLFLAG);
  1680. Xf_retsmtp            return (PFLAG);
  1681. Xf_smtp                return (IIFLAG);
  1682. Xf_addrw                return (CCFLAG);
  1683. X[A-Za-z][A-Za-z0-9_-]*        {
  1684. X                /* store identifiers in symbol table */
  1685. X                yylval.phe = LookupSymbol (yytext);
  1686. X                return (IDENT);
  1687. X                }
  1688. X["]((\\\n)|(\\\")|[^"\n])*    {
  1689. X                if ((INch = input()) == LEXnewline) {
  1690. X                    ErrorReport ("End of line in string.\n");
  1691. X                    unput (INch);
  1692. X                }
  1693. X                yylval.psb = (char *) malloc (strlen (yytext) + 1);
  1694. X                strcpy (yylval.psb, yytext + 1);
  1695. X                return (SCONST);
  1696. X                }
  1697. X[0][0-7]*            {
  1698. X                sscanf (yytext, "%o", &yylval.ival);  /* octal constant */
  1699. X                return (ICONST);
  1700. X                }
  1701. X[-]?[1-9][0-9]*            {
  1702. X                yylval.ival = atoi (yytext);
  1703. X                return (ICONST);
  1704. X                }
  1705. X"="                return (ASGN);
  1706. X","                return (COMMA);
  1707. X"{"                return (LBRACE);
  1708. X"}"                return (RBRACE);
  1709. X"("                return (LPAREN);
  1710. X")"                return (RPAREN);
  1711. X";"                return (SEMI);
  1712. X"$"                return (DOLLAR);
  1713. X":"                return (COLON);
  1714. X"*"                return (STAR);
  1715. X"/*"                {
  1716. X                /* eat C comments */
  1717. X                INch = input ();
  1718. X                while ((INch != '*') || 
  1719. X                      ((INch = input ()) != '/')) {
  1720. X                    if (INch == LEXnewline)
  1721. X                        Lcount++;
  1722. X                    else
  1723. X                        if (INch == LEXeof) {
  1724. X                            ErrorReport ("End of file in comment.\n");
  1725. X                            break;
  1726. X                        }
  1727. X                    if (INch != '*')
  1728. X                        INch = input ();
  1729. X                }
  1730. X                }
  1731. X[\\]?.                {
  1732. X                if (RMatch) {    /* in rulesets, return literal character */
  1733. X                    yylval.ival = (yytext[0] == '\\') ? yytext[1] : yytext[0];
  1734. X                    return (SEPCHAR);
  1735. X                } else {
  1736. X                    ErrorReport ("Illegal delimiter character");
  1737. X                    printf (": (octal code) \\%03o\n", *yytext);
  1738. X                }
  1739. X                }
  1740. X%%
  1741. END_OF_FILE
  1742. if test 5031 -ne `wc -c <'src/lexan.l'`; then
  1743.     echo shar: \"'src/lexan.l'\" unpacked with wrong size!
  1744. fi
  1745. # end of 'src/lexan.l'
  1746. fi
  1747. if test -f 'src/main.c' -a "${1}" != "-c" ; then 
  1748.   echo shar: Will not clobber existing file \"'src/main.c'\"
  1749. else
  1750. echo shar: Extracting \"'src/main.c'\" \(3915 characters\)
  1751. sed "s/^X//" >'src/main.c' <<'END_OF_FILE'
  1752. X/*    $Header: /usr/src/local/etc/ease/RCS/main.c,v 1.2 85/10/29 23:43:38 jss Exp $    */
  1753. X
  1754. X/*
  1755. X *      main.c     -- Main procedure for Ease Translator.
  1756. X *
  1757. X *      author     -- James S. Schoner, Purdue University Computing Center
  1758. X *                        West Lafayette, Indiana  47907
  1759. X *
  1760. X *      date       -- July 9, 1985
  1761. X *
  1762. X *    Copyright (c) 1985 by Purdue Research Foundation
  1763. X *
  1764. X *    All rights reserved.
  1765. X *
  1766. X */
  1767. X
  1768. X#include <stdio.h>
  1769. X
  1770. Xextern FILE *DIAGf;            /* diagnostic file */
  1771. Xextern void InitError (), 
  1772. X        InitSymbolTable (),
  1773. X        DefScan (),
  1774. X        FatalError (),
  1775. X            PreLoad ();
  1776. X
  1777. Xint ErrorCount;                /* translation error count */
  1778. Xvoid GetArgs ();            /* gets arguments to "et"  */
  1779. X
  1780. X/*
  1781. X *    main () -- Main procedure for the Ease Translator et.  If no files are 
  1782. X *                  given as arguments to et, stdin is translated and written to 
  1783. X *               stdout.  If one file is given, it is translated and written 
  1784. X *               to stdout.  If two files are given, the first is translated
  1785. X *               and written to the second.  If the first filename is "-",
  1786. X *               standard input is assumed.  A translation is performed on 
  1787. X *               valid Ease input only, producing a regular sendmail 
  1788. X *           configuration file. 
  1789. X *
  1790. X */
  1791. Xvoid
  1792. Xmain (argc, argv)
  1793. Xint argc;        /* argument count for "et"  */
  1794. Xchar *argv[];        /* argument vector for "et" */
  1795. X{
  1796. X    InitError ();            /* initialize error conditions */
  1797. X    InitSymbolTable ();        /* initialize the symbol table */
  1798. X    PreLoad ();            /* preload special identifiers */
  1799. X    GetArgs (argc, argv);        /* set up argument files       */
  1800. X    (void) yyparse ();        /* perform translation           */
  1801. X    if (fflush (stdout) == EOF)
  1802. X        FatalError ("Cannot flush output stream/file", (char *) NULL);
  1803. X    DefScan ();                /* warn about undefined idents */
  1804. X    if (ErrorCount)
  1805. X        fprintf (DIAGf, "\n\n*** %d error(s) detected.\n", ErrorCount);
  1806. X    exit (ErrorCount);
  1807. X}
  1808. X
  1809. X
  1810. X/*
  1811. X *    GetArgs () -- Processes arguments to the Ease translator "et".  The
  1812. X *              arguments are files (margv) which may replace either/both
  1813. X *              of the files standard input and standard output.  The 
  1814. X *              following cases are possible:
  1815. X *            
  1816. X *              -- et f.e f.cf
  1817. X *                Translate Ease file f.e and write result
  1818. X *                to f.cf.
  1819. X *
  1820. X *              -- et f.e
  1821. X *                Translate Ease file f.e and write result to
  1822. X *                standard output.
  1823. X *
  1824. X *              -- et - f.cf
  1825. X *                Translate standard input and write result to
  1826. X *                f.cf.
  1827. X *
  1828. X *              -- et
  1829. X *                Translate standard input and write result to
  1830. X *                standard output.
  1831. X *
  1832. X *              Finally, a message indicating the volatility of the 
  1833. X *              Ease output is written.
  1834. X *
  1835. X */
  1836. Xvoid
  1837. XGetArgs (margc, margv)
  1838. Xregister int   margc;        /* argument count  */
  1839. Xregister char *margv[];        /* argument vector */
  1840. X{
  1841. X    switch (margc) {
  1842. X        case 1 : break;
  1843. X        case 2 :
  1844. X        case 3 : if (strcmp (margv[1], "-") && (freopen (margv[1], "r", stdin) == NULL))
  1845. X                FatalError ("Cannot open input stream/file:", margv[1]);
  1846. X             if ((margc == 3) && (freopen (margv[2], "w", stdout) == NULL))
  1847. X                FatalError ("Cannot open output file:", margv[2]);
  1848. X             break;
  1849. X        default: FatalError ("Usage: et [infile [outfile]]", (char *) NULL);
  1850. X             break;
  1851. X    }
  1852. X    printf ("###################################################\n");
  1853. X    printf ("##                                               ##\n");
  1854. X    printf ("##  WARNING: THIS FILE IS TO BE MODIFIED BY      ##\n");
  1855. X    printf ("##           THE EASE TRANSLATOR (ET) ONLY.      ##\n");
  1856. X    printf ("##                                               ##\n");
  1857. X    printf ("##           ALL OTHER MODIFICATIONS WILL        ##\n");
  1858. X    printf ("##           DISAPPEAR THE NEXT TIME ET IS RUN.  ##\n");
  1859. X    printf ("##                                               ##\n");
  1860. X    printf ("##           MAKE MODIFICATIONS TO THE EASE      ##\n");
  1861. X    printf ("##           SOURCE ONLY.                        ##\n");
  1862. X    printf ("##                                               ##\n");
  1863. X    printf ("###################################################\n");
  1864. X}
  1865. END_OF_FILE
  1866. if test 3915 -ne `wc -c <'src/main.c'`; then
  1867.     echo shar: \"'src/main.c'\" unpacked with wrong size!
  1868. fi
  1869. # end of 'src/main.c'
  1870. fi
  1871. if test -f 'src/symtab.c' -a "${1}" != "-c" ; then 
  1872.   echo shar: Will not clobber existing file \"'src/symtab.c'\"
  1873. else
  1874. echo shar: Extracting \"'src/symtab.c'\" \(5288 characters\)
  1875. sed "s/^X//" >'src/symtab.c' <<'END_OF_FILE'
  1876. X/*    $Header: /usr/src/local/etc/ease/RCS/symtab.c,v 1.2 85/10/29 23:46:48 jss Exp $    */
  1877. X
  1878. X/*
  1879. X *      symtab.c   -- Contains Ease Translator symbol table routines.
  1880. X *
  1881. X *      author     -- James S. Schoner, Purdue University Computing Center,
  1882. X *                        West Lafayette, Indiana  47907
  1883. X *
  1884. X *      date       -- July 9, 1985
  1885. X *
  1886. X *    Copyright (c) 1985 by Purdue Research Foundation
  1887. X *
  1888. X *    All rights reserved.
  1889. X *
  1890. X */
  1891. X
  1892. X#include <stdio.h>
  1893. X#include <ctype.h>
  1894. X#include "symtab.h"
  1895. X
  1896. X#define ERRORMAILER "error"        /* predefined error mailer name */
  1897. X
  1898. Xextern void FatalError (),
  1899. X        PrintWarning ();
  1900. X
  1901. Xstruct he *LookupSymbol ();
  1902. X
  1903. Xstruct Defmac {                /* predefined macro struct def  */
  1904. X    char *macname;
  1905. X    char  macrep;
  1906. X};
  1907. X
  1908. Xstruct he *SymTab[SST];            /* hash table base array        */
  1909. Xstatic struct Defmac MacDefs[] = {    /* predefined macros            */
  1910. X            {"m_smtp",    'e'},
  1911. X            {"m_oname",    'j'},
  1912. X            {"m_ufrom",    'l'},
  1913. X            {"m_daemon",    'n'},
  1914. X            {"m_addrops",    'o'},
  1915. X            {"m_defaddr",    'q'},
  1916. X            {"m_sitename",    'w'},
  1917. X            {"m_odate",    'a'},
  1918. X            {"m_adate",    'b'},
  1919. X            {"m_hops",    'c'},
  1920. X            {"m_udate",    'd'},
  1921. X            {"m_saddr",    'f'},
  1922. X            {"m_sreladdr",    'g'},
  1923. X            {"m_rhost",    'h'},
  1924. X            {"m_qid",    'i'},
  1925. X            {"m_pid",    'p'},
  1926. X            {"m_protocol",    'r'},
  1927. X            {"m_shostname", 's'},
  1928. X            {"m_ctime",    't'},
  1929. X            {"m_ruser",    'u'},
  1930. X            {"m_version",    'v'},
  1931. X            {"m_sname",    'x'},
  1932. X            {"m_stty",    'y'},
  1933. X            {"m_rhdir",    'z'},
  1934. X            {"sentinel",    '\0'}
  1935. X};
  1936. X
  1937. X
  1938. X/*
  1939. X *    DefScan () -- Scan symbol table to find macros, classes, mailers, 
  1940. X *              and rulesets which have been referenced or declared, but
  1941. X *              not defined.  A warning is printed for each such 
  1942. X *              occurence.  This routine is usually called at the end
  1943. X *              of a successful Ease translation.
  1944. X *
  1945. X */
  1946. Xvoid
  1947. XDefScan ()
  1948. X{
  1949. X    register int stindex;        /* symbol table hash index   */
  1950. X    register struct he *hcsearch;    /* hash chain search pointer */
  1951. X
  1952. X    for (stindex = 0; stindex < SST; stindex++) {
  1953. X        if ((hcsearch = SymTab[stindex]) != NULL)
  1954. X            while (hcsearch != NULL) {
  1955. X                if ((ISMACRO(hcsearch->idtype) && 
  1956. X                     isupper(hcsearch->idval.idc)) &&
  1957. X                     !ISMACRO(hcsearch->idd))
  1958. X                    PrintWarning ("Macro not defined: %s\n", hcsearch->psb);
  1959. X                if (ISCLASS(hcsearch->idtype) && !ISCLASS(hcsearch->idd))
  1960. X                    PrintWarning ("Class not defined: %s\n", hcsearch->psb);
  1961. X                if (ISMAILER(hcsearch->idtype) && !ISMAILER(hcsearch->idd))
  1962. X                    PrintWarning ("Mailer not defined: %s\n", hcsearch->psb);
  1963. X                if (ISRULESET(hcsearch->idtype) && !ISRULESET(hcsearch->idd))
  1964. X                    PrintWarning ("Ruleset not defined: %s\n", hcsearch->psb);
  1965. X                hcsearch = hcsearch->phe;
  1966. X            }
  1967. X    }
  1968. X}
  1969. X                     
  1970. X
  1971. X/*
  1972. X *    InitSymbolTable () -- Invoked by main () to initialize the symbol table.
  1973. X *
  1974. X */
  1975. Xvoid
  1976. XInitSymbolTable ()
  1977. X{
  1978. X    int i;
  1979. X
  1980. X    for (i = 0; i < SST; i++)        /* initialize base array */
  1981. X        SymTab[i] = NULL;
  1982. X}
  1983. X
  1984. X
  1985. X/*
  1986. X *    PreLoad () -- Invoked by main () to preload special macro names 
  1987. X *              and mailer declarations.
  1988. X *
  1989. X */
  1990. Xvoid
  1991. XPreLoad ()
  1992. X{
  1993. X    struct Defmac *macptr;
  1994. X    struct he     *symptr;
  1995. X
  1996. X    /* preload special (lower-case) macros */
  1997. X    for (macptr = &MacDefs[0]; (*macptr).macrep != '\0'; macptr++) {
  1998. X        symptr = LookupSymbol ((*macptr).macname);
  1999. X        symptr->idtype |= ID_MACRO;
  2000. X        symptr->idval.idc = (*macptr).macrep;
  2001. X    }
  2002. X
  2003. X    /* preload error mailer declaration */
  2004. X    symptr = LookupSymbol (ERRORMAILER);
  2005. X    symptr->idtype |= ID_MAILER;
  2006. X    symptr->idd |= ID_MAILER;
  2007. X}
  2008. X    
  2009. X
  2010. X/*
  2011. X *    LookupSymbol () -- Returns a pointer to the hash entry already 
  2012. X *               existing, or newly created, which corresponds 
  2013. X *               to string sb.
  2014. X *
  2015. X */
  2016. Xstruct he *
  2017. XLookupSymbol (sb)
  2018. Xchar sb[];            /* string buffer containing identifier */
  2019. X{
  2020. X    struct he *phe;        /* hash entry search pointer  */
  2021. X    int      hc;        /* hash code of sb identifier */
  2022. X
  2023. X    phe = SymTab[hc = HashCode (sb)];
  2024. X    while (phe != NULL)            /* find hash entry for sb */
  2025. X        if (!strcmp (phe->psb, sb))
  2026. X            return (phe);
  2027. X        else
  2028. X            phe = phe->phe;
  2029. X    /* make new symbol table entry */
  2030. X    if ((phe = (struct he *) malloc (sizeof (struct he))) == NULL)
  2031. X        FatalError ("System out of space in LookupSymbol ()", (char *) NULL);
  2032. X    if ((phe->psb = (char *) malloc (strlen (sb) + 1)) == NULL)
  2033. X        FatalError ("System out of space in LookupSymbol ()", (char *) NULL);
  2034. X    strcpy (phe->psb, sb);
  2035. X    phe->idval.idc = '\0';
  2036. X    phe->idtype = ID_UNTYPED;
  2037. X    phe->idd = ID_UNTYPED;
  2038. X    phe->phe = SymTab[hc];
  2039. X    return (SymTab[hc] = phe);
  2040. X}
  2041. X
  2042. X
  2043. X/*
  2044. X *    RemoveSymbol () -- Removes the symbol table entry phe from the 
  2045. X *               symbol table.
  2046. X *
  2047. X */
  2048. Xvoid
  2049. XRemoveSymbol (phe)
  2050. Xstruct he *phe;       /* pointer to hash entry to be removed from symbol table */
  2051. X{
  2052. X    int hc;               /* hash code of entry phe       */
  2053. X    struct he *sphe;    /* search pointer for entry phe */
  2054. X
  2055. X    if (phe == NULL)
  2056. X        return;
  2057. X    else {            /* search and remove entry phe  */
  2058. X        sphe = SymTab[hc = HashCode (phe->psb)];
  2059. X        free (phe->psb);
  2060. X        if (sphe == phe)
  2061. X            SymTab[hc] = phe->phe;
  2062. X        else
  2063. X            while (sphe != NULL)
  2064. X                if (sphe->phe == phe) {
  2065. X                    sphe->phe = phe->phe;
  2066. X                    return;
  2067. X                } else
  2068. X                    sphe = sphe->phe;
  2069. X    }
  2070. X}
  2071. X
  2072. X
  2073. X/*
  2074. X *    HashCode () -- Returns the hash code of the string in sb by adding 
  2075. X *               the character values and applying mod by the hash 
  2076. X *               table size.
  2077. X *
  2078. X */
  2079. Xint
  2080. XHashCode (sb)
  2081. Xchar sb[];
  2082. X{
  2083. X    int ccSum = 0;            /* sum of char values in string sb */
  2084. X    int i;
  2085. X
  2086. X    for (i = 0; sb[i]; i++)        /* add char codes for sb chars     */
  2087. X        ccSum += sb[i];
  2088. X    return (ccSum % SST);        /* return sum mod table size       */
  2089. X}
  2090. END_OF_FILE
  2091. if test 5288 -ne `wc -c <'src/symtab.c'`; then
  2092.     echo shar: \"'src/symtab.c'\" unpacked with wrong size!
  2093. fi
  2094. # end of 'src/symtab.c'
  2095. fi
  2096. echo shar: End of archive 2 \(of 4\).
  2097. cp /dev/null ark2isdone
  2098. MISSING=""
  2099. for I in 1 2 3 4 ; do
  2100.     if test ! -f ark${I}isdone ; then
  2101.     MISSING="${MISSING} ${I}"
  2102.     fi
  2103. done
  2104. if test "${MISSING}" = "" ; then
  2105.     echo You have unpacked all 4 archives.
  2106.     rm -f ark[1-9]isdone
  2107. else
  2108.     echo You still need to unpack the following archives:
  2109.     echo "        " ${MISSING}
  2110. fi
  2111. ##  End of shell archive.
  2112. exit 0
  2113. -- 
  2114.  
  2115. Rich $alz            "Anger is an energy"
  2116. Cronus Project, BBN Labs    rsalz@bbn.com
  2117. Moderator, comp.sources.unix    sources@uunet.uu.net
  2118.