token.l revision 255570
1255570Strasz%{
2255570Strasz/*-
3255570Strasz * Copyright (c) 2012 The FreeBSD Foundation
4255570Strasz * All rights reserved.
5255570Strasz *
6255570Strasz * This software was developed by Edward Tomasz Napierala under sponsorship
7255570Strasz * from the FreeBSD Foundation.
8255570Strasz *
9255570Strasz * Redistribution and use in source and binary forms, with or without
10255570Strasz * modification, are permitted provided that the following conditions
11255570Strasz * are met:
12255570Strasz * 1. Redistributions of source code must retain the above copyright
13255570Strasz *    notice, this list of conditions and the following disclaimer.
14255570Strasz * 2. Redistributions in binary form must reproduce the above copyright
15255570Strasz *    notice, this list of conditions and the following disclaimer in the
16255570Strasz *    documentation and/or other materials provided with the distribution.
17255570Strasz *
18255570Strasz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19255570Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20255570Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21255570Strasz * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22255570Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23255570Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24255570Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25255570Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26255570Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27255570Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28255570Strasz * SUCH DAMAGE.
29255570Strasz *
30255570Strasz * $FreeBSD: head/usr.sbin/ctld/token.l 255570 2013-09-14 15:29:06Z trasz $
31255570Strasz */
32255570Strasz
33255570Strasz#include <stdio.h>
34255570Strasz#include <stdint.h>
35255570Strasz#include <string.h>
36255570Strasz
37255570Strasz#include "ctld.h"
38255570Strasz#include "y.tab.h"
39255570Strasz
40255570Straszint lineno;
41255570Strasz
42255570Strasz#define	YY_DECL int yylex(void)
43255570Straszextern int	yylex(void);
44255570Strasz
45255570Strasz%}
46255570Strasz
47255570Strasz%option noinput
48255570Strasz%option nounput
49255570Strasz
50255570Strasz%%
51255570Straszalias			{ return ALIAS; }
52255570Straszauth-group		{ return AUTH_GROUP; }
53255570Straszbackend			{ return BACKEND; }
54255570Straszblocksize		{ return BLOCKSIZE; }
55255570Straszchap			{ return CHAP; }
56255570Straszchap-mutual		{ return CHAP_MUTUAL; }
57255570Straszdebug			{ return DEBUG; }
58255570Straszdevice-id		{ return DEVICE_ID; }
59255570Straszdiscovery-auth-group	{ return DISCOVERY_AUTH_GROUP; }
60255570Straszlisten			{ return LISTEN; }
61255570Straszlisten-iser		{ return LISTEN_ISER; }
62255570Straszlun			{ return LUN; }
63255570Straszmaxproc			{ return MAXPROC; }
64255570Straszoption			{ return OPTION; }
65255570Straszpath			{ return PATH; }
66255570Straszpidfile			{ return PIDFILE; }
67255570Straszportal-group		{ return PORTAL_GROUP; }
68255570Straszserial			{ return SERIAL; }
69255570Straszsize			{ return SIZE; }
70255570Strasztarget			{ return TARGET; }
71255570Strasztimeout			{ return TIMEOUT; }
72255570Strasz[0-9]+[kKmMgGtTpPeE]?	{ if (expand_number(yytext, &yylval.num) == 0)
73255570Strasz				return NUM;
74255570Strasz			  else
75255570Strasz				return STR;
76255570Strasz			}
77255570Strasz\"[^"]+\"		{ yylval.str = strndup(yytext + 1,
78255570Strasz			    strlen(yytext) - 2); return STR; }
79255570Strasz[a-zA-Z0-9\.\-_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; }
80255570Strasz\{			{ return OPENING_BRACKET; }
81255570Strasz\}			{ return CLOSING_BRACKET; }
82255570Strasz#.*$			/* ignore comments */;
83255570Strasz\n			{ lineno++; }
84255570Strasz[ \t]+			/* ignore whitespace */;
85255570Strasz%%
86