1: /*
2: * Convert mail alias file to nameserver DB format.
3: */
4:
5: %{
6: #include <stdio.h>
7: #include <ctype.h>
8:
9: char yytext[BUFSIZ];
10: int lineno = 1;
11: %}
12:
13: %token NAME
14:
15: %start list
16:
17: %%
18:
19: list: /* empty */
20: | list alias ':' a_list
21: ;
22:
23: alias: NAME {
24: printf("%s IN MB UCB-VAX.ARPA\n", yytext);
25: }
26: ;
27:
28: a_list: aname
29: | a_list ',' aname
30: ;
31:
32: aname: NAME {
33: printf(" IN MG %s\n", yytext);
34: }
35: ;
36: %%
37:
38: yylex()
39: {
40: register char *cp;
41: register int c;
42: char op[32];
43:
44: for (;;) {
45: c = getchar();
46: top:
47: switch (c) {
48: case '#':
49: while ((c = getchar()) != EOF && c != '\n')
50: ;
51: goto top;
52:
53: case '\\':
54: if ((c = getchar()) == EOF) {
55: c = '\\';
56: break;
57: }
58: if (c != '\n') {
59: ungetc(c, stdin);
60: c = '\\';
61: break;
62: }
63: case '\n':
64: lineno++;
65: case ' ':
66: case '\t':
67: continue;
68:
69: case EOF:
70: case ':':
71: case ',':
72: return (c);
73: }
74: cp = yytext;
75: do {
76: if (c == '"') {
77: do {
78: if (cp >= &yytext[BUFSIZ-1]) {
79: yyerror("buffer overflow");
80: break;
81: }
82: *cp++ = c;
83: } while ((c = getchar()) != EOF && c != '"');
84: }
85: if (cp >= &yytext[BUFSIZ-1]) {
86: yyerror("buffer overflow");
87: break;
88: }
89: if (islower(c))
90: c = toupper(c);
91: *cp++ = c;
92: } while ((c = getchar()) != EOF && !any(c, ",: \t\n"));
93: ungetc(c, stdin);
94: *cp = '\0';
95: return (NAME);
96: }
97: }
98:
99: any(c, s)
100: int c;
101: register char *s;
102: {
103: while (*s)
104: if (c == *s++)
105: return (1);
106: return (0);
107: }
108:
109: main()
110: {
111: yyparse();
112: }
113:
114: yyerror(s)
115: char *s;
116: {
117: fprintf(stderr, "line %d: %s\n", lineno, s);
118: }
Defined functions
_any
defined in line
99; used 1 times