               
%{
/*
 * Copyright (c) 1992, 1993 Arno Augustin, Frank Hoering, University of
 * Erlangen-Nuremberg, Germany.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	Erlangen-Nuremberg, Germany.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software has not been validated by the ``Bundesamt fuer Zulassungen in
 * der Telekommunikation'' of the ``Deutsche Bundepost Telekom'' and thus
 * must not be used for accessing the BTX-Network of the Telekom in Germany.
 *
 * Diese Software hat keine Zulassung durch das Bundesamt fuer Zulassungen in
 * der Telekommunikation der Deutschen Bundespost Telekom und darf daher nicht
 * am Netz der Deutschen Bundespost Telekom in Deutschland betrieben werden.
 */

        /* space for c program and include*/

static int line_number=1;
static int last_number=0;
static char last_string[256];
int setbaud();

dolex()
{
   line_number=1;
   return yylex();
}

#undef yywrap

int yywrap()
{ 
	return 1;
}
#define YYRETURN(c)  {yy_init = 1; yy_start = 0; return (c);}

%}

NUMBER   [0-9]+
DIGIT    [0-9]
STRING   \"([ -!#-~]|"\\\"")*\"
WHITE    [ \t\n]

%s ebaud
%s edevicename
%s edevicespeed
%s ehangupstring
%s esendstring
%s esleep
%s ewaitnumber
%s econnectstring
%s ebusystring
%s enocarrierstring
%s enodialtonestring
%s eisdndevice
%s eisdnport

%%

baud[ \t]+              BEGIN(ebaud);
<ebaud>{NUMBER} {
                  if( setbaud( atoi(yytext) ) == -1) 
                     YYRETURN(line_number)
                  BEGIN(INITIAL);
               }
<ebaud>.          YYRETURN(line_number)


hangupstring[ \t]+      BEGIN(ehangupstring);
<ehangupstring>{STRING} {
                  sethangupstring(yytext);
                  BEGIN(INITIAL);
               }
<ehangupstring>.  YYRETURN(line_number)

connectstring[ \t]+      BEGIN(econnectstring);
<econnectstring>{STRING} {
                  setconnectstring(yytext);
                  BEGIN(INITIAL);
               }
<econnectstring>.  YYRETURN(line_number)

nodialtonestring[ \t]+      BEGIN(enodialtonestring);
<enodialtonestring>{STRING} {
                  setnodialtonestring(yytext);
                  BEGIN(INITIAL);
               }
<enodialtonestring>.  YYRETURN(line_number)

nocarrierstring[ \t]+      BEGIN(enocarrierstring);
<enocarrierstring>{STRING} {
                  setnocarrierstring(yytext);
                  BEGIN(INITIAL);
               }
<enocarrierstring>.  YYRETURN(line_number)


busystring[ \t]+      BEGIN(ebusystring);
<ebusystring>{STRING} {
                  setbusystring(yytext);
                  BEGIN(INITIAL);
               }
<ebusystring>.  YYRETURN(line_number)



opendevice[ \t]+              BEGIN(edevicespeed);
<edevicespeed>{NUMBER} {
                  last_number = atoi(yytext);
                  BEGIN(edevicename);
               }
<edevicespeed>.    YYRETURN(line_number)

<edevicename>{STRING} {
                  if(-1 == opendevice(yytext,last_number))
		     YYRETURN(line_number)
                  BEGIN(INITIAL);
               }                  
<edevicename>[ \t]+   /* skip white spaces */
<edevicename>.    YYRETURN(line_number)





openisdn[ \t]+              BEGIN(eisdnport);
<eisdnport>{STRING} {
                	  	strcpy(last_string,yytext);
                  		BEGIN(eisdndevice);
            	    }
<eisdnport>.   YYRETURN(line_number)

<eisdndevice>{STRING} {
                  if(-1 == isdn(yytext,last_string))
		     YYRETURN(line_number)
                  BEGIN(INITIAL);
               }                  
<eisdndevice>[ \t]+   /* skip white spaces */
<eisdndevice>.    YYRETURN(line_number)




sleep[ \t]+              BEGIN(esleep);
<esleep>{NUMBER} {
                  wsleep(atoi(yytext));
                  BEGIN(INITIAL);
               }
<esleep>.         YYRETURN(line_number)



send[ \t]+              BEGIN(esendstring);
<esendstring>{STRING} {
                  sendstring(yytext);
                  BEGIN(INITIAL);
               }
<esendstring>.    YYRETURN(line_number)


wait[ \t]+              BEGIN(ewaitnumber);
<ewaitnumber>{NUMBER} {
                  if(-1 == waitconnect(atoi(yytext))) YYRETURN(line_number);
                  BEGIN(INITIAL);
               }
<ewaitnumber>.         YYRETURN(line_number)


[ \t]+           /* skip white spaces   */

#.*\n            line_number++; /* # skip comment  */
\n               line_number++;
.                YYRETURN(line_number) /* ERROR */
<<EOF>>          {
                     YYRETURN(0)
                 }
%%




