home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / shape / part09 < prev    next >
Text File  |  1989-05-31  |  55KB  |  1,981 lines

  1. Subject:  v19i022:  A software configuration management system, Part09/33
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Axel Mahler <unido!coma!axel>
  7. Posting-number: Volume 19, Issue 22
  8. Archive-name: shape/part09
  9.  
  10.  
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 9 (of 33)."
  19. # Contents:  man/man1/save.1 src/inc/afs.h src/shape/inherit.c
  20. #   src/shape/main.c src/shape/shape.l src/shape/varsec.c
  21. # Wrapped by rsalz@papaya.bbn.com on Thu Jun  1 19:26:57 1989
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'man/man1/save.1' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'man/man1/save.1'\"
  25. else
  26. echo shar: Extracting \"'man/man1/save.1'\" \(7936 characters\)
  27. sed "s/^X//" >'man/man1/save.1' <<'END_OF_FILE'
  28. X...
  29. X... Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  30. X...  and U. Pralle
  31. X... 
  32. X... This software is published on an as-is basis. There is ABSOLUTELY NO
  33. X... WARRANTY for any part of this software to work correctly or as described
  34. X... in the manuals. We do not accept any liability for any kind of damage
  35. X... caused by use of this software, such as loss of data, time, money, or 
  36. X... effort.
  37. X... 
  38. X... Permission is granted to use, copy, modify, or distribute any part of
  39. X... this software as long as this is done without asking for charge, and
  40. X... provided that this copyright notice is retained as part of the source
  41. X... files. You may charge a distribution fee for the physical act of
  42. X... transferring a copy, and you may at your option offer warranty
  43. X... protection in exchange for a fee.
  44. X... 
  45. X... Direct questions to: Tech. Univ. Berlin
  46. X...              Wilfried Koch
  47. X...              Sekr. FR 5-6 
  48. X...              Franklinstr. 28/29
  49. X...              D-1000 Berlin 10, West Germany
  50. X... 
  51. X...              Tel: +49-30-314-22972
  52. X...              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  53. X... 
  54. X...
  55. X... $Header: save.1[3.1] Thu Feb 23 18:13:51 1989 axel@coma published $
  56. X... 
  57. X... Log for /u/shape/dist-tape/src/vc/save.1[3.0]
  58. X...     Thu Feb 23 18:13:51 1989 axel@coma published $
  59. X...  --- empty log message ---
  60. X...  save.1[3.1] Thu Feb 23 18:13:51 1989 axel@coma published $
  61. X...  --- empty log message ---
  62. X...
  63. X.TH SAVE 1 save \n(dy.\n(mo.\n(yr
  64. X.SH NAME
  65. Xsave \- save revision of a file
  66. X.SH SYNOPSIS
  67. X.IP \fBsave\fR \w'\fBSave++\fR'u
  68. X[\ \fIoptions\fR\ ]\ files \.\|.
  69. X.IP \fBSave\fR
  70. X[\ \fIoptions\fR\ ]\ files \.\|.
  71. X.IP \fBsbmt\fR
  72. X[\ \fIoptions\fR\ ]\ files \.\|.
  73. X.IP \fIOptions:\fR \w'\fIOptions:++\fR'u
  74. X[\ \fB\-fhqu\fR\ ]\ [\ \fB\-a\ \fIafile\fR\ ] [\ \fB\-m\ \fImessage\fR\ ]
  75. X[\ \fB\-n\ \fIname\fR\ ] [\ \fB\-p\ \fIprojectname\fR\ ] 
  76. X.br
  77. X[\ \fB\-setvnum\ \fIversion\fR\ ]
  78. X[\ \fB\-t\ \fItextfile\fR\ ]\ [\ \fB\-unlock\fR\ ]\ [\ \fB\-version\fR\ ]
  79. X.SH DESCRIPTION
  80. X.PP
  81. X\fISave\fR stores the current state of the specified files into 
  82. Xarchive files and
  83. Xassigns a unique \fIversion number\fR to the saved version. Versions
  84. Xin archives are inalterable.
  85. XAn archive will be created
  86. Xin a subdirectory named \fIAFS\fR the first time a file saved.
  87. XThe AFS subdirectory must be present.
  88. XWhen an archive is created, save asks for the purpose
  89. Xof the saved document. If a subsequent version is saved, the user
  90. Xis prompted for a comment concerning the modifications.
  91. XThe \fBsave\fR command requires that the object history corresponding
  92. Xto the file to be saved is either \fIlocked\fR by the user
  93. Xissuing the command or not locked at all.
  94. XBefore a file is saved it will be checked whether it has actually 
  95. Xchanged. If the file hasn't changed, the user will be asked if it
  96. Xshould be saved anyway. The command line option \fB\-f\fR overrides the query.
  97. XA newly created object version in the archive will be assigned the
  98. Xstate \fIsaved\fR. This status marks the lowest level of quality,
  99. Xsuggesting that the version is just saved for possible later retrieval 
  100. Xbut may be inconsistent. Versions that meet higher quality standards
  101. X(or are part of a release) should be marked by appropriate status
  102. X(see \fBvadm\fR \-promote\fR or \fBsbmt\fR).
  103. X.PP
  104. XIf the program is invoked as \fBSave\fR (that is with capital-S) 
  105. Xa \fInew generation\fR of the document history is initiated \-
  106. Xprovided the programmer issuing the command has the permission to do this.
  107. X.PP
  108. XIf the program is invoked as \fBsbmt\fR, a newly created version
  109. Xwill be set to status \fIpublished\fR. If the file to be saved
  110. Xis unchanged with respect to the last saved version, the status
  111. Xof the last saved version will be promoted to \fIpublished\fR.
  112. X.LP
  113. XIn complete detail, \fBsave\fR can be invoked with the following options:
  114. X.IP \fB\-f\fR \w'\fB\-p\ \fIproject++\fR'u
  115. Xforces a revision deposit (i.e. without asking), even if the busy
  116. Xversion hasn't changed since the last time it was saved.
  117. X.IP \fB\-h\fR
  118. Xprint short information about usage of this command.
  119. X.IP \fB\-q\fR
  120. Xquiet operation. No messages are printed on standard output. 
  121. XIf the busy version is unchanged, it will not be saved unless
  122. X\fB\-f\fR is set. The user will not be prompted for a descriptive
  123. Xnote. If no message or note is supplied with the command line 
  124. X(see options \fB\-m\fR and \fB\-t\fR) the log
  125. Xwill remain empty. This option is useful for batch operation.
  126. X.IP \fB\-u\fR
  127. Xunlock object history upon save. This option is identical to 
  128. X\fB\-unlock\fR (see below).
  129. X.IP \fB\-a\ \fIafile\fR
  130. Xassign all the attributes specified in \fIafile\fR to the evolving
  131. Xnew versions. Attributes must be given in the form \fIname=value\fR
  132. Xwith one attribute specification per line and no white-space.
  133. XWhile the attribute value is optional, the \fIequal\fR symbol must
  134. Xbe present. If the \fB\-a\fR option is omitted, \fBsave\fR searches
  135. Xthe environment for a variable \fISVATTRS\fR. If this variable
  136. Xis absent, no user defined attributes will be assigned to the evolving
  137. Xversions.
  138. X.IP \fB\-m\ \fImessage\fR
  139. Xsets \fImessage\fR as descriptive note for all document versions 
  140. Xthat result from the invocation of \fBsave\fR. This option is alternative
  141. Xto \fB\-t\fR which overrides \fB\-m\fR.
  142. X.IP \fB\-n\ \fIname\fR
  143. Xassigns a symbolic name \fIname\fR to the saved version. In more detail,
  144. Xan attribute \fISYMNAME\fR is set to the value specified in \fIname\fR.
  145. XThe specified symbolic name must not be assigned to any other version
  146. Xwithin the same object history.
  147. X.IP \fB\-p\ \fIproject\fR
  148. Xspecifies the name of a project to provide a \fIproject context\fR
  149. Xin which the save operation takes place. This project context may 
  150. Xdetermine a number of addtional parameters that affect the overall
  151. Xbehaviour of the save command. Such parameters might be
  152. Xa set of standard attributes that are to be assigned to evolving versions
  153. Xcertain permissions or some general project policy.
  154. X.br
  155. X\fHUNIMPLEMENTED FEATURE.\fR
  156. X.IP \fB\-setvnum\ \fI<version>\fR
  157. Xsets the version number of the newly created revision to \fIversion\fR.
  158. XThe \fIversion\fR must be given in the format \fI<generation>.<revision>\fR
  159. Xwhere \fIgeneration\fR and \fIrevision\fR are integers. Example:
  160. X.RS
  161. X.DS
  162. X\fCsave -setvnum 4.3 mkattr.c\fR
  163. X.DE
  164. XThe specified \fIversion\fR must be greater than the highest previously
  165. Xassigned version number in a given object history. \fB\-setvnum\fR
  166. Xis useful for keeping consistent version numbering across related, physically
  167. Xdifferent object bases, or for converting archive formats of other
  168. Xrevision control systems to this toolkit (see: \fBrcs2afs\fR).
  169. X.RE
  170. X.IP \fB\-t\ \fIfile\fR
  171. Xsets the text contained in \fIfile\fR as descriptive note for all document
  172. Xversions that result from the invocation of \fBsave\fR. This option is
  173. Xalternative to \fB\-m\fR which is superseded by \fB\-t\fR.
  174. X.IP \fB\-unlock\fR
  175. Xgives up the lock for the object history into which the new revision
  176. Xof a file is saved. Upon unlocking the history, the user is prompted 
  177. Xfor a description of the applied changes with the original \fIchange 
  178. Xintent\fR (see \fBretrv \-lock\fR and \fBvadm -lock\fR) as initial
  179. Xcomment. This comment might be edited appropriately. The change intention
  180. Xis cleared afterwards.
  181. X.IP \fB\-version\fR
  182. Xprints the version of the program itself.
  183. X.SH FILES
  184. XAll revisions of documents are stored in archive files in the subdirectory
  185. XAFS.
  186. X.SH SEE ALSO
  187. Xretrv(1), rsrv(1), sbmt(1), shape(1), vadm(1), vl(1), 
  188. Xaf_intro(3), af_archive(5)
  189. X.SH BUGS
  190. XProject support is unimplemented.
  191. X.PP
  192. XSupport of user-defined attributes is rudimentary. Specification of such
  193. Xattributes must be syntactically correct.
  194. X.PP
  195. X\fBsave\fR neither reads the \fIShapefile\fR nor the \fIMakefile\fR and
  196. Xconsequently sticks with the 'individual document level' rather than to
  197. Xsupport the saving of entire systems or subsystems (higer level targets
  198. Xin \fI{Shape,Make}file\fRs).
  199. X.SH AUTHOR
  200. XAxel Mahler
  201. X.br
  202. XTechnical University Berlin
  203. X.sp
  204. X\fIUUCP:\fR        axel@coma.uucp (unido!coma!axel)
  205. X.br
  206. X\fIBITNET:\fR    axel@db0tui62
  207. END_OF_FILE
  208. if test 7936 -ne `wc -c <'man/man1/save.1'`; then
  209.     echo shar: \"'man/man1/save.1'\" unpacked with wrong size!
  210. fi
  211. # end of 'man/man1/save.1'
  212. fi
  213. if test -f 'src/inc/afs.h' -a "${1}" != "-c" ; then 
  214.   echo shar: Will not clobber existing file \"'src/inc/afs.h'\"
  215. else
  216. echo shar: Extracting \"'src/inc/afs.h'\" \(8320 characters\)
  217. sed "s/^X//" >'src/inc/afs.h' <<'END_OF_FILE'
  218. X/*
  219. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  220. X *  and U. Pralle
  221. X * 
  222. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  223. X * WARRANTY for any part of this software to work correctly or as described
  224. X * in the manuals. We do not accept any liability for any kind of damage
  225. X * caused by use of this software, such as loss of data, time, money, or 
  226. X * effort.
  227. X * 
  228. X * Permission is granted to use, copy, modify, or distribute any part of
  229. X * this software as long as this is done without asking for charge, and
  230. X * provided that this copyright notice is retained as part of the source
  231. X * files. You may charge a distribution fee for the physical act of
  232. X * transferring a copy, and you may at your option offer warranty
  233. X * protection in exchange for a fee.
  234. X * 
  235. X * Direct questions to: Tech. Univ. Berlin
  236. X *              Wilfried Koch
  237. X *              Sekr. FR 5-6 
  238. X *              Franklinstr. 28/29
  239. X *              D-1000 Berlin 10, West Germany
  240. X * 
  241. X *              Tel: +49-30-314-22972
  242. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  243. X */
  244. X/*
  245. X *    Shape/AFS
  246. X *
  247. X *    afs.h - Type and Constant-Definitions for the 
  248. X *        Attribute-Filesystem
  249. X *
  250. X *    Author:    Andreas Lampen (andy@coma.UUCP
  251. X *                andy@db0tui62.BITNET)
  252. X *
  253. X *    $Header: afs.h[1.4] Wed Feb 22 16:29:43 1989 andy@coma published $
  254. X */
  255. X
  256. X#ifndef _AFSHDR_
  257. X#define _AFSHDR_
  258. X
  259. X/*=========================================================================
  260. X * Installation dependent constants 
  261. X *=========================================================================*/
  262. X
  263. X#include <stdio.h>
  264. X#include <sys/types.h>
  265. X#ifndef MAXNAMLEN
  266. X#include <sys/dir.h>
  267. X#endif
  268. X#include <sys/param.h>
  269. X
  270. X#define MAXTYPLEN      256
  271. X#define MAXVARLEN      256
  272. X#define MAXUSERNAMELEN 64
  273. X
  274. X/*=========================================================================
  275. X * External Type Definitions
  276. X *=========================================================================*/
  277. X
  278. X#include "afsys.h"
  279. X
  280. X/**** filekey ****/
  281. Xtypedef struct {
  282. X        Af_revlist *af_ldes;        /* ptr to revlist descriptor */
  283. X        int        af_lpos;             /* position in revlist */
  284. X           } Af_key;
  285. X
  286. X/**** Set descriptor ****/
  287. Xtypedef struct {
  288. X        int    af_nkeys;
  289. X        int    af_setlen;
  290. X        Af_key    *af_klist;
  291. X           } Af_set;
  292. X
  293. X/**** User Identification ****/
  294. Xtypedef struct {
  295. X                char    af_username[MAXUSERNAMELEN];
  296. X        char    af_userhost[MAXHOSTNAMELEN];
  297. X           } Af_user;
  298. X
  299. X/**** Attribute buffer ****/
  300. Xtypedef struct {
  301. X        char    af_host[MAXHOSTNAMELEN]; /* hostname */
  302. X        char    af_syspath[MAXNAMLEN+1]; /* system path */
  303. X        char    af_name[MAXNAMLEN+1];    /* filename */
  304. X        char    af_type[MAXTYPLEN];    /* filename extension (type) */
  305. X        int    af_gen;            /* generation number */
  306. X        int    af_rev;            /* revision number */
  307. X        char    af_variant[MAXVARLEN];  /* variant attribute */
  308. X        int    af_state;        /* version state (see below) */
  309. X        Af_user af_owner;        /* owner */
  310. X        Af_user af_author;        /* author */
  311. X        off_t   af_size;                /* size of file */
  312. X        u_short af_mode;        /* protection (from inode) */
  313. X        Af_user af_locker;              /* locker */
  314. X        time_t    af_mtime;        /* date of last modification */
  315. X        time_t    af_atime;        /* date of last access */
  316. X        time_t    af_ctime;        /* date of last status change*/
  317. X        time_t    af_stime;        /* save date */
  318. X        time_t  af_ltime;               /* date of last lock change */
  319. X        char    *af_udattrs[AF_MAXUDAS]; /* user def. attributes */
  320. X           } Af_attrs;
  321. X
  322. X/*=========================================================================
  323. X * Constant Definitions
  324. X *=========================================================================*/
  325. X
  326. X/**** Version states ****/
  327. X
  328. X#define AF_NOSTATE     -1
  329. X#define    AF_BUSY        0
  330. X#define AF_SAVED    1
  331. X#define AF_PROPOSED    2
  332. X#define AF_PUBLISHED    3
  333. X#define AF_ACCESSED    4
  334. X#define AF_FROZEN    5
  335. X
  336. X/**** Settings for Attrbuf ****/
  337. X
  338. X#define AF_NONAME       "\0"
  339. X#define AF_NOTYPE       "\0"
  340. X#define AF_NOVNUM    -1
  341. X#define AF_NOSIZE    -1
  342. X#define AF_NOMODE    0
  343. X#define AF_NOTIME       -1
  344. X
  345. X/**** Modes ****/
  346. X
  347. X#define AF_ADD          1   /* user-defined attributes */
  348. X#define AF_REMOVE       2   /* " */
  349. X#define AF_REPLACE      3   /* " */
  350. X
  351. X#define AF_BUSYVERS     -2   /* version identification */
  352. X#define AF_FIRSTVERS    -3   /* " */
  353. X#define AF_LASTVERS     -4   /* " */
  354. X
  355. X#define AF_LASTPOS      -4   /* set position */
  356. X
  357. X/**** Object classes ****/
  358. X
  359. X#define AF_SOURCE       00
  360. X#define AF_DERIVED      01
  361. X#define AF_VALID        02
  362. X
  363. X/**** Locking Modes ****/
  364. X
  365. X#define AF_VERSIONLOCK   0
  366. X#define AF_GLOBALLOCK    1
  367. X
  368. X/*=========================================================================
  369. X * Attribute names
  370. X *=========================================================================*/
  371. X
  372. X#define AF_UDANAMLEN    128       /* maximum length of uda name */
  373. X#define AF_ATTNUM       20        /* number of attrributes in attrbuf */
  374. X
  375. X#define AF_ATTHOST    "af_host"
  376. X#define AF_ATTSPATH    "af_syspath"
  377. X#define AF_ATTNAME      "af_name"
  378. X#define AF_ATTTYPE      "af_type"
  379. X#define AF_ATTGEN    "af_gen"
  380. X#define AF_ATTREV    "af_rev"
  381. X#define AF_ATTVARIANT   "af_variant"
  382. X#define AF_ATTVERSION    "af_version" /* compound attribute: gen.rev */
  383. X#define AF_ATTHUMAN     "af_human"   /* compound name,type,gen,rev,variant */
  384. X#define AF_ATTSTATE    "af_state"
  385. X#define AF_ATTOWNER    "af_owner"
  386. X#define AF_ATTAUTHOR    "af_author"
  387. X#define AF_ATTSIZE      "af_size"
  388. X#define AF_ATTMODE      "af_mode"
  389. X#define AF_ATTLOCKER    "af_locker"
  390. X#define AF_ATTMTIME    "af_mtime"
  391. X#define AF_ATTATIME    "af_atime"
  392. X#define AF_ATTCTIME    "af_ctime"
  393. X#define AF_ATTSTIME    "af_stime"
  394. X#define AF_ATTLTIME    "af_ltime"
  395. X
  396. X
  397. X
  398. X/*=========================================================================
  399. X * Errorcodes
  400. X *=========================================================================*/
  401. X
  402. X/* General */
  403. X#define AF_OK         0
  404. X
  405. X#define AF_ESYSERR     -2    /* Error during execution of Syslib-command */
  406. X#define AF_EACCES        -3     /* permission denied */
  407. X#define AF_EARCHANGED    -4     /* archive has changed since last read */
  408. X#define AF_EARLOCKED     -5     /* archive is locked for writing */
  409. X#define AF_EBPFULL       -6     /* no additional place in binary pool */
  410. X#define AF_EBUSY         -7     /* spec. revision must not be a busy version */
  411. X#define AF_EDERIVED      -8     /* spec. revision is a derived object */
  412. X#define AF_EFORMAT       -9     /* illegal format of var or uda string */
  413. X#define AF_EINVKEY     -10    /* invalid key */
  414. X#define AF_EINVSET    -11     /* invalid set */
  415. X#define AF_EINVUSER     -12     /* invalid user */
  416. X#define AF_EINVVNUM     -13     /* bad version number */
  417. X#define AF_ELOC        -14    /* invalid location of archive */
  418. X#define AF_EMISC        -15     /* miscellaneous errors */
  419. X#define AF_EMODE        -16     /* invalid mode */
  420. X#define AF_ENOAFSDIR    -17     /* no AFS subdirectory */
  421. X#define AF_ENOKEY       -18     /* key does not exist in set */
  422. X#define AF_ENOPOS       -19     /* invalid position in set */
  423. X#define AF_ENOREV       -20     /* specified revision does not exist */
  424. X#define AF_ENOTBUSY     -21     /* specified object is no busy version */
  425. X#define AF_ENOTDERIVED  -22     /* specified object is no derived object */
  426. X#define AF_ENOTLOCKED   -23     /* version is not locked or - by another user*/
  427. X#define AF_ENOTREGULAR  -24     /* specified object is no regular file */
  428. X#define AF_ENOTVERS     -25     /* specified object has no versions */
  429. X#define AF_ENOUDA       -26     /* user defined attribute does not exist */
  430. X#define AF_ESAVED       -27     /* saved versions cannot be modified */
  431. X#define AF_ESTATE    -28    /* invalid state transition */
  432. X#define AF_ETOOLONG     -29     /* string too long */
  433. X#define AF_EUDASNUM     -30     /* too many user defined attributes */
  434. X#define AF_EWRONGSTATE  -31     /* wrong state */
  435. X
  436. X/* codes for really serious errors */
  437. X#define AF_EDELTA       -32     /* error during delta operation */
  438. X#define AF_EINCONSIST    -33    /* Archive file inconsistent */
  439. X#define AF_EINTERNAL    -34    /* internal error */
  440. X#define AF_ENOAFSFILE   -35     /* no AFS file */
  441. X
  442. X/*=========================================================================
  443. X * Declarations
  444. X *=========================================================================*/
  445. X
  446. Xchar *af_afname(), *af_afpath(), *af_aftype(), *af_rvariant();
  447. Xchar *af_rname(), *af_rsyspath(), *af_rtype(), *af_rnote(), *af_rudattr();
  448. XFILE *af_open();
  449. XAf_user *af_lock(), *af_unlock(), *af_testlock(), *af_rowner(), *af_rauthor();
  450. XAf_user *af_getuser();
  451. Xvoid af_perror();
  452. X
  453. X#endif /* __AFSHDR__ */
  454. X
  455. END_OF_FILE
  456. if test 8320 -ne `wc -c <'src/inc/afs.h'`; then
  457.     echo shar: \"'src/inc/afs.h'\" unpacked with wrong size!
  458. fi
  459. # end of 'src/inc/afs.h'
  460. fi
  461. if test -f 'src/shape/inherit.c' -a "${1}" != "-c" ; then 
  462.   echo shar: Will not clobber existing file \"'src/shape/inherit.c'\"
  463. else
  464. echo shar: Extracting \"'src/shape/inherit.c'\" \(8336 characters\)
  465. sed "s/^X//" >'src/shape/inherit.c' <<'END_OF_FILE'
  466. X/*
  467. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  468. X *  and U. Pralle
  469. X * 
  470. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  471. X * WARRANTY for any part of this software to work correctly or as described
  472. X * in the manuals. We do not accept any liability for any kind of damage
  473. X * caused by use of this software, such as loss of data, time, money, or 
  474. X * effort.
  475. X * 
  476. X * Permission is granted to use, copy, modify, or distribute any part of
  477. X * this software as long as this is done without asking for charge, and
  478. X * provided that this copyright notice is retained as part of the source
  479. X * files. You may charge a distribution fee for the physical act of
  480. X * transferring a copy, and you may at your option offer warranty
  481. X * protection in exchange for a fee.
  482. X * 
  483. X * Direct questions to: Tech. Univ. Berlin
  484. X *              Wilfried Koch
  485. X *              Sekr. FR 5-6 
  486. X *              Franklinstr. 28/29
  487. X *              D-1000 Berlin 10, West Germany
  488. X * 
  489. X *              Tel: +49-30-314-22972
  490. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  491. X */
  492. X#ifndef lint
  493. Xstatic char *RCSid = "$Header: inherit.c,v 3.2 89/02/15 16:24:39 wolfgang Exp $";
  494. X#endif
  495. X#ifndef lint
  496. Xstatic char *ConfFlg = CFFLGS;    /* should be defined from within Makefile */
  497. X#endif
  498. X/*
  499. X * $Log:    inherit.c,v $
  500. X * Revision 3.2  89/02/15  16:24:39  wolfgang
  501. X * bug fixed.
  502. X * 
  503. X * Revision 3.1  89/02/06  14:25:20  wolfgang
  504. X * calls of forbidden() cahnged
  505. X * 
  506. X * Revision 3.0  89/01/24  11:35:46  wolfgang
  507. X * New System Generation
  508. X * 
  509. X * Revision 1.15  89/01/03  13:10:48  wolfgang
  510. X * changes done for lint
  511. X * 
  512. X * Revision 1.14  88/12/22  13:23:16  wolfgang
  513. X * minor bug fixed.
  514. X * 
  515. X * Revision 1.13  88/12/21  15:03:29  wolfgang
  516. X * changes done for lint
  517. X * 
  518. X * Revision 1.12  88/12/19  13:22:59  wolfgang
  519. X * forbidden() & finddep() added.
  520. X * 
  521. X * Revision 1.9  88/11/21  15:51:01  wolfgang
  522. X * return code of all malloc's checked
  523. X * 
  524. X * Revision 1.8  88/11/09  16:26:30  wolfgang
  525. X * bug fixed in comapare_attrstring(). dropset was located wrong
  526. X * 
  527. X * Revision 1.7  88/11/08  19:28:33  wolfgang
  528. X * expandall or expandnothing added to ATTR-string
  529. X * 
  530. X * Revision 1.6  88/11/08  18:07:07  wolfgang
  531. X * inheritance changed: attributes should now be correct.
  532. X * 
  533. X * Revision 1.5  88/11/04  16:43:50  wolfgang
  534. X * This version is part of a release
  535. X * 
  536. X * Revision 1.4  88/09/20  10:03:54  wolfgang
  537. X * bug fixed. concatenation of vflags was not correct.
  538. X * 
  539. X * Revision 1.3  88/08/18  10:25:49  wolfgang
  540. X * This version is part of a release
  541. X * 
  542. X * Revision 1.2  88/08/12  08:58:09  wolfgang
  543. X * This version is part of a release
  544. X * 
  545. X */
  546. X
  547. X#include "shape.h"
  548. X
  549. Xextern char *expandmacro();
  550. Xextern char *build_attrstring();
  551. Xextern int error();
  552. Xextern void warning();
  553. Xextern Af_attrs buft;
  554. Xextern char *longattrs[];
  555. Xextern int depth;
  556. Xextern Bool error_occ;
  557. Xextern Bool finddep();
  558. Xextern Bool forbidden();
  559. Xextern struct rules *get_target();
  560. X
  561. Xsave_targets(rulename, srcname, objrulename,attrstr)
  562. X     struct rules *rulename;
  563. X     char *srcname;
  564. X     struct rules *objrulename;
  565. X     char *attrstr;
  566. X{
  567. X  Af_key busykey, savekey;
  568. X  char *syspath;
  569. X  char *name;
  570. X  char *type;
  571. X  int gen = AF_BUSYVERS;
  572. X  int rev = AF_BUSYVERS;
  573. X  char attr[MAXATTRLENGTH];
  574. X  char *p;
  575. X  int retcode;
  576. X  char savepath[MAXNAMLEN];
  577. X
  578. X#ifdef NOBPOOL
  579. X  return;
  580. X#endif NOBPOOL
  581. X
  582. X  if(error_occ)
  583. X    {
  584. X      error_occ = FALSE;
  585. X      return;
  586. X    }
  587. X
  588. X  if(noexflg)
  589. X    return;
  590. X
  591. X  if ((rindex(srcname,'/')) != NIL)
  592. X    {
  593. X      (void) strcpy(savepath,srcname);
  594. X      p = rindex(savepath,'/');
  595. X      *p = '\0';
  596. X      p++;
  597. X      srcname = p;
  598. X      syspath = &savepath[0];
  599. X    }
  600. X  else
  601. X    syspath = curvpath[0];
  602. X
  603. X  if(objrulename != (struct rules *) NIL)
  604. X    {
  605. X      if((name = malloc((unsigned) (strlen(objrulename->name) + 1))) == NIL)
  606. X    errexit(10,"malloc");
  607. X      (void) strcpy(name, objrulename->name);
  608. X    }
  609. X  else
  610. X    {
  611. X      if((name = malloc((unsigned) (strlen(srcname) + 1))) == NIL)
  612. X     errexit(10,"malloc");
  613. X      (void) strcpy(name,srcname);
  614. X    }
  615. X
  616. X  if (rulename->name[0] == '%')
  617. X    {
  618. X      if((p = rindex(name,'.')) != NIL)
  619. X    {
  620. X      *p = '\0';
  621. X      (void) strcat(name, rulename->name+1);
  622. X    }
  623. X    }
  624. X
  625. X  if ((p = rindex(name,'.')) != NIL)
  626. X    {
  627. X      *p = '\0';
  628. X      type = p+1;
  629. X    }
  630. X  else
  631. X    type = NIL;
  632. X
  633. X
  634. X  if ((af_getkey(syspath,name,type,gen,rev,NIL,&busykey)) == -1)
  635. X    errexit(10, "af_getkey");
  636. X
  637. X  af_errno = 0; /* sollte nocht sein */
  638. X
  639. X  retcode = af_sudattr(&busykey,AF_REMOVE,ATTRNAME);
  640. X
  641. X  if ((retcode == -1) && (af_errno == AF_ENOAFSDIR))
  642. X    {
  643. X      af_initattrs(&buft);
  644. X      af_dropkey(&busykey);
  645. X      return;
  646. X    }
  647. X  
  648. X  if ((retcode == -1) && (af_errno != AF_ENOUDA) &&
  649. X      (af_errno != AF_ENOAFSDIR))
  650. X    errexit(10,"af_sudattr");
  651. X
  652. X  if ((bpoolflg) || (nobpoolflg))
  653. X    {
  654. X      if(!forbidden(syspath,name,type))
  655. X    {
  656. X      if ((af_savebinary(&busykey,&savekey)) == -1)
  657. X        {
  658. X          if(af_errno == AF_ENOAFSDIR)
  659. X        warning(1,NIL);
  660. X          else
  661. X        errexit(10, "af_savebinary");
  662. X        }
  663. X    }
  664. X    }
  665. X
  666. X  if(attrstr[0] == '\0')
  667. X    (void) strcpy(attr,build_attrstring(rulename,srcname,objrulename));
  668. X  else
  669. X    (void) strcpy(attr,attrstr);
  670. X
  671. X  if ((bpoolflg) || (nobpoolflg))
  672. X    {
  673. X      if(!forbidden(syspath,name,type))
  674. X    {
  675. X      retcode = af_sudattr(&savekey,AF_REPLACE,attr);
  676. X      if (retcode == -1)
  677. X        {
  678. X          retcode = af_sudattr(&savekey,AF_ADD,attr);
  679. X          if ((retcode == -1) && (af_errno != AF_ETOOLONG) &&
  680. X          (af_errno != AF_ENOAFSDIR))
  681. X        errexit(10,"af_sudattr");
  682. X          if (af_errno == AF_ETOOLONG)
  683. X        {
  684. X          retcode = af_errno;
  685. X          /* attrs are too long */
  686. X          if ((af_rm(&savekey)) == -1)
  687. X            errexit(10,"af_rm");
  688. X        }
  689. X        }
  690. X      if (retcode != AF_ETOOLONG)
  691. X        {
  692. X          if (buft.af_gen != -1)
  693. X        {
  694. X          if ((af_svnum(&savekey,buft.af_gen,buft.af_rev)) == -1)
  695. X            errexit(10,"af_svnum");
  696. X        }
  697. X          else
  698. X        {
  699. X          if ((af_svnum(&savekey,AF_BUSYVERS,AF_BUSYVERS)) == -1)
  700. X            errexit(10,"af_svnum");
  701. X        }
  702. X        }
  703. X      af_dropkey(&savekey);
  704. X    }
  705. X    }
  706. X
  707. X  if ((af_sudattr(&busykey,AF_REPLACE,attr)) == -1)
  708. X    {
  709. X      if ((af_sudattr(&busykey,AF_ADD,attr)) == -1)
  710. X    errexit(10,"af_sudattr");
  711. X    }
  712. X  af_initattrs(&buft);
  713. X}
  714. X
  715. Xchar *build_attrstring(rulename,srcname,objrulename)
  716. X     struct rules *rulename;
  717. X     /*ARGSUSED*/
  718. X     char *srcname;
  719. X     struct rules *objrulename;
  720. X
  721. X{
  722. X  char attr[MAXATTRLENGTH];
  723. X  int i = 0;
  724. X  char *p;
  725. X
  726. X  attr[0] = '\0';
  727. X  (void) strcpy(attr,ATTRNAME);
  728. X  
  729. X  if(expflg)
  730. X    (void) strcat(attr,"expandall");
  731. X  if(noexpflg)
  732. X    (void) strcat(attr,"expandnothing");
  733. X
  734. X  for( i = 0; rulename->targetlist[i] != NIL; i++)
  735. X    {
  736. X      (void) strcat(attr,rulename->targetlist[i] + 1);
  737. X    }
  738. X  for(i = 0; rulename->heritage[i] != NIL; i++)
  739. X    {
  740. X      (void) strcat(attr, rulename->heritage[i]);
  741. X      (void) strcat(attr,"=");
  742. X      (void) strcat(attr,rulename->heritage[i]);
  743. X      p = rindex(attr,'+');
  744. X      *p = '$';
  745. X      (void) strcpy(attr,expandmacro(attr));
  746. X    }
  747. X
  748. X/*  if (buft.af_gen != -1)
  749. X    {
  750. X       (void) sprintf(attr,"%sversion=%d.%d",attr,buft.af_gen,buft.af_rev);
  751. X    }
  752. X    else
  753. X    (void) sprintf(attr,"%sversion=%d.%d",attr,AF_BUSYVERS,AF_BUSYVERS); */
  754. X  (void) strcat(attr, longattrs[depth]);
  755. X  (void) strcpy(longattrs[depth],attr);
  756. X  return(attr);
  757. X}
  758. X
  759. X
  760. XBool forbidden(syspath,name,type)
  761. X     char *syspath;
  762. X     char *name;
  763. X     char *type;
  764. X{
  765. X  char fullname[MAXNAMLEN];
  766. X  Bool bp = FALSE;
  767. X  Bool nobp = FALSE;
  768. X  struct rules *bpool;
  769. X  struct rules *nobpool;
  770. X  
  771. X  fullname[0] = '\0';
  772. X  if (strcmp(syspath,curvpath[0]))
  773. X    {
  774. X      (void) strcpy(fullname,syspath);
  775. X      (void) strcat(fullname,"/");
  776. X      (void) strcat(fullname,name);
  777. X    }
  778. X  else
  779. X    {
  780. X      (void) strcpy(fullname,name);
  781. X    }
  782. X
  783. X  if (type != NIL)
  784. X    {
  785. X      (void) strcat(fullname,".");
  786. X      (void) strcat(fullname,type);
  787. X    }
  788. X
  789. X  bpool = get_target(".BPOOL");
  790. X  nobpool = get_target(".NOBPOOL");
  791. X
  792. X  if (bpool != (struct rules *) NIL)
  793. X    {
  794. X      bp = finddep(bpool,fullname);
  795. X    }
  796. X  else
  797. X    bp = TRUE;
  798. X  
  799. X  if (nobpool != (struct rules *) NIL)
  800. X    {
  801. X      nobp = finddep(nobpool,fullname);
  802. X    }
  803. X
  804. X  if (bp && nobp)
  805. X    return(TRUE);
  806. X
  807. X  if (bp && (!nobp))
  808. X    return(FALSE);
  809. X
  810. X  if ((!bp) && nobp)
  811. X    return(TRUE);
  812. X  
  813. X  if ((!bp) && (!nobp))
  814. X    return(TRUE);
  815. X/*NOTREACHED*/
  816. Xreturn(FALSE);
  817. X}
  818. X
  819. XBool finddep(rule,name)
  820. X     struct rules *rule;
  821. X     char *name;
  822. X{
  823. X  int i = 0;
  824. X  while(rule->deplist[i] != NIL)
  825. X    {
  826. X      if (!strcmp(rule->deplist[i],name))
  827. X    return(TRUE);
  828. X      i++;
  829. X    }
  830. X  return(FALSE);
  831. X}
  832. END_OF_FILE
  833. if test 8336 -ne `wc -c <'src/shape/inherit.c'`; then
  834.     echo shar: \"'src/shape/inherit.c'\" unpacked with wrong size!
  835. fi
  836. # end of 'src/shape/inherit.c'
  837. fi
  838. if test -f 'src/shape/main.c' -a "${1}" != "-c" ; then 
  839.   echo shar: Will not clobber existing file \"'src/shape/main.c'\"
  840. else
  841. echo shar: Extracting \"'src/shape/main.c'\" \(8311 characters\)
  842. sed "s/^X//" >'src/shape/main.c' <<'END_OF_FILE'
  843. X/*
  844. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  845. X *  and U. Pralle
  846. X * 
  847. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  848. X * WARRANTY for any part of this software to work correctly or as described
  849. X * in the manuals. We do not accept any liability for any kind of damage
  850. X * caused by use of this software, such as loss of data, time, money, or 
  851. X * effort.
  852. X * 
  853. X * Permission is granted to use, copy, modify, or distribute any part of
  854. X * this software as long as this is done without asking for charge, and
  855. X * provided that this copyright notice is retained as part of the source
  856. X * files. You may charge a distribution fee for the physical act of
  857. X * transferring a copy, and you may at your option offer warranty
  858. X * protection in exchange for a fee.
  859. X * 
  860. X * Direct questions to: Tech. Univ. Berlin
  861. X *              Wilfried Koch
  862. X *              Sekr. FR 5-6 
  863. X *              Franklinstr. 28/29
  864. X *              D-1000 Berlin 10, West Germany
  865. X * 
  866. X *              Tel: +49-30-314-22972
  867. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  868. X */
  869. X#ifndef lint
  870. Xstatic char *RCSid = "$Header: main.c,v 3.1 89/02/20 16:25:58 wolfgang Exp $";
  871. X#endif
  872. X#ifndef lint
  873. Xstatic char *ConfFlg = CFFLGS;    /* should be defined from within Makefile */
  874. X#endif
  875. X/*
  876. X * $Log:    main.c,v $
  877. X * Revision 3.1  89/02/20  16:25:58  wolfgang
  878. X * NET-RELEASE
  879. X * 
  880. X * Revision 3.0  89/01/24  11:36:03  wolfgang
  881. X * New System Generation
  882. X * 
  883. X * Revision 2.16  89/01/18  13:42:29  wolfgang
  884. X * call of init_selruletab() added.
  885. X * 
  886. X * Revision 2.15  89/01/03  13:11:31  wolfgang
  887. X * changes done for lint
  888. X * 
  889. X * Revision 2.14  88/12/22  13:22:33  wolfgang
  890. X * initializarion of bpoolflg added.
  891. X * 
  892. X * Revision 2.13  88/12/21  15:10:52  wolfgang
  893. X * changes done for lint
  894. X * 
  895. X * Revision 2.12  88/11/22  17:37:23  wolfgang
  896. X * This version is part of a release
  897. X * 
  898. X * Revision 2.11  88/11/21  15:50:36  wolfgang
  899. X * return code of all malloc's checked
  900. X * 
  901. X * Revision 2.10  88/10/10  14:16:58  wolfgang
  902. X * feature for -p option added.
  903. X * 
  904. X * Revision 2.9  88/09/22  16:16:24  wolfgang
  905. X * call of cleanup_links changed. call of shape_cleanup added.
  906. X * 
  907. X * Revision 2.8  88/09/22  10:02:17  wolfgang
  908. X * declaration of ruleset changed.
  909. X * 
  910. X * Revision 2.7  88/09/07  11:21:13  wolfgang
  911. X * changes for include mechanism: now a tmp file is produced which
  912. X * contains all input files for shape.
  913. X * 
  914. X * Revision 2.6  88/08/25  15:17:19  wolfgang
  915. X * stdmacros changed: the macros for sccs replaced by two macros
  916. X * for shape: SHAPEFLAGS & SHAPE.
  917. X * 
  918. X * Revision 2.5  88/08/23  16:38:06  wolfgang
  919. X * Rebuild feature added (to rebuild something from a confid).
  920. X * 
  921. X * Revision 2.4  88/08/23  10:24:28  wolfgang
  922. X * Changed ruledump() to ruledump(fd) to be able to use it for
  923. X * generating confid's.
  924. X * 
  925. X * Revision 2.3  88/08/22  17:02:12  wolfgang
  926. X * dump() changed to dump(fd).
  927. X * finis_confid added.
  928. X * 
  929. X * Revision 2.2  88/08/22  10:12:15  wolfgang
  930. X * Changed main.c, so that it is no longer necessary to have a description
  931. X * file. It's enaugh to have the name of a target to produce on the command
  932. X * line
  933. X * 
  934. X * Revision 2.1  88/08/19  10:17:37  wolfgang
  935. X * This version is part of a release
  936. X * 
  937. X */
  938. X
  939. X#include "shape.h"
  940. X#include "ParseArgs.h"
  941. X
  942. X#include <stdio.h>
  943. X
  944. X#define MAXCMDTARGETS 32
  945. X
  946. Xextern char *getwd();
  947. Xextern char *mktemp();
  948. X
  949. Xextern int hashval();
  950. Xextern void addhash();
  951. Xextern int adjust_stdrules();
  952. Xextern int dump();
  953. Xextern int ruleend();
  954. Xextern int ruledump();
  955. Xextern int errexit();
  956. Xextern int init_ruletab();
  957. Xextern int init_selruletab();
  958. Xextern int seldump();
  959. Xextern int selruledef();
  960. Xextern int stdrules();
  961. Xextern Bool is_selrule_name();
  962. Xextern int catch_sigs();
  963. X
  964. Xextern int yylex();
  965. Xextern FILE *yyin;
  966. Xextern FILE *vmfopen();
  967. X
  968. Xextern int cleanup_links();
  969. Xextern int af_cleanup();
  970. X
  971. Xextern struct linkreg *link_reg;
  972. X
  973. Xextern char *firsttarget;
  974. Xextern char ruleset[];
  975. Xextern char *stdsuff;
  976. X
  977. Xextern struct selection_rules *currule;
  978. Xextern char *busy_rule;
  979. Xextern char *longattrs[];
  980. Xextern char *template;
  981. Xextern FILE *temp;
  982. Xchar rbfile[MAXNAMLEN];
  983. X
  984. Xchar *filenames[] = {"Shapefile", "shapefile", "Makefile", "makefile"};
  985. X
  986. X#define STDMACROS 29
  987. X
  988. Xchar *stdmacros[] = { "SHAPEFLAGS=","SHAPE=shape","ASFLAGS=","AS=as",
  989. X            "RFLAGS=","FFLAGS=","FC=f77","M2FLAGS=",
  990. X            "M2C=m2c","PFLAGS=","PC=pc","CFLAGS=",
  991. X            "CC=cc","LDFLAGS=","LD=ld","LFLAGS=",
  992. X            "LEX=lex","YFLAGS=","YACC=yacc","MAKE=make",
  993. X            "$=$$","MFLAGS=-b","MAKEFLAGS=b",
  994. X                "@=$@", "?=$?", "<=$<", "*=$*",
  995. X            "+=$+"};
  996. X
  997. Xstruct linked_list *shapefiles = (struct linked_list *) NIL;
  998. X     /* list of names of files from
  999. X    command line via the -f option */
  1000. Xstruct linked_list *shfiles;
  1001. X
  1002. Xchar *cmdtargets[MAXCMDTARGETS];
  1003. X     /* list of target form the    command line */
  1004. X
  1005. X
  1006. XBool synterrflg = FALSE;
  1007. XBool Oldsuffs = FALSE;
  1008. XBool Newsuffs = FALSE;
  1009. Xchar *suffs;
  1010. X#ifdef MEMDEBUG
  1011. XFILE *memprot;
  1012. X#endif
  1013. X
  1014. Xmain(argc, argv)
  1015. X     int argc;
  1016. X     char **argv;
  1017. X     
  1018. X{
  1019. Xint newac = 0;
  1020. Xchar **newav;
  1021. X
  1022. Xint i;
  1023. Xint k = 0;
  1024. Xint gen = AF_BUSYVERS;
  1025. Xint rev = AF_BUSYVERS;
  1026. Xchar macrostr[2048];
  1027. Xextern OptDesc odesc[];
  1028. X
  1029. X#ifdef MEMDEBUG
  1030. Xmemprot = fopen ("memprot", "w");
  1031. X#endif
  1032. X
  1033. Xrebuildflg = FALSE;
  1034. Xbpoolflg = TRUE;
  1035. X
  1036. Xcatch_sigs(); 
  1037. X
  1038. Xif (argc != 1)
  1039. X  {
  1040. X    if(ParseArgs (argc, argv, &newac, &newav, odesc))
  1041. X      {
  1042. X    pa_ShortUsage(argv[0], odesc, "\n\t      rtfm! (read the manual)");
  1043. X    exit(1);
  1044. X      }
  1045. X  }
  1046. X
  1047. Xif ((curvpath[0] = malloc(MAXNAMLEN)) == NIL)
  1048. X  errexit(10,"malloc");
  1049. X(void) getwd(curvpath[0]);
  1050. Xinit_ruletab();
  1051. Xinit_selruletab();
  1052. X(void) mktemp(template);
  1053. Xtemp = fopen(template,"w");
  1054. Xif(logflg)
  1055. X  {
  1056. X    logfd = fopen("SHAPE.LOGFILE","a");
  1057. X    for (i = 0; i<argc; i++)
  1058. X      fprintf(logfd,"%s ", argv[i]);
  1059. X    fprintf(logfd,"\n");
  1060. X    (void) fclose(logfd);
  1061. X  }
  1062. X
  1063. Xfor(i = 0; i < newac; i++)
  1064. X  {
  1065. X    if (index(newav[i],'=') != NIL)
  1066. X      {
  1067. X    (void) strcpy(macrostr,newav[i]);
  1068. X    macrodef(macrostr);
  1069. X      }
  1070. X  }
  1071. X
  1072. Xfor (i = 0; i < STDMACROS; i++)
  1073. X     macrodef(stdmacros[i]);
  1074. X
  1075. X
  1076. Xif  (!rebuildflg)
  1077. X  {
  1078. X
  1079. X    if (fileflg)
  1080. X      {
  1081. X    shfiles = shapefiles;
  1082. X    while(shfiles != (struct linked_list *) NIL)
  1083. X      {
  1084. X        if ((yyin = vmfopen(shfiles->string,"r", gen, rev)) == (FILE *)NIL)
  1085. X          errexit(12,shfiles->string);
  1086. X        else
  1087. X          {
  1088. X        get_macros(yyin);
  1089. X        (void) fclose(yyin);
  1090. X          }
  1091. X        shfiles = shfiles->nextstring;
  1092. X      }
  1093. X    if (stdinflg == TRUE)
  1094. X      get_macros(stdin);
  1095. X      }
  1096. X    else
  1097. X      {
  1098. X    for ( i = 0; i <= 3; i++)
  1099. X      {
  1100. X        if ((yyin = vmfopen (filenames[i], "r", gen, rev)) != (FILE *)NIL) 
  1101. X          break;
  1102. X      }
  1103. X    if (yyin == (FILE *)NIL)
  1104. X      nostdfile = TRUE;
  1105. X    else
  1106. X      {
  1107. X        nostdfile = FALSE;
  1108. X        get_macros(yyin);
  1109. X        (void) fclose(yyin);
  1110. X      }
  1111. X      }
  1112. X  }
  1113. X
  1114. Xelse
  1115. X  {
  1116. X    if(( yyin = vmfopen(rbfile, "r", gen, rev)) == (FILE *) NIL)
  1117. X      errexit(12, rbfile);
  1118. X    get_macros(yyin);
  1119. X    (void) fclose(yyin);
  1120. X  }
  1121. X
  1122. X(void) fclose(temp);
  1123. X
  1124. Xfor(i = 0; i < newac; i++)
  1125. X  {
  1126. X    if (index(newav[i],'=') != NIL)
  1127. X      macrodef(newav[i]);
  1128. X    else
  1129. X      {
  1130. X    if ((cmdtargets[k] = malloc((unsigned) (strlen(newav[i]) + sizeof(char)))) == NIL)
  1131. X      errexit(10,"malloc");
  1132. X    (void) strcpy(cmdtargets[k++],newav[i]);
  1133. X    cmdtargets[k] = NIL;
  1134. X      }
  1135. X  }
  1136. X
  1137. Xadd_stdrules();
  1138. Xfirsttarget = NIL;
  1139. X
  1140. Xif ((yyin = fopen(template,"r")) == (FILE *)NIL)
  1141. X  errexit(12,template);
  1142. Xelse
  1143. X  {
  1144. X    (void) unlink(template);
  1145. X    (void) yylex();
  1146. X    (void) fclose(yyin);
  1147. X  }
  1148. X
  1149. X
  1150. Xif (synterrflg == TRUE)
  1151. X  errexit(15,NIL);
  1152. X
  1153. Xruleend(); /* just for security ????  */
  1154. X
  1155. Xadjust_stdrules(suffs);
  1156. X
  1157. X/* add busy rule */
  1158. X
  1159. Xselruledef(busy_rule);
  1160. X(void) is_selrule_name("-STD-");
  1161. X
  1162. Xinitattrfield();
  1163. X
  1164. Xproduce();
  1165. X/*
  1166. X#ifdef DEBUG_HASH
  1167. Xdump();
  1168. X#endif DEBUG_HASH
  1169. X#ifdef DEBUG_RULE
  1170. Xruledump(stdout);
  1171. X#endif DEBUG_RULE
  1172. X#ifdef DEBUG_SELRULE
  1173. Xseldump();
  1174. X#endif DEBUG_SELRULE */
  1175. X(void) fclose(yyin);
  1176. Xif (confid)
  1177. X  {
  1178. X    finish_confid();
  1179. X    af_close(cid);
  1180. X  }
  1181. Xif (debugflg)
  1182. X  {
  1183. X    if (suffs_deleted)
  1184. X      printf("no suffix list");
  1185. X    dump(stdout);  /* dumping macros */
  1186. X    ruledump(stdout); /* dumping targets, dependents & commands, resp. */
  1187. X  }
  1188. X
  1189. Xif (printflg)
  1190. X  {
  1191. X    if (suffs_deleted)
  1192. X      printf("no suffix list");
  1193. X    dump(stdout);  /* dumping macros */
  1194. X    ruledump(stdout); /* dumping targets, dependents & commands, resp. */
  1195. X  }
  1196. X
  1197. Xcleanup_links(link_reg);
  1198. Xaf_cleanup();
  1199. Xexit(0);
  1200. X}
  1201. X
  1202. Xint initattrfield()
  1203. X{
  1204. X  int i;
  1205. X  for(i = 0; i < MAXDEPTH; i++)
  1206. X    {
  1207. X      if((longattrs[i] = malloc(MAX_ATTR)) == NIL)
  1208. X    errexit(10,"malloc");
  1209. X      (void) strcpy(longattrs[i],"");
  1210. X    }
  1211. X}
  1212. X
  1213. X    
  1214. END_OF_FILE
  1215. if test 8311 -ne `wc -c <'src/shape/main.c'`; then
  1216.     echo shar: \"'src/shape/main.c'\" unpacked with wrong size!
  1217. fi
  1218. # end of 'src/shape/main.c'
  1219. fi
  1220. if test -f 'src/shape/shape.l' -a "${1}" != "-c" ; then 
  1221.   echo shar: Will not clobber existing file \"'src/shape/shape.l'\"
  1222. else
  1223. echo shar: Extracting \"'src/shape/shape.l'\" \(8084 characters\)
  1224. sed "s/^X//" >'src/shape/shape.l' <<'END_OF_FILE'
  1225. X%a 40000
  1226. X%p 20000
  1227. X%o 10000
  1228. X
  1229. X%{
  1230. X/*
  1231. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  1232. X *  and U. Pralle
  1233. X * 
  1234. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  1235. X * WARRANTY for any part of this software to work correctly or as described
  1236. X * in the manuals. We do not accept any liability for any kind of damage
  1237. X * caused by use of this software, such as loss of data, time, money, or 
  1238. X * effort.
  1239. X * 
  1240. X * Permission is granted to use, copy, modify, or distribute any part of
  1241. X * this software as long as this is done without asking for charge, and
  1242. X * provided that this copyright notice is retained as part of the source
  1243. X * files. You may charge a distribution fee for the physical act of
  1244. X * transferring a copy, and you may at your option offer warranty
  1245. X * protection in exchange for a fee.
  1246. X * 
  1247. X * Direct questions to: Tech. Univ. Berlin
  1248. X *              Wilfried Koch
  1249. X *              Sekr. FR 5-6 
  1250. X *              Franklinstr. 28/29
  1251. X *              D-1000 Berlin 10, West Germany
  1252. X * 
  1253. X *              Tel: +49-30-314-22972
  1254. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  1255. X */
  1256. X/*
  1257. X *    Scanner for SHAPE
  1258. X */
  1259. X
  1260. X#ifndef lint
  1261. Xstatic char *RCSid = "$Header: shape.l,v 3.1 89/02/14 11:06:40 wolfgang Exp $";
  1262. X#endif
  1263. X#ifndef lint
  1264. Xstatic char *ConfFlg = CFFLGS;    /* should be defined from within Makefile */
  1265. X#endif
  1266. X/*
  1267. X * $Log:    shape.l,v $
  1268. X * Revision 3.1  89/02/14  11:06:40  wolfgang
  1269. X * YYLMAX increased to 20000
  1270. X * 
  1271. X * Revision 3.0  89/01/24  11:35:50  wolfgang
  1272. X * New System Generation
  1273. X * 
  1274. X * Revision 2.13  89/01/18  13:17:10  wolfgang
  1275. X * bug fixed. didn't recognize lines with a single TAB as layout line.
  1276. X * 
  1277. X * Revision 2.12  89/01/03  13:10:56  wolfgang
  1278. X * changes done for lint
  1279. X * 
  1280. X * Revision 2.11  88/12/21  15:03:37  wolfgang
  1281. X * changes done for lint
  1282. X * 
  1283. X * Revision 2.10  88/11/21  15:49:23  wolfgang
  1284. X * return code of all malloc's checked
  1285. X * 
  1286. X * Revision 2.9  88/11/21  12:46:12  wolfgang
  1287. X * yyless deleted
  1288. X * 
  1289. X * Revision 2.8  88/10/18  17:42:31  wolfgang
  1290. X * new variant handling
  1291. X * 
  1292. X * Revision 2.7  88/10/06  15:41:10  wolfgang
  1293. X * no more macrodefs evaluated by lex
  1294. X * 
  1295. X * Revision 2.6  88/09/07  11:20:15  wolfgang
  1296. X * any2 changed ==> no comments are allowed within rule- or variant-section!
  1297. X * 
  1298. X * Revision 2.5  88/08/23  14:05:30  wolfgang
  1299. X * YYLMAX increased to 10000 (Scheiss LEX)
  1300. X * 
  1301. X * Revision 2.4  88/08/12  09:08:00  wolfgang
  1302. X * This version is part of a release
  1303. X * 
  1304. X * Revision 2.2  88/08/12  08:58:11  wolfgang
  1305. X * This version is part of a release
  1306. X * 
  1307. X */
  1308. X
  1309. X
  1310. X#include <stdio.h>
  1311. X#include <ctype.h>
  1312. X#include "shape.h"
  1313. X
  1314. Xextern char *malloc();
  1315. X
  1316. Xextern struct hash *hashtab[];
  1317. Xextern char *sel_rule_name;
  1318. Xextern Bool synterrflg;
  1319. Xextern Bool Oldsuffs;
  1320. Xextern Bool Newsuffs;
  1321. Xextern char *shaperules;
  1322. Xextern char *stdsuff;
  1323. Xextern char *expandmacro();
  1324. X
  1325. Xextern int macrodef();
  1326. Xextern int ruledef();
  1327. Xextern int rulecont();
  1328. Xextern int ruleend();
  1329. Xextern int selruledef();
  1330. Xextern int vclassdef();
  1331. Xextern int errexit();
  1332. X#undef YYLMAX
  1333. X#define YYLMAX 20000  /* Scheiss LEX */
  1334. Xchar *ppp;
  1335. Xextern char *suffs;
  1336. Xextern char *suffs;
  1337. XBool suffs_deleted = FALSE;
  1338. X%}
  1339. X%START RULEDEF RULESEC VARSEC
  1340. XWhiteSpace    [ \t\n]
  1341. XLayout        [ \t]
  1342. XBlank        " "
  1343. XColon        ":"
  1344. XPeriod        "."
  1345. XSemi        ";"
  1346. XSemiperiod    [;.]
  1347. XSemicomma    [;,]
  1348. XLayoutline    {Layout}*\n
  1349. XTab        \t
  1350. XNotab        [^\t]
  1351. XAny        .\n
  1352. XAny2        [^#]
  1353. XAnybutnewline    .
  1354. XNC1        "\\\n"
  1355. XNC3        "\\\n"
  1356. XNC2        [^#\n]*
  1357. XNC4        [^\n]*
  1358. XNocomment    ({NC1}*|{NC2}?)*\n?
  1359. XNocomment2    ({NC3}*|{NC4}?)*\n?
  1360. XMacroname    [0-9a-zA-Z_-]
  1361. XVcl        "::=".*
  1362. XVclass        "vclass"{Layout}*{Ruledef}{Nocomment}
  1363. XMacrodef    {Macroname}+{Layout}*"="{Layout}*{Nocomment}
  1364. XRulesecstart    "#%"{Layout}*"RULE-SECTION"{Layout}*
  1365. XRulesecend    "#%"{Layout}*"END-RULE-SECTION"{Layout}*
  1366. XSelectionrule    {Rulesecstart}+{Any2}*{Rulesecend}+
  1367. XVarsecstart    "#%"{Layout}*"VARIANT-SECTION"{Layout}*
  1368. XVarsecend    "#%"{Layout}*"END-VARIANT-SECTION"{Layout}*
  1369. XDepstart    [@%0-9a-zA-Z.\-/$("{""}")_~,]
  1370. XDepcont        [@%0-9a-zA-Z.\-/\t $("{""}")_~,+]
  1371. XSuff        [a-zA-Z0-9~,]
  1372. XRuledef        {Depstart}+{Depcont}*{Colon}+{Colon}*{Depcont}*{Nocomment}
  1373. XRulecont    {Tab}+{Nocomment2}
  1374. XOthers        [^#\n]
  1375. X%%
  1376. X
  1377. X{Selectionrule}    {
  1378. X#ifdef DEBUG_LEX
  1379. X        fprintf(yyout, "\nSelection Rule: %s\n", yytext);
  1380. X#endif DEBUG_LEX
  1381. X(void) strcpy(yytext,expandmacro(yytext));
  1382. X        selruledef(yytext);
  1383. X        }
  1384. X
  1385. X{Varsecstart}    {
  1386. X#ifdef DEBUG_LEX
  1387. X        fprintf(yyout, "\nVariant Section Start: %s\n", yytext);
  1388. X#endif DEBUG_LEX
  1389. X        ;
  1390. X        BEGIN VARSEC;
  1391. X        }
  1392. X
  1393. X<VARSEC>^{Tab}{Macrodef}    {
  1394. X#ifdef DEBUG_LEX
  1395. X        fprintf(yyout, "\nMacro in variant section: %s\n", yytext);
  1396. X#endif DEBUG_LEX
  1397. X        varmacrodef(yytext);
  1398. X        }
  1399. X
  1400. X<VARSEC>^{Layoutline}$    {
  1401. X#ifdef DEBUG_LEX
  1402. X        fprintf(yyout,"\n Layoutline in variant section\n");
  1403. X#endif DEBUG_LEX
  1404. X        }
  1405. X
  1406. X
  1407. X<VARSEC>^"\n"    {
  1408. X#ifdef DEBUG_LEX
  1409. X        fprintf(yyout,"\n Empty line in variant section\n");
  1410. X#endif DEBUG_LEX
  1411. X        }
  1412. X
  1413. X<VARSEC>{Ruledef}    {
  1414. X#ifdef DEBUG_LEX
  1415. X        fprintf(yyout, "\nVariant name: %s\n", yytext);
  1416. X#endif DEBUG_LEX
  1417. X        varsec_name(yytext);
  1418. X        }
  1419. X
  1420. X<VARSEC>{Varsecend}    {
  1421. X#ifdef DEBUG_LEX
  1422. X        fprintf(yyout, "\nVarsec end: %s\n", yytext);
  1423. X#endif DEBUG_LEX
  1424. X        ;
  1425. X        BEGIN 0;
  1426. X        }
  1427. X
  1428. X<VARSEC>{Vclass}    {
  1429. X#ifdef DEBUG_LEX
  1430. X        fprintf(yyout, "\nvclass definition: %s\n", yytext);
  1431. X#endif DEBUG_LEX
  1432. X        vclassdef(yytext);        
  1433. X        }
  1434. X
  1435. X
  1436. X<RULEDEF>^{Macrodef}    {
  1437. X        ruleend();
  1438. X#ifdef DEBUG_LEX
  1439. X        fprintf(yyout, "\n Ruledef end found\n");
  1440. X        fprintf(yyout, "\nMacrodefinition: %s\n", yytext);
  1441. X#endif DEBUG_LEX
  1442. X        /* if (yytext[yyleng-1] == '\n')
  1443. X              yytext[yyleng-1] = '\0';
  1444. X        macrodef(yytext) */ ;
  1445. X        BEGIN 0;
  1446. X        }
  1447. X
  1448. X<RULEDEF>{Varsecstart}    {
  1449. X        ruleend();
  1450. X#ifdef DEBUG_LEX
  1451. X        fprintf(yyout, "\n Ruledef end found\n");
  1452. X        fprintf(yyout, "\nVarsec start: %s\n", yytext);
  1453. X#endif DEBUG_LEX
  1454. X        /* if (yytext[yyleng-1] == '\n')
  1455. X              yytext[yyleng-1] = '\0';
  1456. X        macrodef(yytext) */ ;
  1457. X        BEGIN VARSEC;
  1458. X        }
  1459. X
  1460. X
  1461. X^{Macrodef}    {
  1462. X#ifdef DEBUG_LEX
  1463. X        fprintf(yyout, "\nMacrodefinition: %s\n", yytext);
  1464. X#endif DEBUG_LEX
  1465. X        /* if (yytext[yyleng-1] == '\n')
  1466. X            yytext[yyleng-1] = '\0';
  1467. X        macrodef(yytext) */ ;
  1468. X        }
  1469. X
  1470. X^{Rulesecstart}    {
  1471. X#ifdef DEBUG_LEX
  1472. X        fprintf(yyout, "\nRulesec starts: %s\n", yytext);
  1473. X#endif DEBUG_LEX
  1474. X        BEGIN RULESEC;
  1475. X        }
  1476. X
  1477. X
  1478. X^{Ruledef}    {
  1479. X#ifdef DEBUG_LEX
  1480. X        fprintf(yyout, "\n Rule: %s\n", yytext);
  1481. X#endif DEBUG_LEX
  1482. X        ruleend();
  1483. X        if (yytext[yyleng-1] == '\n')
  1484. X            yytext[yyleng-1] = '\0';
  1485. X        if ((strncmp(yytext,".SUFFIXES:",10) == 0))
  1486. X            {
  1487. X            if((ppp = index(yytext,'%')) == NIL)
  1488. X            /* old style suffix list */
  1489. X                {
  1490. X                    Oldsuffs = TRUE;
  1491. X                ppp = yytext + 10;
  1492. X                if (index(ppp,'.') != NIL)
  1493. X                    {
  1494. X                    if ((suffs = malloc((unsigned) 
  1495. X                          (strlen(yytext) +
  1496. X                           strlen(stdsuff) + 3))) == NIL)
  1497. X                          errexit(10,"malloc");
  1498. X                    suffs[0] = '\0';
  1499. X                        (void) strcat(suffs,".SUFFIXES: ");
  1500. X                    if (!suffs_deleted)
  1501. X                        (void) strcat(suffs,stdsuff);
  1502. X                        (void) strcat(suffs,ppp);
  1503. X                    suffs_deleted = FALSE;
  1504. X                    }
  1505. X                else
  1506. X                    {
  1507. X                    suffs_deleted = TRUE;
  1508. X                    }
  1509. X                }
  1510. X            else
  1511. X                {
  1512. X                /* new style suffixes */
  1513. X                Newsuffs = TRUE;
  1514. X                ppp = yytext + 10;
  1515. X                if ((suffs =
  1516. X                     malloc ((unsigned) 
  1517. X                     (strlen(yytext) + strlen(shaperules)
  1518. X                        + 3))) == NIL)
  1519. X                      errexit(10,"malloc");
  1520. X                suffs[0] = '\0';
  1521. X                    (void) strcat(suffs,".SUFFIXES");
  1522. X                if (!suffs_deleted)
  1523. X                    (void) strcat(suffs,shaperules);
  1524. X                    (void) strcat(suffs,ppp);
  1525. X                suffs_deleted = FALSE;
  1526. X                }
  1527. X#ifdef DEBUG_LEX
  1528. Xfprintf(yyout,"suffixes:%s\n", suffs);
  1529. X#endif DEBUG_LEX
  1530. X            }
  1531. X        else    
  1532. X            ruledef(yytext);        
  1533. X        BEGIN RULEDEF;
  1534. X        }
  1535. X
  1536. X<RULEDEF>^{Layoutline}$    {
  1537. X#ifdef DEBUG_LEX
  1538. X        fprintf(yyout,"\n Layoutline in ruledef\n");
  1539. X#endif DEBUG_LEX
  1540. X        }
  1541. X
  1542. X<RULEDEF>^{Rulecont}    {
  1543. X#ifdef DEBUG_LEX
  1544. X        fprintf(yyout, "\n Rulecont: %s\n", yytext);
  1545. X#endif DEBUG_LEX
  1546. X        /* strcpy(yytext,expandmacro(yytext)); */
  1547. X        rulecont(yytext);        
  1548. X        }
  1549. X
  1550. X
  1551. X
  1552. X<RULEDEF>^{Notab}    {
  1553. X#ifdef DEBUG_LEX
  1554. X        fprintf(yyout, "\n Ruledef end found\n");
  1555. X#endif DEBUG_LEX
  1556. X        ruleend();
  1557. X        yyless(yyleng-1);
  1558. X        BEGIN 0;
  1559. X        }
  1560. X^{Layoutline}$    {
  1561. X#ifdef DEBUG_LEX
  1562. X        fprintf(yyout,"\n Layoutline\n");
  1563. X#endif DEBUG_LEX
  1564. X        }
  1565. X
  1566. X^{Blank}*    {
  1567. X#ifdef DEBUG_LEX
  1568. X        fprintf(yyout,"\n Layoutline\n");
  1569. X#endif DEBUG_LEX
  1570. X        }
  1571. X
  1572. X^{Tab}*        {
  1573. X#ifdef DEBUG_LEX
  1574. X        fprintf(yyout,"\n Layoutline\n");
  1575. X#endif DEBUG_LEX
  1576. X        }    
  1577. X
  1578. X\n        {
  1579. X        ;
  1580. X        }
  1581. X
  1582. X^\n        {
  1583. X        ;
  1584. X        }
  1585. X
  1586. X{Others}*    {
  1587. X        synterrflg = TRUE;
  1588. X        errexit(14,yytext);
  1589. X        BEGIN 0;
  1590. X        }
  1591. X
  1592. X%%
  1593. END_OF_FILE
  1594. if test 8084 -ne `wc -c <'src/shape/shape.l'`; then
  1595.     echo shar: \"'src/shape/shape.l'\" unpacked with wrong size!
  1596. fi
  1597. # end of 'src/shape/shape.l'
  1598. fi
  1599. if test -f 'src/shape/varsec.c' -a "${1}" != "-c" ; then 
  1600.   echo shar: Will not clobber existing file \"'src/shape/varsec.c'\"
  1601. else
  1602. echo shar: Extracting \"'src/shape/varsec.c'\" \(8140 characters\)
  1603. sed "s/^X//" >'src/shape/varsec.c' <<'END_OF_FILE'
  1604. X/*
  1605. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  1606. X *  and U. Pralle
  1607. X * 
  1608. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  1609. X * WARRANTY for any part of this software to work correctly or as described
  1610. X * in the manuals. We do not accept any liability for any kind of damage
  1611. X * caused by use of this software, such as loss of data, time, money, or 
  1612. X * effort.
  1613. X * 
  1614. X * Permission is granted to use, copy, modify, or distribute any part of
  1615. X * this software as long as this is done without asking for charge, and
  1616. X * provided that this copyright notice is retained as part of the source
  1617. X * files. You may charge a distribution fee for the physical act of
  1618. X * transferring a copy, and you may at your option offer warranty
  1619. X * protection in exchange for a fee.
  1620. X * 
  1621. X * Direct questions to: Tech. Univ. Berlin
  1622. X *              Wilfried Koch
  1623. X *              Sekr. FR 5-6 
  1624. X *              Franklinstr. 28/29
  1625. X *              D-1000 Berlin 10, West Germany
  1626. X * 
  1627. X *              Tel: +49-30-314-22972
  1628. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  1629. X */
  1630. X#ifndef lint
  1631. Xstatic char *RCSid = "$Header: varsec.c,v 3.0 89/01/24 11:37:15 wolfgang Stable $";
  1632. X#endif
  1633. X#ifndef lint
  1634. Xstatic char *ConfFlg = CFFLGS;    /* should be defined from within Makefile */
  1635. X#endif
  1636. X/*
  1637. X * $Log:    varsec.c,v $
  1638. X * Revision 3.0  89/01/24  11:37:15  wolfgang
  1639. X * New System Generation
  1640. X * 
  1641. X * Revision 2.18  89/01/03  13:14:14  wolfgang
  1642. X * changes done for lint
  1643. X * 
  1644. X * Revision 2.17  88/12/21  15:13:22  wolfgang
  1645. X * changes done for lint
  1646. X * 
  1647. X * Revision 2.16  88/11/22  18:32:17  wolfgang
  1648. X * bug fixed: missing initialisation.
  1649. X * 
  1650. X * Revision 2.15  88/11/21  15:48:20  wolfgang
  1651. X * return code of all malloc's checked
  1652. X * 
  1653. X * Revision 2.14  88/11/03  17:30:22  wolfgang
  1654. X * bug fixed in is_varname().
  1655. X * 
  1656. X * Revision 2.13  88/10/27  16:37:34  wolfgang
  1657. X * bugs fixed (new variant handling).
  1658. X * 
  1659. X * Revision 2.12  88/10/26  13:13:36  wolfgang
  1660. X * changes done for new syntax of variant deps
  1661. X * 
  1662. X * Revision 2.11  88/10/24  16:21:56  wolfgang
  1663. X * another segmentation violation fixed in is_varname().
  1664. X * 
  1665. X * Revision 2.10  88/10/21  11:36:37  wolfgang
  1666. X * bug fixed in is_varname: produced a segmentation violation ($(RULE)+.
  1667. X * 
  1668. X * Revision 2.9  88/10/20  13:20:16  wolfgang
  1669. X * 
  1670. X * bug fixed in is_varname: string = "+" caused segmentation violation.
  1671. X * 
  1672. X * Revision 2.8  88/10/18  17:41:56  wolfgang
  1673. X * nearly newly written (for new variant handling)
  1674. X * 
  1675. X * Revision 2.7  88/10/14  17:15:05  wolfgang
  1676. X * varsecname() & varmacrodef() added. vardump() changed.
  1677. X * 
  1678. X * Revision 2.6  88/09/19  18:40:29  wolfgang
  1679. X * Bug fixes. Second endless loop in check_vclass. Shit!!!!
  1680. X * 
  1681. X * Revision 2.5  88/09/19  18:11:36  wolfgang
  1682. X * bug fixed (endless loop in check_vclass).
  1683. X * 
  1684. X * Revision 2.4  88/09/15  18:41:05  wolfgang
  1685. X * check_vclass & reset_vclass added.
  1686. X * 
  1687. X * Revision 2.3  88/09/15  12:42:54  wolfgang
  1688. X * bug fixed.
  1689. X * 
  1690. X * Revision 2.2  88/08/23  11:23:40  wolfgang
  1691. X * New procedure added: vardump(fd). To be used for the generation of
  1692. X * confid's. Dumps the variant section.
  1693. X * 
  1694. X * Revision 2.1  88/08/19  10:18:16  wolfgang
  1695. X * This version is part of a release
  1696. X * 
  1697. X */
  1698. X
  1699. X#include <sys/types.h>
  1700. X#include <sys/dir.h>
  1701. X
  1702. X#include "shape.h"
  1703. X#include "varsec.h"
  1704. X
  1705. Xvarsec_name(string)
  1706. X     char *string;
  1707. X{
  1708. X  char *p;
  1709. X  int k = 0;
  1710. X
  1711. X  if (( p = index(string,':')) == 0)
  1712. X    errexit(14, string);
  1713. X
  1714. X  *p = '\0';
  1715. X  while((vardefs[k] != (struct vardef *) NIL))
  1716. X    {
  1717. X      if (!strcmp(vardefs[k]->name,string))
  1718. X    errexit(33, string);
  1719. X      k++;
  1720. X    }
  1721. X  if ((vardefs[k] = (struct vardef *) malloc (sizeof (struct vardef))) == (struct vardef *) NIL)
  1722. X    errexit(10,"malloc");
  1723. X  if ((vardefs[k]->name = malloc((unsigned) (strlen(string) + sizeof(char)))) == NIL)
  1724. X    errexit(10,"malloc");
  1725. X  (void) strcpy(vardefs[k]->name, string);
  1726. X
  1727. X  lastvardef = k;
  1728. X  vardefs[k+1] = (struct vardef *) NIL;
  1729. X
  1730. X  vardefs[k]->vpath = NIL;
  1731. X  vardefs[k]->vflags = NIL;
  1732. X  
  1733. X  for(k = 0; k < MAXVMACROS; k++)
  1734. X    vardefs[lastvardef]->vmacros[k] = NIL;
  1735. X}
  1736. X
  1737. X
  1738. Xvarmacrodef(string)
  1739. X     char *string;
  1740. X{
  1741. X  char *p;
  1742. X  int k = 0;
  1743. X
  1744. X  if (string[strlen(string) - 1] == '\n')
  1745. X    string[strlen(string) - 1] = '\0';
  1746. X
  1747. X  while((*string == '\t') || (*string == ' '))
  1748. X    string++;
  1749. X
  1750. X  if(!strncmp(string,"vpath",5))
  1751. X    {
  1752. X      if ((p = index(string,'=')) == NIL)
  1753. X    errexit(7, string);
  1754. X      p++;
  1755. X      while((*p == ' ') || (*p == '\t'))
  1756. X    p++;
  1757. X      
  1758. X      if ((vardefs[lastvardef]->vpath = malloc((unsigned) (strlen(p)+sizeof(char)))) == NIL)
  1759. X    errexit(10,"malloc");
  1760. X      (void) strcpy(vardefs[lastvardef]->vpath,p);
  1761. X      return;
  1762. X    }
  1763. X
  1764. X  if(!strncmp(string,"vflags",6))
  1765. X    {
  1766. X      if ((p = index(string,'=')) == NIL)
  1767. X    errexit(7, string);
  1768. X      p++;
  1769. X      while((*p == ' ') || (*p == '\t'))
  1770. X    p++;
  1771. X      
  1772. X      if ((vardefs[lastvardef]->vflags = malloc((unsigned) (strlen(p)+sizeof(char)))) == NIL)
  1773. X    errexit(10,"malloc");
  1774. X      (void) strcpy(vardefs[lastvardef]->vflags,p);
  1775. X      return;
  1776. X    }
  1777. X
  1778. X  while(vardefs[lastvardef]->vmacros[k] != NIL)
  1779. X    k++;
  1780. X  
  1781. X  if ((vardefs[lastvardef]->vmacros[k] = malloc((unsigned) (strlen(string) + sizeof(char)))) == NIL)
  1782. X    errexit(10,"malloc");
  1783. X  (void) strcpy(vardefs[lastvardef]->vmacros[k],string);
  1784. X}
  1785. X  
  1786. X
  1787. X
  1788. Xint vardump(fd)
  1789. X     FILE *fd;
  1790. X{
  1791. Xint i = 0;
  1792. Xint k = 0;
  1793. X
  1794. Xif (vardefs[i] != (struct vardef *) NIL)
  1795. X  {
  1796. X
  1797. X    fprintf(fd,"#%% VARIANT-SECTION\n");
  1798. X
  1799. X    for(i = 0; vardefs[i] != (struct vardef *) NIL; i++)
  1800. X      {
  1801. X    fprintf(fd,"\n");
  1802. X
  1803. X    fprintf(fd,"%s:\n", vardefs[i]->name);
  1804. X
  1805. X    if(vardefs[i]->vflags != NIL)
  1806. X      fprintf(fd,"\tvflags = %s\n", vardefs[i]->vflags);
  1807. X
  1808. X    if(vardefs[i]->vpath != NIL)
  1809. X      fprintf(fd,"\tvpath = %s\n", vardefs[i]->vpath);
  1810. X
  1811. X    while(vardefs[i]->vmacros[k] != NIL)
  1812. X      {
  1813. X        fprintf(fd,"\t%s\n",vardefs[i]->vmacros[k]);
  1814. X        k++;
  1815. X      }
  1816. X    k = 0;
  1817. X      }
  1818. X    fprintf(fd,"\n");
  1819. X
  1820. X    fprintf(fd,"#%% END-VARIANT-SECTION\n");
  1821. X    
  1822. X    (void) fflush(fd);
  1823. X  }
  1824. X}
  1825. X
  1826. X        
  1827. Xvclassdef(string)
  1828. X     char *string;
  1829. X{
  1830. Xchar *p;
  1831. Xchar *vname;
  1832. Xint k = 0;
  1833. Xint l = 0;
  1834. Xint j = 0;
  1835. Xchar vc[32];
  1836. X
  1837. Xif ((p = index(string,' ')) == NIL)
  1838. X  errexit(14,string);
  1839. Xelse
  1840. X  {
  1841. X    *p = '\0';
  1842. X    p++;
  1843. X    vname = p;
  1844. X    string = p;
  1845. X    if ((p = index(string,':')) == NIL)
  1846. X      errexit(14,string);
  1847. X    *p = '\0';
  1848. X    string++;
  1849. X    if ((p = index(vname,' ')) != NIL)
  1850. X      *p = '\0';
  1851. X    while(vclass[k] != (struct varclass *) NIL)
  1852. X      k++;
  1853. X    if((vclass[k] = (struct varclass *) malloc( sizeof (struct varclass))) == (struct varclass *) NIL)
  1854. X      errexit(10,"malloc");
  1855. X    if ((vclass[k]->name = malloc((unsigned) (strlen(vname) + sizeof(char)))) == NIL)
  1856. X      errexit(10,"malloc");
  1857. X    (void) strcpy(vclass[k]->name,vname);
  1858. X    vclass[k]->active = -1;
  1859. X  }
  1860. X
  1861. Xwhile(*string != '(')
  1862. X  string++;
  1863. X
  1864. Xstring++;
  1865. X
  1866. Xwhile(*string != ')')
  1867. X  {
  1868. X    while((*string == ' ') || (*string == '\t'))
  1869. X      string++;
  1870. X
  1871. X    while((*string != ',') && (*string != ')'))
  1872. X      {
  1873. X    vc[j] = *string;
  1874. X    string++;
  1875. X    j++;
  1876. X      }
  1877. X    if (*string == ',')
  1878. X      string++;
  1879. X
  1880. X    vc[j] = '\0';
  1881. X    if ((vclass[k]->variants[l] = malloc((unsigned) (strlen(vc) + sizeof(char)))) == NIL)
  1882. X      errexit(10,"malloc");
  1883. X    (void) strcpy(vclass[k]->variants[l],vc);
  1884. X    l++;
  1885. X    vclass[k]->variants[l] = NIL;
  1886. X    j = 0;
  1887. X    while((*string == ' ') || (*string == '\t'))
  1888. X      string++;
  1889. X  }
  1890. X}
  1891. X
  1892. X    
  1893. XBool check_vclass(varname)
  1894. X     char *varname;
  1895. X{
  1896. X  int i = 0;
  1897. X  int j = 0;
  1898. X  
  1899. X  while(vclass[i] != (struct varclass *) NIL)
  1900. X    {
  1901. X      j = 0;
  1902. X      while(vclass[i]->variants[j] != NIL)
  1903. X    {
  1904. X      if(strcmp(vclass[i]->variants[j],varname) == 0)
  1905. X        {
  1906. X          if((vclass[i]->active != -1) && (vclass[i]->active != j))
  1907. X        return(FALSE);
  1908. X          vclass[i]->active = j;
  1909. X          return(TRUE);
  1910. X        }
  1911. X      j++;
  1912. X    }
  1913. X      i++;
  1914. X    }
  1915. X  if(vclass[i] == (struct varclass *) NIL)
  1916. X    return(TRUE);
  1917. X/*NOTREACHED*/
  1918. Xreturn(FALSE);
  1919. X}
  1920. X
  1921. Xreset_vclass()
  1922. X{
  1923. X  int i = 0;
  1924. X
  1925. X  while( vclass[i] != (struct varclass *) NIL)
  1926. X    {
  1927. X      vclass[i]->active = -1;
  1928. X      i++;
  1929. X    }
  1930. X}
  1931. X
  1932. X
  1933. X    
  1934. XBool is_varname(string)
  1935. X     char *string;
  1936. X{
  1937. X  char *p;
  1938. X  int k = 0;
  1939. X
  1940. X  if(string == NIL)
  1941. X    return(FALSE);
  1942. X
  1943. X  if(string[0] != '+')
  1944. X    return(FALSE);
  1945. X
  1946. X  p = index(string,'+');
  1947. X  p++;
  1948. X
  1949. X  while(vardefs[k] != (struct vardef *) NIL)
  1950. X    {
  1951. X      if(!strcmp(vardefs[k]->name,p))
  1952. X    return(TRUE);
  1953. X      k++;
  1954. X    }
  1955. X  return(FALSE);
  1956. X}
  1957. END_OF_FILE
  1958. if test 8140 -ne `wc -c <'src/shape/varsec.c'`; then
  1959.     echo shar: \"'src/shape/varsec.c'\" unpacked with wrong size!
  1960. fi
  1961. # end of 'src/shape/varsec.c'
  1962. fi
  1963. echo shar: End of archive 9 \(of 33\).
  1964. cp /dev/null ark9isdone
  1965. MISSING=""
  1966. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
  1967.     if test ! -f ark${I}isdone ; then
  1968.     MISSING="${MISSING} ${I}"
  1969.     fi
  1970. done
  1971. if test "${MISSING}" = "" ; then
  1972.     echo You have unpacked all 33 archives.
  1973.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1974. else
  1975.     echo You still need to unpack the following archives:
  1976.     echo "        " ${MISSING}
  1977. fi
  1978. ##  End of shell archive.
  1979. exit 0
  1980.