3 * APM (Advanced Power Management) Event Dispatcher
5 * Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
6 * Copyright (c) 1999 KOIE Hidetaka <koie@suri.co.jp>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/types.h>
36 #include <bitstring.h>
44 /* We don't need it, avoid the warning. */
62 <TOP>, { return COMMA; }
63 <TOP>; { return SEMICOLON; }
66 <TOP>apm_event { return APMEVENT; }
68 <TOP>NOEVENT { yylval.ev = EVENT_NOEVENT; return EVENT; }
69 <TOP>STANDBYREQ { yylval.ev = EVENT_STANDBYREQ; return EVENT; }
70 <TOP>SUSPENDREQ { yylval.ev = EVENT_SUSPENDREQ; return EVENT; }
71 <TOP>NORMRESUME { yylval.ev = EVENT_NORMRESUME; return EVENT; }
72 <TOP>CRITRESUME { yylval.ev = EVENT_CRITRESUME; return EVENT; }
73 <TOP>BATTERYLOW { yylval.ev = EVENT_BATTERYLOW; return EVENT; }
74 <TOP>POWERSTATECHANGE { yylval.ev = EVENT_POWERSTATECHANGE; return EVENT; }
75 <TOP>UPDATETIME { yylval.ev = EVENT_UPDATETIME; return EVENT; }
76 <TOP>CRITSUSPEND { yylval.ev = EVENT_CRITSUSPEND; return EVENT; }
77 <TOP>USERSTANDBYREQ { yylval.ev = EVENT_USERSTANDBYREQ; return EVENT; }
78 <TOP>USERSUSPENDREQ { yylval.ev = EVENT_USERSUSPENDREQ; return EVENT; }
79 <TOP>STANDBYRESUME { yylval.ev = EVENT_STANDBYRESUME; return EVENT; }
80 <TOP>CAPABILITIESCHANGE { yylval.ev = EVENT_CAPABILITIESCHANGE; return EVENT; }
82 <TOP>apm_battery { return APMBATT; }
84 <TOP>charging { return BATTCHARGE; }
85 <TOP>discharging { return BATTDISCHARGE; }
87 yylval.i = atoi(yytext);
91 yylval.i = -atoi(yytext);
95 <TOP>exec { return EXECCMD; }
96 <TOP>reject { return REJECTCMD; }
98 <TOP>\{ { return BEGINBLOCK; }
99 <TOP>\} { return ENDBLOCK; }
101 int len = strlen(yytext) - 2;
102 if ((yylval.str = (char *) malloc(len + 1)) == NULL)
104 memcpy(yylval.str, yytext + 1, len);
105 yylval.str[len] = '\0';
110 <TOP>[^"{},;#\n\t ]+ { yylval.str = strdup(yytext); return UNKNOWN; }
114 yyerror(const char *s)
116 syslog(LOG_ERR, "line %d: %s%s %s.\n", lineno, yytext, yytext?":":"", s);