1 /* -*- Mode: C; tab-width: 4 -*- 2 * 3 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 %{ 19 #include <string.h> 20 #include <stdio.h> 21 #include "dnsextd_parser.h" 22 23 24 extern YYSTYPE yylval; 25 26 /* Mac OS X 10.4 has flex version 2.5.4, which doesn't define yylineno for us */ 27 /* Mac OS X 10.5 has flex version 2.5.33, which does define yylineno */ 28 #if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION <= 4 29 int yylineno = 1; 30 #endif 31 32 int yylex(void); 33 34 static char* 35 StripQuotes 36 ( 37 const char * string 38 ) 39 { 40 char * dup; 41 42 dup = strdup( string + 1); 43 44 dup[ strlen( dup ) - 1 ] = '\0'; 45 46 return dup; 47 } 48 49 50 %} 51 52 %option nounput 53 %% 54 55 options return OPTIONS; 56 listen-on return LISTEN_ON; 57 nameserver return NAMESERVER; 58 port return PORT; 59 address return ADDRESS; 60 llq return LLQ; 61 public return PUBLIC; 62 private return PRIVATE; 63 key return KEY; 64 allow-update return ALLOWUPDATE; 65 allow-query return ALLOWQUERY; 66 algorithm return ALGORITHM; 67 secret return SECRET; 68 zone return ZONE; 69 type return TYPE; 70 allow return ALLOW; 71 \{ return OBRACE; 72 \} return EBRACE; 73 ; return SEMICOLON; 74 IN return IN; 75 \* yylval.string = strdup(yytext); return WILDCARD; 76 [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ yylval.string = strdup(yytext); return DOTTED_DECIMAL_ADDRESS; 77 [0123456789]+ yylval.number = atoi(yytext); return NUMBER; 78 [a-zA-Z0-9]+(\.[a-zA-Z0-9]+)* yylval.string = strdup(yytext); return HOSTNAME; 79 [a-zA-Z0-9\.]+([a-zA-Z0-9\.]+)* yylval.string = strdup(yytext); return DOMAINNAME; 80 \"([^"\\\r\n]*(\\.[^"\\\r\n]*)*)\" yylval.string = StripQuotes(yytext); return QUOTEDSTRING; 81 [\/][\/].* /* ignore C++ style comments */; 82 \n yylineno++; /* ignore EOL */; 83 [ \t]+ /* ignore whitespace */; 84 %% 85