4 * Copyright (C) 1990 Transarc Corporation
5 * Licensed Materials - Property of Transarc
9 * Special test version of the grammar defining the set of
10 * things recognized by package, the AFS workstation config-
14 #include <afs/param.h>
15 #include <sys/param.h>
17 #include <sys/types.h>
19 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)
20 #include <sys/mkdev.h>
22 #ifdef AFS_LINUX20_ENV
23 #include <sys/sysmacros.h>
31 #if defined(AFS_AIX41_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV)
32 int test_linecounter; /*Line number currently being parsed*/
35 char *appendchtostr();
36 #endif /* AFS_AIX41_ENV */
63 %token <strval> PATHNAME
67 %type <usval> filetype
68 %type <usval> devicetype
69 %type <usval> updatespecs
70 %type <usval> updateflag
71 %type <strval> filename
72 %type <protoval> devprototype
73 %type <protoval> fileprototype
77 %type <ownval> ownershipinfo
78 %type <strval> username
79 %type <strval> groupname
82 %type <usval> octalnumber
88 { $$ = InitializeConfigTree();
89 test_linecounter = 1; }
91 { $$ = ($1 == 0)? $2 : $1; }
94 entry : COMMENT NEWLINE
95 { $$ = 0; test_linecounter++; }
97 { $$ = 0; test_linecounter++; }
98 | devicetype /*Specifies type of device to be updated
100 updatespecs /*Specifies actions during update, if
102 filename /*Name of device being updated*/
103 devprototype /*Device numbers for device being updated*/
104 ownershipinfo /*Ownership info for device being updated*/
105 mode /*Protection bits for file being updated*/
108 $$ = testAddEntry($1, $2, $3, $4, $5, $6);
116 ReleaseEntry($3, $4, $5);
120 | filetype /*Specifies type of file to be updated;
121 e.g. regular file, directory, special
123 updatespecs /*Specifies actions during update, if
125 filename /*Name of file being updated*/
126 fileprototype /*Prototype for file being updated, if
127 necessary - e.g., directory prefix,
128 master copy, device numbers etc.*/
129 ownershipinfo /*Ownership info for file being updated,
130 should default to info from prototype*/
131 mode /*Protection bits for file being updated;
132 should default to info from prototype*/
135 $$ = testAddEntry($1, $2, $3, $4, $5, $6);
143 ReleaseEntry($3, $4, $5);
148 devicetype: BLKTYPE /*Block device*/
150 | CHRTYPE /*Character device*/
152 | PIPETYPE /*Named pipe*/
160 filetype: REGTYPE /*Regular file*/
162 | DIRTYPE /*Directory*/
164 | LNKTYPE /* symbolic link */
170 #endif /* AFS_AIX_ENV */
175 updatespecs : /*empty */
177 | /*empty */ WHITESPACE
179 | updatespecs updateflag
181 | updatespecs updateflag WHITESPACE
187 * Throw this out later
194 /*Make this a lost+found directory*/
199 /*Extra files not configured to be removed*/
204 /*Update only if file not present*/
209 /*Rename old copy with a suffix of .old*/
214 /*Prototype specifies an absolute path
215 rather than the prefix*/
220 /*Exit with status=4 if file is updated,
221 indicating that a reboot is needed*/
229 filename : PATHNAME /*Pathname of the file to be
230 updated, may not have white-
233 | PATHNAME WHITESPACE /*Pathname of the file to be
238 fileprototype: /* empty */
239 { $$.flag = P_NONE; }
240 | filename /*Pathname of prototype file or directory
242 { $$.flag = P_FILE; $$.info.path = $1; }
245 devprototype: devmajor WHITESPACE devminor /*Major & minor device
247 { $$.flag = P_DEV; $$.info.rdev = makedev($1, $3); }
253 if ((0 > $1) || ($1 > 255))
254 fatal("%d; invalid device number", $1);
261 if ((0 > $1) || ($1 > 255))
262 fatal("%d; invalid device number", $1);
267 if ((0 > $1) || ($1 > 255))
268 fatal("%d; invalid device number", $1);
275 dbgprint((stderr, "digit %u\n", $$));
279 dbgprint((stderr, "10 * %u + %u = %u\n", $1,$2,$$));
283 ownershipinfo: /* empty */
284 { $$.username = NULL; $$.groupname = NULL; }
286 { $$.username = $1; $$.groupname = $2; }
295 groupname: /* empty */
304 { $$ = ch2str(yylval.chval); }
306 { $$ = ch2str('0'+$1); } */
308 { $$ = appendchtostr($1, $2); }
310 { $$ = appendchtostr($1, '0'+$2); }
314 { $$.inherit_flag = TRUE; }
316 { $$.inherit_flag = TRUE; }
317 | octalnumber /*Last field of entry, may not have
318 anything before newline*/
319 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
320 | octalnumber WHITESPACE /*Last field of entry, but may have
321 some whitespace before newline*/
322 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
323 | octalnumber COMMENT /*Last field of entry, but may have
324 a comment before newline*/
325 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
326 | octalnumber WHITESPACE COMMENT /*Last field of entry, but
327 may have some whitespace
328 and a comment before the
330 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
335 dbgprint((stderr, "digit %u\n", $$));
339 dbgprint((stderr, "8 * %u + %u = %u\n", $1,$2, $$));
346 #ifndef AFS_AIX41_ENV
347 int test_linecounter; /*Line number currently being parsed*/
348 #endif /* !AFS_AIX41_ENV */
353 * Returns the pointer to a string consisting of the character c
358 s = (char *)emalloc(2);
363 char *appendchtostr(s, c)
366 * Returns the pointer to a NULL terminated string containing the
367 * character c appended to the contents of the string s
371 str = (char *)emalloc((unsigned)(strlen(s) + 2));
372 sprintf(str, "%s%c", s, c);
377 ReleaseEntry(f, p, o)
382 * Release storage allocated for various data structures during the
383 * parsing of an entry.
386 if (f != NULL) free(f);
387 if ((p.flag == P_FILE) && (p.info.path != NULL)) free(p.info.path);
388 if (o.username != NULL) free(o.username);
389 if (o.groupname != NULL) free(o.groupname);