|
|
1.1 root 1: %{
2:
3: /*-
4: * Copyright (c) 1985 The Regents of the University of California.
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms are permitted provided
8: * that: (1) source distributions retain this entire copyright notice and
9: * comment, and (2) distributions including binaries display the following
10: * acknowledgement: ``This product includes software developed by the
11: * University of California, Berkeley and its contributors'' in the
12: * documentation or other materials provided with the distribution and in
13: * all advertising materials mentioning features or use of this software.
14: * Neither the name of the University nor the names of its contributors may
15: * be used to endorse or promote products derived from this software without
16: * specific prior written permission.
17: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20: */
21:
22: #ifndef lint
23: static char sccsid[] = "@(#)commands.l 5.13 (Berkeley) 7/24/90";
24: #endif /* not lint */
25:
26: /*
27: *******************************************************************************
28: *
29: * commands.l
30: *
31: * Andrew Cherenson CS298-26 Fall 1985
32: *
33: * Lex input file for the nslookup program command interpreter.
34: * When a sequence is recognized, the associated action
35: * routine is called. The action routine may need to
36: * parse the string for additional information.
37: *
38: * Recognized commands: (identifiers are shown in uppercase)
39: *
40: * server NAME - set default server to NAME, using default server
41: * lserver NAME - set default server to NAME, using initial server
42: * finger [NAME] - finger the optional NAME
43: * exit - exit the program
44: * root - set default server to the root
45: * ls NAME - list the domain NAME
46: * view FILE - sorts and view the file with more
47: * set OPTION - set an option
48: * help - print help information
49: * ? - print help information
50: * NAME - print info about the host/domain NAME
51: * using default server.
52: * NAME1 NAME2 - as above, but use NAME2 as server
53: *
54: *
55: * yylex Results:
56: * 0 upon end-of-file.
57: * 1 after each command.
58: *
59: *******************************************************************************
60: */
61:
62: #include "res.h"
63: extern char rootServerName[];
64:
65: %}
66: WS [ \t]
67: FLET [A-Za-z0-9.*\\]
68: LET [A-Za-z0-9.*]
69: NAME [A-Za-z0-9.*=_/-]
70: %%
71: ^{WS}*server{WS}+{LET}{NAME}*{WS}*$ {
72: /*
73: * 0 == use current server to find
74: * the new one.
75: * 1 == use original server to find
76: * the new one.
77: */
78: SetDefaultServer(yytext, 0);
79: return(1);
80: }
81: ^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$ {
82: SetDefaultServer(yytext, 1);
83: return(1);
84: }
85: ^{WS}*exit{WS}*$ {
86: return(0);
87: }
88: ^{WS}*root{WS}*$ {
89: SetDefaultServer(rootServerName, 1);
90: return(1);
91: }
92: ^{WS}*finger({WS}+{LET}{NAME}*)?{WS}+>>?{WS}*{NAME}+{WS}*$ {
93: /*
94: * 2nd arg.
95: * 0 == output to stdout
96: * 1 == output to file
97: */
98: Finger(yytext, 1);
99: return(1);
100: }
101: ^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$ {
102: Finger(yytext, 0);
103: return(1);
104: }
105: ^{WS}*view{WS}+{NAME}+{WS}*$ {
106: ViewList(yytext);
107: return(1);
108: }
109: ^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
110: /*
111: * 2nd arg.
112: * 0 == output to stdout
113: * 1 == output to file
114: */
115: ListHosts(yytext, 1);
116: return(1);
117: }
118: ^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}*$ {
119: ListHosts(yytext, 0);
120: return(1);
121: }
122: ^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
123: /*
124: * 2nd arg.
125: * 0 == output to stdout
126: * 1 == output to file
127: */
128: ListHostsByType(yytext, 1);
129: return(1);
130: }
131: ^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}*$ {
132: ListHostsByType(yytext, 0);
133: return(1);
134: }
135: ^{WS}*set{WS}+{NAME}+{WS}*$ {
136: SetOption(yytext);
137: return(1);
138: }
139: ^{WS}*help{WS}*$ {
140: extern void PrintHelp();
141:
142: PrintHelp();
143: return(1);
144: }
145: ^{WS}*"?"{WS}*$ {
146: PrintHelp();
147: return(1);
148: }
149: ^{WS}*{FLET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
150: /*
151: * 0 == output to stdout
152: * 1 == output to file
153: */
154: LookupHost(yytext, 1);
155: return(1);
156: }
157: ^{WS}*{FLET}{NAME}*{WS}*$ {
158: LookupHost(yytext, 0);
159: return(1);
160: }
161: ^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
162: /*
163: * 0 == output to stdout
164: * 1 == output to file
165: */
166: LookupHostWithServer(yytext, 1);
167: return(1);
168: }
169: ^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}*$ {
170: LookupHostWithServer(yytext, 0);
171: return(1);
172: }
173: ^{WS}*\n {
174: return(1);
175: }
176: ^.*\n {
177: printf("Unrecognized command: %s",
178: yytext);
179: return(1);
180: }
181: \n { ; }
182: %%
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.