4 * Copyright (C) 1990 Transarc Corporation
5 * Licensed Materials - Property of Transarc
9 * Grammar defining the set of things recognized by package,
10 * the AFS workstation configuration facility.
13 #include <afs/param.h>
14 #include <sys/param.h>
16 #include <sys/types.h>
18 #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)
19 #include <sys/mkdev.h>
21 #ifdef AFS_LINUX20_ENV
22 #include <sys/sysmacros.h>
29 #if defined(AFS_AIX41_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV)
30 int test_linecounter; /*Line number currently being parsed*/
32 char *appendchtostr();
33 #endif /* AFS_AIX41_ENV */
62 %token <strval> PATHNAME
66 %type <usval> filetype
67 %type <usval> devicetype
68 %type <usval> updatespecs
69 %type <usval> updateflag
70 %type <strval> filename
71 %type <protoval> devprototype
72 %type <protoval> fileprototype
76 %type <ownval> ownershipinfo
77 %type <strval> username
78 %type <strval> groupname
81 %type <usval> octalnumber
87 { $$ = InitializeConfigTree();
88 test_linecounter = 1; }
90 { $$ = ($1 == 0)? $2 : $1; }
93 entry : COMMENT NEWLINE
94 { $$ = 0; test_linecounter++; }
96 { $$ = 0; test_linecounter++; }
97 | devicetype /*Specifies type of device to be updated
99 updatespecs /*Specifies actions during update, if
101 filename /*Name of device being updated*/
102 devprototype /*Device numbers for device being updated*/
103 ownershipinfo /*Ownership info for device being updated*/
104 mode /*Protection bits for file being updated*/
107 $$ = AddEntry($1, $2, $3, $4, $5, $6);
115 ReleaseEntry($3, $4, $5);
119 | filetype /*Specifies type of file to be updated;
120 e.g., regular file, directory, special
122 updatespecs /*Specifies actions during update, if
124 filename /*Name of file being updated*/
125 fileprototype /*Prototype for file being updated, if
126 necessary - e.g., directory prefix,
127 master copy, device numbers, etc.*/
128 ownershipinfo /*Ownership info for file being updated;
129 should default to info from prototype*/
130 mode /*Protection bits for file being updated;
131 should default to info from prototype*/
134 $$ = AddEntry($1, $2, $3, $4, $5, $6);
142 ReleaseEntry($3, $4, $5);
147 devicetype: BLKTYPE /*Block device*/
149 | CHRTYPE /*Character device*/
151 | PIPETYPE /*Named pipe*/
159 filetype: REGTYPE /*Regular file*/
161 | DIRTYPE /*Directory*/
163 | LNKTYPE /*Symbolic link*/
169 #endif /* AFS_AIX_ENV */
174 updatespecs : /*empty */
176 | /*empty */ WHITESPACE
178 | updatespecs updateflag
180 | updatespecs updateflag WHITESPACE
185 * Throw this out later.
192 /*Make this a lost+found directory*/
197 /*Extra unconfigured files to be removed*/
202 /*Update only if file not present*/
207 /*Rename old copy with a suffix of .old*/
212 /*Prototype specifies an absolute path
213 rather than the prefix*/
218 /*Exit with status=4 if file is updated,
219 indicating that a reboot is needed*/
226 filename : PATHNAME /*Pathname of the file to be
227 updated; may not have white-
230 | PATHNAME WHITESPACE /*Pathname of the file to be
235 fileprototype: /* empty */
236 { $$.flag = P_NONE; }
237 | filename /*Pathname of prototype file or directory
239 { $$.flag = P_FILE; $$.info.path = $1; }
242 devprototype: devmajor WHITESPACE devminor /*Major & minor device
244 { $$.flag = P_DEV; $$.info.rdev = makedev($1, $3); }
265 dbgprint((stderr, "digit %u\n", $$));
269 dbgprint((stderr, "10 * %u + %u = %u\n", $1,$2,$$));
273 ownershipinfo: /* empty */
274 { $$.username = NULL; $$.groupname = NULL; }
276 { $$.username = $1; $$.groupname = $2; }
285 groupname: /* empty */
294 { $$ = ch2str(yylval.chval); }
296 { $$ = ch2str('0'+$1); }
298 { $$ = appendchtostr($1, $2); }
300 { $$ = appendchtostr($1, '0'+$2); }
305 { $$.inherit_flag = TRUE; }
307 { $$.inherit_flag = TRUE; }
308 | octalnumber /*Last field of entry, may not have
309 anything before newline*/
310 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
311 | octalnumber WHITESPACE /*Last field of entry, but may have
312 some whitespace before newline*/
313 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
314 | octalnumber COMMENT /*Last field of entry, but may have
315 a comment before newline*/
316 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
317 | octalnumber WHITESPACE COMMENT /*Last field of entry, but
318 may have some whitespace
319 and a comment before the
321 { $$.inherit_flag = FALSE; $$.modeval = (afs_uint32)$1; }
326 dbgprint((stderr, "digit %u\n", $$));
330 dbgprint((stderr, "8 * %u + %u = %u\n", $1,$2, $$));
337 #ifndef AFS_AIX41_ENV
338 int test_linecounter; /*Line number currently being parsed*/
339 #endif /* !AFS_AIX41_ENV */
344 * Returns the pointer to a string consisting of the character c
349 s = (char *)emalloc(2);
354 char *appendchtostr(s, c)
357 * Returns the pointer to a NULL-terminated string containing the
358 * character c appended to the contents of the string s
362 str = (char *)emalloc((unsigned)(strlen(s) + 2));
363 sprintf(str, "%s%c", s, c);
368 ReleaseEntry(f, p, o)
373 * Release storage allocated for various data structures during the
374 * parsing of an entry.
377 if (f != NULL) free(f);
378 if ((p.flag == P_FILE) && (p.info.path != NULL)) free(p.info.path);
379 if (o.username != NULL) free(o.username);
380 if (o.groupname != NULL) free(o.groupname);