a14828c43e439f776afae99d56d6631eb41906e2
[openafs.git] / src / uss / grammar.y
1 %{
2 /*
3  * Copyright 2000, International Business Machines Corporation and others.
4  * All Rights Reserved.
5  * 
6  * This software has been released under the terms of the IBM Public
7  * License.  For details, see the LICENSE file in the top-level source
8  * directory or online at http://www.openafs.org/dl/license10.html
9  */
10
11 #include <afsconfig.h>
12 #include <afs/param.h>
13 #include <stdio.h>
14 #include <string.h>
15
16 extern int line;
17 extern int uss_perr;
18 %}
19
20 %union
21 {
22    int ival;
23   char chval;
24   char strval[1000];
25 }
26
27 %token  EOL_TKN
28 %token  DIR_TKN
29 %token FILE_TKN
30 %token ECHO_TKN
31 %token EXEC_TKN
32 %token LINK_TKN
33 %token SYMLINK_TKN
34 %token VOL_TKN
35 %token GROUP_TKN
36 %token AUTH_TKN
37 %token <strval> STRING_TKN
38 %token VOL1_TKN
39 %type <ival> input
40 %type <ival> entry
41 %type <strval> accesslist
42
43 %%      /* rules */
44
45 input   :       /* empty */
46                         { $$ = 0;}
47         |       input entry
48                         { $$ = ($1 == 0)? $2 : $1;}
49         ;
50
51 entry   :       DIR_TKN
52                 STRING_TKN      /*2-directory name*/
53                 STRING_TKN      /*3-mode*/
54                 STRING_TKN      /*4-owner*/
55                 accesslist      /*5-access list*/
56                         {$$ = uss_perr = uss_procs_BuildDir($2,$3,$4,$5);}
57         |       FILE_TKN
58                 STRING_TKN      /*2-filename*/
59                 STRING_TKN      /*3-mode*/
60                 STRING_TKN      /*4-owner*/
61                 STRING_TKN      /*5-rototype*/
62                         {$$ = uss_perr = uss_procs_CpFile($2, $3, $4, $5);}
63         |       ECHO_TKN
64                 STRING_TKN      /*2-filename*/
65                 STRING_TKN      /*3-mode*/
66                 STRING_TKN      /*4-owner*/
67                 STRING_TKN      /*5-file content*/
68                         {$$ = uss_perr = uss_procs_EchoToFile($2, $3, $4, $5);}
69         |       EXEC_TKN
70                 STRING_TKN      /*2-command string*/
71                         {$$ = uss_perr = uss_procs_Exec($2);}
72         |       LINK_TKN
73                 STRING_TKN      /*2-filename1*/
74                 STRING_TKN      /*3-filename2*/
75                         {$$ = uss_perr = uss_procs_SetLink($2, $3,'h');}
76
77         |       SYMLINK_TKN
78                 STRING_TKN      /*2-filename1*/
79                 STRING_TKN      /*3-filename2*/
80                         {$$ = uss_perr = uss_procs_SetLink($2, $3,'s');}
81         |       VOL_TKN
82                 STRING_TKN      /*2-vol name*/
83                 STRING_TKN      /*3-server*/
84                 STRING_TKN      /*4-partition*/
85                 STRING_TKN      /*5-quota*/
86                 STRING_TKN      /*6-Mount point*/
87                 STRING_TKN      /*7-Owner*/
88                 accesslist      /*8-access list*/
89                         {$$ = uss_perr = uss_vol_CreateVol($2, $3, $4, $5, $6, $7, $8);}
90         |       GROUP_TKN
91                 STRING_TKN      /*2-declared dir*/
92                         {$$ = uss_perr = uss_procs_AddToDirPool($2);}
93         |       AUTH_TKN
94                 STRING_TKN      /*2-user name*/
95                 STRING_TKN      /*3-password lifetime (days<255)*/
96                 STRING_TKN      /*4-reuse/noreuse */
97                 STRING_TKN      /*5-failed login attempts */
98                 STRING_TKN      /*6-lockout time */
99                         {$$ = uss_perr = uss_kauth_SetFields($2, $3, $4, $5, $6);}
100         |       VOL1_TKN
101                 STRING_TKN      /*2-vol name*/
102                 STRING_TKN      /*3-server*/
103                 STRING_TKN      /*4-partition*/
104                 STRING_TKN      /*5-quota*/
105                 STRING_TKN      /*6-Mount point*/
106                 STRING_TKN      /*7-Owner*/
107                 STRING_TKN      /*8-access list*/
108                         {$$ = uss_perr = uss_vol_CreateVol($2, $3, $4, $5, $6, $7, $8);}
109         |       EOL_TKN /*End of line */
110                         {$$=0;}
111         |       error entry
112                     {uss_procs_PrintErr(line-1, " near \"%s\"\n",yylval.strval);}
113         ;
114
115
116 accesslist :    /* empty */
117                         {strcpy($$," ");}
118         |       STRING_TKN
119                 STRING_TKN
120                 accesslist
121                         {strcat($1," "); strcat($2," ");strcat($1,strcat($2,$3));strcpy($$,$1);}
122                 
123         ;
124
125 %%
126 yyerror(s)
127 char *s;
128 {
129 fprintf(stderr,"%s. ",s);
130 }