2 * Advanced Linux Sound Architecture Control Program
3 * Copyright (c) 1998 by Perex, APS, University of South Bohemia
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include "alsactl_parser.h"
35 #define YY_CDECL int YY_PROTO(yylex( void ));
43 /* special characters */
45 "{"|"}" return yytext[0];
46 "("|")" return yytext[0];
47 "["|"]" return yytext[0];
48 ")"[ \t]*"{" return L_DOUBLE1;
54 soundcard return L_SOUNDCARD;
55 control return L_CONTROL;
57 element return L_ELEMENT;
58 switch return L_SWITCH;
59 rawdata return L_RAWDATA;
61 rawmidi return L_RAWMIDI;
62 playback return L_PLAYBACK;
63 record return L_RECORD;
64 output return L_OUTPUT;
66 iec958ocs return L_IEC958OCS;
72 protect return L_PROTECT;
74 fsunlock return L_FSUNLOCK;
76 gstatus return L_GSTATUS;
77 enable return L_ENABLE;
78 disable return L_DISABLE;
80 mono_sw return L_MONO_SW;
82 volume return L_VOLUME;
83 center return L_CENTER;
87 feedback return L_FEEDBACK;
89 treble return L_TREBLE;
93 Switch1 return L_SWITCH1;
94 Switch2 return L_SWITCH2;
95 Switch3 return L_SWITCH3;
96 Volume1 return L_VOLUME1;
100 ToneControl1 return L_TONE_CONTROL1;
101 _3D_Effect1 return L_3D_EFFECT1;
105 false|off|no return L_FALSE;
106 true|on|yes return L_TRUE;
110 [0-9]+ { yylval.i_value = atoi(yytext); return L_INTEGER; }
111 0x[0-9a-f]+ { char *end;
112 yylval.i_value = strtol(yytext, &end, 0);
117 "@"([0-9a-f]{2}:){0,31}([0-9a-f]{2})"@" {
118 char *p = yytext + 1, x[3];
121 yylval.a_value.data = d = (unsigned char *)malloc( 32 );
122 yylval.a_value.datalen = 0;
124 strncpy(x, p, 2); x[2] = '\0';
125 sscanf(x, "%02x", &val);
127 ++yylval.a_value.datalen;
129 return L_BYTEARRAY; }
133 \"[^\"]*\" { yytext[strlen(yytext) - 1] = 0;
134 yylval.s_value = strdup(&yytext[1]);
136 \'[^\']*\' { yytext[strlen(yytext) - 1] = 0;
137 yylval.s_value = strdup(&yytext[1]);
139 [a-z0-9/\~@-Za-z_]+ { yylval.s_value = strdup(yytext);
141 $[a-z0-9/\~@-Za-z_]+ { yylval.s_value = strdup(getenv(&yytext[1]));
144 /* comments & whitespaces */
146 [#\;][^\n]*\n { linecount++; }
149 . fprintf( stderr, "alsactl: discarding char '%c' - line %i\n", yytext[0], linecount + 1 );
154 int yywrap(void) /* do this avoid to do -lfl */