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>
21
RCSID("$Header: /afs/sipb.mit.edu/project/openafs/debian/cvs/openafs/src/uss/lex.c,v 1.1.1.6 2003/07/30 17:13:24 hartmans Exp $");
24
#include "uss_common.h"
27
#define dprint(x) {fprintf(stderr, x); fflush(stderr);}
37
S [\.A-Z0-9a-z/$][^ \t\n#=\^\!\|\(\)\{\};]*
43
{C} {dprint(("got a comment\n"));}
44
^{EOL} {dprint(("got an empty line\n")); line++;}
45
^{INVAL} {uss_procs_PrintErr(line," Invalid command \n");}
46
^[D]{W} {dprint(("got a Dir\n"));return(DIR_TKN);}
47
^[F]{W} {dprint(("got a File\n"));return(FILE_TKN);}
48
^[L]{W} {dprint(("got a Link\n"));return(LINK_TKN);}
49
^[S]{W} {dprint(("got a Symlink\n"));return(SYMLINK_TKN);}
50
^[E]{W} {dprint(("got an Echo\n"));return(ECHO_TKN);}
51
^[X]{W} {dprint(("got an Exec\n"));return(EXEC_TKN);}
52
^[V]{W} {dprint(("got a Vol\n"));return(VOL_TKN);}
53
^[G]{W} {dprint(("got a Group Declaration\n"));return(GROUP_TKN);}
54
^[A]{W} {dprint(("got an Auth\n"));return(AUTH_TKN);}
55
^[Y]{W} {dprint(("got a Vol1\n"));return(VOL1_TKN);}
56
{S} {dprint(("got a string(%s)\n", yytext));
57
Replace(yytext, yylval.strval);
60
{Q} {dprint(("got a quote: '%s'\n", yytext));
61
Replace(yytext, yylval.strval);
70
* This routine copies the in buf to out and replaces every known
71
* variable, e.g. $user, $1, ... by its value. This value either
72
* comes from main program, or the handling routine will figure it
73
* out. If given a quoted string, it ignores the first double quote
74
* and replaces the second with a null.
82
char *in_text, *in_var, *out_cp, VarNo;
89
* Strip the opening quote, remember we're handling a
101
while ((in_var = strchr(in_text, '$')) != NULL) {
102
while(in_text < in_var)
103
*out_cp++ = *in_text++;
105
if(VarNo >= '0' && VarNo <= '9') {
110
"$0 is the program name. Please start from $1.\n");
115
"Illegal variable number ($%d is the largest acceptable)\n",
120
strcpy(out_cp, uss_Var[n]);
121
out_cp += strlen(uss_Var[n]);
125
else if (strncmp(in_var, "$USER", 5) == 0) {
126
strcpy(out_cp, uss_User);
127
out_cp += strlen(uss_User);
131
else if (strncmp(in_var, "$UID", 4) == 0) {
132
strcpy(out_cp, uss_Uid);
133
out_cp += strlen(uss_Uid);
137
else if (strncmp(in_var, "$SERVER", 7) == 0) {
138
strcpy(out_cp, uss_Server);
139
out_cp += strlen(uss_Server);
143
else if (strncmp(in_var, "$PART", 5) == 0) {
144
strcpy(out_cp, uss_Partition);
145
out_cp += strlen(uss_Partition);
149
else if (strncmp(in_var, "$MTPT", 5) == 0) {
150
strcpy(out_cp, uss_MountPoint);
151
out_cp += strlen(uss_MountPoint);
155
else if (strncmp(in_var, "$NAME", 5) == 0) {
156
strcpy(out_cp, uss_RealName);
157
out_cp += strlen(uss_RealName);
161
else if (strncmp(in_var, "$AUTO", 5) == 0) {
162
/*Picks a dir with minimum entries*/
163
uss_procs_PickADir(out, out_cp /*, uss_Auto*/);
164
printf("debug: $AUTO = %s\n", uss_Auto);
165
strcpy(out_cp, uss_Auto);
166
out_cp += strlen(uss_Auto);
169
else if (strncmp(in_var, "$PWEXPIRES", 10) == 0) {
170
sprintf(out_cp, " %d ", uss_Expires);
171
out_cp += strlen(out_cp);
178
"Warning: unknown variable in config file: '%s'\n",
180
*out_cp++ = *in_text++;
185
* At this point, we've copied over the in buffer up to the point
186
* of the last variable instance, so copy over the rest. If this
187
* is a quoted string, we place the terminating null where the
188
* ending double quote is.
190
while(*in_text != '\0')
191
*out_cp++ = *in_text++;
193
if (isQuotedString) {
194
nullP = strchr(out, '"');
195
if (nullP == (char *)0)