Import Upstream version 1.8.5
[hcoop/debian/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 <roken.h>
14
15 #include <stdio.h>
16 #include <string.h>
17 #include "uss_procs.h"
18 #include "uss_vol.h"
19 #include "uss_kauth.h"
20
21 extern int line;
22 extern int uss_perr;
23
24 extern int yylex(void);
25 static int yyerror(char *);
26
27 %}
28
29 %union
30 {
31 int ival;
32 char chval;
33 char strval[1000];
34 }
35
36 %token EOL_TKN
37 %token DIR_TKN
38 %token FILE_TKN
39 %token ECHO_TKN
40 %token EXEC_TKN
41 %token LINK_TKN
42 %token SYMLINK_TKN
43 %token VOL_TKN
44 %token GROUP_TKN
45 %token AUTH_TKN
46 %token <strval> STRING_TKN
47 %token VOL1_TKN
48 %type <ival> input
49 %type <ival> entry
50 %type <strval> accesslist
51
52 %% /* rules */
53
54 input : /* empty */
55 { $$ = 0;}
56 | input entry
57 { $$ = ($1 == 0)? $2 : $1;}
58 ;
59
60 entry : DIR_TKN
61 STRING_TKN /*2-directory name*/
62 STRING_TKN /*3-mode*/
63 STRING_TKN /*4-owner*/
64 accesslist /*5-access list*/
65 {$$ = uss_perr = uss_procs_BuildDir($2,$3,$4,$5);}
66 | FILE_TKN
67 STRING_TKN /*2-filename*/
68 STRING_TKN /*3-mode*/
69 STRING_TKN /*4-owner*/
70 STRING_TKN /*5-rototype*/
71 {$$ = uss_perr = uss_procs_CpFile($2, $3, $4, $5);}
72 | ECHO_TKN
73 STRING_TKN /*2-filename*/
74 STRING_TKN /*3-mode*/
75 STRING_TKN /*4-owner*/
76 STRING_TKN /*5-file content*/
77 {$$ = uss_perr = uss_procs_EchoToFile($2, $3, $4, $5);}
78 | EXEC_TKN
79 STRING_TKN /*2-command string*/
80 {$$ = uss_perr = uss_procs_Exec($2);}
81 | LINK_TKN
82 STRING_TKN /*2-filename1*/
83 STRING_TKN /*3-filename2*/
84 {$$ = uss_perr = uss_procs_SetLink($2, $3,'h');}
85
86 | SYMLINK_TKN
87 STRING_TKN /*2-filename1*/
88 STRING_TKN /*3-filename2*/
89 {$$ = uss_perr = uss_procs_SetLink($2, $3,'s');}
90 | VOL_TKN
91 STRING_TKN /*2-vol name*/
92 STRING_TKN /*3-server*/
93 STRING_TKN /*4-partition*/
94 STRING_TKN /*5-quota*/
95 STRING_TKN /*6-Mount point*/
96 STRING_TKN /*7-Owner*/
97 accesslist /*8-access list*/
98 {$$ = uss_perr = uss_vol_CreateVol($2, $3, $4, $5, $6, $7, $8);}
99 | GROUP_TKN
100 STRING_TKN /*2-declared dir*/
101 {$$ = uss_perr = uss_procs_AddToDirPool($2);}
102 | AUTH_TKN
103 STRING_TKN /*2-user name*/
104 STRING_TKN /*3-password lifetime (days<255)*/
105 STRING_TKN /*4-reuse/noreuse */
106 STRING_TKN /*5-failed login attempts */
107 STRING_TKN /*6-lockout time */
108 {$$ = uss_perr = uss_kauth_SetFields($2, $3, $4, $5, $6);}
109 | VOL1_TKN
110 STRING_TKN /*2-vol name*/
111 STRING_TKN /*3-server*/
112 STRING_TKN /*4-partition*/
113 STRING_TKN /*5-quota*/
114 STRING_TKN /*6-Mount point*/
115 STRING_TKN /*7-Owner*/
116 STRING_TKN /*8-access list*/
117 {$$ = uss_perr = uss_vol_CreateVol($2, $3, $4, $5, $6, $7, $8);}
118 | EOL_TKN /*End of line */
119 {$$=0;}
120 | error entry
121 {uss_procs_PrintErr(line-1, " near \"%s\"\n",yylval.strval);}
122 ;
123
124
125 accesslist : /* empty */
126 {strcpy($$," ");}
127 | STRING_TKN
128 STRING_TKN
129 accesslist
130 {strcat($1," "); strcat($2," ");strcat($1,strcat($2,$3));strcpy($$,$1);}
131
132 ;
133
134 %%
135 static int
136 yyerror(char *s)
137 {
138 fprintf(stderr,"%s. ",s);
139 return 0;
140 }