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>
26 #include "uss_common.h"
29 #define dprint(x) {fprintf(stderr, x); fflush(stderr);}
39 S [\.A-Z0-9a-z/$][^ \t\n#=\^\!\|\(\)\{\};]*
45 {C} {dprint(("got a comment\n"));}
46 ^{EOL} {dprint(("got an empty line\n")); line++;}
47 ^{INVAL} {uss_procs_PrintErr(line," Invalid command \n");}
48 ^[D]{W} {dprint(("got a Dir\n"));return(DIR_TKN);}
49 ^[F]{W} {dprint(("got a File\n"));return(FILE_TKN);}
50 ^[L]{W} {dprint(("got a Link\n"));return(LINK_TKN);}
51 ^[S]{W} {dprint(("got a Symlink\n"));return(SYMLINK_TKN);}
52 ^[E]{W} {dprint(("got an Echo\n"));return(ECHO_TKN);}
53 ^[X]{W} {dprint(("got an Exec\n"));return(EXEC_TKN);}
54 ^[V]{W} {dprint(("got a Vol\n"));return(VOL_TKN);}
55 ^[G]{W} {dprint(("got a Group Declaration\n"));return(GROUP_TKN);}
56 ^[A]{W} {dprint(("got an Auth\n"));return(AUTH_TKN);}
57 ^[Y]{W} {dprint(("got a Vol1\n"));return(VOL1_TKN);}
58 {S} {dprint(("got a string(%s)\n", yytext));
59 Replace(yytext, yylval.strval);
62 {Q} {dprint(("got a quote: '%s'\n", yytext));
63 Replace(yytext, yylval.strval);
72 * This routine copies the in buf to out and replaces every known
73 * variable, e.g. $user, $1, ... by its value. This value either
74 * comes from main program, or the handling routine will figure it
75 * out. If given a quoted string, it ignores the first double quote
76 * and replaces the second with a null.
84 char *in_text, *in_var, *out_cp, VarNo;
91 * Strip the opening quote, remember we're handling a
103 while ((in_var = strchr(in_text, '$')) != NULL) {
104 while(in_text < in_var)
105 *out_cp++ = *in_text++;
107 if(VarNo >= '0' && VarNo <= '9') {
112 "$0 is the program name. Please start from $1.\n");
117 "Illegal variable number ($%d is the largest acceptable)\n",
122 strcpy(out_cp, uss_Var[n]);
123 out_cp += strlen(uss_Var[n]);
127 else if (strncmp(in_var, "$USER", 5) == 0) {
128 strcpy(out_cp, uss_User);
129 out_cp += strlen(uss_User);
133 else if (strncmp(in_var, "$UID", 4) == 0) {
134 strcpy(out_cp, uss_Uid);
135 out_cp += strlen(uss_Uid);
139 else if (strncmp(in_var, "$SERVER", 7) == 0) {
140 strcpy(out_cp, uss_Server);
141 out_cp += strlen(uss_Server);
145 else if (strncmp(in_var, "$PART", 5) == 0) {
146 strcpy(out_cp, uss_Partition);
147 out_cp += strlen(uss_Partition);
151 else if (strncmp(in_var, "$MTPT", 5) == 0) {
152 strcpy(out_cp, uss_MountPoint);
153 out_cp += strlen(uss_MountPoint);
157 else if (strncmp(in_var, "$NAME", 5) == 0) {
158 strcpy(out_cp, uss_RealName);
159 out_cp += strlen(uss_RealName);
163 else if (strncmp(in_var, "$AUTO", 5) == 0) {
164 /*Picks a dir with minimum entries*/
165 uss_procs_PickADir(out, out_cp /*, uss_Auto*/);
166 printf("debug: $AUTO = %s\n", uss_Auto);
167 strcpy(out_cp, uss_Auto);
168 out_cp += strlen(uss_Auto);
171 else if (strncmp(in_var, "$PWEXPIRES", 10) == 0) {
172 sprintf(out_cp, " %d ", uss_Expires);
173 out_cp += strlen(out_cp);
180 "Warning: unknown variable in config file: '%s'\n",
182 *out_cp++ = *in_text++;
187 * At this point, we've copied over the in buffer up to the point
188 * of the last variable instance, so copy over the rest. If this
189 * is a quoted string, we place the terminating null where the
190 * ending double quote is.
192 while(*in_text != '\0')
193 *out_cp++ = *in_text++;
195 if (isQuotedString) {
196 nullP = strchr(out, '"');