/* $Id: parser.c,v 1.24 2004/01/05 11:57:38 reinelt Exp $ * * row definition parser * * Copyright 1999, 2000 Michael Reinelt * * This file is part of LCD4Linux. * * LCD4Linux is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * LCD4Linux is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * $Log: parser.c,v $ * Revision 1.24 2004/01/05 11:57:38 reinelt * added %y tokens to make the Evaluator useable * * Revision 1.23 2003/11/11 04:40:20 reinelt * WIFI patch from Xavier Vello * * Revision 1.22 2003/10/12 06:08:28 nicowallmeier * imond/telmond support * * Revision 1.21 2003/10/05 17:58:50 reinelt * libtool junk; copyright messages cleaned up * * Revision 1.20 2003/09/01 04:09:35 reinelt * icons nearly finished, but MatrixOrbital only * * Revision 1.19 2003/06/21 05:46:18 reinelt * DVB client integrated * * Revision 1.18 2002/12/05 19:23:01 reinelt * fixed undefined operations found by gcc3 * * Revision 1.17 2002/08/19 04:41:20 reinelt * introduced bar.c, moved bar stuff from display.h to bar.h * * Revision 1.16 2001/03/16 16:40:17 ltoetsch * implemented time bar * * Revision 1.15 2001/03/14 13:19:29 ltoetsch * Added pop3/imap4 mail support * * Revision 1.14 2001/03/13 08:34:15 reinelt * * corrected a off-by-one bug with sensors * * Revision 1.13 2001/03/08 15:25:38 ltoetsch * improved exec * * Revision 1.12 2001/03/07 18:10:21 ltoetsch * added e(x)ec commands * * Revision 1.11 2001/03/02 10:18:03 ltoetsch * added /proc/apm battery stat * * Revision 1.10 2001/02/19 00:15:46 reinelt * * integrated mail and seti client * major rewrite of parser and tokenizer to support double-byte tokens * * Revision 1.9 2001/02/16 08:23:09 reinelt * * new token 'ic' (ISDN connected) by Carsten Nau * * Revision 1.8 2001/02/14 07:40:16 reinelt * * first (incomplete) GPO implementation * * Revision 1.7 2000/08/10 09:44:09 reinelt * * new debugging scheme: error(), info(), debug() * uses syslog if in daemon mode * * Revision 1.6 2000/05/21 06:20:35 reinelt * * added ppp throughput * token is '%t[iomt]' at the moment, but this will change in the near future * * Revision 1.5 2000/03/24 11:36:56 reinelt * * new syntax for raster configuration * changed XRES and YRES to be configurable * PPM driver works nice * * Revision 1.4 2000/03/19 08:41:28 reinelt * * documentation available! README, README.MatrixOrbital, README.Drivers * added Skeleton.c as a starting point for new drivers * * Revision 1.3 2000/03/18 10:31:06 reinelt * * added sensor handling (for temperature etc.) * made data collecting happen only if data is used * (reading /proc/meminfo takes a lot of CPU!) * released lcd4linux-0.92 * * Revision 1.2 2000/03/17 09:21:42 reinelt * * various memory statistics added * * Revision 1.1 2000/03/13 15:58:24 reinelt * * release 0.9 * moved row parsing to parser.c * all basic work finished * */ /* * exported functions: * * char *parse_row (char *string, int supported_bars, int usage[]) * converts a row definition from the config file * into the internal form using tokens * sets the array usage[token] to usage count * * char parse_gpo (char *string, int usage[]) * converts a GPO definition from the config file * into the internal form using tokens * sets the array usage[token] to usage count * */ #include #include #include #include #include "debug.h" #include "display.h" #include "bar.h" #include "parser.h" typedef struct { char *symbol; TOKEN token; CLASS class; int bar; } SYMTAB; static SYMTAB Symtab[] = {{ "%", T_PERCENT, C_GENERIC, 0 }, { "$", T_DOLLAR, C_GENERIC, 0 }, { "&", T_AMPERSAND, C_GENERIC, 0 }, { "o", T_OS, C_GENERIC, 0 }, { "v", T_RELEASE, C_GENERIC, 0 }, { "p", T_CPU, C_GENERIC, 0 }, { "r", T_RAM, C_GENERIC, 0 }, { "mt", T_MEM_TOTAL, C_MEM, 1 }, { "mu", T_MEM_USED, C_MEM, 1 }, { "mf", T_MEM_FREE, C_MEM, 1 }, { "ms", T_MEM_SHARED, C_MEM, 1 }, { "mb", T_MEM_BUFFER, C_MEM, 1 }, { "mc", T_MEM_CACHE, C_MEM, 1 }, { "ma", T_MEM_AVAIL, C_MEM, 1 }, { "l1", T_LOAD_1, C_LOAD, 1 }, { "l2", T_LOAD_2, C_LOAD, 1 }, { "l3", T_LOAD_3, C_LOAD, 1 }, { "L", T_OVERLOAD, C_LOAD, 0 }, { "cu", T_CPU_USER, C_CPU, 1 }, { "cn", T_CPU_NICE, C_CPU, 1 }, { "cs", T_CPU_SYSTEM, C_CPU, 1 }, { "cb", T_CPU_BUSY, C_CPU, 1 }, { "ci", T_CPU_IDLE, C_CPU, 1 }, { "dr", T_DISK_READ, C_DISK, 1 }, { "dw", T_DISK_WRITE, C_DISK, 1 }, { "dt", T_DISK_TOTAL, C_DISK, 1 }, { "dm", T_DISK_MAX, C_DISK, 1 }, { "nr", T_ETH_RX, C_ETH, 1 }, { "nw", T_ETH_TX, C_ETH, 1 }, { "nt", T_ETH_TOTAL, C_ETH, 1 }, { "nm", T_ETH_MAX, C_ETH, 1 }, { "ic", T_ISDN_USED, C_ISDN, 0 }, { "ii", T_ISDN_IN, C_ISDN, 1 }, { "io", T_ISDN_OUT, C_ISDN, 1 }, { "it", T_ISDN_TOTAL, C_ISDN, 1 }, { "im", T_ISDN_MAX, C_ISDN, 1 }, { "ws", T_WIFI_SIGNAL, C_WIFI, 1 }, { "wl", T_WIFI_LINK, C_WIFI, 1 }, { "wn", T_WIFI_NOISE, C_WIFI, 1 }, { "ti", T_PPP_RX, C_PPP, 1 }, { "to", T_PPP_TX, C_PPP, 1 }, { "tt", T_PPP_TOTAL, C_PPP, 1 }, { "tm", T_PPP_MAX, C_PPP, 1 }, { "hc", T_SETI_PRC, C_SETI, 1 }, { "ht", T_SETI_CPU, C_SETI, 0 }, { "bp", T_BATT_PERC, C_BATT, 1 }, { "bs", T_BATT_STAT, C_BATT, 0 }, { "bd", T_BATT_DUR, C_BATT, 0 }, { "ss", T_DVB_STRENGTH, C_DVB, 1 }, { "sn", T_DVB_SNR, C_DVB, 1 }, { "e*", T_MAIL, C_MAIL, 0 }, { "u*", T_MAIL_UNSEEN,C_MAIL, 0 }, { "s*", T_SENSOR, C_SENSOR, 1 }, { "x*", T_EXEC, C_EXEC, 1 }, { "y*", T_EXPR, C_EXPR, 1 }, { "jc", T_IMON_CPU, C_IMON, 1 }, { "jv", T_IMON_VER, C_IMON, 0 }, { "jd", T_IMON_DATE, C_IMON, 0 }, { "jm", T_IMON_TIME, C_IMON, 0 }, { "ji*",T_IMON_RIN, C_IMON, 1 }, { "jo*",T_IMON_ROUT, C_IMON, 1 }, { "js*",T_IMON_STATUS,C_IMON, 0 }, { "jn*",T_IMON_PHONE, C_IMON, 0 }, { "jp*",T_IMON_IP, C_IMON, 0 }, { "jt*",T_IMON_OTIME, C_IMON, 0 }, { "jk*",T_IMON_CHARGE,C_IMON, 0 }, { "kn", T_TELMON_NUMBER, C_TELMON,0 }, { "km", T_TELMON_MSN, C_TELMON, 0 }, { "kd", T_TELMON_DATE, C_TELMON, 0 }, { "kt", T_TELMON_TIME, C_TELMON, 0 }, { "", -1, 0 }}; static int bar_type (char tag) { switch (tag) { case 'l': return BAR_L; case 'r': return BAR_R; case 'u': return BAR_U; case 'd': return BAR_D; case 't': return BAR_T; default: return 0; } } static int get_token (char *s, char **p, int bar, int usage[]) { char c; int i, l; for (i=0; Symtab[i].token!=-1; i++) { if (bar && !Symtab[i].bar) continue; l=strlen(Symtab[i].symbol); if (Symtab[i].symbol[l-1]=='*') { if (Symtab[i].tokenpre { line-height: 125%; margin: 0; } td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Channel table for Itabuna - BA - Brazil
# Source: http://www.portalbsd.com.br/terrestres_channels.php?channels=144

# Physical channel 15
[Rede Vida]
	DELIVERY_SYSTEM = ISDBT
	BANDWIDTH_HZ = 6000000
	FREQUENCY = 479142857
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	ISDBT_LAYER_ENABLED = 7
	ISDBT_SOUND_BROADCASTING = 0
	ISDBT_SB_SUBCHANNEL_ID = 0
	ISDBT_SB_SEGMENT_IDX = 0
	ISDBT_SB_SEGMENT_COUNT = 0
	ISDBT_LAYERA_FEC = AUTO
	ISDBT_LAYERA_MODULATION = QAM/AUTO
	ISDBT_LAYERA_SEGMENT_COUNT = 0
	ISDBT_LAYERA_TIME_INTERLEAVING = 0
	ISDBT_LAYERB_FEC = AUTO
	ISDBT_LAYERB_MODULATION = QAM/AUTO
	ISDBT_LAYERB_SEGMENT_COUNT = 0
	ISDBT_LAYERB_TIME_INTERLEAVING = 0
	ISDBT_LAYERC_FEC = AUTO
	ISDBT_LAYERC_MODULATION = QAM/AUTO
	ISDBT_LAYERC_SEGMENT_COUNT = 0
	ISDBT_LAYERC_TIME_INTERLEAVING = 0

# Physical channel 17
[Record TV CabrĂ¡lia]
	DELIVERY_SYSTEM = ISDBT
	BANDWIDTH_HZ = 6000000
	FREQUENCY = 491142857
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	ISDBT_LAYER_ENABLED = 7
	ISDBT_SOUND_BROADCASTING = 0
	ISDBT_SB_SUBCHANNEL_ID = 0
	ISDBT_SB_SEGMENT_IDX = 0
	ISDBT_SB_SEGMENT_COUNT = 0
	ISDBT_LAYERA_FEC = AUTO
	ISDBT_LAYERA_MODULATION = QAM/AUTO
	ISDBT_LAYERA_SEGMENT_COUNT = 0
	ISDBT_LAYERA_TIME_INTERLEAVING = 0
	ISDBT_LAYERB_FEC = AUTO
	ISDBT_LAYERB_MODULATION = QAM/AUTO
	ISDBT_LAYERB_SEGMENT_COUNT = 0
	ISDBT_LAYERB_TIME_INTERLEAVING = 0
	ISDBT_LAYERC_FEC = AUTO
	ISDBT_LAYERC_MODULATION = QAM/AUTO
	ISDBT_LAYERC_SEGMENT_COUNT = 0
	ISDBT_LAYERC_TIME_INTERLEAVING = 0

# Physical channel 21
[Record News]
	DELIVERY_SYSTEM = ISDBT
	BANDWIDTH_HZ = 6000000
	FREQUENCY = 515142857
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	ISDBT_LAYER_ENABLED = 7
	ISDBT_SOUND_BROADCASTING = 0
	ISDBT_SB_SUBCHANNEL_ID = 0
	ISDBT_SB_SEGMENT_IDX = 0
	ISDBT_SB_SEGMENT_COUNT = 0
	ISDBT_LAYERA_FEC = AUTO
	ISDBT_LAYERA_MODULATION = QAM/AUTO
	ISDBT_LAYERA_SEGMENT_COUNT = 0
	ISDBT_LAYERA_TIME_INTERLEAVING = 0
	ISDBT_LAYERB_FEC = AUTO
	ISDBT_LAYERB_MODULATION = QAM/AUTO
	ISDBT_LAYERB_SEGMENT_COUNT = 0
	ISDBT_LAYERB_TIME_INTERLEAVING = 0
	ISDBT_LAYERC_FEC = AUTO
	ISDBT_LAYERC_MODULATION = QAM/AUTO
	ISDBT_LAYERC_SEGMENT_COUNT = 0
	ISDBT_LAYERC_TIME_INTERLEAVING = 0

# Physical channel 30
[TV Santa Cruz]
	DELIVERY_SYSTEM = ISDBT
	BANDWIDTH_HZ = 6000000
	FREQUENCY = 569142857
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	ISDBT_LAYER_ENABLED = 7
	ISDBT_SOUND_BROADCASTING = 0
	ISDBT_SB_SUBCHANNEL_ID = 0
	ISDBT_SB_SEGMENT_IDX = 0
	ISDBT_SB_SEGMENT_COUNT = 0
	ISDBT_LAYERA_FEC = AUTO
	ISDBT_LAYERA_MODULATION = QAM/AUTO
	ISDBT_LAYERA_SEGMENT_COUNT = 0
	ISDBT_LAYERA_TIME_INTERLEAVING = 0
	ISDBT_LAYERB_FEC = AUTO
	ISDBT_LAYERB_MODULATION = QAM/AUTO
	ISDBT_LAYERB_SEGMENT_COUNT = 0
	ISDBT_LAYERB_TIME_INTERLEAVING = 0
	ISDBT_LAYERC_FEC = AUTO
	ISDBT_LAYERC_MODULATION = QAM/AUTO
	ISDBT_LAYERC_SEGMENT_COUNT = 0
	ISDBT_LAYERC_TIME_INTERLEAVING = 0

# Physical channel 42
[Band Bahia]
	DELIVERY_SYSTEM = ISDBT
	BANDWIDTH_HZ = 6000000
	FREQUENCY = 641142857
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	INVERSION = AUTO
	GUARD_INTERVAL = AUTO
	TRANSMISSION_MODE = AUTO
	ISDBT_LAYER_ENABLED = 7
	ISDBT_SOUND_BROADCASTING = 0
	ISDBT_SB_SUBCHANNEL_ID = 0
	ISDBT_SB_SEGMENT_IDX = 0
	ISDBT_SB_SEGMENT_COUNT = 0
	ISDBT_LAYERA_FEC = AUTO
	ISDBT_LAYERA_MODULATION = QAM/AUTO
	ISDBT_LAYERA_SEGMENT_COUNT = 0
	ISDBT_LAYERA_TIME_INTERLEAVING = 0
	ISDBT_LAYERB_FEC = AUTO
	ISDBT_LAYERB_MODULATION = QAM/AUTO
	ISDBT_LAYERB_SEGMENT_COUNT = 0
	ISDBT_LAYERB_TIME_INTERLEAVING = 0
	ISDBT_LAYERC_FEC = AUTO
	ISDBT_LAYERC_MODULATION = QAM/AUTO
	ISDBT_LAYERC_SEGMENT_COUNT = 0
	ISDBT_LAYERC_TIME_INTERLEAVING = 0