home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / reviewed / volume02 / cextract / part01 < prev    next >
Encoding:
Internet Message Format  |  1992-11-02  |  56.7 KB

  1. From: Adam Bryant <adb@cs.bu.edu>
  2. Subject: v02i039: cextract - (Ver. 1.7) C prototyper/header file generator, Part01/05
  3. Newsgroups: comp.sources.reviewed
  4. Approved: csr@calvin.dgbt.doc.ca
  5.  
  6. Submitted-by: Adam Bryant <adb@cs.bu.edu>
  7. Posting-number: Volume 2, Issue 39
  8. Archive-name: cextract/part01
  9. Supersedes: cextract: Volume 1, Issue 4-8
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 1 (of 5)."
  18. # Contents:  INSTALL INSTALL.VMS MANIFEST MANIFEST.BAK Makefile
  19. #   Makefile.dist README TODO build.com cextdoc.1 cextrc.5
  20. #   newbuild.com patchlevel.h proto.h xtract.h
  21. # Wrapped by adb@csa on Fri Oct 30 16:20:35 1992
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'INSTALL'\"
  25. else
  26. echo shar: Extracting \"'INSTALL'\" \(2868 characters\)
  27. sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  28. XVMS sites should see the file INSTALL.VMS for installation
  29. Xinstructions.
  30. X
  31. XThe installation of the program is pretty simple:
  32. X
  33. X   - Read through this INSTALL file.
  34. X   - Read and edit the Makefile.
  35. X   - Type "make".
  36. X   - You might want to remove any old configuration files that are on
  37. X    the system, to allow defaults to be installed properly.
  38. X   - Test the program to be sure it works.  This can be done by
  39. X    typing "make test" which will run a test using its own code.
  40. X    [The system configuration file will be installed, if there is
  41. X    not already one in place.  You will need to have permission to
  42. X    create this file, so you might need to do this as "root".]
  43. X   - Type "make install" to install the binary, cextdoc link and
  44. X    to generate the system configuration file (if not already done).
  45. X   - Type "make install.man" to install the manual pages.
  46. X   - If necessary, edit the system configuration file for your site.
  47. X
  48. X  NOTE: As stated above, when the system configuration file is
  49. X   installed, you will need permission to write to whatever
  50. X   location was chosen for it.  So, it is likely that you will
  51. X   need to run the "make test" or "make install" as root, or have
  52. X   write permission to the directory where the file will be
  53. X   placed.
  54. X
  55. XFor those systems with a non-standard C preprocesser or for those of
  56. Xyou who want to be especially thorough:
  57. X
  58. X    - You might need to edit the values of CPP and CPP_COMMENT in
  59. X      the Makefile.  These should be set to whatever C
  60. X      preprocessor you can get, preferably one that leaves
  61. X      comments intact, and the flag that leaves them intact.
  62. X
  63. XAfter you are done with the installation of the binary and
  64. Xdocumentation, you might want to take a look at the "cextrc" manual
  65. Xpage and edit the system configuration file for your system.  The
  66. Xlocation and name of this header file is determined by the setting
  67. Xof "SYSRC" in the Makefile.  A default one should already have been
  68. Xbuilt for your system with the "make install" or "make test"
  69. Xcommands.
  70. X
  71. XThis file can hold the default options you wish to implement (probably
  72. Xbased on the default system compiler), as well as any system-dependent
  73. Xreplacements due to "#define"s.
  74. X
  75. XTo determine what kind of things might need replacing, you can look at
  76. Xthe standard header files on your system, searching for things which
  77. Xyou had considered a "typedef" but which were really "#define"
  78. Xsequences.  The one noticeable one on my Sun is:
  79. X
  80. X#define FILE struct _iobuf
  81. X
  82. XSince I found that FILE was defined like this on most systems, I made
  83. Xsure to automatically build the replacement into the default
  84. Xconfiguration file.  The varargs system also uses a similiar
  85. Xmechanism, so I made sure to handle that as well.
  86. X
  87. XIf you get any error messages or warnings, please let me know.  If you
  88. Xhave any problems at all, or even just a friendly suggestion, feel
  89. Xfree to send me mail about it.
  90. X
  91. XAdam Bryant
  92. Xadb@bu.edu
  93. END_OF_FILE
  94. if test 2868 -ne `wc -c <'INSTALL'`; then
  95.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  96. fi
  97. # end of 'INSTALL'
  98. fi
  99. if test -f 'INSTALL.VMS' -a "${1}" != "-c" ; then 
  100.   echo shar: Will not clobber existing file \"'INSTALL.VMS'\"
  101. else
  102. echo shar: Extracting \"'INSTALL.VMS'\" \(3374 characters\)
  103. sed "s/^X//" >'INSTALL.VMS' <<'END_OF_FILE'
  104. XOkay, so, I have to assume that you somehow got the unix shar files
  105. Xunpacked.  If you got some warnings about "wc" not being found, then
  106. Xyou can ignore them, since that is a unix program which was just trying
  107. Xto do "checksums".  [hopefully everything unpacked okay :-)]
  108. X
  109. XNow, the way to build the programs is simple:
  110. X
  111. X - first take a look at the xtract.h file and determine if any of the
  112. X   settings need adjusting.  Pay careful attention to the following
  113. X   definitions:
  114. X
  115. X        CEXTDOC_NAME      - name of the documentation extraction program
  116. X        CONFIG_FILE       - name of the configuration file
  117. X        SYS_CONFIG        - location of the global system configuration file
  118. X    CPP          - the C preprocessor to handle the "#define"s
  119. X    CPP_COMMENT      - the flag to tell the C preprocessor not to
  120. X                strip the comments out.
  121. X
  122. X   It should be possible to change them on the command line, using the
  123. X   newbuild.com file, instead of build.com, but I have not been able
  124. X   to test it.
  125. X
  126. X - @build (or @newbuild) or just compile and then link the main.c and
  127. X   parse.c files.
  128. X
  129. XNote that on VMS systems that I have heard about the C compilers do
  130. Xnot have support for retaining the comments after preprocessing. So,
  131. Xthe cextdoc program and the cextract comment functions are pretty
  132. Xuseless on VMS systems.  [I have had reports that the GNU C
  133. Xpreprocessor works on VMS systems, so you might want to grab that and
  134. Xuse that.  You could probably make good use of it normally anyway.]
  135. X
  136. XI have provided a VMS help file to give a documentation method for
  137. Xnormal VMS users.  It is the file:
  138. X
  139. X  cextract.hlp
  140. X
  141. XYou might also want to look at the text files:
  142. X
  143. X  cextract.doc cextrc.doc
  144. X
  145. Xsince even though they are the documentation for a normal Unix system,
  146. Xthey do document most everything in the VMS version as well.  The
  147. X".hlp" file should be more than enough, though.
  148. X
  149. XAnyway, you can now place the binary wherever you want.  You can also
  150. Xcopy it into "cextdoc" (or whatever you set CEXTDOC_NAME to) and
  151. Xthereby obtain a program with the documentation extractor as the
  152. Xdefault mode.  [It checks the name as it is called]
  153. X
  154. XIn order to simplify access to the program(s), you will need to define
  155. Xa foreign command using:
  156. X
  157. X      cextract == "$the_disc:[the_directory]cextract"
  158. X
  159. XWhere "the_disc" and "the_directory" have the values for where you
  160. Xplaced the binary.  I suppose that line can be added to your LOGIN.COM
  161. Xfile.
  162. X
  163. XYou might consider building a system configuration file, using the
  164. X"/SYSTEM-BUILD" qualifier.  You could then edit it to your taste,
  165. Xhaving it contain any default options you might wish to have, as well
  166. Xas any "replace" commands which your system might need.
  167. X
  168. XTo determine what kind of things might need replacing, you can look at
  169. Xthe standard header files on your system, searching for things which
  170. Xyou had considered a "typedef" but which were really "#define"
  171. Xsequences.  The one noticable one on my Sun is:
  172. X
  173. X#define FILE struct _iobuf
  174. X
  175. XSince I found that FILE was defined like this on most systems, I made
  176. Xsure to automatically build the replacement into /SYSTEM-BUILD
  177. Xprocess.  The varargs system also uses a similiar mechanism, so I made
  178. Xsure to handle that as well.
  179. X
  180. XIf you get any error messages or warnings, please let me know.  If you
  181. Xhave any problems at all, or even just a friendly suggestion, feel
  182. Xfree to send me mail about it.
  183. X
  184. XAdam Bryant
  185. Xadb@bu.edu
  186. X
  187. X
  188. END_OF_FILE
  189. if test 3374 -ne `wc -c <'INSTALL.VMS'`; then
  190.     echo shar: \"'INSTALL.VMS'\" unpacked with wrong size!
  191. fi
  192. # end of 'INSTALL.VMS'
  193. fi
  194. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  195.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  196. else
  197. echo shar: Extracting \"'MANIFEST'\" \(778 characters\)
  198. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  199. X   File Name        Archive #    Description
  200. X-----------------------------------------------------------
  201. X INSTALL                    1    
  202. X INSTALL.VMS                1    
  203. X MANIFEST                   1    
  204. X MANIFEST.BAK               1    
  205. X Makefile                   1    
  206. X Makefile.dist              1    
  207. X README                     1    
  208. X TODO                       1    
  209. X build.com                  1    
  210. X cextdoc.1                  1    
  211. X cextract.1                 2    
  212. X cextract.doc               2    
  213. X cextract.hlp               2    
  214. X cextrc.5                   1    
  215. X cextrc.doc                 2    
  216. X io.c                       4    
  217. X main.c                     3    
  218. X newbuild.com               1    
  219. X parse.c                    5    
  220. X patchlevel.h               1    
  221. X proto.h                    1    
  222. X xtract.h                   1    
  223. END_OF_FILE
  224. if test 778 -ne `wc -c <'MANIFEST'`; then
  225.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  226. fi
  227. # end of 'MANIFEST'
  228. fi
  229. if test -f 'MANIFEST.BAK' -a "${1}" != "-c" ; then 
  230.   echo shar: Will not clobber existing file \"'MANIFEST.BAK'\"
  231. else
  232. echo shar: Extracting \"'MANIFEST.BAK'\" \(716 characters\)
  233. sed "s/^X//" >'MANIFEST.BAK' <<'END_OF_FILE'
  234. X   File Name        Archive #    Description
  235. X-----------------------------------------------------------
  236. X INSTALL                    1    
  237. X INSTALL.VMS                1    
  238. X MANIFEST                   1    
  239. X Makefile                   1    
  240. X README                     1    
  241. X TODO                       1    
  242. X build.com                  1    
  243. X cextdoc.1                  1    
  244. X cextract.1                 2    
  245. X cextract.doc               2    
  246. X cextract.hlp               2    
  247. X cextrc.5                   1    
  248. X cextrc.doc                 1    
  249. X io.c                       4    
  250. X main.c                     3    
  251. X newbuild.com               1    
  252. X parse.c                    5    
  253. X patchlevel.h               1    
  254. X proto.h                    1    
  255. X xtract.h                   1    
  256. END_OF_FILE
  257. if test 716 -ne `wc -c <'MANIFEST.BAK'`; then
  258.     echo shar: \"'MANIFEST.BAK'\" unpacked with wrong size!
  259. fi
  260. # end of 'MANIFEST.BAK'
  261. fi
  262. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  263.   echo shar: Will not clobber existing file \"'Makefile'\"
  264. else
  265. echo shar: Extracting \"'Makefile'\" \(5871 characters\)
  266. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  267. X#
  268. X#    This Makefile is for the cextract/cextdoc program.  If
  269. X#    you should experience any problems please send mail to:
  270. X#
  271. X#            adb@bu.edu
  272. X#
  273. X
  274. X#    Adjust anything as needed
  275. X
  276. X#    shell used by make [some make versions need this]
  277. XSHELL    = /bin/sh
  278. X
  279. X#    compiler to build programs with
  280. XCC    = gcc
  281. X
  282. X#    C preprocessor, if you don't wish to use the default.
  283. X#    [this line can usually be left commented out]
  284. X#CPPFLG    = -DCPP=\"/lib/cpp\"
  285. X
  286. X#    Flag to tell the C preprocessor to not strip out comments,
  287. X#    if the default value is not correct.
  288. X#    [this line can usually be left commented out]
  289. X#CPPCMT    = -DCPP_COMMENTS=\"-C\"
  290. X
  291. X#    If your system does not support pipes (have the "popen()"
  292. X#    function), you should uncomment this line.  [You might need to
  293. X#    carefully look at the definitions of PIPETMP_FMT and
  294. X#    PIPEOUT_FMT in xtract.h]
  295. X#PIPFLG    = -DNO_POPEN
  296. X
  297. X#    Compiler options, such as '-O' for cc
  298. X#     or '-O -g -Wall -ansi' for GNU compilers
  299. XCOPTS    = -O -g -Wall -ansi
  300. X
  301. X#    sequence to get rid of ${RM} error messages [blank to see them]
  302. XNULL    = 2>/dev/null
  303. X
  304. X#    System information flags; give the proper settings for your
  305. X#    machine.  You can also add:
  306. X#
  307. X#        -DSETBUFFER    if your system has setbuffer(3S)
  308. X#                and you wish to use it, in the (slim?)
  309. X#                hope of increasing performance.
  310. X#
  311. X#        -DNO_PERROR    if your system does not have the
  312. X#                perror(3) function.
  313. X#
  314. X#SYSFLG    = -DBSD            # Most BSD derivatives
  315. X#SYSFLG    = -DSYSV        # Most SysV derivatives
  316. XSYSFLG    = -DSYSV -DBSD        # Sun OS 4.1
  317. X#SYSFLG    = -DSYSV -DAIX        # IBM AIX operating systems
  318. X#SYSFLG    = -DSYSV -DSGI        # Silicon Graphics machines
  319. X#SYSFLG    = -DBSD -DULTRIX    # Digital Ultrix systems
  320. X#SYSFLG    = -DSYSV -DCLIX        # Intergraph Clix operating systems
  321. X#SYSFLG    = -DHPUX        # Hewlett Packard HPUX systems
  322. X#SYSFLG    = -DSYSV -DXENIX    # Xenix SysV systems
  323. X#SYSFLG    = -DBSD -DXENIX        # Xenix BSD systems (?)
  324. X#SYSFLG    = -DVAXC -DVMS        # Digital VAX VMS machines
  325. X#SYSFLG = -DBSD -U__STDC__    # Apollo sites aren't really ANSI (?)
  326. X
  327. X#    final location of the executable
  328. XBINDIR    = /usr/local/bin
  329. X
  330. X#    prefix directory, such as "/mnt". usually left blank
  331. XDESTDIR    =
  332. X
  333. X#    settings for the manual pages, change as desired
  334. XMANDIR    = /usr/local/man/man
  335. XM1TAG    = 1
  336. XM1DIR    = ${MANDIR}${M1TAG}
  337. XM5TAG    = 5
  338. XM5DIR    = ${MANDIR}${M5TAG}
  339. X
  340. X#    name of the cextractor program
  341. XCXTRACT    = cextract
  342. X
  343. X#    name of the documentation extractor
  344. XDOCTRG    = cextdoc
  345. X
  346. X#    name of the cextrc configuration file
  347. XRCFILE    = .cextrc
  348. X
  349. X#    full path and name for the system level configuration file
  350. XSYSRC    = /usr/local/lib/cext.config
  351. X
  352. X#    == List of miscellaneous commands needed by make ==
  353. X#
  354. X#    check for the existence of a directory
  355. XTESTDIR    = test -d
  356. X#    create a new directory
  357. XMKDIR    = mkdir
  358. X#    install a file (used in INSTBIN and INSTMAN settings)
  359. XINSTALL    = install
  360. X#    echo any arguments to the standard output
  361. XECHO    = echo
  362. X#    string editor
  363. XSED    = sed
  364. X#    search for any differences between two files
  365. XDIFF    = diff
  366. X#    produce readable ASCII from roff "man" source
  367. XNROFF    = nroff -man
  368. X#    remove any files [-f flag means to override permissions]
  369. XRM    = /bin/rm -f
  370. X
  371. X#    command to install the binaries
  372. XINSTBIN    = ${INSTALL} -s
  373. X
  374. X#    command to install the manual pages
  375. XINSTMAN    = ${INSTALL} -m 444
  376. X
  377. X#    set permission on the configuration file after installation
  378. XCHMOD    = chmod 644
  379. X
  380. X#    this command is used to create the "cextdoc" program.
  381. X#    [If a symbolic link is available, use that, so it need
  382. X#     not be remade each time.  Otherwise use a normal hard link,
  383. X#     or just 'cp'.]
  384. XLINK    = ln -s
  385. X
  386. X#
  387. X#===== end of configurables
  388. X#
  389. X
  390. X#    list of object files
  391. XCXTOBJS    = main.o parse.o io.o
  392. X
  393. X#    command to build everything
  394. Xall:    ${CXTRACT}
  395. X    @${ECHO} all targets done
  396. X
  397. X#    install the binary
  398. Xinstall:    ${CXTRACT} ${SYSRC}
  399. X    ${TESTDIR} ${DESTDIR}${BINDIR} || ${MKDIR} ${DESTDIR}${BINDIR}
  400. X    ${INSTBIN} ${CXTRACT} ${DESTDIR}${BINDIR}
  401. X    -(cd ${DESTDIR}${BINDIR}; ${RM} ${DOCTRG} ${NULL}; ${LINK} ${CXTRACT} ${DOCTRG})
  402. X
  403. X#    install the manual pages
  404. Xinstall.man:    cextract.tman cextrc.tman cextdoc.tman
  405. X    ${TESTDIR} ${DESTDIR}${M1DIR} || ${MKDIR} ${DESTDIR}${M1DIR}
  406. X    ${TESTDIR} ${DESTDIR}${M5DIR} || ${MKDIR} ${DESTDIR}${M5DIR}
  407. X    ${INSTMAN} cextract.tman ${DESTDIR}${M1DIR}/cextract.${M1TAG}
  408. X    ${INSTMAN} cextdoc.tman ${DESTDIR}${M1DIR}/cextdoc.${M1TAG}
  409. X    ${INSTMAN} cextrc.tman ${DESTDIR}${M5DIR}/cextrc.${M5TAG}
  410. X
  411. X#    build up the documentation
  412. Xdocs:    cextract.tman cextrc.tman
  413. X    ${NROFF} cextract.tman > cextract.doc
  414. X    ${NROFF} cextrc.tman > cextrc.doc
  415. X
  416. Xcextract.tman:    cextract.1 tmp.sed
  417. X    ${SED} -f tmp.sed cextract.1 > cextract.tman
  418. X
  419. Xcextrc.tman:    cextrc.5 tmp.sed
  420. X    ${SED} -f tmp.sed cextrc.5 > cextrc.tman
  421. X
  422. Xcextdoc.tman:    cextdoc.1 tmp.sed
  423. X    ${SED} -f tmp.sed cextdoc.1 > cextdoc.tman
  424. X
  425. Xtmp.sed:
  426. X    ${ECHO} "s;SYSCXTRC;${SYSRC};g" > tmp.sed
  427. X    ${ECHO} "s;NORMRC;${RCFILE};g" >> tmp.sed
  428. X    ${ECHO} "s;CDOCNAME;${DOCTRG};g" >> tmp.sed
  429. X
  430. X${SYSRC}:    ${CXTRACT}
  431. X    @${ECHO} "Building new system wide configuration file"
  432. X    ./${CXTRACT} -B
  433. X    ${CHMOD} ${SYSRC}
  434. X
  435. X#    Cleaning things up
  436. Xclean:
  437. X    ${RM} *.o *~ \#* ${NULL}
  438. X
  439. X#    Really clean things up
  440. Xclobber:    clean
  441. X    ${RM} ${CXTRACT} testproto.h tmp.sed cextract.tman ${NULL}
  442. X    ${RM} cextdoc.tman cextrc.tman ${NULL}
  443. X
  444. X#    Build the header file
  445. Xproto:    
  446. X    ${CXTRACT} -o proto.h -H_proto_h_ -S +CFacPZ main.c io.c parse.c
  447. X
  448. X#
  449. Xtest:    ${CXTRACT} ${SYSRC}
  450. X    ./${CXTRACT} -o testproto.h -H_proto_h_ -S +CFacPZ main.c io.c parse.c
  451. X    @${ECHO} ===
  452. X    @${ECHO} === The only output from the following command should show
  453. X    @${ECHO} === two date strings at line 5 of both files.
  454. X    @${ECHO} ===
  455. X    @${ECHO} === Errors from make can be ignored if this is the case.
  456. X    @${ECHO} === 
  457. X    -${DIFF} proto.h testproto.h
  458. X
  459. X#
  460. X#    define flags for the compilation
  461. XCFLAGS    = -DSYS_CONFIG=\"${SYSRC}\" -DCONFIG_FILE=\"${RCFILE}\" -DCEXTDOC_NAME=\"${DOCTRG}\" ${CPPFLG} ${CPPCMT} ${PIPFLG}
  462. X
  463. X#
  464. X#    Rules and dependencies for this Makefile
  465. X#
  466. X.c.o:    $<
  467. X    ${CC} ${SYSFLG} ${COPTS} ${CFLAGS} -c $*.c
  468. X
  469. X#    The prototype extraction program
  470. X${CXTRACT}:    ${CXTOBJS}
  471. X    ${CC} ${COPTS} -o ${CXTRACT} ${CXTOBJS}
  472. X
  473. X#
  474. X#    Added dependencies
  475. X${CXTOBJS}:    xtract.h proto.h
  476. X
  477. X#
  478. END_OF_FILE
  479. if test 5871 -ne `wc -c <'Makefile'`; then
  480.     echo shar: \"'Makefile'\" unpacked with wrong size!
  481. fi
  482. # end of 'Makefile'
  483. fi
  484. if test -f 'Makefile.dist' -a "${1}" != "-c" ; then 
  485.   echo shar: Will not clobber existing file \"'Makefile.dist'\"
  486. else
  487. echo shar: Extracting \"'Makefile.dist'\" \(5821 characters\)
  488. sed "s/^X//" >'Makefile.dist' <<'END_OF_FILE'
  489. X#
  490. X#    This Makefile is for the cextract/cextdoc program.  If
  491. X#    you should experience any problems please send mail to:
  492. X#
  493. X#            adb@bu.edu
  494. X#
  495. X
  496. X#    Adjust anything as needed
  497. X
  498. X#    shell used by make [some make versions need this]
  499. XSHELL    = /bin/sh
  500. X
  501. X#    compiler to build programs with
  502. XCC    = cc
  503. X
  504. X#    C preprocessor, if you don't wish to use the default.
  505. X#    [this line can usually be left commented out]
  506. X#CPPFLG    = -DCPP=\"/lib/cpp\"
  507. X
  508. X#    Flag to tell the C preprocessor to not strip out comments,
  509. X#    if the default value is not correct.
  510. X#    [this line can usually be left commented out]
  511. X#CPPCMT    = -DCPP_COMMENTS=\"-C\"
  512. X
  513. X#    If your system does not support pipes (have the "popen()"
  514. X#    function), you should uncomment this line.  [You might need to
  515. X#    carefully look at the definitions of PIPETMP_FMT and
  516. X#    PIPEOUT_FMT in xtract.h]
  517. X#PIPFLG    = -DNO_POPEN
  518. X
  519. X#    Compiler options, such as '-O' for cc
  520. X#     or '-O -g -Wall -ansi' for GNU compilers
  521. XCOPTS    = -O
  522. X
  523. X#    sequence to get rid of ${RM} error messages [blank to see them]
  524. XNULL    = 2>/dev/null
  525. X
  526. X#    System information flags; give the proper settings for your
  527. X#    machine.  You can also add:
  528. X#
  529. X#        -DSETBUFFER    if your system has setbuffer(3S)
  530. X#                and you wish to use it, in the (slim?)
  531. X#                hope of increasing performance.
  532. X#
  533. X#        -DNO_PERROR    if your system does not have the
  534. X#                perror(3) function.
  535. X#
  536. X#SYSFLG    = -DBSD            # Most BSD derivatives
  537. X#SYSFLG    = -DSYSV        # Most SysV derivatives
  538. XSYSFLG    = -DSYSV -DBSD        # Sun OS 4.1
  539. X#SYSFLG    = -DSYSV -DAIX        # IBM AIX operating systems
  540. X#SYSFLG    = -DSYSV -DSGI        # Silicon Graphics machines
  541. X#SYSFLG    = -DBSD -DULTRIX    # Digital Ultrix systems
  542. X#SYSFLG    = -DSYSV -DCLIX        # Intergraph Clix operating systems
  543. X#SYSFLG    = -DHPUX        # Hewlett Packard HPUX systems
  544. X#SYSFLG    = -DSYSV -DXENIX    # Xenix SysV systems
  545. X#SYSFLG    = -DBSD -DXENIX        # Xenix BSD systems (?)
  546. X#SYSFLG    = -DVAXC -DVMS        # Digital VAX VMS machines
  547. X#SYSFLG = -DBSD -U__STDC__    # Apollo sites aren't really ANSI (?)
  548. X
  549. X#    final location of the executable
  550. XBINDIR    = /usr/local/bin
  551. X
  552. X#    prefix directory, such as "/mnt". usually left blank
  553. XDESTDIR    =
  554. X
  555. X#    settings for the manual pages, change as desired
  556. XMANDIR    = /usr/man/man
  557. XM1TAG    = 1
  558. XM1DIR    = ${MANDIR}${M1TAG}
  559. XM5TAG    = 5
  560. XM5DIR    = ${MANDIR}${M5TAG}
  561. X
  562. X#    name of the cextractor program
  563. XCXTRACT    = cextract
  564. X
  565. X#    name of the documentation extractor
  566. XDOCTRG    = cextdoc
  567. X
  568. X#    name of the cextrc configuration file
  569. XRCFILE    = .cextrc
  570. X
  571. X#    full path and name for the system level configuration file
  572. XSYSRC    = /usr/local/lib/cext.config
  573. X
  574. X#    == List of miscellaneous commands needed by make ==
  575. X#
  576. X#    check for the existence of a directory
  577. XTESTDIR    = test -d
  578. X#    create a new directory
  579. XMKDIR    = mkdir
  580. X#    install a file (used in INSTBIN and INSTMAN settings)
  581. XINSTALL    = install
  582. X#    echo any arguments to the standard output
  583. XECHO    = echo
  584. X#    string editor
  585. XSED    = sed
  586. X#    search for any differences between two files
  587. XDIFF    = diff
  588. X#    produce readable ASCII from roff "man" source
  589. XNROFF    = nroff -man
  590. X#    remove any files [-f flag means to override permissions]
  591. XRM    = /bin/rm -f
  592. X
  593. X#    command to install the binaries
  594. XINSTBIN    = ${INSTALL} -s
  595. X
  596. X#    command to install the manual pages
  597. XINSTMAN    = ${INSTALL} -m 444
  598. X
  599. X#    set permission on the configuration file after installation
  600. XCHMOD    = chmod 644
  601. X
  602. X#    this command is used to create the "cextdoc" program.
  603. X#    [If a symbolic link is available, use that, so it need
  604. X#     not be remade each time.  Otherwise use a normal hard link,
  605. X#     or just 'cp'.]
  606. XLINK    = ln -s
  607. X
  608. X#
  609. X#===== end of configurables
  610. X#
  611. X
  612. X#    list of object files
  613. XCXTOBJS    = main.o parse.o io.o
  614. X
  615. X#    command to build everything
  616. Xall:    ${CXTRACT}
  617. X    @${ECHO} all targets done
  618. X
  619. X#    install the binary
  620. Xinstall:    ${CXTRACT} ${SYSRC}
  621. X    ${TESTDIR} ${DESTDIR}${BINDIR} || ${MKDIR} ${DESTDIR}${BINDIR}
  622. X    ${INSTBIN} ${CXTRACT} ${DESTDIR}${BINDIR}
  623. X    -(cd ${DESTDIR}${BINDIR}; ${RM} ${DOCTRG} ${NULL}; ${LINK} ${CXTRACT} ${DOCTRG})
  624. X
  625. X#    install the manual pages
  626. Xinstall.man:    cextract.tman cextrc.tman cextdoc.tman
  627. X    ${TESTDIR} ${DESTDIR}${M1DIR} || ${MKDIR} ${DESTDIR}${M1DIR}
  628. X    ${TESTDIR} ${DESTDIR}${M5DIR} || ${MKDIR} ${DESTDIR}${M5DIR}
  629. X    ${INSTMAN} cextract.tman ${DESTDIR}${M1DIR}/cextract.${M1TAG}
  630. X    ${INSTMAN} cextdoc.tman ${DESTDIR}${M1DIR}/cextdoc.${M1TAG}
  631. X    ${INSTMAN} cextrc.tman ${DESTDIR}${M5DIR}/cextrc.${M5TAG}
  632. X
  633. X#    build up the documentation
  634. Xdocs:    cextract.tman cextrc.tman
  635. X    ${NROFF} cextract.tman > cextract.doc
  636. X    ${NROFF} cextrc.tman > cextrc.doc
  637. X
  638. Xcextract.tman:    cextract.1 tmp.sed
  639. X    ${SED} -f tmp.sed cextract.1 > cextract.tman
  640. X
  641. Xcextrc.tman:    cextrc.5 tmp.sed
  642. X    ${SED} -f tmp.sed cextrc.5 > cextrc.tman
  643. X
  644. Xcextdoc.tman:    cextdoc.1 tmp.sed
  645. X    ${SED} -f tmp.sed cextdoc.1 > cextdoc.tman
  646. X
  647. Xtmp.sed:
  648. X    ${ECHO} "s;SYSCXTRC;${SYSRC};g" > tmp.sed
  649. X    ${ECHO} "s;NORMRC;${RCFILE};g" >> tmp.sed
  650. X    ${ECHO} "s;CDOCNAME;${DOCTRG};g" >> tmp.sed
  651. X
  652. X${SYSRC}:    ${CXTRACT}
  653. X    @${ECHO} "Building new system wide configuration file"
  654. X    ./${CXTRACT} -B
  655. X    ${CHMOD} ${SYSRC}
  656. X
  657. X#    Cleaning things up
  658. Xclean:
  659. X    ${RM} *.o *~ \#* ${NULL}
  660. X
  661. X#    Really clean things up
  662. Xclobber:    clean
  663. X    ${RM} ${CXTRACT} testproto.h tmp.sed cextract.tman cextrc.tman ${NULL}
  664. X
  665. X#    Build the header file
  666. Xproto:    
  667. X    ${CXTRACT} -o proto.h -H_proto_h_ -S +CFacPZ main.c io.c parse.c
  668. X
  669. X#
  670. Xtest:    ${CXTRACT} ${SYSRC}
  671. X    ./${CXTRACT} -o testproto.h -H_proto_h_ -S +CFacPZ main.c io.c parse.c
  672. X    @${ECHO} ===
  673. X    @${ECHO} === The only output from the following command should show
  674. X    @${ECHO} === two date strings at line 5 of both files.
  675. X    @${ECHO} ===
  676. X    @${ECHO} === Errors from make can be ignored if this is the case.
  677. X    @${ECHO} === 
  678. X    -${DIFF} proto.h testproto.h
  679. X
  680. X#
  681. X#    define flags for the compilation
  682. XCFLAGS    = -DSYS_CONFIG=\"${SYSRC}\" -DCONFIG_FILE=\"${RCFILE}\" -DCEXTDOC_NAME=\"${DOCTRG}\" ${CPPFLG} ${CPPCMT} ${PIPFLG}
  683. X
  684. X#
  685. X#    Rules and dependencies for this Makefile
  686. X#
  687. X.c.o:    $<
  688. X    ${CC} ${SYSFLG} ${COPTS} ${CFLAGS} -c $*.c
  689. X
  690. X#    The prototype extraction program
  691. X${CXTRACT}:    ${CXTOBJS}
  692. X    ${CC} ${COPTS} -o ${CXTRACT} ${CXTOBJS}
  693. X
  694. X#
  695. X#    Added dependencies
  696. X${CXTOBJS}:    xtract.h proto.h
  697. X
  698. X#
  699. END_OF_FILE
  700. if test 5821 -ne `wc -c <'Makefile.dist'`; then
  701.     echo shar: \"'Makefile.dist'\" unpacked with wrong size!
  702. fi
  703. # end of 'Makefile.dist'
  704. fi
  705. if test -f 'README' -a "${1}" != "-c" ; then 
  706.   echo shar: Will not clobber existing file \"'README'\"
  707. else
  708. echo shar: Extracting \"'README'\" \(7026 characters\)
  709. sed "s/^X//" >'README' <<'END_OF_FILE'
  710. XThis package is cextract, version 1, patchlevel 7.  This is the second
  711. Xofficial release and is being distributed through the newsgroup
  712. Xcomp.sources.reviewed, with the first version [1.2] being released
  713. Xthere as well.
  714. X
  715. XSee the file INSTALL for installing on Unix systems or the file
  716. XINSTALL.VMS for installing on VMS systems.
  717. X
  718. XThe cextract/cextdoc program is copyright 1992 by Adam Bryant.
  719. X
  720. XThe code is freely distributable and there are no restrictions other
  721. Xthan the fact that it not be used for monetary gain and that copyright
  722. Xnotices must be kept intact.
  723. X
  724. XThe program may be used to generate proprietary source code or
  725. Xdocumentation, but its own source code may not be used as a part of
  726. Xany proprietary programs.
  727. X
  728. XAll of the output created by cextract and cextdoc programs should be
  729. Xcovered by the copyright notices for the source code which was read to
  730. Xcreate the output, since it is really a derivative work based on that
  731. Xsource code.
  732. X
  733. X-=-=-=-=-
  734. X
  735. XThis package contains a C prototype extractor.
  736. X
  737. Xcextract is ideal for generating header files for large multi-file C
  738. Xprograms, and will provide an automated method for generating all of
  739. Xthe prototypes for all of the functions in such a program.
  740. X
  741. Xcextract also functions as a rudimentary documentation extractor,
  742. Xgenerating a sorted list of all functions and their locations.
  743. X
  744. X-=-=-=-=-
  745. X
  746. XThe basic method I used in this program involves the following steps:
  747. X
  748. X    1)  Send the file to the C preprocessor.
  749. X    2)  Parse the output from the C preprocessor.
  750. X    3)  Isolate any function declaration sequence.
  751. X    4)  Determine if the parameter list is empty, contains
  752. X        a list of K&R C style declarations, or contains a
  753. X        list of ANSI C style declarations.
  754. X    5a) If the list is empty, then store a "(void)" for
  755. X        that function.
  756. X    5b) If it is a K&R declaration, traverse both the
  757. X        variable list and the declaration portion,
  758. X        associating matched pairs and providing default
  759. X        "int" type if needed.  Check for replacement
  760. X        matches and remove variable names if desired.
  761. X    5c) If the declaration is ANSI, separate into the
  762. X        declaration sequences and perform any replacements
  763. X        and/or variable name removals.
  764. X    6)  Store the list of functions, with associated
  765. X        declaration strings.
  766. X    7)  Store the formatted function output, in the
  767. X        appropriate order, in one or two memory locations
  768. X        [Two for dual output, one otherwise].  This step
  769. X        can be performed after all files have been parsed,
  770. X        if needed.
  771. X    8)  After all files have been parsed and the results
  772. X        stored, the results are sent to the final output
  773. X        location, either the standard output or a file.
  774. X
  775. X-=-=-=-=-
  776. X
  777. XThe main advantages that I find with this program over other
  778. Xprototyping programs:
  779. X
  780. X  - smaller.  [You can distribute it with your own packages so that
  781. X    other programmers can rebuild your header files.]
  782. X
  783. X  - fully written in C.  [You don't need a lex or yacc compiler
  784. X    to get this going.]
  785. X
  786. X  - more portable.  [As far as I know, it only requires that
  787. X    the system has a C preprocessor for it to work.]  I have even
  788. X    provided support for VMS systems, although I wish the compiler
  789. X    on that system allowed the comments to be retained.  [Using the
  790. X    GNU C preprocessor on such systems is supposed to work, though.]
  791. X
  792. X  - reads either ANSI or K&R C code and outputs either K&R or
  793. X    ANSI [or both!] function definitions.
  794. X
  795. X  - can catch all #define statements within the parameter list
  796. X    and replace before output, if needed.  [such as
  797. X    "#define FILE struct _iobuf"]  This feature is provided to
  798. X    account for adjustments caused by the C preprocessor.
  799. X
  800. X  - automatically catches and replaces FILE and varargs stuff.
  801. X
  802. X  - has a built in documentation extraction program.
  803. X
  804. X  - supports configuration files and the automatic generation of such
  805. X    files.
  806. X
  807. X-=-=-=-=-
  808. X
  809. XLikely disadvantages:
  810. X
  811. X  - it is not a fully implemented compiler, so it might not
  812. X    complain if it is reading invalid C code.
  813. X
  814. X  - might barf on extremely complex code.
  815. X
  816. X  - could probably be a little faster.  [any speed up
  817. X    suggestions are welcome]
  818. X
  819. X  - with heavily conditional (#ifdef'ed) code, it might not be
  820. X    able to generate a "generic" header file which would work for
  821. X    all possible code permutations.
  822. X
  823. X  - isn't fully C++ compatible.
  824. X
  825. X-=-=-=-=-
  826. X
  827. XList of changes from version 1.2 to version 1.6:
  828. X
  829. X  o Updated the documentation to handle the new features.
  830. X  o Fixed bug which made functions with comments in a parameter list to
  831. X     be skipped.
  832. X  o Added support for the CPP definition within the Makefile and
  833. X     it is now possible to change the preprocessor at runtime.
  834. X  o Changed the "#ifdef __STDC__" to "#if __STDC__".
  835. X  o Wrote a configuration file generation system.
  836. X  o Check for duplicate replace commands and definition options.
  837. X  o Swapped my use of the CFLAGS and COPTS definitions in the Makefile.
  838. X  o Fixed problems with the 'Q' flag parsing.
  839. X  o Automatically create the system configuration file on a "make install".
  840. X  o Fixed problems with the NO_OPEN option being VMS specific.
  841. X  o Fixed problems with the replacement of types.
  842. X  o Fixed bug tagging on an extra "int" unnecessarily.
  843. X  o Allow any style of text inside the brackets and parenthesis in the
  844. X    variable declaration lists.
  845. X  o Fixed typos in the font error messages. [% --> %%]
  846. X  o Automatically remove the "register" from the parameter lists.
  847. X  o Added an option to provide compact output of the ANSI and K&R prototypes.
  848. X  o Added support for // single line C++ style comments.
  849. X
  850. X-=-=-=-=-
  851. X
  852. XIf you have any problems, or suggestions, please feel free to get in
  853. Xtouch with me.
  854. X
  855. XAdam Bryant
  856. Xadb@bu.edu
  857. X
  858. X-=-=-=-=-
  859. X
  860. XHOW I USE IT:
  861. X
  862. X  - I use this program myself in support of a project written
  863. X    in over 60,000 lines of C code.
  864. X
  865. X  - Within my main header file, I have lines similar to*:
  866. X
  867. X#ifndef __CEXTRACT__
  868. X#include "proto.h"
  869. X#endif /* __CEXTRACT__ */
  870. X
  871. X  - In my Makefile, I have an entries similar to:
  872. X
  873. X#
  874. X#    list of all files in the program
  875. XCFILS    = a.c b.c c.c d.c e.c
  876. X
  877. X#
  878. X#    build the new prototype file
  879. Xproto:
  880. X    cextract +CaFPSc -o proto.h ${CFILS}
  881. X
  882. X  - and then all I need do is type "make proto" and I get an
  883. X    automatically updated header file listing all of my functions.
  884. X
  885. X* The "#ifndef __CEXTRACT__" sequence is there so that I can
  886. X  rebuild the header file even if it was somehow destroyed.
  887. X
  888. XADDITIONAL NOTES:
  889. X
  890. X  - If you are concerned with type promotion at your site, you may
  891. X    make use of the "replace" function.  For example, adding the
  892. X    following lines to a configuration file will handle a number of
  893. X    type promotions:
  894. X
  895. X         replace type "char" with "int"
  896. X         replace type "unsigned char" with "unsigned int"
  897. X         replace type "float" with "double"
  898. X
  899. X  - While the documentation extractor might not be ideal for full
  900. X    production specs, it can be a useful step in an automatic generation
  901. X    process, especially if the comments preceding each function are
  902. X    adequately descriptive.
  903. X
  904. END_OF_FILE
  905. if test 7026 -ne `wc -c <'README'`; then
  906.     echo shar: \"'README'\" unpacked with wrong size!
  907. fi
  908. # end of 'README'
  909. fi
  910. if test -f 'TODO' -a "${1}" != "-c" ; then 
  911.   echo shar: Will not clobber existing file \"'TODO'\"
  912. else
  913. echo shar: Extracting \"'TODO'\" \(1518 characters\)
  914. sed "s/^X//" >'TODO' <<'END_OF_FILE'
  915. XThis file lists possible future enhancements:
  916. X
  917. X  - Get it to properly handle a function which returns a structure
  918. X    or structure pointer where the structure is declared along with
  919. X    the function.  [Ack... who programs like that anyway? :-)]
  920. X
  921. X    Example:
  922. X       extern struct play {int field;} *play(void) { ... } /* etc. */
  923. X
  924. X    [It should already handle structures within the parameter list.]
  925. X
  926. X  - Get it working on any systems it is not working on, such as IBM PCs.
  927. X    [Patches welcome!]
  928. X
  929. X  - Find some way to improve the I/O speed.  Perhaps through the use
  930. X    of another method for reading from the pipe?
  931. X
  932. X  - Capture variables and structures as well as functions.
  933. X
  934. X  - Enhance the documentation extraction portion.
  935. X
  936. X  - Get it to work with C++ code as well as C.
  937. X
  938. X  - Provide automatic generation of conditional header files.  [This
  939. X    would probably be quite tricky as well as require multiple
  940. X    passes ==> slooooow.]
  941. X
  942. X  - Use the standard command argument parsing routines on VMS systems.
  943. X
  944. X  - Better memory management for the buffers and string storage space.
  945. X    The arbitrary arrays just don't cut it anymore.
  946. X
  947. X  - Provide option of taking first comment within a function instead
  948. X    of first comment before a function.
  949. X
  950. X  - Provide support for very strange functional declarations.
  951. X    [Pointers to functions with functions as parameters, far pointers, etc.]
  952. X
  953. X  - Handle far pointers, looking into ANSI C specs on this.
  954. X
  955. X  - Provide a flag to insert a copyright notice into headers automatically.
  956. X
  957. END_OF_FILE
  958. if test 1518 -ne `wc -c <'TODO'`; then
  959.     echo shar: \"'TODO'\" unpacked with wrong size!
  960. fi
  961. # end of 'TODO'
  962. fi
  963. if test -f 'build.com' -a "${1}" != "-c" ; then 
  964.   echo shar: Will not clobber existing file \"'build.com'\"
  965. else
  966. echo shar: Extracting \"'build.com'\" \(283 characters\)
  967. sed "s/^X//" >'build.com' <<'END_OF_FILE'
  968. X$!
  969. X$! Quickie VMS .com file to build under VMS.
  970. X$!
  971. X$! Written by John Carr (jrcarr@iup.bitnet)
  972. X$! modified by Adam Bryant (adb@bu.edu)
  973. X$! 
  974. X$ cc main,parse,io
  975. X$!
  976. X$! Options decrease .exe file size by 2/3
  977. X$!
  978. X$ link/exe=cextract main,parse,io, sys$input/opt
  979. Xsys$share:vaxcrtl.exe/share
  980. END_OF_FILE
  981. if test 283 -ne `wc -c <'build.com'`; then
  982.     echo shar: \"'build.com'\" unpacked with wrong size!
  983. fi
  984. # end of 'build.com'
  985. fi
  986. if test -f 'cextdoc.1' -a "${1}" != "-c" ; then 
  987.   echo shar: Will not clobber existing file \"'cextdoc.1'\"
  988. else
  989. echo shar: Extracting \"'cextdoc.1'\" \(56 characters\)
  990. sed "s/^X//" >'cextdoc.1' <<'END_OF_FILE'
  991. X.so man1/cextract.1
  992. X.\" use the cextract(1) manual page
  993. END_OF_FILE
  994. if test 56 -ne `wc -c <'cextdoc.1'`; then
  995.     echo shar: \"'cextdoc.1'\" unpacked with wrong size!
  996. fi
  997. # end of 'cextdoc.1'
  998. fi
  999. if test -f 'cextrc.5' -a "${1}" != "-c" ; then 
  1000.   echo shar: Will not clobber existing file \"'cextrc.5'\"
  1001. else
  1002. echo shar: Extracting \"'cextrc.5'\" \(7576 characters\)
  1003. sed "s/^X//" >'cextrc.5' <<'END_OF_FILE'
  1004. X.TH CEXTRC 5 "3 September 1992"
  1005. X.SH NAME
  1006. Xcextrc \- C prototype/documentation extractor customization file format
  1007. X.SH SYNOPSIS
  1008. X.B NORMRC
  1009. X.SH DESCRIPTION
  1010. XThe programs \fIcextract\fR(1) and \fICDOCNAME\fR(1) extract function
  1011. Xprototypes from C source code and create header and documentation
  1012. Xfiles respectively.  The \fINORMRC\fR customization files allow users
  1013. Xto specify which options are set for those programs, without having to
  1014. Xalways use the command line.
  1015. X.sp
  1016. XThe configuration files are read prior to the parsing of the command
  1017. Xline options, as well as whenever the `-q' flag is encountered.
  1018. X.SH FORMAT
  1019. XThe file should be a normal text file, with each customization command
  1020. Xon a separate line.  Blank lines and any line beginning with a `#'
  1021. Xwill be ignored.
  1022. X.sp
  1023. XAny command preceded by the string "doc-only " will only be used in
  1024. Xdocumentation mode, and any command preceded by "extract-only " will
  1025. Xonly be used in extraction mode.
  1026. X.sp
  1027. XCommands which are preceded by either a `!' or the string "no-" or
  1028. X"no" will be interpreted as disabling that option, if appropriate.
  1029. X.SH COMMANDS
  1030. XThe full list of configuration commands is given below.
  1031. X.IP ansi-code
  1032. XIf dual-output and merge-output modes are not enabled, produce output
  1033. Xin ANSI C format, with full prototyping.  This command does not do
  1034. Xanything when used in documentation mode.
  1035. X.IP break-after-types
  1036. X.IP break-types
  1037. XWhen enabled, a newline will be inserted between the function type and
  1038. Xthe function name in the function declarations.
  1039. X.IP comments
  1040. X.IP yank-comments
  1041. XExtract the comment immediately before the function definition, and
  1042. Xdisplay it upon output.
  1043. X.IP "config-file: \fIfile\fR"
  1044. XRead in the specified file and parse it for configuration commands.
  1045. X.IP "cpp-program: \fIprogram\fR"
  1046. XSpecify which program is to be used as a C preprocessor.  This program
  1047. Xshould resolve all C defines and while, hopefully, leaving the comments
  1048. Xintact.
  1049. X.IP doc-mode
  1050. XEnable documentation mode with normal text output.  This is the
  1051. Xdefault setting for \fICDOCNAME\fR(1).
  1052. X.IP "define: \fIexpression\fR"
  1053. XPass the specified expression to the C preprocessor with a "-D" string
  1054. Xprepended to it.  This command is equivalent to the `-D' command line
  1055. Xoption.
  1056. X.IP dual-output
  1057. XProvide output in both ANSI and K&R C formats, separated by an
  1058. X"#if __STDC__" ... "#else" ... "#endif" construct.  This command does
  1059. Xnot do anything when used in documentation mode or if the merge-output
  1060. Xoption is enabled.
  1061. X.IP externs
  1062. XPrepend an "extern" to each function description upon output.
  1063. X.IP extract-mode
  1064. XEnable extraction mode and generate output which can be used as a C
  1065. Xheader file defining the prototypes for all of the functions which are
  1066. Xencountered.  The is the default mode for \fIcextract\fR(1).
  1067. X.IP first-comments
  1068. XInclude in the output the initial comment encountered in each file.
  1069. X.IP filename
  1070. X.IP prepend-filename
  1071. XIf the "first-comments" option is enabled, prepend the name of each
  1072. Xfile to the output of initial comments.
  1073. X.IP "font % ##"
  1074. XAssign a troff font "##" to a given font type `%', when using troff
  1075. Xdocumentation mode.  The possible font types are `1' or `t', `2'
  1076. Xor `c', `3' or `n', and `4' or `p' for the title, comment, name, and
  1077. Xparameter list respectively.  The troff font "##" is a normal one or
  1078. Xtwo character troff font, such as "CO" for Courier Oblique.
  1079. X.IP "header-string: \fIstring\fR"
  1080. XWhen in extraction mode, enclose the output within preprocessor
  1081. Xdirectives testing for the definition of \fIstring\fR.  This method is
  1082. Xused with many system header files, to insure that they are not
  1083. X"#include"d more than once.  If this option is not used, the output
  1084. Xwill be enclosed within a "#ifndef __CEXTRACT__", "#endif /*
  1085. X__CEXTRACT__ */" sequence instead.
  1086. X.IP "include: \fIdirectory\fR"
  1087. XPass the specified directory to the C preprocessor with a "-I" string
  1088. Xprepended to it.  This command is equivalent to the `-I' command-line
  1089. Xoption.
  1090. X.IP merge-output
  1091. XMerge the ANSI and K&R output into a single line of output to make it
  1092. Xtake up less space.  A macro is used to expand the parameter list for
  1093. XANSI compilers.  This option overrides both the dual-output and
  1094. Xansi-code options.  There is no affect if the documentation mode is
  1095. Xenabled.
  1096. X.IP multi-comments
  1097. X.IP multiple-comments
  1098. XWhen extracting comments, assume that consecutive comments are
  1099. Xactually one single comment.  This allows people that place comment
  1100. Xdelimiters at the beginning and end of each line to have their
  1101. Xcomments properly captured.
  1102. X.IP "output-file: \fIoutfile\fR"
  1103. XStore the output in the specified file.
  1104. X.IP replace
  1105. XReplace the first string which matches a variable, type, or both
  1106. X(as selected) with the second string.   The format is:
  1107. X.br
  1108. X    replace [all/type/variable] "\fIstring1\fR" "\fIstring2\fR"
  1109. X.br
  1110. XFor example, on Sun machines, the automatic "FILE" replacement could
  1111. Xbe accomplished using a command like:
  1112. X.br
  1113. X    replace type "struct _iobuf" "FILE"
  1114. X.br
  1115. XHowever, this should not need to be entered by the average user since
  1116. Xit is handled automatically by \fIcextract\fR(1), as is the varargs
  1117. Xsystem.
  1118. X.IP remove-names
  1119. X.IP discard-names
  1120. XRemove variable names from the prototype list prior to output.
  1121. X.IP roff-mode
  1122. X.IP troff-mode
  1123. XEnable documentation mode with troff -ms format output.  This option
  1124. Xis overridden by the doc-mode or extract-mode options.
  1125. X.IP show-all
  1126. X.IP show-anyway
  1127. XWhen output is K&R C, display prototypes in comments.  When
  1128. Xdual-output is enabled, display comments and prototypes in both
  1129. Xsections; otherwise, display comments and prototypes only in the ANSI
  1130. XC portion.  This option does nothing in documentation mode. 
  1131. X.IP single-comments
  1132. XWhen extracting comments from a file, take only one comment,
  1133. Xdiscarding all preceding comments.  This option is the reverse of the
  1134. Xmulti-comments option.
  1135. X.IP sort-all
  1136. XAlphabetically sort all of the functions from all of the files before
  1137. Xgenerating output.
  1138. X.IP sort-by-files
  1139. XFor each file processed, sort all of the functions prior to output.
  1140. X.IP statics
  1141. X.IP "statics: none"
  1142. X.IP "statics: any"
  1143. X.IP "statics: only"
  1144. XSelect the method for how static functions should be treated.  If
  1145. X"none" is selected, statics will be ignored.  If "only" is selected,
  1146. Xnon-static functions will be ignored.  Finally, "any" indicates that
  1147. Xall functions will be extracted.  If no selection is made, it will be
  1148. Xthe same as selecting "any" or (with a preceding `!') "none".
  1149. X.IP "tab-width: \fIwidth\fR"
  1150. XSet the tab width to be an integer number \fIwidth\fR.  This works
  1151. Xonly during documentation generation.
  1152. X.IP "undefine: \fIname\fR"
  1153. XUndefine any previously defined macro.  If none is encountered, pass
  1154. Xthe specified expression to the C preprocessor with a "-U" string
  1155. Xprepended to it.  This command is equivalent to the `-U' command-line
  1156. Xoption.
  1157. X.IP "wrap-parameters: #"
  1158. XIf the length of the parameter list for a function would cause it to
  1159. Xexceed a given number of columns [72 by default], a newline will be
  1160. Xinserted in place of a space character, so that the function will not
  1161. Xexceed that given length.  The optional number after the command will
  1162. Xoverride a negation prefix if encountered.
  1163. X.SH FILES
  1164. X.IP "SYSCXTRC, $HOME/NORMRC, NORMRC"
  1165. Xconfiguration files.
  1166. X.SH VMS
  1167. XConfiguration files are also supported under VMS.  The default
  1168. Xconfiguration files for VMS systems are sys$library:cext.cnf,
  1169. Xsys$login:cext.cnf, and cext.cnf.
  1170. X.sp
  1171. XSince the VMS C compiler strips out comments, the documentation mode
  1172. Xand comment options are not very useful.  Using the GNU C preprocessor
  1173. Xinstead might be a possible solution.
  1174. X.SH SEE ALSO
  1175. Xcextract(1), CDOCNAME(1)
  1176. X.SH AUTHOR
  1177. X.nf
  1178. XAdam Bryant
  1179. Xadb@bu.edu
  1180. X.sp
  1181. Xinitial VMS port by John Carr
  1182. Xjrcarr@iup.bitnet
  1183. END_OF_FILE
  1184. if test 7576 -ne `wc -c <'cextrc.5'`; then
  1185.     echo shar: \"'cextrc.5'\" unpacked with wrong size!
  1186. fi
  1187. # end of 'cextrc.5'
  1188. fi
  1189. if test -f 'newbuild.com' -a "${1}" != "-c" ; then 
  1190.   echo shar: Will not clobber existing file \"'newbuild.com'\"
  1191. else
  1192. echo shar: Extracting \"'newbuild.com'\" \(360 characters\)
  1193. sed "s/^X//" >'newbuild.com' <<'END_OF_FILE'
  1194. X$!
  1195. X$! Quickie VMS .com file to build under VMS.
  1196. X$!
  1197. X$! Written by John Carr (jrcarr@iup.bitnet)
  1198. X$! modified by Adam Bryant (adb@bu.edu)
  1199. X$! 
  1200. X$ cc main,parse,io/def= -
  1201. X(SYS_CONFIG="""sys$library:cext.cnf""",CONFIG_FILE="""cext.cnf""")
  1202. X$!
  1203. X$! Options decrease .exe file size by 2/3
  1204. X$!
  1205. X$ link/exe=cextract main,parse,io, sys$input/opt
  1206. Xsys$share:vaxcrtl.exe/share
  1207. X$!
  1208. END_OF_FILE
  1209. if test 360 -ne `wc -c <'newbuild.com'`; then
  1210.     echo shar: \"'newbuild.com'\" unpacked with wrong size!
  1211. fi
  1212. # end of 'newbuild.com'
  1213. fi
  1214. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  1215.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  1216. else
  1217. echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
  1218. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  1219. X#define PATCHLEVEL 7
  1220. END_OF_FILE
  1221. if test 21 -ne `wc -c <'patchlevel.h'`; then
  1222.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  1223. fi
  1224. # end of 'patchlevel.h'
  1225. fi
  1226. if test -f 'proto.h' -a "${1}" != "-c" ; then 
  1227.   echo shar: Will not clobber existing file \"'proto.h'\"
  1228. else
  1229. echo shar: Extracting \"'proto.h'\" \(5485 characters\)
  1230. sed "s/^X//" >'proto.h' <<'END_OF_FILE'
  1231. X/*
  1232. X *   This file was automatically generated by version 1.7 of cextract.
  1233. X *   Manual editing not recommended.
  1234. X *
  1235. X *   Created: Fri Oct 30 15:57:04 1992
  1236. X */
  1237. X#ifndef _proto_h_
  1238. X#define _proto_h_
  1239. X#if __STDC__
  1240. X#define PL_(x) x
  1241. X#else
  1242. X#define PL_(x) ( )
  1243. X#endif /* __STDC__ */
  1244. X
  1245. X/* main.c:
  1246. X *
  1247. X * The purpose of this program is to extract the function descriptions
  1248. X * (prototypes) from C source code.  It also provides for the creation
  1249. X * of documentation based on those prototypes.
  1250. X *
  1251. X * The specific reason for the creation of this program was to
  1252. X * provide a method for automatically creating header files to
  1253. X * describe all of the functions to be used within a multi-file
  1254. X * program.
  1255. X *
  1256. X * This file makes use of code in the companion files parse.c and io.c.
  1257. X *
  1258. X * Copyright (c) 1990, 1991, 1992 by Adam Bryant
  1259. X *
  1260. X * See Copyright notice in the file parse.c or in the manual page.
  1261. X *
  1262. X */
  1263. X
  1264. X/* quick function to copy a "string" */
  1265. Xextern int copy_str PL_(( char *o_str, char *in_str ));
  1266. X
  1267. X/* return FALSE if character is not a normal part of a filename */
  1268. Xextern int fname_char PL_(( int ch ));
  1269. X
  1270. X/* retrieve the value of a global option */
  1271. Xextern int get_option PL_(( Optype which ));
  1272. X
  1273. X/* control program flow and command line options */
  1274. Xextern int main PL_(( int argc, char **argv ));
  1275. X
  1276. X/* output filter from the parsing routines */
  1277. Xextern void out_char PL_(( int type, int outch ));
  1278. X
  1279. X/* transmit the currently stored comment to the output file */
  1280. Xextern void send_first_comment PL_(( char *begin_str ));
  1281. X
  1282. X/* set the value of a global option */
  1283. Xextern void set_option PL_(( Optype which, int how, int value ));
  1284. X
  1285. X/* show all of the settings */
  1286. Xextern void show_settings PL_(( void ));
  1287. X
  1288. X/* show the usage for the program */
  1289. Xextern void show_usage PL_(( void ));
  1290. X
  1291. X/* show the version of the program */
  1292. Xextern void show_version PL_(( void ));
  1293. X
  1294. X/* io.c:
  1295. X *
  1296. X * cextract input/output routines.
  1297. X *
  1298. X * Copyright (c) 1992 by Adam Bryant
  1299. X *
  1300. X * See the Copyright notice in the file parse.c or in the manual page.
  1301. X *
  1302. X */
  1303. X
  1304. X/* close up the "pipe" */
  1305. Xextern int close_input PL_(( FILE *stream ));
  1306. X
  1307. X/* close up properly; sending out final output */
  1308. Xextern void cxt_close PL_(( void ));
  1309. X
  1310. X/* read in all configuration files */
  1311. Xextern void do_config PL_(( void ));
  1312. X
  1313. X/* send a system error message */
  1314. Xextern void err_msg PL_(( char *estr ));
  1315. X
  1316. X/* routine to check return value of fputs */
  1317. Xextern void fput_string PL_(( char *outstr, FILE *filep ));
  1318. X
  1319. X/* quickie function to distinquish proper switches */
  1320. Xextern int is_switch PL_(( int ch ));
  1321. X
  1322. X/* return pointer to string containing the date */
  1323. Xextern char * mach_time PL_(( void ));
  1324. X
  1325. X/* does the string match a minimum number of characters */
  1326. Xextern int minmatch_str PL_(( char *str_in, char *str_base, int num ));
  1327. X
  1328. X/* function to open a "pipe" to the input */
  1329. Xextern FILE * open_input PL_(( char *pname, char *modestr ));
  1330. X
  1331. X/* output given function prototype */
  1332. Xextern void out_proto PL_(( int omode, P_PROTO f_ptr, int mode, int do_comments ));
  1333. X
  1334. X/* call the external routine out_char() and send out all characters */
  1335. Xextern void out_str PL_(( int omode, char *str ));
  1336. X
  1337. X/* determine the configuration command, exit if invalid */
  1338. Xextern void parse_cmd PL_(( char *cmd_str, int set_val, int cmd_line ));
  1339. X
  1340. X/* function to parse the configuration file */
  1341. Xextern void parse_config PL_(( char *conf_fname ));
  1342. X
  1343. X/* output results of entire file search */
  1344. Xextern void send_file PL_(( void ));
  1345. X
  1346. X/* send a message that their was a syntax error */
  1347. Xextern void syntax_err PL_(( char *estr ));
  1348. X
  1349. X/* search for expanded value of the varargs setup */
  1350. Xextern int vargs_find PL_(( void ));
  1351. X
  1352. X/* parse.c:
  1353. X *
  1354. X * main parsing routines for the cextract/cextdoc programs.
  1355. X * Also includes a number of generic routines applicable to both.
  1356. X *
  1357. X * These routines provide the methods used to extract comments,
  1358. X * prototypes and function names from C source files.
  1359. X *
  1360. X * Copyright (c) 1990, 1991, 1992 by Adam Bryant
  1361. X *
  1362. X * The only restrictions on the use of these routines is that they not
  1363. X * be used for monetary gain, and that this copyright notice be left
  1364. X * intact.
  1365. X *
  1366. X * Note:  These programs may be freely used to extract code and/or
  1367. X *        documentation at proprietary/corporate sites, as long as the
  1368. X *        actual source code is not used within any proprietary code.
  1369. X *
  1370. X *        The generated output (header) files are distributable in any
  1371. X *        manner desired as they are based on the scanned source code,
  1372. X *        not my program.
  1373. X */
  1374. X
  1375. X/* add a new macro to the macro list */
  1376. Xextern void add_macro PL_(( int select, char *str ));
  1377. X
  1378. X/* add a new substitution macro to the substitution list */
  1379. Xextern void add_subst PL_(( int type, int select, char *f_str, char *t_str ));
  1380. X
  1381. X/* initialize the page for troff output, if needed */
  1382. Xextern void init_roff PL_(( int omode ));
  1383. X
  1384. X/* go through the file extracting functions */
  1385. Xextern void parse_file PL_(( void ));
  1386. X
  1387. X/* remove the top item on the stack */
  1388. Xextern void pop_proto PL_(( void ));
  1389. X
  1390. X/* check preprocessor statement for line numbering changes */
  1391. Xextern int preprocessor_check PL_(( void ));
  1392. X
  1393. X/* if the matching definition is in the list, remove it */
  1394. Xextern int removed_macro PL_(( int select, char *str ));
  1395. X
  1396. X/* sort the list of functions and their prototypes */
  1397. Xextern void sort_proto PL_(( void ));
  1398. X
  1399. X/* compare two strings considering cases the same */
  1400. Xextern int str_test PL_(( char *s1, char *s2 ));
  1401. X
  1402. X/* remove any preceding and trailing spaces */
  1403. Xextern void trim_str PL_(( char *str ));
  1404. X
  1405. X#undef PL_
  1406. X#endif /* _proto_h_ */
  1407. END_OF_FILE
  1408. if test 5485 -ne `wc -c <'proto.h'`; then
  1409.     echo shar: \"'proto.h'\" unpacked with wrong size!
  1410. fi
  1411. # end of 'proto.h'
  1412. fi
  1413. if test -f 'xtract.h' -a "${1}" != "-c" ; then 
  1414.   echo shar: Will not clobber existing file \"'xtract.h'\"
  1415. else
  1416. echo shar: Extracting \"'xtract.h'\" \(8013 characters\)
  1417. sed "s/^X//" >'xtract.h' <<'END_OF_FILE'
  1418. X/* header for routines and structures storing C function prototypes */
  1419. X
  1420. X/* system header files */
  1421. X#ifdef SGI
  1422. X/* I hate having to do this! */
  1423. X#if __STDC__
  1424. X#ifndef __EXTENSIONS__
  1425. X#define __EXTENSIONS__
  1426. X#endif /* __EXTENSIONS__ */
  1427. X#ifndef _POSIX_SOURCE
  1428. X#define _POSIX_SOURCE
  1429. X#endif /* _POSIX_SOURCE */
  1430. X#endif /* __STDC__ */
  1431. X#endif /* SGI */
  1432. X#include <stdio.h>
  1433. X#include <ctype.h>
  1434. X#include <time.h>
  1435. X#ifdef _POSIX_SOURCE
  1436. X#include <stdlib.h>
  1437. X#endif /* _POSIX_SOURCE_ */
  1438. X#if __STDC__ 
  1439. X#ifndef VMS
  1440. X#include <unistd.h>
  1441. X#endif /* VMS */
  1442. X#endif /* __STDC__ */
  1443. X
  1444. X/* patchlevel information */
  1445. X#include "patchlevel.h"
  1446. X
  1447. X/* === start of system configurations === */
  1448. X
  1449. X/*
  1450. X * This option is enabled if a VMS compiler doesn't have "popen()"
  1451. X * command to open a pipe to a system command; this is standard
  1452. X * Unix I/O function.
  1453. X */
  1454. X#ifdef VAXC
  1455. X#define NO_POPEN    /* use a hack to get a "pipe" command */
  1456. X#endif /* VAXC */
  1457. X
  1458. X/*
  1459. X * This definition checks for a failure by the "system()" function.
  1460. X */
  1461. X#ifdef VAXC
  1462. X#define SYSCMD_FAILED    0    /* if system() fails, it returns a zero? */
  1463. X#else
  1464. X#define SYSCMD_FAILED    -1    /* if system() fails, it returns a -1 */
  1465. X#endif /* VAXC */
  1466. X
  1467. X/* the command to perform the C preprocessing (full path best) */
  1468. X#ifndef CPP
  1469. X#ifndef VMS
  1470. X#define CPP "/lib/cpp"
  1471. X#else
  1472. X#define CPP "cc"
  1473. X#endif /* VMS */
  1474. X#endif /* CPP */
  1475. X
  1476. X/* flag to CPP to retain comments */
  1477. X#ifndef VAXC
  1478. X#define CPP_COMMENTS "-C"
  1479. X#else
  1480. X#define CPP_COMMENTS ""
  1481. X#endif /* VAXC */
  1482. X
  1483. X/* an sprintf format statement with 1 %d to build a temporary file */
  1484. X#ifndef TMPFILE_FMT
  1485. X#ifndef VMS
  1486. X#define TMPFILE_FMT    "/tmp/.cxtprs.%d"
  1487. X#else
  1488. X#define TMPFILE_FMT    "sys$scratch:cxtprs.%d"
  1489. X#endif /* VMS */
  1490. X#endif /* TMPFILE_FMT */
  1491. X
  1492. X/* same thing, but only needed for systems without the popen() command */
  1493. X#ifdef NO_POPEN
  1494. X#ifndef PIPETMP_FMT
  1495. X#ifndef VMS
  1496. X#define PIPETMP_FMT    "/tmp/.cxtpip.%d"
  1497. X#else
  1498. X#define PIPETMP_FMT    "sys$scratch:cxtpip.%d"
  1499. X#endif /* VMS */
  1500. X#endif /* PIPETMP_FMT */
  1501. X#endif /* NO_POPEN */
  1502. X
  1503. X/* how to generate the output to a temp file if there is no popen() */
  1504. X/* note:  need two %s entries:  first = command, second = outfile */
  1505. X#ifdef NO_POPEN
  1506. X#ifndef PIPEOUT_FMT
  1507. X#ifndef VMS
  1508. X#define PIPEOUT_FMT "%s > %s"
  1509. X#else
  1510. X#define PIPEOUT_FMT "%s /preprocess=%s"
  1511. X#endif /* VMS */
  1512. X#endif /* PIPEOUT_FMT */
  1513. X#endif /* NO_POPEN */
  1514. X
  1515. X/* the name for the documentation builder */
  1516. X#ifndef CEXTDOC_NAME
  1517. X#define CEXTDOC_NAME "cextdoc"
  1518. X#endif /* CEXTDOC_NAME */
  1519. X
  1520. X/* the name for the configuration file */
  1521. X#ifndef CONFIG_FILE
  1522. X#ifndef VMS
  1523. X#define CONFIG_FILE    ".cextrc"
  1524. X#else
  1525. X#define CONFIG_FILE    "cext.cnf"
  1526. X#endif /* VMS */
  1527. X#endif /* CONFIG_FILE */
  1528. X
  1529. X/* full path to any possible system configuration file */
  1530. X#ifndef SYS_CONFIG
  1531. X#ifndef VMS
  1532. X#define SYS_CONFIG    "/usr/local/lib/cext.config"
  1533. X#else
  1534. X#define SYS_CONFIG    "sys$library:cext.cnf"
  1535. X#endif /* VMS */
  1536. X#endif /* SYS_CONFIG */
  1537. X
  1538. X/* directory separator on the system */
  1539. X#ifndef DIR_SEPARATOR
  1540. X#ifdef VMS
  1541. X#define DIR_SEPARATOR    ""
  1542. X#else
  1543. X#ifdef MS_DOS
  1544. X#define DIR_SEPARATOR    "\\"
  1545. X#else
  1546. X#define DIR_SEPARATOR    "/"
  1547. X#endif /* MS_DOS */
  1548. X#endif /* VMS */
  1549. X#endif /* DIR_SEPARATOR */
  1550. X
  1551. X/* commands to C processor and Switch on invocation line */
  1552. X#ifndef DEF_LEADER
  1553. X#ifndef VAXC
  1554. X#define DEF_LEADER    "-D"
  1555. X#else
  1556. X#define DEF_LEADER    "/define="
  1557. X#endif /* VAXC */
  1558. X#endif /* DEF_LEADER */
  1559. X
  1560. X#ifndef UNDEF_LEADER
  1561. X#ifndef VAXC
  1562. X#define UNDEF_LEADER    "-U"
  1563. X#else
  1564. X#define UNDEF_LEADER    "/undefine="
  1565. X#endif /* VAXC */
  1566. X#endif /* UNDEF_LEADER */
  1567. X
  1568. X#ifndef INC_LEADER
  1569. X#ifndef VAXC
  1570. X#define INC_LEADER    "-I"
  1571. X#else
  1572. X#define INC_LEADER    "/include="
  1573. X#endif /* VAXC */
  1574. X#endif /* INC_LEADER */
  1575. X
  1576. X/* === end of system configurations === */
  1577. X
  1578. X/* structure for prototype storage */
  1579. Xtypedef struct s_proto {
  1580. X  char *name;        /* name of the function */
  1581. X  char *ftype;        /* type of the function */
  1582. X  char *fname;        /* name of file where located */
  1583. X  char *plist;        /* ANSI format prototype list */
  1584. X  char *comment;    /* comment associated with function */
  1585. X  struct s_proto *next;
  1586. X} S_PROTO, *P_PROTO;
  1587. X
  1588. X/* structure definition for holding macros */
  1589. Xtypedef struct s_macro {
  1590. X  char *m_str;        /* storage for the macro element */
  1591. X  struct s_macro *next;    /* pointer to next macro element */
  1592. X  char usewhen;        /* indicator of when it is to be used */
  1593. X} S_MACRO, *P_MACRO;
  1594. X
  1595. X/* structure definition for substitutions */
  1596. Xtypedef struct s_subst {
  1597. X  char *from_str;    /* the string to substitute for */
  1598. X  char *to_str;        /* the string to substitute with */
  1599. X  char submode;        /* indicator of substitution type */
  1600. X  char usewhen;        /* indicator of when it is to be used */
  1601. X  struct s_subst *next;    /* pointer to the next string */
  1602. X} S_SUBST, *P_SUBST;
  1603. X
  1604. X/* pseudo boolean definitions */
  1605. X#ifndef TRUE
  1606. X#define TRUE    (1)
  1607. X#define FALSE    (0)
  1608. X#endif
  1609. X
  1610. X/* the list of substitution types */
  1611. X#define SUBST_FULL    1    /* replace both variable type and name */
  1612. X#define SUBST_TYPE    2    /* replace for match with type only */
  1613. X#define SUBST_NAME    3    /* replace for complete name match only */
  1614. X
  1615. X/* now declare the variable space */
  1616. Xextern P_SUBST subst_list;
  1617. X
  1618. X/* list of options flags */
  1619. Xtypedef enum e_opts {
  1620. X  OPT_COMMENTS, OPT_FIRSTCOMMENT, OPT_SINGLECOMMENTS, OPT_PREPEND,
  1621. X  OPT_EXTERNS, OPT_STATICMODE, OPT_WRAPPOINT, OPT_TYPEWRAP,
  1622. X  OPT_SHOWANYWAY, OPT_STDCUSE, OPT_BOTHUSE, OPT_SORTMODE,
  1623. X  OPT_TABWIDTH, OPT_NONAMES, OPT_COMPACT
  1624. X} Optype;
  1625. X
  1626. X/* how many different options are there? */
  1627. X#define OPT_NUMBER    15
  1628. X
  1629. X/* modes of output */
  1630. X#define MODE_ANSI    0
  1631. X#define MODE_COMMENT    1
  1632. X#define MODE_OLDC    2
  1633. X
  1634. X/* modes of sorting */
  1635. X#define SORT_NONE    0
  1636. X#define SORT_FILE    1
  1637. X#define SORT_ALL    2
  1638. X
  1639. X/* different documentation modes */
  1640. X#define DOC_NORMAL    0
  1641. X#define DOC_ROFF    1
  1642. X#define DOC_NONE    2
  1643. X
  1644. X/* different static modes */
  1645. X#define NO_STATICS    0
  1646. X#define ONLY_STATICS    1
  1647. X#define ANY_STATICS    2
  1648. X
  1649. X/* the number of characters allocated for parsing */
  1650. X#define MAX_SIZE 100000
  1651. X#define MID_SIZE 4000
  1652. X#define FNAME_SIZE 256
  1653. X
  1654. X/* structure for the internal temporary storage */
  1655. Xtypedef struct s_bufdata {
  1656. X  char data[MID_SIZE + 1];    /* work with 1,000 characters at a time */
  1657. X  struct s_bufdata *next;    /* to the next element */
  1658. X} S_BUFDATA, *P_BUFDATA;
  1659. X
  1660. X#ifdef SETBUFFER
  1661. X/* allocation for buffering */
  1662. X#define BUFFER_SIZE    20480    /* 20 kilobytes of buffering */
  1663. X#endif /* SETBUFFER */
  1664. X
  1665. X/* set the version information */
  1666. X#define VERSION    1
  1667. X
  1668. X/* quickie macro for variable component recognition */
  1669. X#define id_char(x)    (isalnum(x) || (x == '_'))
  1670. X
  1671. X/* call in the file with the prototypes */
  1672. X#ifndef __CEXTRACT__
  1673. X#include "proto.h"
  1674. X#endif /* __CEXTRACT__ */
  1675. X
  1676. X/* data that should be defined */
  1677. Xextern char prog_name[FNAME_SIZE];
  1678. X
  1679. X/* system functions */
  1680. X#if defined(SYSV) || !defined(BSD)
  1681. X#include <string.h>
  1682. X#define index strchr
  1683. X#else
  1684. X#include <strings.h>
  1685. X#endif /* SYSV */
  1686. X#ifdef VAXC
  1687. X#define unlink remove
  1688. X#endif /* VAXC */
  1689. X
  1690. X#ifdef XENIX
  1691. X/* Provide a strstr() replacement on Xenix sites */
  1692. X#define NO_STRSTR
  1693. X#endif /* XENIX */
  1694. X
  1695. X/* I don't want to see this on SunOS */
  1696. X#ifdef BSD
  1697. X#ifdef SYSV
  1698. X#ifndef toupper
  1699. Xextern int toupper();
  1700. X#endif /* toupper */
  1701. Xextern int fprintf(), sscanf();
  1702. Xextern int _flsbuf(), _filbuf();
  1703. Xextern void perror();
  1704. Xextern long time();
  1705. Xextern int fputs(), fclose(), pclose();
  1706. X#ifdef SETBUFFER
  1707. Xextern void setbuffer();
  1708. X#endif /* SETBUFFER */
  1709. X#endif /* SYSV */
  1710. X#endif /* BSD */
  1711. X
  1712. X/* options for different parsing methods */
  1713. Xextern int global_opts[2][OPT_NUMBER];
  1714. Xextern int doc_extract, cfg_switch;
  1715. X
  1716. X/* variables for keeping track of things */
  1717. Xextern int start_block, files_parsed, total_out, dont_space;
  1718. X
  1719. X/* storage */
  1720. Xextern FILE *fpin;
  1721. Xextern P_MACRO macro_list, last_macro;
  1722. Xextern P_PROTO proto_list;
  1723. Xextern char file_name[], start_comment[], cfg_file[], tmp_str[];
  1724. X
  1725. X/* various fonts for documentation troff formats */
  1726. Xextern char ft_title[3], ft_comment[3], ft_name[3], ft_plist[3];
  1727. X
  1728. X/* other data declarations */
  1729. Xextern P_BUFDATA tempbuf[2];
  1730. Xextern char cur_cfg_file[FNAME_SIZE], header_string[MID_SIZE];
  1731. X#ifdef SETBUFFER
  1732. Xextern char outbuffer[BUFFER_SIZE], inbuffer[BUFFER_SIZE];
  1733. X#endif /* SETBUFFER */
  1734. Xextern FILE *fpout;
  1735. Xextern char output_file[2][MID_SIZE];
  1736. Xextern char cpp_prog[MID_SIZE], errout_filename[MID_SIZE];
  1737. Xextern int out_filenum, line_count;
  1738. END_OF_FILE
  1739. if test 8013 -ne `wc -c <'xtract.h'`; then
  1740.     echo shar: \"'xtract.h'\" unpacked with wrong size!
  1741. fi
  1742. # end of 'xtract.h'
  1743. fi
  1744. echo shar: End of archive 1 \(of 5\).
  1745. cp /dev/null ark1isdone
  1746. MISSING=""
  1747. for I in 1 2 3 4 5 ; do
  1748.     if test ! -f ark${I}isdone ; then
  1749.     MISSING="${MISSING} ${I}"
  1750.     fi
  1751. done
  1752. if test "${MISSING}" = "" ; then
  1753.     echo You have unpacked all 5 archives.
  1754.     rm -f ark[1-9]isdone
  1755. else
  1756.     echo You still need to unpack the following archives:
  1757.     echo "        " ${MISSING}
  1758. fi
  1759. ##  End of shell archive.
  1760. exit 0
  1761.  
  1762. exit 0 # Just in case...
  1763.