1 /* -*- Mode: C; tab-width: 4 -*- 2 * 3 * Copyright (c) 2006-2011 Apple 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 #if !defined YYSTYPE_yylineno 27 #if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION <= 4 28 int yylineno = 1; 29 #endif 30 #endif 31 32 #define YY_NO_INPUT 1 33 int yylex(void); 34 35 static char* StripQuotes(const char * string)36StripQuotes 37 ( 38 const char * string 39 ) 40 { 41 char * dup; 42 43 dup = strdup( string + 1); 44 45 dup[ strlen( dup ) - 1 ] = '\0'; 46 47 return dup; 48 } 49 50 51 %} 52 53 %option nounput 54 %% 55 56 options return OPTIONS; 57 listen-on return LISTEN_ON; 58 nameserver return NAMESERVER; 59 port return PORT; 60 address return ADDRESS; 61 llq return LLQ; 62 public return PUBLIC; 63 private return PRIVATE; 64 key return KEY; 65 allow-update return ALLOWUPDATE; 66 allow-query return ALLOWQUERY; 67 algorithm return ALGORITHM; 68 secret return SECRET; 69 zone return ZONE; 70 type return TYPE; 71 allow return ALLOW; 72 \{ return OBRACE; 73 \} return EBRACE; 74 ; return SEMICOLON; 75 IN return IN; 76 \* yylval.string = strdup(yytext); return WILDCARD; 77 [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ yylval.string = strdup(yytext); return DOTTED_DECIMAL_ADDRESS; 78 [0123456789]+ yylval.number = atoi(yytext); return NUMBER; 79 [a-zA-Z0-9]+(\.[a-zA-Z0-9]+)* yylval.string = strdup(yytext); return HOSTNAME; 80 [a-zA-Z0-9\.]+([a-zA-Z0-9\.]+)* yylval.string = strdup(yytext); return DOMAINNAME; 81 \"([^"\\\r\n]*(\\.[^"\\\r\n]*)*)\" yylval.string = StripQuotes(yytext); return QUOTEDSTRING; 82 [\/][\/].* /* ignore C++ style comments */; 83 \n yylineno++; /* ignore EOL */; 84 [ \t]+ /* ignore whitespace */; 85 %% 86