Blame lib/nss_tok.l

Packit 8480eb
%{
Packit 8480eb
/* ----------------------------------------------------------------------- *
Packit 8480eb
 *   
Packit 8480eb
 *  nss_tok.l - nsswitch tokenizer.
Packit 8480eb
 *
Packit 8480eb
 *   Copyright 2006 Ian Kent <raven@themaw.net>
Packit 8480eb
 *
Packit 8480eb
 *   This program is free software; you can redistribute it and/or modify
Packit 8480eb
 *   it under the terms of the GNU General Public License as published by
Packit 8480eb
 *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
Packit 8480eb
 *   USA; either version 2 of the License, or (at your option) any later
Packit 8480eb
 *   version.
Packit 8480eb
 *   
Packit 8480eb
 *   This program is distributed in the hope that it will be useful,
Packit 8480eb
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8480eb
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8480eb
 *   GNU General Public License for more details.
Packit 8480eb
 *
Packit 8480eb
 * ----------------------------------------------------------------------- */
Packit 8480eb
Packit 8480eb
#ifdef ECHO
Packit 8480eb
# undef ECHO
Packit 8480eb
#endif /* ECHO */
Packit 8480eb
static void nss_echo(void);	/* forward definition */
Packit 8480eb
#define ECHO nss_echo()
Packit 8480eb
Packit 8480eb
#include <stdio.h>
Packit 8480eb
#include <stdlib.h>
Packit 8480eb
#include <string.h>
Packit 8480eb
#include "nss_parse.tab.h"
Packit 8480eb
Packit 8480eb
/*
Packit 8480eb
 * There are some things that need to be defined only if useing GNU flex.
Packit 8480eb
 * These must not be defined if using standard lex
Packit 8480eb
 */
Packit 8480eb
#ifdef FLEX_SCANNER
Packit 8480eb
int nss_lineno;
Packit 8480eb
#endif
Packit 8480eb
Packit 8480eb
int nss_lex(void);
Packit 8480eb
#ifndef nss_wrap
Packit 8480eb
int nss_wrap(void);
Packit 8480eb
#endif
Packit 8480eb
#define YY_SKIP_YYWRAP
Packit 8480eb
Packit 8480eb
#ifndef YY_STACK_USED
Packit 8480eb
#define YY_STACK_USED 0
Packit 8480eb
#endif
Packit 8480eb
#ifndef YY_ALWAYS_INTERACTIVE
Packit 8480eb
#define YY_ALWAYS_INTERACTIVE 0
Packit 8480eb
#endif
Packit 8480eb
#ifndef YY_NEVER_INTERACTIVE
Packit 8480eb
#define YY_NEVER_INTERACTIVE 0
Packit 8480eb
#endif
Packit 8480eb
#ifndef YY_MAIN
Packit 8480eb
#define YY_MAIN 0
Packit 8480eb
#endif
Packit 8480eb
Packit 8480eb
extern unsigned int nss_automount_found;
Packit 8480eb
Packit 8480eb
%}
Packit 8480eb
Packit 8480eb
%option nounput
Packit 8480eb
Packit 8480eb
%x AUTOMOUNT ACTIONSTR
Packit 8480eb
Packit 8480eb
WS		[[:blank:]]+
Packit 8480eb
Packit 8480eb
automount	([Aa][Uu][Tt][Oo][Mm][Oo][Uu][Nn][Tt])
Packit 8480eb
Packit 8480eb
source		[[:alnum:]@$%^&*()-+_":;?,<>./'{}~`]+
Packit 8480eb
Packit 8480eb
success		([Ss][Uu][Cc][Cc][Ee][Ss][Ss])
Packit 8480eb
notfound	([Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd])
Packit 8480eb
unavail		([Uu][Nn][Aa][Vv][Aa][Ii][Ll])
Packit 8480eb
tryagain	([Tt][Rr][Yy][Aa][Gg][Aa][Ii][Nn])
Packit 8480eb
Packit 8480eb
status		({success}|{notfound}|{unavail}|{tryagain})
Packit 8480eb
Packit 8480eb
continue	([Cc][Oo][Nn][Tt][Ii][Nn][Uu][Ee])
Packit 8480eb
return		([Rr][Ee][Tt][Uu][Rr][Nn])
Packit 8480eb
Packit 8480eb
action		({continue}|{return})
Packit 8480eb
Packit 8480eb
%%
Packit 8480eb
Packit 8480eb
^{automount}: {
Packit 8480eb
	nss_automount_found = 1;
Packit 8480eb
	BEGIN(AUTOMOUNT);
Packit 8480eb
}
Packit 8480eb
Packit 8480eb
\n|.	{}
Packit 8480eb
Packit 8480eb
<AUTOMOUNT>{
Packit 8480eb
	{WS}	{ }
Packit 8480eb
Packit 8480eb
	{source} {
Packit 8480eb
		strcpy(nss_lval.strval, nss_text);
Packit 8480eb
		return SOURCE;
Packit 8480eb
	}
Packit 8480eb
Packit 8480eb
	"["	{ BEGIN(ACTIONSTR); yyless(0); }
Packit 8480eb
Packit 8480eb
	\n	{ BEGIN(INITIAL); return NL; }
Packit 8480eb
}
Packit 8480eb
Packit 8480eb
<ACTIONSTR>{
Packit 8480eb
	{WS}	{ }
Packit 8480eb
Packit 8480eb
	{status} {
Packit 8480eb
		strcpy(nss_lval.strval, nss_text);
Packit 8480eb
		return STATUS;
Packit 8480eb
	}
Packit 8480eb
Packit 8480eb
	{action} {
Packit 8480eb
		strcpy(nss_lval.strval, nss_text);
Packit 8480eb
		return ACTION;
Packit 8480eb
	}
Packit 8480eb
Packit 8480eb
	"["	{ return LBRACKET; }
Packit 8480eb
	"]"	{ BEGIN(AUTOMOUNT); return RBRACKET; }
Packit 8480eb
	"="	{ return EQUAL; }
Packit 8480eb
	"!"	{ return BANG; }
Packit 8480eb
Packit 8480eb
	.	{ BEGIN(AUTOMOUNT); yyless(0); }
Packit 8480eb
	\n	{ BEGIN(INITIAL); return NL; }
Packit 8480eb
}
Packit 8480eb
Packit 8480eb
%%
Packit 8480eb
Packit 8480eb
#include "automount.h"
Packit 8480eb
Packit 8480eb
int nss_wrap(void)
Packit 8480eb
{
Packit 8480eb
	return 1;
Packit 8480eb
}
Packit 8480eb
Packit 8480eb
static void nss_echo(void)
Packit 8480eb
{
Packit 8480eb
	logmsg("%s", nss_text);
Packit 8480eb
	return;
Packit 8480eb
}