|
|
1.1 ! root 1: %{ ! 2: /* ! 3: ******************************************************************************* ! 4: * ! 5: * Copyright (c) 1985 Regents of the University of California. ! 6: * All rights reserved. The Berkeley software License Agreement ! 7: * specifies the terms and conditions for redistribution. ! 8: * ! 9: * @(#)commands.l 5.3 (Berkeley) 2/14/86 ! 10: * ! 11: * commands.l ! 12: * ! 13: * Andrew Cherenson CS298-26 Fall 1985 ! 14: * ! 15: * Lex input file for the nslookup program command interpreter. ! 16: * When a sequence is recognized, the associated action ! 17: * routine is called. The action routine may need to ! 18: * parse the string for additional information. ! 19: * ! 20: * Recognized commands: (identifiers are shown in uppercase) ! 21: * ! 22: * server NAME - set default server to NAME, using default server ! 23: * lserver NAME - set default server to NAME, using initial server ! 24: * finger [NAME] - finger the optional NAME ! 25: * root - set default server to the root ! 26: * ls NAME - list the domain NAME ! 27: * view FILE - sorts and view the file with more ! 28: * set OPTION - set an option ! 29: * help - print help information ! 30: * ? - print help information ! 31: * opt[ions] - print options, current server, host ! 32: * NAME - print info about the host/domain NAME ! 33: * using default server. ! 34: * NAME1 NAME2 - as above, but use NAME2 as server ! 35: * ! 36: * ! 37: * yylex Results: ! 38: * 0 upon end-of-file. ! 39: * 1 after each command. ! 40: * ! 41: ******************************************************************************* ! 42: */ ! 43: ! 44: #include "res.h" ! 45: extern char rootServerName[]; ! 46: ! 47: %} ! 48: WS [ \t] ! 49: LET [A-Za-z0-9.*] ! 50: NAME [A-Za-z0-9.*=_/-] ! 51: %% ! 52: ^{WS}*server{WS}+{LET}{NAME}*{WS}*$ { ! 53: /* ! 54: * 0 == use current server to find ! 55: * the new one. ! 56: * 1 == use original server to find ! 57: * the new one. ! 58: */ ! 59: SetDefaultServer(yytext, 0); ! 60: return(1); ! 61: } ! 62: ^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$ { ! 63: SetDefaultServer(yytext, 1); ! 64: return(1); ! 65: } ! 66: ^{WS}*root{WS}*$ { ! 67: SetDefaultServer(rootServerName, 1); ! 68: return(1); ! 69: } ! 70: ^{WS}*finger({WS}+{LET}{NAME}*)?{WS}+>>?{WS}+{NAME}+{WS}*$ { ! 71: /* ! 72: * 2nd arg. ! 73: * 0 == output to stdout ! 74: * 1 == output to file ! 75: */ ! 76: Finger(yytext, 1); ! 77: return(1); ! 78: } ! 79: ^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$ { ! 80: Finger(yytext, 0); ! 81: return(1); ! 82: } ! 83: ^{WS}*view{WS}+{NAME}+{WS}*$ { ! 84: ViewList(yytext); ! 85: return(1); ! 86: } ! 87: ^{WS}*ls{WS}+(("-a"|"-h"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ { ! 88: /* ! 89: * 2nd arg. ! 90: * 0 == output to stdout ! 91: * 1 == output to file ! 92: */ ! 93: ListHosts(yytext, 1); ! 94: return(1); ! 95: } ! 96: ^{WS}*ls{WS}+(("-a"|"-h"|"-m"){WS}+)?{LET}{NAME}*{WS}*$ { ! 97: ListHosts(yytext, 0); ! 98: return(1); ! 99: } ! 100: ^{WS}*set{WS}+{NAME}+{WS}*$ { ! 101: SetOption(yytext); ! 102: return(1); ! 103: } ! 104: ^{WS}*help{WS}*$ { ! 105: extern void PrintHelp(); ! 106: ! 107: PrintHelp(); ! 108: return(1); ! 109: } ! 110: ^{WS}*"?"{WS}*$ { ! 111: PrintHelp(); ! 112: return(1); ! 113: } ! 114: ^{WS}*opt(ions)?{WS}*$ { ! 115: ShowOptions(TRUE); ! 116: return(1); ! 117: } ! 118: ^{WS}*{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ { ! 119: /* ! 120: * 0 == output to stdout ! 121: * 1 == output to file ! 122: */ ! 123: LookupHost(yytext, 1); ! 124: return(1); ! 125: } ! 126: ^{WS}*{LET}{NAME}*{WS}*$ { ! 127: LookupHost(yytext, 0); ! 128: return(1); ! 129: } ! 130: ^{WS}*{LET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ { ! 131: /* ! 132: * 0 == output to stdout ! 133: * 1 == output to file ! 134: */ ! 135: LookupHostWithServer(yytext, 1); ! 136: return(1); ! 137: } ! 138: ^{WS}*{LET}{NAME}*{WS}+{LET}{NAME}*{WS}*$ { ! 139: LookupHostWithServer(yytext, 0); ! 140: return(1); ! 141: } ! 142: ^{WS}*\n { ! 143: return(1); ! 144: } ! 145: ^.*\n { ! 146: printf("Unrecognized command: %s", ! 147: yytext); ! 148: return(1); ! 149: } ! 150: \n { ; } ! 151: %%
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.