3 * Copyright 2000, International Business Machines Corporation and others.
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
11 #include <afsconfig.h>
12 #include <afs/param.h>
20 #include "uss_common.h"
23 #define dprint(x) {fprintf(stderr, x); fflush(stderr);}
33 S [\.A-Z0-9a-z/$][^ \t\n#=\^\!\|\(\)\{\};]*
39 {C} {dprint(("got a comment\n"));}
40 ^{EOL} {dprint(("got an empty line\n")); line++;}
41 ^{INVAL} {uss_procs_PrintErr(line," Invalid command \n");}
42 ^[D]{W} {dprint(("got a Dir\n"));return(DIR_TKN);}
43 ^[F]{W} {dprint(("got a File\n"));return(FILE_TKN);}
44 ^[L]{W} {dprint(("got a Link\n"));return(LINK_TKN);}
45 ^[S]{W} {dprint(("got a Symlink\n"));return(SYMLINK_TKN);}
46 ^[E]{W} {dprint(("got an Echo\n"));return(ECHO_TKN);}
47 ^[X]{W} {dprint(("got an Exec\n"));return(EXEC_TKN);}
48 ^[V]{W} {dprint(("got a Vol\n"));return(VOL_TKN);}
49 ^[G]{W} {dprint(("got a Group Declaration\n"));return(GROUP_TKN);}
50 ^[A]{W} {dprint(("got an Auth\n"));return(AUTH_TKN);}
51 ^[Y]{W} {dprint(("got a Vol1\n"));return(VOL1_TKN);}
52 {S} {dprint(("got a string(%s)\n", yytext));
53 Replace(yytext, yylval.strval);
56 {Q} {dprint(("got a quote: '%s'\n", yytext));
57 Replace(yytext, yylval.strval);
66 * This routine copies the in buf to out and replaces every known
67 * variable, e.g. $user, $1, ... by its value. This value either
68 * comes from main program, or the handling routine will figure it
69 * out. If given a quoted string, it ignores the first double quote
70 * and replaces the second with a null.
78 char *in_text, *in_var, *out_cp, VarNo;
85 * Strip the opening quote, remember we're handling a
97 while ((in_var = strchr(in_text, '$')) != NULL) {
98 while(in_text < in_var)
99 *out_cp++ = *in_text++;
101 if(VarNo >= '0' && VarNo <= '9') {
106 "$0 is the program name. Please start from $1.\n");
111 "Illegal variable number ($%d is the largest acceptable)\n",
116 strcpy(out_cp, uss_Var[n]);
117 out_cp += strlen(uss_Var[n]);
121 else if (strncmp(in_var, "$USER", 5) == 0) {
122 strcpy(out_cp, uss_User);
123 out_cp += strlen(uss_User);
127 else if (strncmp(in_var, "$UID", 4) == 0) {
128 strcpy(out_cp, uss_Uid);
129 out_cp += strlen(uss_Uid);
133 else if (strncmp(in_var, "$SERVER", 7) == 0) {
134 strcpy(out_cp, uss_Server);
135 out_cp += strlen(uss_Server);
139 else if (strncmp(in_var, "$PART", 5) == 0) {
140 strcpy(out_cp, uss_Partition);
141 out_cp += strlen(uss_Partition);
145 else if (strncmp(in_var, "$MTPT", 5) == 0) {
146 strcpy(out_cp, uss_MountPoint);
147 out_cp += strlen(uss_MountPoint);
151 else if (strncmp(in_var, "$NAME", 5) == 0) {
152 strcpy(out_cp, uss_RealName);
153 out_cp += strlen(uss_RealName);
157 else if (strncmp(in_var, "$AUTO", 5) == 0) {
158 /*Picks a dir with minimum entries*/
159 uss_procs_PickADir(out, out_cp /*, uss_Auto*/);
160 printf("debug: $AUTO = %s\n", uss_Auto);
161 strcpy(out_cp, uss_Auto);
162 out_cp += strlen(uss_Auto);
165 else if (strncmp(in_var, "$PWEXPIRES", 10) == 0) {
166 sprintf(out_cp, " %d ", uss_Expires);
167 out_cp += strlen(out_cp);
174 "Warning: unknown variable in config file: '%s'\n",
176 *out_cp++ = *in_text++;
181 * At this point, we've copied over the in buffer up to the point
182 * of the last variable instance, so copy over the rest. If this
183 * is a quoted string, we place the terminating null where the
184 * ending double quote is.
186 while(*in_text != '\0')
187 *out_cp++ = *in_text++;
189 if (isQuotedString) {
190 nullP = strchr(out, '"');