home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume22 / et / part01 next >
Internet Message Format  |  1990-10-09  |  51KB

  1. Path: j.cc.purdue.edu!mentor.cc.purdue.edu!purdue!tut.cis.ohio-state.edu!snorkelwacker!apple!bbn.com!papaya.bbn.com!rsalz
  2. From: rsalz@uunet.uu.net (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v22i022:  Error table compiler and library, Part01/03
  5. Message-ID: <2502@papaya.bbn.com>
  6. Date: 7 May 90 20:50:42 GMT
  7. Lines: 1850
  8. Approved: rsalz@uunet.UU.NET
  9.  
  10. Submitted-by: "Jonathan I. Kamens" <jik@pit-manager.mit.edu>
  11. Posting-number: Volume 22, Issue 22
  12. Archive-name: et/part01
  13.  
  14. [  This was originally bundled into the Delete package, but I split it out
  15.    because I think it should be available more easily.  It's used in lots of
  16.    Athena software.
  17.  
  18.    The introduction below comes from the manpage. The file texinfo.tex was
  19.    split into two parts for posting.  --r$  ]
  20.  
  21. This is an error-table library.
  22.  
  23.     #include <com_err.h>
  24.     void com_err (whoami, code, format, ...);
  25.         const char *whoami;
  26.         long code;
  27.         const char *format;
  28.     proc = set_com_err_hook (proc);
  29.     void (* proc) (const char *, long, const char *, va_list);
  30.     proc = reset_com_err_hook ();
  31.     void initialize_XXXX_error_table ();
  32.  
  33. Com_err displays an error message on the standard error stream stderr
  34. composed of the whoami string, which should specify the program name or
  35. some subportion of a program, followed by an error message generated from
  36. the code value (derived from compile_et, and a string produced using the
  37. format string and any following arguments, in the same style as fprintf.
  38.  
  39. The behavior of com_err can be modified using set_com_err_hook; this
  40. defines a procedure which is called with the arguments passed to com_err,
  41. instead of the default internal procedure which sends the formatted text
  42. to error output.  Thus the error messages from a program can all easily be
  43. diverted to another form of diagnostic logging, such as syslog (3).
  44. Reset_com_err_hook may be used to restore the behavior of com_err to its
  45. default form.  Both procedures return the previous ``hook'' value.  These
  46. ``hook'' procedures must have the declaration given for proc above in the
  47. synopsis.
  48.  
  49. #! /bin/sh
  50. # This is a shell archive.  Remove anything before this line, then unpack
  51. # it by saving it into a file and typing "sh file".  To overwrite existing
  52. # files, type "sh file -c".  You can also feed this as standard input via
  53. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  54. # will see the following message at the end:
  55. #        "End of archive 1 (of 3)."
  56. # Contents:  MANIFEST Makefile com_err.3 com_err.c com_err.h
  57. #   compile_et.1 compile_et.c compiler.h error_message.c error_table.h
  58. #   error_table.y et_lex.lex.l et_name.c init_et.c internal.h
  59. #   mit-sipb-copyright.h profiled strcasecmp.c test.c test1.et
  60. #   test2.et
  61. # Wrapped by rsalz@litchi.bbn.com on Mon May  7 16:40:32 1990
  62. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  63. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  64.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  65. else
  66. echo shar: Extracting \"'MANIFEST'\" \(874 characters\)
  67. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  68. X   File Name        Archive #    Description
  69. X-----------------------------------------------------------
  70. X MANIFEST                   1    This shipping list
  71. X Makefile                   1    
  72. X com_err.3                  1    
  73. X com_err.c                  1    
  74. X com_err.h                  1    
  75. X com_err.texinfo            2    
  76. X compile_et.1               1    
  77. X compile_et.c               1    
  78. X compiler.h                 1    
  79. X error_message.c            1    
  80. X error_table.h              1    
  81. X error_table.y              1    
  82. X et_lex.lex.l               1    
  83. X et_name.c                  1    
  84. X init_et.c                  1    
  85. X internal.h                 1    
  86. X mit-sipb-copyright.h       1    
  87. X profiled                   1    
  88. X strcasecmp.c               1    
  89. X test.c                     1    
  90. X test1.et                   1    
  91. X test2.et                   1    
  92. X texinfo.tex.1              3    (part 1)
  93. X texinfo.tex.2              2    (part 2)
  94. END_OF_FILE
  95. if test 874 -ne `wc -c <'MANIFEST'`; then
  96.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  97. fi
  98. # end of 'MANIFEST'
  99. fi
  100. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  101.   echo shar: Will not clobber existing file \"'Makefile'\"
  102. else
  103. echo shar: Extracting \"'Makefile'\" \(3918 characters\)
  104. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  105. X#
  106. X# Makefile for error-table routines
  107. X#
  108. X# Copyright 1987, 1989 MIT Student Information Processing Board
  109. X# For copyright info, see mit-sipb-copyright.h.
  110. X#
  111. X#    $Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/Makefile,v 1.2 89/11/07 18:56:09 jik Exp $
  112. X#    $Locker:  $
  113. X#
  114. X
  115. XCFLAGS=    -O
  116. XLINTFLAGS= -uhvpb
  117. XLINTFILES= error_message.c et_name.c init_et.c com_err.c # perror.c
  118. XLIBOBJS= error_message.o et_name.o init_et.o com_err.o # perror.o
  119. X
  120. XBINDIR=/usr/athena
  121. XINCDIR=/usr/include
  122. XLIBDIR=/usr/athena/lib
  123. XDOCDIR=/usr/doc/athena
  124. XDESTDIR=
  125. X
  126. XFILES=    Makefile et_name.c error_message.c compile_et.c \
  127. X        error_table.y et_lex.lex.l init_et.c \
  128. X        com_err.c com_err.h \
  129. X        error_table.h mit-sipb-copyright.h \
  130. X        test.c test1.et test2.et \
  131. X        compiler.h internal.h \
  132. X        com_err.texinfo texinfo.tex strcasecmp.c
  133. XCFILES=    compile_et.c error_table.c error_message.c et_name.c \
  134. X    init_et.c com_err.c strcasecmp.c
  135. X
  136. X#
  137. X# what to build...
  138. X#
  139. Xall:    compile_et libcom_err.a libcom_err_p.a
  140. X
  141. Xlint:    llib-lcom_err.ln
  142. X
  143. Xarchive:    et.tar
  144. X
  145. Xdoc:    com_err.dvi
  146. X
  147. X#
  148. X# rules
  149. X#
  150. X.SUFFIXES: .h .c .et .ps .x9700 .mss .dvi .texinfo
  151. X
  152. X.et.c:
  153. X    ./compile_et $*.et
  154. X
  155. X.et.h:
  156. X    ./compile_et $*.et
  157. X
  158. X.texinfo.dvi:
  159. X    tex $<
  160. X
  161. X.dvi.ps:
  162. X    rm -f $@.new
  163. X    dvi2ps -r $< > $@.new
  164. X    mv $@.new $@
  165. X
  166. X.c.o:
  167. X    ${CC} -c -pg ${CFLAGS} $*.c
  168. X    mv $*.o profiled/$*.o
  169. X    ${CC} -c ${CFLAGS} $*.c
  170. X
  171. X#
  172. X# real entries...
  173. X#
  174. Xcompile_et:    compile_et.o error_table.o strcasecmp.o
  175. X    ${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o\
  176. X        strcasecmp.o -ll
  177. X
  178. Xet.tar:    ${FILES}
  179. X    rm -f et.tar
  180. X    tar cfrlv et.tar ${FILES}
  181. X
  182. Xtags:    TAGS
  183. X
  184. Xcom_err.ps : com_err.dvi
  185. Xcom_err.dvi: com_err.texinfo
  186. X
  187. Xerror_table.o: et_lex.lex.c
  188. X
  189. Xinstall: all
  190. X    install -c -s compile_et ${DESTDIR}${BINDIR}/compile_et
  191. X    install -c -m 444 com_err.h ${DESTDIR}${INCDIR}/com_err.h
  192. X    install -c -m 444 mit-sipb-copyright.h \
  193. X                ${DESTDIR}${INCDIR}/mit-sipb-copyright.h
  194. X    install -c libcom_err.a ${DESTDIR}${LIBDIR}/libcom_err.a
  195. X    ranlib ${DESTDIR}${LIBDIR}/libcom_err.a
  196. X    install -c libcom_err_p.a ${DESTDIR}${LIBDIR}/libcom_err_p.a
  197. X    ranlib ${DESTDIR}${LIBDIR}/libcom_err_p.a
  198. X    install -c com_err.texinfo ${DESTDIR}${DOCDIR}/com_err.texinfo
  199. X    install -c com_err.3 ${DESTDIR}/usr/man/man3/com_err.3
  200. X    install -c compile_et.1 ${DESTDIR}/usr/man/man1/compile_et.1
  201. X
  202. XTAGS:    et_name.c error_message.c compile_et.c error_table.c \
  203. X        lex.yy.c perror.c init_et.c
  204. X    etags et_name.c error_message.c compile_et.c \
  205. X        error_table.c perror.c init_et.c
  206. X
  207. Xlibcom_err.a:    $(LIBOBJS)
  208. X    ar cruv libcom_err.a $(LIBOBJS)
  209. X    ranlib libcom_err.a
  210. X
  211. Xlibcom_err_p.a:    $(LIBOBJS)
  212. X    (cd profiled; ar uv ../libcom_err_p.a $(LIBOBJS); \
  213. X        ranlib ../libcom_err_p.a)
  214. X
  215. Xlibcom_err.o:    $(LIBOBJS)
  216. X    ld -r -s -o libcom_err.o $(LIBOBJS)
  217. X    chmod -x libcom_err.o
  218. X
  219. Xllib-lcom_err.ln: $(LINTFILES)
  220. X    lint -Ccom_err $(LINTFLAGS) $(LINTFILES)
  221. X
  222. Xclean:
  223. X    rm -f *~ \#* *.bak \
  224. X        *.otl *.aux *.toc *.PS *.dvi *.x9700 *.ps \
  225. X        *.cp *.fn *.ky *.log *.pg *.tp *.vr \
  226. X        *.o profiled/*.o libcom_err.a libcom_err_p.a \
  227. X        com_err.o compile_et \
  228. X        et.ar TAGS y.tab.c lex.yy.c error_table.c \
  229. X        et_lex.lex.c \
  230. X        test1.h test1.c test2.h test2.c test \
  231. X        eddep makedep
  232. X
  233. X# for testing
  234. Xtest:    test.o test1.o test2.o libcom_err.a
  235. X    cc ${CFLAGS} -o test test.o test1.o test2.o libcom_err.a
  236. Xtest.o:    test1.h test2.h
  237. Xtest1.o : test1.c
  238. Xtest1.c : test1.et
  239. Xtest2.o : test2.c
  240. Xtest2.c : test2.et
  241. X# 'make depend' code
  242. Xdepend: ${CFILES} et_lex.lex.c
  243. X    rm -f eddep makedep
  244. X    /bin/cc -M ${CFLAGS} ${CFILES} | \
  245. X    sed 's; ./; ;' | \
  246. X    sed -e ':loop' \
  247. X        -e 's/\.\.\/[^ /]*\/\.\./../' \
  248. X        -e 't loop' > makedep
  249. X# add a blank line so that if there are no dependencies, ed
  250. X# won't report an error (it does on some 
  251. X    echo "$$" > eddep
  252. X    echo "a" >> eddep
  253. X    echo "" >> eddep
  254. X    echo "." >> eddep
  255. X    echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >> eddep
  256. X    echo '$$r makedep' >>eddep
  257. X    echo 'w' >>eddep
  258. X    cp Makefile Makefile.bak
  259. X    ed - Makefile < eddep
  260. X    rm eddep makedep
  261. X#
  262. X# the last line in the makefile should be...
  263. X# DO NOT DELETE THIS LINE -- make depend depends on it.
  264. END_OF_FILE
  265. if test 3918 -ne `wc -c <'Makefile'`; then
  266.     echo shar: \"'Makefile'\" unpacked with wrong size!
  267. fi
  268. # end of 'Makefile'
  269. fi
  270. if test -f 'com_err.3' -a "${1}" != "-c" ; then 
  271.   echo shar: Will not clobber existing file \"'com_err.3'\"
  272. else
  273. echo shar: Extracting \"'com_err.3'\" \(2531 characters\)
  274. sed "s/^X//" >'com_err.3' <<'END_OF_FILE'
  275. X.\" Copyright (c) 1988 Massachusetts Institute of Technology,
  276. X.\" Student Information Processing Board.  All rights reserved.
  277. X.\"
  278. X.\" $Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/com_err.3,v 1.1 89/11/07 19:05:23 jik Exp $
  279. X.\"
  280. X.TH COM_ERR 3 "22 Nov 1988" SIPB
  281. X.SH NAME
  282. Xcom_err \- common error display routine
  283. X.SH SYNOPSIS
  284. X.nf
  285. X #include <com_err.h>
  286. X.PP
  287. Xvoid com_err (whoami, code, format, ...);
  288. X    const char *whoami;
  289. X    long code;
  290. X    const char *format;
  291. X.PP
  292. Xproc = set_com_err_hook (proc);
  293. X.fi
  294. Xvoid (*
  295. X.I proc
  296. X) (const char *, long, const char *, va_list);
  297. X.nf
  298. X.PP
  299. Xproc = reset_com_err_hook ();
  300. X.PP
  301. Xvoid initialize_XXXX_error_table ();
  302. X.fi
  303. X.SH DESCRIPTION
  304. X.I Com_err
  305. Xdisplays an error message on the standard error stream
  306. X.I stderr
  307. X(see
  308. X.IR stdio (3S))
  309. Xcomposed of the
  310. X.I whoami
  311. Xstring, which should specify the program name or some subportion of
  312. Xa program, followed by an error message generated from the
  313. X.I code
  314. Xvalue (derived from
  315. X.IR compile_et (1)),
  316. Xand a string produced using the
  317. X.I format
  318. Xstring and any following arguments, in the same style as
  319. X.IR fprintf (3).
  320. X
  321. XThe behavior of
  322. X.I com_err
  323. Xcan be modified using
  324. X.I set_com_err_hook;
  325. Xthis defines a procedure which is called with the arguments passed to
  326. X.I com_err,
  327. Xinstead of the default internal procedure which sends the formatted
  328. Xtext to error output.  Thus the error messages from a program can all
  329. Xeasily be diverted to another form of diagnostic logging, such as
  330. X.IR syslog (3).
  331. X.I Reset_com_err_hook
  332. Xmay be used to restore the behavior of
  333. X.I com_err
  334. Xto its default form.  Both procedures return the previous ``hook''
  335. Xvalue.  These ``hook'' procedures must have the declaration given for
  336. X.I proc
  337. Xabove in the synopsis.
  338. X
  339. XThe
  340. X.I initialize_XXXX_error_table
  341. Xroutine is generated mechanically by
  342. X.IR compile_et (1)
  343. Xfrom a source file containing names and associated strings.  Each
  344. Xtable has a name of up to four characters, which is used in place of
  345. Xthe
  346. X.B XXXX
  347. Xin the name of the routine.  These routines should be called before
  348. Xany of the corresponding error codes are used, so that the
  349. X.I com_err
  350. Xlibrary will recognize error codes from these tables when they are
  351. Xused.
  352. X
  353. XThe
  354. X.B com_err.h
  355. Xheader file should be included in any source file that uses routines
  356. Xfrom the
  357. X.I com_err
  358. Xlibrary; executable files must be linked using
  359. X.I ``-lcom_err''
  360. Xin order to cause the
  361. X.I com_err
  362. Xlibrary to be included.
  363. X
  364. X.\" .IR for manual entries
  365. X.\" .PP for paragraph breaks
  366. X
  367. X.SH "SEE ALSO"
  368. Xcompile_et (1), syslog (3).
  369. X
  370. XKen Raeburn, "A Common Error Description Library for UNIX".
  371. END_OF_FILE
  372. if test 2531 -ne `wc -c <'com_err.3'`; then
  373.     echo shar: \"'com_err.3'\" unpacked with wrong size!
  374. fi
  375. # end of 'com_err.3'
  376. fi
  377. if test -f 'com_err.c' -a "${1}" != "-c" ; then 
  378.   echo shar: Will not clobber existing file \"'com_err.c'\"
  379. else
  380. echo shar: Extracting \"'com_err.c'\" \(2900 characters\)
  381. sed "s/^X//" >'com_err.c' <<'END_OF_FILE'
  382. X/*
  383. X * Copyright 1987, 1988 by MIT Student Information Processing Board.
  384. X *
  385. X * For copyright info, see mit-sipb-copyright.h.
  386. X */
  387. X
  388. X#include <stdio.h>
  389. X#include "mit-sipb-copyright.h"
  390. X
  391. X/*
  392. X * Our environment only provides for ANSI's <stdarg.h> when using GNU
  393. X * C.  Grump grump...
  394. X */
  395. X#if ! __GNUC__
  396. X#define VARARGS 1
  397. X#endif
  398. X
  399. X/* We don't have the v*printf routines... */
  400. X#define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
  401. X
  402. X#if __STDC__ && !VARARGS
  403. X#    include <stdarg.h>
  404. X#else /* varargs: not STDC or no <stdarg> */
  405. X    /* Non-ANSI, always take <varargs.h> path. */
  406. X#    undef VARARGS
  407. X#    define VARARGS 1
  408. X#    include <varargs.h>
  409. X#    undef vfprintf
  410. X#    define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
  411. X#endif /* varargs */
  412. X
  413. X#include "error_table.h"
  414. X#include "internal.h"
  415. X
  416. X/*
  417. X * Protect us from header version (externally visible) of com_err, so
  418. X * we can survive in a <varargs.h> environment.  I think.
  419. X */
  420. X#define com_err com_err_external
  421. X#include "com_err.h"
  422. X#undef com_err
  423. X
  424. X/* BSD. sigh. */
  425. X#undef vfprintf
  426. X#define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
  427. X
  428. X#if ! lint
  429. Xstatic const char rcsid[] =
  430. X    "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/com_err.c,v 1.2 89/11/07 18:57:42 jik Exp $";
  431. X#endif    /* ! lint */
  432. X
  433. Xstatic void
  434. X#ifdef __STDC__
  435. Xdefault_com_err_proc (const char *whoami, long code, const char *fmt, va_list args)
  436. X#else
  437. Xdefault_com_err_proc (whoami, code, fmt, args)
  438. X    const char *whoami;
  439. X    long code;
  440. X    const char *fmt;
  441. X    va_list args;
  442. X#endif
  443. X{
  444. X    if (whoami) {
  445. X    fputs(whoami, stderr);
  446. X    fputs(": ", stderr);
  447. X    }
  448. X    if (code) {
  449. X    fputs(error_message(code), stderr);
  450. X    fputs(" ", stderr);
  451. X    }
  452. X    if (fmt) {
  453. X        vfprintf (stderr, fmt, args);
  454. X    }
  455. X    putc('\n', stderr);
  456. X    /* should do this only on a tty in raw mode */
  457. X    putc('\r', stderr);
  458. X    fflush(stderr);
  459. X}
  460. X
  461. Xerrf com_err_hook = default_com_err_proc;
  462. X
  463. Xvoid com_err_va (whoami, code, fmt, args)
  464. X    const char *whoami;
  465. X    long code;
  466. X    const char *fmt;
  467. X    va_list args;
  468. X{
  469. X    (*com_err_hook) (whoami, code, fmt, args);
  470. X}
  471. X
  472. X#if ! VARARGS
  473. Xvoid com_err (const char *whoami,
  474. X          long code,
  475. X          const char *fmt, ...)
  476. X{
  477. X#else
  478. Xvoid com_err (va_alist)
  479. X    va_dcl
  480. X{
  481. X    const char *whoami, *fmt;
  482. X    long code;
  483. X#endif
  484. X    va_list pvar;
  485. X
  486. X    if (!com_err_hook)
  487. X    com_err_hook = default_com_err_proc;
  488. X#if VARARGS
  489. X    va_start (pvar);
  490. X    whoami = va_arg (pvar, const char *);
  491. X    code = va_arg (pvar, long);
  492. X    fmt = va_arg (pvar, const char *);
  493. X#else
  494. X    va_start(pvar, fmt);
  495. X#endif
  496. X    com_err_va (whoami, code, fmt, pvar);
  497. X    va_end(pvar);
  498. X}
  499. X
  500. X#ifdef __STDC__
  501. Xerrf set_com_err_hook (errf new_proc)
  502. X#else
  503. Xerrf set_com_err_hook (new_proc)
  504. X    errf new_proc;
  505. X#endif
  506. X{
  507. X    errf x = com_err_hook;
  508. X    com_err_hook = new_proc ? new_proc : (errf) default_com_err_proc;
  509. X    return x;
  510. X}
  511. X
  512. Xerrf reset_com_err_hook () {
  513. X    errf x = com_err_hook;
  514. X    com_err_hook = default_com_err_proc;
  515. X    return x;
  516. X}
  517. END_OF_FILE
  518. if test 2900 -ne `wc -c <'com_err.c'`; then
  519.     echo shar: \"'com_err.c'\" unpacked with wrong size!
  520. fi
  521. # end of 'com_err.c'
  522. fi
  523. if test -f 'com_err.h' -a "${1}" != "-c" ; then 
  524.   echo shar: Will not clobber existing file \"'com_err.h'\"
  525. else
  526. echo shar: Extracting \"'com_err.h'\" \(1010 characters\)
  527. sed "s/^X//" >'com_err.h' <<'END_OF_FILE'
  528. X/*
  529. X * Header file for common error description library.
  530. X *
  531. X * Copyright 1988, Student Information Processing Board of the
  532. X * Massachusetts Institute of Technology.
  533. X *
  534. X * For copyright and distribution info, see the documentation supplied
  535. X * with this package.
  536. X */
  537. X
  538. X#ifndef __COM_ERR_H
  539. X
  540. X#ifdef __STDC__
  541. X#ifndef __HIGHC__        /* gives us STDC but not stdarg */
  542. X#include <stdarg.h>
  543. X#else
  544. X#include <varargs.h>
  545. X#endif
  546. X/* ANSI C -- use prototypes etc */
  547. Xtypedef void (*errf) (const char *, long, const char *, va_list);
  548. Xvoid com_err (const char *, long, const char *, ...);
  549. Xchar const *error_message (long);
  550. Xvoid (*com_err_hook) (const char *, long, const char *, va_list);
  551. Xerrf set_com_err_hook (errf);
  552. Xvoid (*reset_com_err_hook ()) (const char *, long, const char *, va_list);
  553. X#else
  554. X/* no prototypes */
  555. Xtypedef void (*errf) ();
  556. Xvoid com_err ();
  557. Xchar *error_message ();
  558. Xvoid (*com_err_hook) ();
  559. Xerrf set_com_err_hook();
  560. Xvoid (*reset_com_err_hook ()) ();
  561. X#endif
  562. X
  563. X#define __COM_ERR_H
  564. X#endif /* ! defined(__COM_ERR_H) */
  565. END_OF_FILE
  566. if test 1010 -ne `wc -c <'com_err.h'`; then
  567.     echo shar: \"'com_err.h'\" unpacked with wrong size!
  568. fi
  569. # end of 'com_err.h'
  570. fi
  571. if test -f 'compile_et.1' -a "${1}" != "-c" ; then 
  572.   echo shar: Will not clobber existing file \"'compile_et.1'\"
  573. else
  574. echo shar: Extracting \"'compile_et.1'\" \(2235 characters\)
  575. sed "s/^X//" >'compile_et.1' <<'END_OF_FILE'
  576. X.\" Copyright (c) 1988 Massachusetts Institute of Technology,
  577. X.\" Student Information Processing Board.  All rights reserved.
  578. X.\"
  579. X.\" $Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/compile_et.1,v 1.1 89/11/07 19:05:47 jik Exp $
  580. X.\"
  581. X.TH COMPILE_ET 1 "22 Nov 1988" SIPB
  582. X.SH NAME
  583. Xcompile_et \- error table compiler
  584. X.SH SYNOPSIS
  585. X.B compile_et
  586. Xfile
  587. X.SH DESCRIPTION
  588. X.B Compile_et
  589. Xconverts a table listing error-code names and associated messages into
  590. Xa C source file suitable for use with the
  591. X.IR com_err (3)
  592. Xlibrary.
  593. X
  594. XThe source file name must end with a suffix of ``.et''; the file
  595. Xconsists of a declaration supplying the name (up to four characters
  596. Xlong) of the error-code table:
  597. X
  598. X.B error_table
  599. X.I name
  600. X
  601. Xfollowed by up to 256 entries of the form:
  602. X
  603. X.B error_code
  604. X.I name,
  605. X"
  606. X.I string
  607. X"
  608. X
  609. Xand a final
  610. X
  611. X.B end
  612. X
  613. Xto indicate the end of the table.
  614. X
  615. XThe name of the table is used to construct the name of a subroutine
  616. X.I initialize_XXXX_error_table
  617. Xwhich must be called in order for the
  618. X.I com_err
  619. Xlibrary to recognize the error table.
  620. X
  621. XThe various error codes defined are assigned sequentially increasing
  622. Xnumbers (starting with a large number computed as a hash function of
  623. Xthe name of the table); thus for compatibility it is suggested that
  624. Xnew codes be added only to the end of an existing table, and that no
  625. Xcodes be removed from tables.
  626. X
  627. XThe names defined in the table are placed into a C header file with
  628. Xpreprocessor directives defining them as integer constants of up to
  629. X32 bits in magnitude.
  630. X
  631. XA C source file is also generated which should be compiled and linked
  632. Xwith the object files which reference these error codes; it contains
  633. Xthe text of the messages and the initialization subroutine.  Both C
  634. Xfiles have names derived from that of the original source file, with
  635. Xthe ``.et'' suffix replaced by ``.c'' and ``.h''.
  636. X
  637. XA ``#'' in the source file is treated as a comment character, and all
  638. Xremaining text to the end of the source line will be ignored.
  639. X
  640. X.SH BUGS
  641. X
  642. XSince
  643. X.B compile_et
  644. Xuses a very simple parser based on
  645. X.IR yacc (1),
  646. Xits error recovery leaves much to be desired.
  647. X
  648. X.\" .IR for manual entries
  649. X.\" .PP for paragraph breaks
  650. X
  651. X.SH "SEE ALSO"
  652. Xcom_err (3).
  653. X
  654. XKen Raeburn, "A Common Error Description Library for UNIX".
  655. END_OF_FILE
  656. if test 2235 -ne `wc -c <'compile_et.1'`; then
  657.     echo shar: \"'compile_et.1'\" unpacked with wrong size!
  658. fi
  659. # end of 'compile_et.1'
  660. fi
  661. if test -f 'compile_et.c' -a "${1}" != "-c" ; then 
  662.   echo shar: Will not clobber existing file \"'compile_et.c'\"
  663. else
  664. echo shar: Extracting \"'compile_et.c'\" \(6760 characters\)
  665. sed "s/^X//" >'compile_et.c' <<'END_OF_FILE'
  666. X/*
  667. X *
  668. X * Copyright 1986, 1987, 1988
  669. X * by MIT Student Information Processing Board.
  670. X *
  671. X * For copyright info, see "mit-sipb-copyright.h".
  672. X *
  673. X */
  674. X
  675. X#include <stdio.h>
  676. X#include <sys/file.h>
  677. X#include <string.h>
  678. X#include <sys/param.h>
  679. X#include "mit-sipb-copyright.h"
  680. X#include "compiler.h"
  681. X
  682. X#ifndef __STDC__
  683. X#define const
  684. X#endif
  685. X
  686. X#ifndef lint
  687. Xstatic const char copyright[] =
  688. X    "Copyright 1987,1988 by MIT Student Information Processing Board";
  689. X
  690. Xstatic const char rcsid_compile_et_c[] =
  691. X    "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/compile_et.c,v 1.1 89/11/07 19:05:27 jik Exp $";
  692. X#endif
  693. X
  694. Xextern char *gensym();
  695. Xextern char *current_token;
  696. Xextern int table_number, current;
  697. Xchar buffer[BUFSIZ];
  698. Xchar *table_name = (char *)NULL;
  699. XFILE *hfile, *cfile;
  700. X
  701. X/* C library */
  702. Xextern char *malloc();
  703. Xextern int errno;
  704. X
  705. X/* lex stuff */
  706. Xextern FILE *yyin;
  707. Xextern int yylineno;
  708. X
  709. Xchar * xmalloc (size) unsigned int size; {
  710. X    char * p = malloc (size);
  711. X    if (!p) {
  712. X    perror (whoami);
  713. X    exit (1);
  714. X    }
  715. X    return p;
  716. X}
  717. X
  718. Xstatic int check_arg (str_list, arg) char const *const *str_list, *arg; {
  719. X    while (*str_list)
  720. X    if (!strcmp(arg, *str_list++))
  721. X        return 1;
  722. X    return 0;
  723. X}
  724. X
  725. Xstatic const char *const debug_args[] = {
  726. X    "d",
  727. X    "debug",
  728. X    0,
  729. X};
  730. X
  731. Xstatic const char *const lang_args[] = {
  732. X    "lang",
  733. X    "language",
  734. X    0,
  735. X};
  736. X
  737. Xstatic const char *const language_names[] = {
  738. X    "C",
  739. X    "K&R C",
  740. X    "C++",
  741. X    0,
  742. X};
  743. X
  744. Xstatic const char * const c_src_prolog[] = {
  745. X    "static const char * const text[] = {\n",
  746. X    0,
  747. X};
  748. X
  749. Xstatic const char * const krc_src_prolog[] = {
  750. X    "#ifdef __STDC__\n",
  751. X    "#define NOARGS void\n",
  752. X    "#else\n",
  753. X    "#define NOARGS\n",
  754. X    "#define const\n",
  755. X    "#endif\n\n",
  756. X    "static const char * const text[] = {\n",
  757. X    0,
  758. X};
  759. X
  760. Xstatic const char *const struct_def[] = {
  761. X    "struct error_table {\n",
  762. X    "    char const * const * msgs;\n",
  763. X    "    long base;\n",
  764. X    "    int n_msgs;\n",
  765. X    "};\n",
  766. X    "struct et_list {\n",
  767. X    "    struct et_list *next;\n",
  768. X    "    const struct error_table * table;\n",
  769. X    "};\n",
  770. X    "extern struct et_list *_et_list;\n",
  771. X    "\n", 0,
  772. X};
  773. X
  774. Xstatic const char warning[] =
  775. X    "/*\n * %s:\n * This file is automatically generated; please do not edit it.\n */\n";
  776. X
  777. X/* pathnames */
  778. Xchar c_file[MAXPATHLEN];    /* output file */
  779. Xchar h_file[MAXPATHLEN];    /* output */
  780. X
  781. Xstatic void usage () {
  782. X    fprintf (stderr, "%s: usage: %s ERROR_TABLE\n",
  783. X         whoami, whoami);
  784. X    exit (1);
  785. X}
  786. X
  787. Xstatic void dup_err (type, one, two) char const *type, *one, *two; {
  788. X    fprintf (stderr, "%s: multiple %s specified: `%s' and `%s'\n",
  789. X         whoami, type, one, two);
  790. X    usage ();
  791. X}
  792. X
  793. Xint main (argc, argv) int argc; char **argv; {
  794. X    char *p, *ename;
  795. X    int len;
  796. X    char const * const *cpp;
  797. X    int got_language = 0;
  798. X
  799. X    /* argument parsing */
  800. X    debug = 0;
  801. X    filename = 0;
  802. X    whoami = argv[0];
  803. X    p = strrchr (whoami, '/');
  804. X    if (p)
  805. X    whoami = p+1;
  806. X    while (argv++, --argc) {
  807. X    char *arg = *argv;
  808. X    if (arg[0] != '-') {
  809. X        if (filename)
  810. X        dup_err ("filenames", filename, arg);
  811. X        filename = arg;
  812. X    }
  813. X    else {
  814. X        arg++;
  815. X        if (check_arg (debug_args, arg))
  816. X        debug++;
  817. X        else if (check_arg (lang_args, arg)) {
  818. X        got_language++;
  819. X        arg = *++argv, argc--;
  820. X        if (!arg)
  821. X            usage ();
  822. X        if (language)
  823. X            dup_err ("languanges", language_names[(int)language], arg);
  824. X#define check_lang(x,v) else if (!strcasecmp(arg,x)) language = v
  825. X        check_lang ("c", lang_C);
  826. X        check_lang ("ansi_c", lang_C);
  827. X        check_lang ("ansi-c", lang_C);
  828. X        check_lang ("krc", lang_KRC);
  829. X        check_lang ("kr_c", lang_KRC);
  830. X        check_lang ("kr-c", lang_KRC);
  831. X        check_lang ("k&r-c", lang_KRC);
  832. X        check_lang ("k&r_c", lang_KRC);
  833. X        check_lang ("c++", lang_CPP);
  834. X        check_lang ("cplusplus", lang_CPP);
  835. X        check_lang ("c-plus-plus", lang_CPP);
  836. X#undef check_lang
  837. X        else {
  838. X            fprintf (stderr, "%s: unknown language name `%s'\n",
  839. X                 whoami, arg);
  840. X            fprintf (stderr, "\tpick one of: C K&R-C\n");
  841. X            exit (1);
  842. X        }
  843. X        }
  844. X        else {
  845. X        fprintf (stderr, "%s: unknown control argument -`%s'\n",
  846. X             whoami, arg);
  847. X        usage ();
  848. X        }
  849. X    }
  850. X    }
  851. X    if (!filename)
  852. X    usage ();
  853. X    if (!got_language)
  854. X    language = lang_KRC;
  855. X    else if (language == lang_CPP) {
  856. X    fprintf (stderr, "%s: Sorry, C++ support is not yet finished.\n",
  857. X         whoami);
  858. X    exit (1);
  859. X    }
  860. X
  861. X    p = xmalloc (strlen (filename) + 5);
  862. X    strcpy (p, filename);
  863. X    filename = p;
  864. X    p = strrchr(filename, '/');
  865. X    if (p == (char *)NULL)
  866. X    p = filename;
  867. X    else
  868. X    p++;
  869. X    ename = p;
  870. X    len = strlen (ename);
  871. X    p += len - 3;
  872. X    if (strcmp (p, ".et"))
  873. X    p += 3;
  874. X    *p++ = '.';
  875. X    /* now p points to where "et" suffix should start */
  876. X    /* generate new filenames */
  877. X    strcpy (p, "c");
  878. X    strcpy (c_file, ename);
  879. X    *p = 'h';
  880. X    strcpy (h_file, ename);
  881. X    strcpy (p, "et");
  882. X
  883. X    yyin = fopen(filename, "r");
  884. X    if (!yyin) {
  885. X    perror(filename);
  886. X    exit(1);
  887. X    }
  888. X
  889. X    hfile = fopen(h_file, "w");
  890. X    if (hfile == (FILE *)NULL) {
  891. X    perror(h_file);
  892. X    exit(1);
  893. X    }
  894. X    fprintf (hfile, warning, h_file);
  895. X
  896. X    cfile = fopen(c_file, "w");
  897. X    if (cfile == (FILE *)NULL) {
  898. X    perror(c_file);
  899. X    exit(1);
  900. X    }
  901. X    fprintf (cfile, warning, c_file);
  902. X
  903. X    /* prologue */
  904. X    if (language == lang_C)
  905. X    cpp = c_src_prolog;
  906. X    else if (language == lang_KRC)
  907. X    cpp = krc_src_prolog;
  908. X    else
  909. X    abort ();
  910. X    while (*cpp)
  911. X    fputs (*cpp++, cfile);
  912. X
  913. X    /* parse it */
  914. X    yyparse();
  915. X    fclose(yyin);        /* bye bye input file */
  916. X
  917. X    fputs ("    0\n};\n\n", cfile);
  918. X    for (cpp = struct_def; *cpp; cpp++)
  919. X    fputs (*cpp, cfile);
  920. X    fprintf(cfile,
  921. X        "static const struct error_table et = { text, %ldL, %d };\n\n",
  922. X        table_number, current);
  923. X    fputs("static struct et_list link = { 0, 0 };\n\n",
  924. X      cfile);
  925. X    fprintf(cfile, "void initialize_%s_error_table (%s) {\n",
  926. X        table_name, (language == lang_C) ? "void" : "NOARGS");
  927. X    fputs("    if (!link.table) {\n", cfile);
  928. X    fputs("        link.next = _et_list;\n", cfile);
  929. X    fputs("        link.table = &et;\n", cfile);
  930. X    fputs("        _et_list = &link;\n", cfile);
  931. X    fputs("    }\n", cfile);
  932. X    fputs("}\n", cfile);
  933. X    fclose(cfile);
  934. X
  935. X    fprintf (hfile, "extern void initialize_%s_error_table ();\n",
  936. X         table_name);
  937. X    fprintf (hfile, "#define ERROR_TABLE_BASE_%s (%ldL)\n",
  938. X         table_name, table_number);
  939. X    /* compatibility... */
  940. X    fprintf (hfile, "\n/* for compatibility with older versions... */\n");
  941. X    fprintf (hfile, "#define init_%s_err_tbl initialize_%s_error_table\n",
  942. X         table_name, table_name);
  943. X    fprintf (hfile, "#define %s_err_base ERROR_TABLE_BASE_%s\n", table_name,
  944. X         table_name);
  945. X    fclose(hfile);        /* bye bye include file */
  946. X
  947. X    return 0;
  948. X}
  949. X
  950. Xint yyerror(s) char *s; {
  951. X    fputs(s, stderr);
  952. X    fprintf(stderr, "\nLine number %d; last token was '%s'\n",
  953. X        yylineno, current_token);
  954. X}
  955. END_OF_FILE
  956. if test 6760 -ne `wc -c <'compile_et.c'`; then
  957.     echo shar: \"'compile_et.c'\" unpacked with wrong size!
  958. fi
  959. # end of 'compile_et.c'
  960. fi
  961. if test -f 'compiler.h' -a "${1}" != "-c" ; then 
  962.   echo shar: Will not clobber existing file \"'compiler.h'\"
  963. else
  964. echo shar: Extracting \"'compiler.h'\" \(379 characters\)
  965. sed "s/^X//" >'compiler.h' <<'END_OF_FILE'
  966. X/*
  967. X * definitions common to the source files of the error table compiler
  968. X */
  969. X
  970. X#ifndef __STDC__
  971. X/* loser */
  972. X#undef const
  973. X#define const
  974. X#endif
  975. X
  976. Xenum lang {
  977. X    lang_C,            /* ANSI C (default) */
  978. X    lang_KRC,            /* C: ANSI + K&R */
  979. X    lang_CPP            /* C++ */
  980. X};
  981. X
  982. Xint debug;            /* dump debugging info? */
  983. Xchar *filename;            /* error table source */
  984. Xenum lang language;
  985. Xconst char *whoami;
  986. END_OF_FILE
  987. if test 379 -ne `wc -c <'compiler.h'`; then
  988.     echo shar: \"'compiler.h'\" unpacked with wrong size!
  989. fi
  990. # end of 'compiler.h'
  991. fi
  992. if test -f 'error_message.c' -a "${1}" != "-c" ; then 
  993.   echo shar: Will not clobber existing file \"'error_message.c'\"
  994. else
  995. echo shar: Extracting \"'error_message.c'\" \(1857 characters\)
  996. sed "s/^X//" >'error_message.c' <<'END_OF_FILE'
  997. X/*
  998. X * $Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/error_message.c,v 1.1 89/11/07 19:05:30 jik Exp $
  999. X * $Source: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/error_message.c,v $
  1000. X * $Locker:  $
  1001. X *
  1002. X * Copyright 1987 by the Student Information Processing Board
  1003. X * of the Massachusetts Institute of Technology
  1004. X *
  1005. X * For copyright info, see "mit-sipb-copyright.h".
  1006. X */
  1007. X
  1008. X#include <stdio.h>
  1009. X#include "error_table.h"
  1010. X#include "mit-sipb-copyright.h"
  1011. X#include "internal.h"
  1012. X
  1013. Xstatic const char rcsid[] =
  1014. X    "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/error_message.c,v 1.1 89/11/07 19:05:30 jik Exp $";
  1015. Xstatic const char copyright[] =
  1016. X    "Copyright 1986, 1987, 1988 by the Student Information Processing Board\nand the department of Information Systems\nof the Massachusetts Institute of Technology";
  1017. X
  1018. Xstatic char buffer[25];
  1019. X
  1020. Xstruct et_list * _et_list = (struct et_list *) NULL;
  1021. X
  1022. Xconst char * error_message (code)
  1023. Xlong    code;
  1024. X{
  1025. X    int offset;
  1026. X    struct et_list *et;
  1027. X    int table_num;
  1028. X    int started = 0;
  1029. X    char *cp;
  1030. X
  1031. X    offset = code & ((1<<ERRCODE_RANGE)-1);
  1032. X    table_num = code - offset;
  1033. X    if (!table_num) {
  1034. X    if (offset < sys_nerr)
  1035. X        return(sys_errlist[offset]);
  1036. X    else
  1037. X        goto oops;
  1038. X    }
  1039. X    for (et = _et_list; et; et = et->next) {
  1040. X    if (et->table->base == table_num) {
  1041. X        /* This is the right table */
  1042. X        if (et->table->n_msgs <= offset)
  1043. X        goto oops;
  1044. X        return(et->table->msgs[offset]);
  1045. X    }
  1046. X    }
  1047. Xoops:
  1048. X    strcpy (buffer, "Unknown code ");
  1049. X    if (table_num) {
  1050. X    strcat (buffer, error_table_name (table_num));
  1051. X    strcat (buffer, " ");
  1052. X    }
  1053. X    for (cp = buffer; *cp; cp++)
  1054. X    ;
  1055. X    if (offset >= 100) {
  1056. X    *cp++ = '0' + offset / 100;
  1057. X    offset %= 100;
  1058. X    started++;
  1059. X    }
  1060. X    if (started || offset >= 10) {
  1061. X    *cp++ = '0' + offset / 10;
  1062. X    offset %= 10;
  1063. X    }
  1064. X    *cp++ = '0' + offset;
  1065. X    *cp = '\0';
  1066. X    return(buffer);
  1067. X}
  1068. END_OF_FILE
  1069. if test 1857 -ne `wc -c <'error_message.c'`; then
  1070.     echo shar: \"'error_message.c'\" unpacked with wrong size!
  1071. fi
  1072. # end of 'error_message.c'
  1073. fi
  1074. if test -f 'error_table.h' -a "${1}" != "-c" ; then 
  1075.   echo shar: Will not clobber existing file \"'error_table.h'\"
  1076. else
  1077. echo shar: Extracting \"'error_table.h'\" \(663 characters\)
  1078. sed "s/^X//" >'error_table.h' <<'END_OF_FILE'
  1079. X/*
  1080. X * Copyright 1988 by the Student Information Processing Board of the
  1081. X * Massachusetts Institute of Technology.
  1082. X *
  1083. X * For copyright info, see mit-sipb-copyright.h.
  1084. X */
  1085. X
  1086. X#ifndef _ET_H
  1087. X/* Are we using ANSI C? */
  1088. X#ifndef __STDC__
  1089. X#define const
  1090. X#endif
  1091. Xextern int errno;
  1092. Xstruct error_table {
  1093. X    char const * const * msgs;
  1094. X    long base;
  1095. X    int n_msgs;
  1096. X};
  1097. Xstruct et_list {
  1098. X    struct et_list *next;
  1099. X    const struct error_table *table;
  1100. X};
  1101. Xextern struct et_list * _et_list;
  1102. X
  1103. X#define    ERRCODE_RANGE    8    /* # of bits to shift table number */
  1104. X#define    BITS_PER_CHAR    6    /* # bits to shift per character in name */
  1105. X
  1106. Xextern const char *error_table_name();
  1107. X#define _ET_H
  1108. X#endif
  1109. END_OF_FILE
  1110. if test 663 -ne `wc -c <'error_table.h'`; then
  1111.     echo shar: \"'error_table.h'\" unpacked with wrong size!
  1112. fi
  1113. # end of 'error_table.h'
  1114. fi
  1115. if test -f 'error_table.y' -a "${1}" != "-c" ; then 
  1116.   echo shar: Will not clobber existing file \"'error_table.y'\"
  1117. else
  1118. echo shar: Extracting \"'error_table.y'\" \(4747 characters\)
  1119. sed "s/^X//" >'error_table.y' <<'END_OF_FILE'
  1120. X%{
  1121. X#include <stdio.h>
  1122. X#if !defined(__STDC__) || defined(__HIGHC__)
  1123. Xchar *malloc(), *realloc();
  1124. X#endif     
  1125. Xchar *str_concat(), *ds(), *quote();
  1126. Xchar *current_token = (char *)NULL;
  1127. Xextern char *table_name;
  1128. X%}
  1129. X%union {
  1130. X    char *dynstr;
  1131. X}
  1132. X
  1133. X%token ERROR_TABLE ERROR_CODE_ENTRY END
  1134. X%token <dynstr> STRING QUOTED_STRING
  1135. X%type <dynstr> ec_name description table_id
  1136. X%{
  1137. X%}
  1138. X%start error_table
  1139. X%%
  1140. X
  1141. Xerror_table    :    ERROR_TABLE table_id error_codes END
  1142. X            { table_name = ds($2);
  1143. X              current_token = table_name;
  1144. X              put_ecs(); }
  1145. X        ;
  1146. X
  1147. Xtable_id    :    STRING
  1148. X            { current_token = $1;
  1149. X              set_table_num($1);
  1150. X              $$ = $1; }
  1151. X        ;
  1152. X
  1153. Xerror_codes    :    error_codes ec_entry
  1154. X        |    ec_entry
  1155. X        ;
  1156. X
  1157. Xec_entry    :    ERROR_CODE_ENTRY ec_name ',' description
  1158. X            { add_ec($2, $4);
  1159. X              free($2);
  1160. X              free($4); }
  1161. X        |    ERROR_CODE_ENTRY ec_name '=' STRING ',' description
  1162. X            { add_ec_val($2, $4, $6);
  1163. X              free($2);
  1164. X              free($4);
  1165. X              free($6);
  1166. X            }
  1167. X        ;
  1168. X
  1169. Xec_name        :    STRING
  1170. X            { $$ = ds($1);
  1171. X              current_token = $$; }
  1172. X        ;
  1173. X
  1174. Xdescription    :    QUOTED_STRING
  1175. X            { $$ = ds($1);
  1176. X              current_token = $$; }
  1177. X        ;
  1178. X
  1179. X%%
  1180. X/*
  1181. X *
  1182. X * Copyright 1986, 1987 by the MIT Student Information Processing Board
  1183. X *
  1184. X * For copyright info, see mit-sipb-copyright.h.
  1185. X */
  1186. X
  1187. X#include <string.h>
  1188. X#include <assert.h>
  1189. X#include <ctype.h>
  1190. X#include <sys/types.h>
  1191. X#include <sys/time.h>
  1192. X#include "internal.h"
  1193. X#include "error_table.h"
  1194. X#include "mit-sipb-copyright.h"
  1195. X
  1196. X#ifndef    lint
  1197. Xstatic char const rcsid_error_table_y[] =
  1198. X    "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/error_table.y,v 1.2 89/11/07 18:55:08 jik Exp $";
  1199. X#endif
  1200. X
  1201. Xextern FILE *hfile, *cfile;
  1202. X
  1203. Xstatic long gensym_n = 0;
  1204. Xchar *
  1205. Xgensym(x)
  1206. X    char const *x;
  1207. X{
  1208. X    char *symbol;
  1209. X    if (!gensym_n) {
  1210. X        struct timeval tv;
  1211. X        struct timezone tzp;
  1212. X        gettimeofday(&tv, &tzp);
  1213. X        gensym_n = (tv.tv_sec%10000)*100 + tv.tv_usec/10000;
  1214. X    }
  1215. X    symbol = malloc(32 * sizeof(char));
  1216. X    gensym_n++;
  1217. X    sprintf(symbol, "et%ld", gensym_n);
  1218. X    return(symbol);
  1219. X}
  1220. X
  1221. Xchar *
  1222. Xds(string)
  1223. X    char const *string;
  1224. X{
  1225. X    char *rv;
  1226. X    rv = malloc(strlen(string)+1);
  1227. X    strcpy(rv, string);
  1228. X    return(rv);
  1229. X}
  1230. X
  1231. Xchar *
  1232. Xquote(string)
  1233. X    char const *string;
  1234. X{
  1235. X    char *rv;
  1236. X    rv = malloc(strlen(string)+3);
  1237. X    strcpy(rv, "\"");
  1238. X    strcat(rv, string);
  1239. X    strcat(rv, "\"");
  1240. X    return(rv);
  1241. X}
  1242. X
  1243. Xlong table_number;
  1244. Xint current = 0;
  1245. Xchar **error_codes = (char **)NULL;
  1246. X
  1247. Xadd_ec(name, description)
  1248. X    char const *name, *description;
  1249. X{
  1250. X    fprintf(cfile, "\t\"%s\",\n", description);
  1251. X    if (error_codes == (char **)NULL) {
  1252. X        error_codes = (char **)malloc(sizeof(char *));
  1253. X        *error_codes = (char *)NULL;
  1254. X    }
  1255. X    error_codes = (char **)realloc((char *)error_codes,
  1256. X                       (current + 2)*sizeof(char *));
  1257. X    error_codes[current++] = ds(name);
  1258. X    error_codes[current] = (char *)NULL;
  1259. X}
  1260. X
  1261. Xadd_ec_val(name, val, description)
  1262. X    char const *name, *val, *description;
  1263. X{
  1264. X    const int ncurrent = atoi(val);
  1265. X    if (ncurrent < current) {
  1266. X        printf("Error code %s (%d) out of order", name,
  1267. X               current);
  1268. X        return;
  1269. X    }
  1270. X      
  1271. X    while (ncurrent > current)
  1272. X         fputs("\t(char *)NULL,\n", cfile), current++;
  1273. X    
  1274. X    fprintf(cfile, "\t\"%s\",\n", description);
  1275. X    if (error_codes == (char **)NULL) {
  1276. X        error_codes = (char **)malloc(sizeof(char *));
  1277. X        *error_codes = (char *)NULL;
  1278. X    }
  1279. X    error_codes = (char **)realloc((char *)error_codes,
  1280. X                       (current + 2)*sizeof(char *));
  1281. X    error_codes[current++] = ds(name);
  1282. X    error_codes[current] = (char *)NULL;
  1283. X} 
  1284. X
  1285. Xput_ecs()
  1286. X{
  1287. X    int i;
  1288. X    for (i = 0; i < current; i++) {
  1289. X         if (error_codes[i] != (char *)NULL)
  1290. X          fprintf(hfile, "#define %-40s (%ldL)\n",
  1291. X              error_codes[i], table_number + i);
  1292. X    }
  1293. X}
  1294. X
  1295. X/*
  1296. X * char_to_num -- maps letters and numbers into a small numbering space
  1297. X *     uppercase ->  1-26
  1298. X *    lowercase -> 27-52
  1299. X *    digits    -> 53-62
  1300. X *    underscore-> 63
  1301. X */
  1302. X
  1303. Xstatic const char char_set[] =
  1304. X    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  1305. X
  1306. Xint char_to_num(c)
  1307. X    char c;
  1308. X{
  1309. X    const char *where;
  1310. X    int diff;
  1311. X
  1312. X    where = strchr (char_set, c);
  1313. X    if (where) {
  1314. X        diff = where - char_set + 1;
  1315. X        assert (diff < (1 << ERRCODE_RANGE));
  1316. X        return diff;
  1317. X    }
  1318. X    else if (isprint (c))
  1319. X        fprintf (stderr,
  1320. X             "Illegal character `%c' in error table name\n",
  1321. X             c);
  1322. X    else
  1323. X        fprintf (stderr,
  1324. X             "Illegal character %03o in error table name\n",
  1325. X             c);
  1326. X    exit (1);
  1327. X}
  1328. X
  1329. Xset_table_num(string)
  1330. X    char *string;
  1331. X{
  1332. X    if (char_to_num (string[0]) > char_to_num ('z')) {
  1333. X        fprintf (stderr, "%s%s%s%s",
  1334. X             "First character of error table name must be ",
  1335. X             "a letter; name ``",
  1336. X             string, "'' rejected\n");
  1337. X        exit (1);
  1338. X    }
  1339. X    if (strlen(string) > 4) {
  1340. X        fprintf(stderr, "Table name %s too long, truncated ",
  1341. X            string);
  1342. X        string[4] = '\0';
  1343. X        fprintf(stderr, "to %s\n", string);
  1344. X    }
  1345. X    while (*string != '\0') {
  1346. X        table_number = (table_number << BITS_PER_CHAR)
  1347. X            + char_to_num(*string);
  1348. X        string++;
  1349. X    }
  1350. X    table_number = table_number << ERRCODE_RANGE;
  1351. X}
  1352. X
  1353. X#include "et_lex.lex.c"
  1354. END_OF_FILE
  1355. if test 4747 -ne `wc -c <'error_table.y'`; then
  1356.     echo shar: \"'error_table.y'\" unpacked with wrong size!
  1357. fi
  1358. # end of 'error_table.y'
  1359. fi
  1360. if test -f 'et_lex.lex.l' -a "${1}" != "-c" ; then 
  1361.   echo shar: Will not clobber existing file \"'et_lex.lex.l'\"
  1362. else
  1363. echo shar: Extracting \"'et_lex.lex.l'\" \(600 characters\)
  1364. sed "s/^X//" >'et_lex.lex.l' <<'END_OF_FILE'
  1365. XPC    [^\"]
  1366. XAN    [A-Z_a-z0-9]
  1367. X%{
  1368. X#include <strings.h>
  1369. X%}
  1370. X%%
  1371. X
  1372. Xerror_table    return ERROR_TABLE;
  1373. Xet        return ERROR_TABLE;
  1374. Xerror_code    return ERROR_CODE_ENTRY;
  1375. Xec        return ERROR_CODE_ENTRY;
  1376. Xend        return END;
  1377. X
  1378. X[\t\n ]        ;
  1379. X
  1380. X\"{PC}*\"    { register char *p; yylval.dynstr = ds(yytext+1);
  1381. X          if (p=rindex(yylval.dynstr, '"')) *p='\0';
  1382. X          return QUOTED_STRING;
  1383. X        }
  1384. X
  1385. X{AN}*    { yylval.dynstr = ds(yytext); return STRING; }
  1386. X
  1387. X#.*\n        ;
  1388. X
  1389. X.        { return (*yytext); }
  1390. X%%
  1391. X#ifndef lint
  1392. Xstatic char rcsid_et_lex_lex_l[] = "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/et_lex.lex.l,v 1.2 89/11/07 19:00:35 jik Exp $";
  1393. X#endif
  1394. END_OF_FILE
  1395. if test 600 -ne `wc -c <'et_lex.lex.l'`; then
  1396.     echo shar: \"'et_lex.lex.l'\" unpacked with wrong size!
  1397. fi
  1398. # end of 'et_lex.lex.l'
  1399. fi
  1400. if test -f 'et_name.c' -a "${1}" != "-c" ; then 
  1401.   echo shar: Will not clobber existing file \"'et_name.c'\"
  1402. else
  1403. echo shar: Extracting \"'et_name.c'\" \(1131 characters\)
  1404. sed "s/^X//" >'et_name.c' <<'END_OF_FILE'
  1405. X/*
  1406. X * Copyright 1987 by MIT Student Information Processing Board
  1407. X *
  1408. X * For copyright info, see mit-sipb-copyright.h.
  1409. X */
  1410. X
  1411. X#include "error_table.h"
  1412. X#include "mit-sipb-copyright.h"
  1413. X#include "internal.h"
  1414. X
  1415. X#ifndef    lint
  1416. Xstatic const char copyright[] =
  1417. X    "Copyright 1987,1988 by Student Information Processing Board, Massachusetts Institute of Technology";
  1418. Xstatic const char rcsid_et_name_c[] =
  1419. X    "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/et_name.c,v 1.1 89/11/07 19:05:32 jik Exp $";
  1420. X#endif
  1421. X
  1422. Xstatic const char char_set[] =
  1423. X    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  1424. X
  1425. Xstatic char buf[6];
  1426. X
  1427. Xconst char * error_table_name(num)
  1428. X    int num;
  1429. X{
  1430. X    int ch;
  1431. X    int i;
  1432. X    char *p;
  1433. X
  1434. X    /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */
  1435. X    p = buf;
  1436. X    num >>= ERRCODE_RANGE;
  1437. X    /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */
  1438. X    num &= 077777777;
  1439. X    /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */
  1440. X    for (i = 4; i >= 0; i--) {
  1441. X    ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
  1442. X    if (ch != 0)
  1443. X        *p++ = char_set[ch-1];
  1444. X    }
  1445. X    *p = '\0';
  1446. X    return(buf);
  1447. X}
  1448. END_OF_FILE
  1449. if test 1131 -ne `wc -c <'et_name.c'`; then
  1450.     echo shar: \"'et_name.c'\" unpacked with wrong size!
  1451. fi
  1452. # end of 'et_name.c'
  1453. fi
  1454. if test -f 'init_et.c' -a "${1}" != "-c" ; then 
  1455.   echo shar: Will not clobber existing file \"'init_et.c'\"
  1456. else
  1457. echo shar: Extracting \"'init_et.c'\" \(1278 characters\)
  1458. sed "s/^X//" >'init_et.c' <<'END_OF_FILE'
  1459. X/*
  1460. X * $Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/init_et.c,v 1.1 89/11/07 19:05:34 jik Exp $
  1461. X * $Source: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/init_et.c,v $
  1462. X * $Locker:  $
  1463. X *
  1464. X * Copyright 1986, 1987, 1988 by MIT Information Systems and
  1465. X *    the MIT Student Information Processing Board.
  1466. X *
  1467. X * For copyright info, see mit-sipb-copyright.h.
  1468. X */
  1469. X
  1470. X#include <stdio.h>
  1471. X#include "error_table.h"
  1472. X#include "mit-sipb-copyright.h"
  1473. X
  1474. X#ifndef __STDC__
  1475. X#define const
  1476. X#endif
  1477. X
  1478. X#ifndef    lint
  1479. Xstatic const char rcsid_init_et_c[] =
  1480. X    "$Header: /afs/athena.mit.edu/user/j/jik/src/delete/et/RCS/init_et.c,v 1.1 89/11/07 19:05:34 jik Exp $";
  1481. X#endif
  1482. X
  1483. Xextern char *malloc(), *realloc();
  1484. X
  1485. Xstruct foobar {
  1486. X    struct et_list etl;
  1487. X    struct error_table et;
  1488. X};
  1489. X
  1490. Xextern struct et_list * _et_list;
  1491. X
  1492. Xint init_error_table(msgs, base, count)
  1493. X    const char * const * msgs;
  1494. X    int base;
  1495. X    int count;
  1496. X{
  1497. X    struct foobar * new_et;
  1498. X
  1499. X    if (!base || !count || !msgs)
  1500. X    return 0;
  1501. X
  1502. X    new_et = (struct foobar *) malloc(sizeof(struct foobar));
  1503. X    if (!new_et)
  1504. X    return errno;    /* oops */
  1505. X    new_et->etl.table = &new_et->et;
  1506. X    new_et->et.msgs = msgs;
  1507. X    new_et->et.base = base;
  1508. X    new_et->et.n_msgs= count;
  1509. X
  1510. X    new_et->etl.next = _et_list;
  1511. X    _et_list = &new_et->etl;
  1512. X    return 0;
  1513. X}
  1514. END_OF_FILE
  1515. if test 1278 -ne `wc -c <'init_et.c'`; then
  1516.     echo shar: \"'init_et.c'\" unpacked with wrong size!
  1517. fi
  1518. # end of 'init_et.c'
  1519. fi
  1520. if test -f 'internal.h' -a "${1}" != "-c" ; then 
  1521.   echo shar: Will not clobber existing file \"'internal.h'\"
  1522. else
  1523. echo shar: Extracting \"'internal.h'\" \(290 characters\)
  1524. sed "s/^X//" >'internal.h' <<'END_OF_FILE'
  1525. X/*
  1526. X * internal include file for com_err package
  1527. X */
  1528. X#include "mit-sipb-copyright.h"
  1529. X#ifndef __STDC__
  1530. X#undef const
  1531. X#define const
  1532. X#endif
  1533. X
  1534. Xextern int errno;
  1535. Xextern char const * const sys_errlist[];
  1536. Xextern const int sys_nerr;
  1537. X
  1538. X#if !defined(__STDC__) || defined(__HIGHC__)
  1539. Xint perror ();
  1540. X#endif
  1541. END_OF_FILE
  1542. if test 290 -ne `wc -c <'internal.h'`; then
  1543.     echo shar: \"'internal.h'\" unpacked with wrong size!
  1544. fi
  1545. # end of 'internal.h'
  1546. fi
  1547. if test -f 'mit-sipb-copyright.h' -a "${1}" != "-c" ; then 
  1548.   echo shar: Will not clobber existing file \"'mit-sipb-copyright.h'\"
  1549. else
  1550. echo shar: Extracting \"'mit-sipb-copyright.h'\" \(769 characters\)
  1551. sed "s/^X//" >'mit-sipb-copyright.h' <<'END_OF_FILE'
  1552. X/*
  1553. X
  1554. XCopyright 1987, 1988 by the Student Information Processing Board
  1555. X    of the Massachusetts Institute of Technology
  1556. X
  1557. XPermission to use, copy, modify, and distribute this software
  1558. Xand its documentation for any purpose and without fee is
  1559. Xhereby granted, provided that the above copyright notice
  1560. Xappear in all copies and that both that copyright notice and
  1561. Xthis permission notice appear in supporting documentation,
  1562. Xand that the names of M.I.T. and the M.I.T. S.I.P.B. not be
  1563. Xused in advertising or publicity pertaining to distribution
  1564. Xof the software without specific, written prior permission.
  1565. XM.I.T. and the M.I.T. S.I.P.B. make no representations about
  1566. Xthe suitability of this software for any purpose.  It is
  1567. Xprovided "as is" without express or implied warranty.
  1568. X
  1569. X*/
  1570. X
  1571. END_OF_FILE
  1572. if test 769 -ne `wc -c <'mit-sipb-copyright.h'`; then
  1573.     echo shar: \"'mit-sipb-copyright.h'\" unpacked with wrong size!
  1574. fi
  1575. # end of 'mit-sipb-copyright.h'
  1576. fi
  1577. if test ! -d 'profiled' ; then
  1578.     echo shar: Creating directory \"'profiled'\"
  1579.     mkdir 'profiled'
  1580. fi
  1581. if test -f 'strcasecmp.c' -a "${1}" != "-c" ; then 
  1582.   echo shar: Will not clobber existing file \"'strcasecmp.c'\"
  1583. else
  1584. echo shar: Extracting \"'strcasecmp.c'\" \(3767 characters\)
  1585. sed "s/^X//" >'strcasecmp.c' <<'END_OF_FILE'
  1586. X/*
  1587. X * Copyright (c) 1987 Regents of the University of California.
  1588. X * All rights reserved.
  1589. X *
  1590. X * Redistribution and use in source and binary forms are permitted
  1591. X * provided that the above copyright notice and this paragraph are
  1592. X * duplicated in all such forms and that any documentation,
  1593. X * advertising materials, and other materials related to such
  1594. X * distribution and use acknowledge that the software was developed
  1595. X * by the University of California, Berkeley.  The name of the
  1596. X * University may not be used to endorse or promote products derived
  1597. X * from this software without specific prior written permission.
  1598. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1599. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1600. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1601. X */
  1602. X
  1603. X#if defined(LIBC_SCCS) && !defined(lint)
  1604. Xstatic char sccsid[] = "@(#)strcasecmp.c    5.6 (Berkeley) 6/27/88";
  1605. X#endif /* LIBC_SCCS and not lint */
  1606. X
  1607. X#include <sys/types.h>
  1608. X
  1609. X/*
  1610. X * This array is designed for mapping upper and lower case letter
  1611. X * together for a case independent comparison.  The mappings are
  1612. X * based upon ascii character sequences.
  1613. X */
  1614. Xstatic u_char charmap[] = {
  1615. X    '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
  1616. X    '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
  1617. X    '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
  1618. X    '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
  1619. X    '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
  1620. X    '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
  1621. X    '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
  1622. X    '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
  1623. X    '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
  1624. X    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
  1625. X    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
  1626. X    '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
  1627. X    '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
  1628. X    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
  1629. X    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
  1630. X    '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
  1631. X    '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
  1632. X    '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
  1633. X    '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
  1634. X    '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
  1635. X    '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
  1636. X    '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
  1637. X    '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
  1638. X    '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
  1639. X    '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
  1640. X    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
  1641. X    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
  1642. X    '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
  1643. X    '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
  1644. X    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
  1645. X    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
  1646. X    '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
  1647. X};
  1648. X
  1649. Xstrcasecmp(s1, s2)
  1650. X    char *s1, *s2;
  1651. X{
  1652. X    register u_char    *cm = charmap,
  1653. X            *us1 = (u_char *)s1,
  1654. X            *us2 = (u_char *)s2;
  1655. X
  1656. X    while (cm[*us1] == cm[*us2++])
  1657. X        if (*us1++ == '\0')
  1658. X            return(0);
  1659. X    return(cm[*us1] - cm[*--us2]);
  1660. X}
  1661. X
  1662. Xstrncasecmp(s1, s2, n)
  1663. X    char *s1, *s2;
  1664. X    register int n;
  1665. X{
  1666. X    register u_char    *cm = charmap,
  1667. X            *us1 = (u_char *)s1,
  1668. X            *us2 = (u_char *)s2;
  1669. X
  1670. X    while (--n >= 0 && cm[*us1] == cm[*us2++])
  1671. X        if (*us1++ == '\0')
  1672. X            return(0);
  1673. X    return(n < 0 ? 0 : cm[*us1] - cm[*--us2]);
  1674. X}
  1675. END_OF_FILE
  1676. if test 3767 -ne `wc -c <'strcasecmp.c'`; then
  1677.     echo shar: \"'strcasecmp.c'\" unpacked with wrong size!
  1678. fi
  1679. # end of 'strcasecmp.c'
  1680. fi
  1681. if test -f 'test.c' -a "${1}" != "-c" ; then 
  1682.   echo shar: Will not clobber existing file \"'test.c'\"
  1683. else
  1684. echo shar: Extracting \"'test.c'\" \(1798 characters\)
  1685. sed "s/^X//" >'test.c' <<'END_OF_FILE'
  1686. X#include <stdio.h>
  1687. X#include <errno.h>
  1688. X#include "com_err.h"
  1689. X#include "test1.h"
  1690. X#include "test2.h"
  1691. X
  1692. Xextern int sys_nerr, errno;
  1693. X
  1694. Xmain()
  1695. X{
  1696. X    printf("Before initiating error table:\n\n");
  1697. X    printf("Table name '%s'\n", error_table_name(KRB_MK_AP_TGTEXP));
  1698. X    printf("UNIX  name '%s'\n", error_table_name(EPERM));
  1699. X    printf("Msg TGT-expired is '%s'\n", error_message(KRB_MK_AP_TGTEXP));
  1700. X    printf("Msg EPERM is '%s'\n", error_message(EPERM));
  1701. X    printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
  1702. X    printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1));
  1703. X    printf("Msg {sys_nerr} is '%s'\n", error_message(sys_nerr));
  1704. X
  1705. X    printf("With 0: tgt-expired -> %s\n", error_message(KRB_MK_AP_TGTEXP));
  1706. X
  1707. X    initialize_krb_error_table();
  1708. X    printf("KRB error table initialized:  base %d (%s), name %s\n",
  1709. X           ERROR_TABLE_BASE_krb, error_message(ERROR_TABLE_BASE_krb),
  1710. X           error_table_name(ERROR_TABLE_BASE_krb));
  1711. X    initialize_krb_error_table();
  1712. X    printf("With krb: tgt-expired -> %s\n",
  1713. X           error_message(KRB_MK_AP_TGTEXP));
  1714. X
  1715. X    initialize_quux_error_table();
  1716. X    printf("QUUX error table initialized: base %d (%s), name %s\n",
  1717. X           ERROR_TABLE_BASE_quux, error_message(ERROR_TABLE_BASE_quux),
  1718. X           error_table_name(ERROR_TABLE_BASE_quux));
  1719. X
  1720. X    printf("Msg for TGT-expired is '%s'\n",
  1721. X           error_message(KRB_MK_AP_TGTEXP));
  1722. X    printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1));
  1723. X    printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
  1724. X    printf("Msg KRB_SKDC_CANT is '%s'\n",
  1725. X            error_message(KRB_SKDC_CANT));
  1726. X    printf("Msg 1e6 (8B 64) is '%s'\n", error_message(1000000));
  1727. X    printf("\n\nCOM_ERR tests:\n");
  1728. X    com_err("whoami", FOO_ERR, (char *)NULL);
  1729. X    com_err("whoami", FOO_ERR, " -- message goes %s", "here");
  1730. X    com_err("whoami", 0, (char *)0);
  1731. X    com_err("whoami", 0, "error number %d\n", 0);
  1732. X}
  1733. END_OF_FILE
  1734. if test 1798 -ne `wc -c <'test.c'`; then
  1735.     echo shar: \"'test.c'\" unpacked with wrong size!
  1736. fi
  1737. # end of 'test.c'
  1738. fi
  1739. if test -f 'test1.et' -a "${1}" != "-c" ; then 
  1740.   echo shar: Will not clobber existing file \"'test1.et'\"
  1741. else
  1742. echo shar: Extracting \"'test1.et'\" \(1129 characters\)
  1743. sed "s/^X//" >'test1.et' <<'END_OF_FILE'
  1744. X    error_table    krb
  1745. X
  1746. X    error_code    KRB_MK_AP_TKFIL,
  1747. X            "Can't read ticket file"
  1748. X
  1749. X    ec        KRB_MK_AP_NOTKT,
  1750. X            "Can't find ticket or TGT"
  1751. X
  1752. X    ec        KRB_MK_AP_TGTEXP,
  1753. X            "TGT expired"
  1754. X
  1755. X    ec        KRB_RD_AP_UNDEC,
  1756. X            "Can't decode authenticator"
  1757. X
  1758. X    ec        KRB_RD_AP_EXP,
  1759. X            "Ticket expired"
  1760. X
  1761. X    ec        KRB_RD_AP_REPEAT,
  1762. X            "Repeated request"
  1763. X
  1764. X    ec        KRB_RD_AP_NOT_US,
  1765. X            "The ticket isn't for us"
  1766. X
  1767. X    ec        KRB_RD_AP_INCON,
  1768. X            "Request is inconsistent"
  1769. X
  1770. X    ec        KRB_RD_AP_TIME,
  1771. X            "Delta-T too big"
  1772. X
  1773. X    ec        KRB_RD_AP_BADD,
  1774. X            "Incorrect net address"
  1775. X
  1776. X    ec        KRB_RD_AP_VERSION,
  1777. X            "Protocol version mismatch"
  1778. X
  1779. X    ec        KRB_RD_AP_MSG_TYPE,
  1780. X            "Invalid message type"
  1781. X
  1782. X    ec        KRB_RD_AP_MODIFIED,
  1783. X            "Message stream modified"
  1784. X
  1785. X    ec        KRB_RD_AP_ORDER,
  1786. X            "Message out of order"
  1787. X
  1788. X    ec        KRB_RD_AP_UNAUTHOR,
  1789. X            "Unauthorized request"
  1790. X
  1791. X    ec        KRB_GT_PW_NULL,
  1792. X            "Current password is null"
  1793. X
  1794. X    ec        KRB_GT_PW_BADPW,
  1795. X            "Incorrect current password"
  1796. X
  1797. X    ec        KRB_GT_PW_PROT,
  1798. X            "Protocol error"
  1799. X
  1800. X    ec        KRB_GT_PW_KDCERR,
  1801. X            "Error returned by KDC"
  1802. X
  1803. X    ec        KRB_GT_PW_NULLTKT,
  1804. X            "Null ticket returned by KDC"
  1805. X
  1806. X    ec        KRB_SKDC_RETRY,
  1807. X            "Retry count exceeded"
  1808. X
  1809. X    ec        KRB_SKDC_CANT,
  1810. X            "Can't send request"
  1811. X
  1812. X    end
  1813. END_OF_FILE
  1814. if test 1129 -ne `wc -c <'test1.et'`; then
  1815.     echo shar: \"'test1.et'\" unpacked with wrong size!
  1816. fi
  1817. # end of 'test1.et'
  1818. fi
  1819. if test -f 'test2.et' -a "${1}" != "-c" ; then 
  1820.   echo shar: Will not clobber existing file \"'test2.et'\"
  1821. else
  1822. echo shar: Extracting \"'test2.et'\" \(85 characters\)
  1823. sed "s/^X//" >'test2.et' <<'END_OF_FILE'
  1824. X    error_table    quux
  1825. X
  1826. X    ec    FOO_ERR, "foo"
  1827. X
  1828. X    ec    BAR_ERR, "bar"
  1829. X
  1830. X    ec    BAZ_ERR, "meow"
  1831. X
  1832. X    end
  1833. END_OF_FILE
  1834. if test 85 -ne `wc -c <'test2.et'`; then
  1835.     echo shar: \"'test2.et'\" unpacked with wrong size!
  1836. fi
  1837. # end of 'test2.et'
  1838. fi
  1839. echo shar: End of archive 1 \(of 3\).
  1840. cp /dev/null ark1isdone
  1841. MISSING=""
  1842. for I in 1 2 3 ; do
  1843.     if test ! -f ark${I}isdone ; then
  1844.     MISSING="${MISSING} ${I}"
  1845.     fi
  1846. done
  1847. if test "${MISSING}" = "" ; then
  1848.     echo You have unpacked all 3 archives.
  1849.     rm -f ark[1-9]isdone
  1850. else
  1851.     echo You still need to unpack the following archives:
  1852.     echo "        " ${MISSING}
  1853. fi
  1854. ##  End of shell archive.
  1855. exit 0
  1856. exit 0 # Just in case...
  1857. -- 
  1858. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  1859. Use a domain-based address or give alternate paths, or you may lose out.
  1860.