1 %{ 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License, Version 1.0 only 7 * (the "License"). You may not use this file except in compliance 8 * with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or http://www.opensolaris.org/os/licensing. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 * 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * HISTORY 31 * Date Developer Comment 32 * 5-13-96 Jerry Yeung combine agent/config 33 * 6-25-96 Jerry Yeung trap handling 34 * 7-03-96 Jerry Yeung WatchDogTime,MaxPollInterval,MaxAgentTimeOut 35 * 7-17-96 Jerry Yeung change personal to registration_file 36 */ 37 38 /* 39 #define DEBUG_LEX printf("\tLEX: %s(%d) at line %d\n", yytext, yyval, yylineno); 40 */ 41 #define DEBUG_LEX 42 43 44 #define QUOTED_STRING_SIZE 300 45 46 static char quoted_string[QUOTED_STRING_SIZE]; 47 static int token_value; 48 49 static void get_quoted_string(); 50 51 %} 52 53 %% 54 55 #.*\n { ; } 56 [ \t\n]* { ; } 57 \" { get_quoted_string(); 58 return QUOTEDSTRING; 59 } 60 61 \{ { DEBUG_LEX return OPENBRACKET; } 62 \} { DEBUG_LEX return CLOSEBRACKET; } 63 \. { DEBUG_LEX return DOT; } 64 = { DEBUG_LEX return EQUAL; } 65 \, { DEBUG_LEX return COMMA; } 66 \[ { DEBUG_LEX return OPENSQUAREBRACKET; } 67 \] { DEBUG_LEX return CLOSESQUAREBRACKET; } 68 \- { DEBUG_LEX return MINUS; } 69 70 [0-9]+ { DEBUG_LEX token_value = atoi(yytext); 71 return NUMBER; 72 } 73 74 [mM][aA][cC][rR][oO][sS] { DEBUG_LEX return MACROS; } 75 [aA][gG][eE][nN][tT][sS] { DEBUG_LEX return AGENTS; } 76 [nN][aA][mM][eE] { DEBUG_LEX return NAME; } 77 [sS][uU][bB][tT][rR][eE][eE][sS] { DEBUG_LEX return SUBTREES; } 78 [tT][aA][bB][lL][eE][sS] { DEBUG_LEX return TABLES; } 79 [tT][aA][bB][lL][eE] { DEBUG_LEX return TABLE; } 80 [cC][oO][lL][uU][mM][nN][sS] { DEBUG_LEX return COLUMNS; } 81 [iI][nN][dD][eE][xX][sS] { DEBUG_LEX return INDEXS; } 82 [iI][nN][dD][eE][xX][eE][sS] { DEBUG_LEX return INDEXS; } 83 [tT][iI][mM][eE][oO][uU][tT] { DEBUG_LEX return TIMEOUT; } 84 [pP][oO][rR][tT] { DEBUG_LEX return PORT; } 85 [wW][aA][tT][cC][hH][-_][dD][o0][gG][-_][tT][iI][mM][eE] { DEBUG_LEX return WATCHDOGTIME; } 86 [pP][oO][lL][lL][-_][iI][nN][tT][eE][rR][vV][aA][lL] { DEBUG_LEX return POLLINTERVAL; } 87 [mM][aA][xX][-_][aA][gG][eE][nN][tT][-_][tT][iI][mM][eE][oO][uU][tT] { DEBUG_LEX return MAXAGENTTIMEOUT; } 88 [eE][nN][vV][iI][rR][oO][nN][mM][eE][nN][tT] { DEBUG_LEX return ENVIRONMENT; } 89 90 [cC][oO][mM][mM][uU][nN][iI][tT][iI][eE][sS] { DEBUG_LEX return COMMUNITIES; } 91 [rR][eE][aA][dD][-_][oO][nN][lL][yY] { DEBUG_LEX return READONLY; } 92 [rR][eE][aA][dD][-_][wW][rR][iI][tT][eE] { DEBUG_LEX return READWRITE; } 93 [mM][aA][nN][aA][gG][eE][rR][sS] { DEBUG_LEX return MANAGERS; } 94 [tT][rR][aA][pP] { DEBUG_LEX return TRAP; } 95 [tT][rR][aA][pP][-_][nN][uU][mM] { DEBUG_LEX return TRAPNUM; } 96 [tT][rR][aA][pP][-_][cC][oO][mM][mM][uU][nN][iI][tT][yY] { DEBUG_LEX return TRAPCOMMUNITY; } 97 [tT][rR][aA][pP][-_][rR][eE][cC][iI][pP][iI][eE][nN][tT][sS] { DEBUG_LEX return TRAPDESTINATORS; } 98 99 [aA][cC][lL] { DEBUG_LEX return ACL; } 100 [aA][cC][cC][eE][sS][sS] { DEBUG_LEX return ACCESS; } 101 [hH][oO][sS][tT][sS] { DEBUG_LEX return HOSTS; } 102 103 [rR][eE][gG][iI][sS][tT][rR][aA][tT][iI][oO][nN][-_][fF][iI][lL][eE] { DEBUG_LEX return REGISTRATION_FILE; } 104 105 [sS][eE][cC][uU][rR][iI][tT][yY] { DEBUG_LEX return SECURITY; } 106 [pP][oO][lL][iI][cC][yY] { DEBUG_LEX return POLICY; } 107 [tT][yY][pP][eE] { DEBUG_LEX return TYPE; } 108 [uU][sS][eE][rR] { DEBUG_LEX return USER; } 109 [cC][oO][mM][mM][aA][nN][dD] { DEBUG_LEX return COMMAND; } 110 [rR][eE][sS][oO][uU][rR][cC][eE] { DEBUG_LEX return RESOURCE; } 111 [dD][iI][rR][eE][cC][tT][oO][rR][yY] { DEBUG_LEX return DIRECTORY; } 112 113 mib-2 { DEBUG_LEX return MIB2; } 114 sun { DEBUG_LEX return SUN; } 115 enterprise { DEBUG_LEX return ENTERPRISE; } 116 117 ([a-zA-Z\*]|[\_\?\-0-9\*+$#%^@!|~&=`<>\\']*[a-zA-Z])[_0-9a-zA-Z-]* { DEBUG_LEX return IDENTIFIER; } 118 119 . { error_exit("syntax error in %s at line %d: the token %s is not valid", 120 config_file_4_res, yylineno, yytext); 121 } 122 123 124 %% 125 126 #undef input 127 #undef unput 128 #undef output 129 130 /* 131 # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) 132 # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} 133 # define output(c) (void)putc(c,yyout) 134 */ 135 136 #define input() (((yytchar=*lexinput++)=='\n'?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) 137 #define unput(c) {yytchar= (c); if(yytchar=='\n')yylineno--;*--lexinput = yytchar;} 138 #define output(c) 139 140 /*************************************************************************/ 141 142 static void get_quoted_string() 143 { 144 int i = 0; 145 int c; 146 147 148 c = input(); 149 while( (c != 0) && (c != '"') ) 150 { 151 if(c == '\n') 152 { 153 error_exit("syntax error at line %d: can not have a \\n in a quoted string", yylineno); 154 } 155 156 if(i < QUOTED_STRING_SIZE - 1) 157 { 158 quoted_string[i++] = c; 159 } 160 161 c = input(); 162 } 163 quoted_string[i] = '\0'; 164 165 if(c == 0) 166 { 167 error_exit("syntax error at line %d: have not found a quote before the end of file", yylineno); 168 } 169 } 170 171 172