aboutsummaryrefslogtreecommitdiff
path: root/gram.y
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-06 18:50:45 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-03-06 18:50:45 +0200
commit248a97fbf0656d12839ca8986287d216820c9849 (patch)
treee23c9635b7c752ca1b6ed95ecabc1590a18c548b /gram.y
parent8f8a1c98f84669306d1489ddc5d55b6f589df9be (diff)
downloadalck-248a97fbf0656d12839ca8986287d216820c9849.tar.gz
alck-248a97fbf0656d12839ca8986287d216820c9849.tar.bz2
Remove site-specific defaults. Improve local-domain options.
* alck.1: Update. * alck.h (read_include): Remove. (freadlist, preadlist): New protos. * gram.y (usage): Update output. (main): Change -f to -T. Add -W option (read class w from a command stdout). Change handling of the -w option. Remove cwfile - there's no longer a default for -w. * lex.l (read_include): Rename to freadlist and rewrite. (preadlist): New function.
Diffstat (limited to 'gram.y')
-rw-r--r--gram.y44
1 files changed, 24 insertions, 20 deletions
diff --git a/gram.y b/gram.y
index 4da7cb2..271c50d 100644
--- a/gram.y
+++ b/gram.y
@@ -20,7 +20,8 @@
20 20
21char *program_name; 21char *program_name;
22SLIST *cw_list; /* List of domain names pertaining to Sendmail 'w' class */ 22SLIST *cw_list; /* List of domain names pertaining to Sendmail 'w' class */
23static int restricted; /* prohibit use of `special' aliases (pipes, 23
24static int restricted; /* prohibit the use of `special' aliases (pipes,
24 file redirections and includes */ 25 file redirections and includes */
25int verbose; /* Verbose mode */ 26int verbose; /* Verbose mode */
26int error_count; /* Number of errors detected so far */ 27int error_count; /* Number of errors detected so far */
@@ -100,7 +101,7 @@ email : string
100 YYERROR; 101 YYERROR;
101 } 102 }
102 $$ = NULL; 103 $$ = NULL;
103 read_include(&$$, $2); 104 freadlist(&$$, $2);
104 } 105 }
105 ; 106 ;
106 107
@@ -111,7 +112,7 @@ string: IDENT
111%% 112%%
112 113
113int 114int
114yyerror (char *s) 115yyerror(char *s)
115{ 116{
116 parserror(file_name, line_num, "%s", s); 117 parserror(file_name, line_num, "%s", s);
117 error_count++; 118 error_count++;
@@ -174,15 +175,17 @@ usage()
174 printf(" l enable lexical analizer debugging\n"); 175 printf(" l enable lexical analizer debugging\n");
175 printf(" Upper-case variants are also accepted. Prepending\n"); 176 printf(" Upper-case variants are also accepted. Prepending\n");
176 printf(" a letter with '-' reverts its sense\n"); 177 printf(" a letter with '-' reverts its sense\n");
177 printf(" -f FILE Read names of alias files from FILE\n"); 178 printf(" -T FILE Read names of alias files from FILE\n");
178 printf(" -h Display this help list\n"); 179 printf(" -h Display this help list\n");
179 printf(" -r Restrict alias file syntax to aliases only (i.e.\n"); 180 printf(" -r Restrict alias file syntax to aliases only (i.e.\n");
180 printf(" prohibit use of pipes and file redirections\n"); 181 printf(" prohibit use of pipes and file redirections\n");
181 printf(" -u Revert the effect of the previous -r option\n"); 182 printf(" -u Revert the effect of the previous -r option\n");
182 printf(" -v Verbose mode\n"); 183 printf(" -v Verbose mode\n");
183 printf(" -V print program version and exit\n"); 184 printf(" -V print program version and exit\n");
184 printf(" -w FILE Read contents of Sendmail `w' class from the given\n"); 185 printf(" -w FILE Read local domain names from the FILE\n");
185 printf(" file.\n"); 186 printf(" -W PROG Run PROG and read local domain names from"
187 " its stdout\n");
188
186 printf("\n"); 189 printf("\n");
187 printf("Report bugs to <%s>\n", "gray@gnu.org"); 190 printf("Report bugs to <%s>\n", "gray@gnu.org");
188} 191}
@@ -210,17 +213,14 @@ main(int argc, char **argv)
210 int c; 213 int c;
211 int file_count = 0; 214 int file_count = 0;
212 int true = 1; 215 int true = 1;
213 char *cwfile = "/etc/mail/sendmail.cw";
214 SLIST *file_list; /* List of files to be read */ 216 SLIST *file_list; /* List of files to be read */
215 struct string_list *s; 217 struct string_list *s;
216 218
217 init_lex(); 219 init_lex();
218 program_name = argv[0]; 220 program_name = argv[0];
219 while ((c = getopt(argc, argv, "-d:f:hp:ruVvw:")) != EOF) { 221 while ((c = getopt(argc, argv, "-d:hp:rT:uVvW:w:")) != EOF) {
220 switch (c) { 222 switch (c) {
221 case 1: 223 case 1:
222 if (!cw_list)
223 read_include(&cw_list, cwfile);
224 openaliases(optarg); 224 openaliases(optarg);
225 yyparse(); 225 yyparse();
226 file_count++; 226 file_count++;
@@ -252,11 +252,9 @@ main(int argc, char **argv)
252 } 252 }
253 break; 253 break;
254 254
255 case 'f': 255 case 'T':
256 if (!cw_list)
257 read_include(&cw_list, cwfile);
258 file_list = NULL; 256 file_list = NULL;
259 read_include(&file_list, optarg); 257 freadlist(&file_list, optarg);
260 if (file_list) { 258 if (file_list) {
261 for (s = file_list->head; s; s = s->next) { 259 for (s = file_list->head; s; s = s->next) {
262 openaliases_prefix(optarg, s->str); 260 openaliases_prefix(optarg, s->str);
@@ -285,24 +283,30 @@ main(int argc, char **argv)
285 283
286 case 'V': 284 case 'V':
287 version(); 285 version();
288 exit (0); 286 exit(0);
289 287
290 case 'w': 288 case 'w':
291 if (file_count) 289 if (file_count)
292 error("-w must be used before first non-option argument"); 290 error("-w must be used before the first "
293 cwfile = optarg; 291 "non-option argument or -T option");
292 freadlist(&cw_list, optarg);
293 break;
294
295 case 'W':
296 if (file_count)
297 error("-W must be used before the first "
298 "non-option argument or -T option");
299 preadlist(&cw_list, optarg);
294 break; 300 break;
295 301
296 default: 302 default:
297 exit (1); 303 exit(1);
298 } 304 }
299 } 305 }
300 306
301 argc -= optind; 307 argc -= optind;
302 argv += optind; 308 argv += optind;
303 309
304 if (!cw_list)
305 read_include(&cw_list, cwfile);
306 while (argc--) { 310 while (argc--) {
307 openaliases(*argv++); 311 openaliases(*argv++);
308 yyparse(); 312 yyparse();

Return to:

Send suggestions and report system problems to the System administrator.