Blame modules/pam_console/configfile.l

Packit 7e982e
%option noyywrap
Packit 7e982e
%{
Packit 7e982e
/* Copyright 1999,2000 Red Hat, Inc.
Packit 7e982e
 * This software may be used under the terms of the GNU General Public
Packit 7e982e
 * License, available in the file COPYING accompanying this file
Packit 7e982e
 */
Packit 7e982e
/* get around an apparant bug in bison; YYSTYPE not copied into config.tab.h */
Packit 7e982e
#define YYSTYPE void *
Packit 7e982e
#include "configfile.h"
Packit 7e982e
#include "configfile.tab.h"
Packit 7e982e
#include <stdio.h>
Packit 7e982e
#include <string.h>
Packit 7e982e
#include <syslog.h>
Packit 7e982e
Packit 7e982e
#include "pam_console.h"
Packit 7e982e
Packit 7e982e
static int lineno;
Packit 7e982e
static const char *filename;
Packit 7e982e
Packit 7e982e
STATIC char *
Packit 7e982e
strip_slash(const char *);
Packit 7e982e
%}
Packit 7e982e
%%
Packit 7e982e
\n			{ lineno++; return EOL; }
Packit 7e982e
\\\n			{ lineno++; }
Packit 7e982e
			/* do not return EOL, eat up escaped newline */
Packit 7e982e
[ \t]+			/* ignore whitespace */
Packit 7e982e
\<			{ return OBRACKET; }
Packit 7e982e
\>=			{ return CBEQUALS; }
Packit 7e982e
\>			{ return CBRACKET; }
Packit 7e982e
([^\t\n #\<\>]|(\\#|\\\<|\\\>))+ { _pc_yylval=strip_slash(yytext); return STRING; }
Packit 7e982e
#.*\n			{ lineno++; return EOL; } /* ignore comments */
Packit 7e982e
%%
Packit 7e982e
Packit 7e982e
static void
Packit 7e982e
lex_file (FILE *in) {
Packit 7e982e
  /* yy_flex_debug = 1; */
Packit 7e982e
  yyin = in;
Packit 7e982e
  lineno = 1;
Packit 7e982e
}
Packit 7e982e
Packit 7e982e
static void
Packit 7e982e
lex_set_filename(const char *name) {
Packit 7e982e
  filename = name;
Packit 7e982e
}
Packit 7e982e
Packit 7e982e
static int
Packit 7e982e
_pc_yyerror (const char *s) {
Packit 7e982e
  _pam_log(NULL, LOG_ERR, 0, "%s line %d: %s: at `%s'\n",
Packit 7e982e
	   filename, lineno, s, (char *)_pc_yylval);
Packit 7e982e
  return 0;
Packit 7e982e
}
Packit 7e982e
Packit 7e982e
STATIC char *
Packit 7e982e
strip_slash(const char *s) {
Packit 7e982e
  char *r, *t;
Packit 7e982e
Packit 7e982e
  t = r = strdup(s);
Packit 7e982e
  while ((t = strchr(t, '\\')) != NULL) {
Packit 7e982e
    if (t[1] == '#' || t[1] == '<' || t[1] == '>') {
Packit 7e982e
      memmove(t, t+1, strlen(t));
Packit 7e982e
    }
Packit 7e982e
    t++;
Packit 7e982e
  }
Packit 7e982e
  return r;
Packit 7e982e
}