comparison spandsp-0.0.3/spandsp-0.0.3/src/at_dictionary_gen.c @ 5:f762bf195c4b

import spandsp-0.0.3
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 16:00:21 +0200
parents
children
comparison
equal deleted inserted replaced
4:26cd8f1ef0b1 5:f762bf195c4b
1 /*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * at_dictionary_gen.c - Generate a trie based dictionary for the AT
5 * commands supported by the AT interpreter.
6 *
7 * Written by Steve Underwood <steveu@coppice.org>
8 *
9 * Copyright (C) 2006 Steve Underwood
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2, as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 * $Id: at_dictionary_gen.c,v 1.7 2006/11/30 15:41:47 steveu Exp $
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #define _GNU_SOURCE
34
35 #include <inttypes.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <stdio.h>
39 #include <fcntl.h>
40 #include <string.h>
41 #include <assert.h>
42
43 const char *wordlist[] =
44 {
45 " ", /* Dummy to absorb spaces in commands */
46 "&C", /* V.250 6.2.8 - Circuit 109 (received line signal detector), behaviour */
47 "&D", /* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
48 "&F", /* V.250 6.1.2 - Set to factory-defined configuration */
49 "+A8A", /* V.251 6.3 - V.8 calling tone indication */
50 "+A8C", /* V.251 6.2 - V.8 answer signal indication */
51 "+A8E", /* V.251 5.1 - V.8 and V.8bis operation controls */
52 "+A8I", /* V.251 6.1 - V.8 CI signal indication */
53 "+A8J", /* V.251 6.4 - V.8 negotiation complete */
54 "+A8M", /* V.251 5.2 - Send V.8 menu signals */
55 "+A8R", /* V.251 6.6 - V.8bis signal and message reporting */
56 "+A8T", /* V.251 5.3 - Send V.8bis signal and/or message(s) */
57 "+ASTO", /* V.250 6.3.15 - Store telephone number */
58 "+CAAP", /* 3GPP TS 27.007 7.25 - Automatic answer for eMLPP Service */
59 "+CACM", /* 3GPP TS 27.007 8.25 - Accumulated call meter */
60 "+CACSP", /* 3GPP TS 27.007 11.1.7 - Voice Group or Voice Broadcast Call State Attribute Presentation */
61 "+CAD", /* IS-99 5.6.3 - Query analogue or digital service */
62 "+CAEMLPP", /* 3GPP TS 27.007 7.22 - eMLPP Priority Registration and Interrogation */
63 "+CAHLD", /* 3GPP TS 27.007 11.1.3 - Leave an ongoing Voice Group or Voice Broadcast Call */
64 "+CAJOIN", /* 3GPP TS 27.007 11.1.1 - Accept an incoming Voice Group or Voice Broadcast Call */
65 "+CALA", /* 3GPP TS 27.007 8.16 - Alarm */
66 "+CALCC", /* 3GPP TS 27.007 11.1.6 - List current Voice Group and Voice Broadcast Calls */
67 "+CALD", /* 3GPP TS 27.007 8.38 - Delete alar m */
68 "+CALM", /* 3GPP TS 27.007 8.20 - Alert sound mode */
69 "+CAMM", /* 3GPP TS 27.007 8.26 - Accumulated call meter maximum */
70 "+CANCHEV", /* 3GPP TS 27.007 11.1.8 - NCH Support Indication */
71 "+CAOC", /* 3GPP TS 27.007 7.16 - Advice of Charge */
72 "+CAPD", /* 3GPP TS 27.007 8.39 - Postpone or dismiss an alarm */
73 "+CAPTT", /* 3GPP TS 27.007 11.1.4 - Talker Access for Voice Group Call */
74 "+CAREJ", /* 3GPP TS 27.007 11.1.2 - Reject an incoming Voice Group or Voice Broadcast Call */
75 "+CAULEV", /* 3GPP TS 27.007 11.1.5 - Voice Group Call Uplink Status Presentation */
76 "+CBC", /* 3GPP TS 27.007 8.4 - Battery charge */
77 "+CBCS", /* 3GPP TS 27.007 11.3.2 - VBS subscriptions and GId status */
78 "+CBIP", /* IS-99 5.6 - Base station IP address */
79 "+CBST", /* 3GPP TS 27.007 6.7 - Select bearer service type */
80 "+CCFC", /* 3GPP TS 27.007 7.11 - Call forwarding number and conditions */
81 "+CCLK", /* 3GPP TS 27.007 8.15 - Clock */
82 "+CCS", /* IS-135 4.1.22 - Compression status */
83 "+CCUG", /* 3GPP TS 27.007 7.10 - Closed user group */
84 "+CCWA", /* 3GPP TS 27.007 7.12 - Call waiting */
85 "+CCWE", /* 3GPP TS 27.007 8.28 - Call Meter maximum event */
86 "+CDIP", /* 3GPP TS 27.007 7.9 - Called line identification presentation */
87 "+CDIS", /* 3GPP TS 27.007 8.8 - Display control */
88 "+CDV", /* IS-99 5.6 - Dial command for voice call */
89 "+CEER", /* 3GPP TS 27.007 6.10 - Extended error report */
90 "+CESP", /* GSM07.05 3.2.4 - Enter SMS block mode protocol */
91 "+CFCS", /* 3GPP TS 27.007 7.24 - Fast call setup conditions */
92 "+CFG", /* IS-99 5.6 - Configuration string */
93 "+CFUN", /* 3GPP TS 27.007 8.2 - Set phone functionality */
94 "+CGACT", /* 3GPP TS 27.007 10.1.10 - PDP context activate or deactivate */
95 "+CGANS", /* 3GPP TS 27.007 10.1.16 - Manual response to a network request for PDP context activation */
96 "+CGATT", /* 3GPP TS 27.007 10.1.9 - PS attach or detach */
97 "+CGAUTO", /* 3GPP TS 27.007 10.1.15 - Automatic response to a network request for PDP context activation */
98 "+CGCAP", /* IS-99 5.6 - Request complete capabilities list */
99 "+CGCLASS", /* 3GPP TS 27.007 10.1.17 - GPRS mobile station class (GPRS only) */
100 "+CGCLOSP", /* 3GPP TS 27.007 10.1.13 - Configure local octet stream PAD parameters (Obsolete) */
101 "+CGCLPAD", /* 3GPP TS 27.007 10.1.12 - Configure local triple-X PAD parameters (GPRS only) (Obsolete) */
102 "+CGCMOD", /* 3GPP TS 27.007 10.1.11 - PDP Context Modify */
103 "+CGCS", /* 3GPP TS 27.007 11.3.1 - VGCS subscriptions and GId status */
104 "+CGDATA", /* 3GPP TS 27.007 10.1.12 - Enter data state */
105 "+CGDCONT", /* 3GPP TS 27.007 10.1.1 - Define PDP Context */
106 "+CGDSCONT",/* 3GPP TS 27.007 10.1.2 - Define Secondary PDP Context */
107 "+CGEQMIN", /* 3GPP TS 27.007 10.1.7 - 3G Quality of Service Profile (Minimum acceptable) */
108 "+CGEQNEG", /* 3GPP TS 27.007 10.1.8 - 3G Quality of Service Profile (Negotiated) */
109 "+CGEQREQ", /* 3GPP TS 27.007 10.1.6 - 3G Quality of Service Profile (Requested) */
110 "+CGEREP", /* 3GPP TS 27.007 10.1.18 - Packet Domain event reporting */
111 "+CGMI", /* 3GPP TS 27.007 5.1 - Request manufacturer identification */
112 "+CGMM", /* 3GPP TS 27.007 5.2 - Request model identification */
113 "+CGMR", /* 3GPP TS 27.007 5.3 - Request revision identification */
114 "+CGOI", /* IS-99 5.6 - Request global object identification */
115 "+CGPADDR", /* 3GPP TS 27.007 10.1.14 - Show PDP address */
116 "+CGQMIN", /* 3GPP TS 27.007 10.1.5 - Quality of Service Profile (Minimum acceptable) */
117 "+CGQREQ", /* 3GPP TS 27.007 10.1.4 - Quality of Service Profile (Requested) */
118 "+CGREG", /* 3GPP TS 27.007 10.1.19 - GPRS network registration status */
119 "+CGSMS", /* 3GPP TS 27.007 10.1.20 - Select service for MO SMS messages */
120 "+CGSN", /* 3GPP TS 27.007 5.4 - Request product serial number identification */
121 "+CGTFT", /* 3GPP TS 27.007 10.1.3 - Traffic Flow Template */
122 "+CHLD", /* 3GPP TS 27.007 7.13 - Call related supplementary services */
123 "+CHSA", /* 3GPP TS 27.007 6.18 - HSCSD non-transparent asymmetry configuration */
124 "+CHSC", /* 3GPP TS 27.007 6.15 - HSCSD current call parameters */
125 "+CHSD", /* 3GPP TS 27.007 6.12 - HSCSD device parameters */
126 "+CHSN", /* 3GPP TS 27.007 6.14 - HSCSD non-transparent call configuration */
127 "+CHSR", /* 3GPP TS 27.007 6.16 - HSCSD parameters report */
128 "+CHST", /* 3GPP TS 27.007 6.13 - HSCSD transparent call configuration */
129 "+CHSU", /* 3GPP TS 27.007 6.17 - HSCSD automatic user initiated upgrading */
130 "+CHUP", /* 3GPP TS 27.007 6.5 - Hangup call */
131 "+CHV", /* IS-99 5.6 - Hang-up voice */
132 "+CIMI", /* 3GPP TS 27.007 5.6 - Request international mobile subscriber identity */
133 "+CIND", /* 3GPP TS 27.007 8.9 - Indicator control */
134 "+CIT", /* IS-99 5.6 - Command state inactivity timer */
135 "+CKPD", /* 3GPP TS 27.007 8.7 - Keypad control */
136 "+CLAC", /* 3GPP TS 27.007 8.37 - List all available AT commands */
137 "+CLAE", /* 3GPP TS 27.007 8.31 - Language Event */
138 "+CLAN", /* 3GPP TS 27.007 8.30 - Set Language */
139 "+CLCC", /* 3GPP TS 27.007 7.18 - List current calls */
140 "+CLCK", /* 3GPP TS 27.007 7.4 - Facility lock */
141 "+CLIP", /* 3GPP TS 27.007 7.6 - Calling line identification presentation */
142 "+CLIR", /* 3GPP TS 27.007 7.7 - Calling line identification restriction */
143 "+CLVL", /* 3GPP TS 27.007 8.23 - Loudspeaker volume level */
144 "+CMAR", /* 3GPP TS 27.007 8.36 - Master reset */
145 "+CMEC", /* 3GPP TS 27.007 8.6 - Mobile termination control mode */
146 "+CMEE", /* GSM07.07 9.1 - Report mobile equipment error */
147 "+CMER", /* 3GPP TS 27.007 8.10 - Mobile termination event reporting */
148 "+CMGC", /* GSM07.05 3.5.5/4.5 - Send command */
149 "+CMGD", /* GSM07.05 3.5.4 - Delete message */
150 "+CMGF", /* GSM07.05 3.2.3 - Message Format */
151 "+CMGL", /* GSM07.05 3.4.2/4.1 - List messages */
152 "+CMGR", /* GSM07.05 3.4.3/4.2 - Read message */
153 "+CMGS", /* GSM07.05 3.5.1/4.3 - Send message */
154 "+CMGW", /* GSM07.05 3.5.3/4.4 - Write message to memory */
155 "+CMIP", /* IS-99 5.6 - Mobile station IP address */
156 "+CMM", /* IS-135 4.1.23 - Menu map */
157 "+CMMS", /* GSM07.05 3.5.6 - More messages to send */
158 "+CMOD", /* 3GPP TS 27.007 6.4 - Call mode */
159 "+CMSS", /* GSM07.05 3.5.2/4.7 - Send message from storage */
160 "+CMUT", /* 3GPP TS 27.007 8.24 - Mute control */
161 "+CMUX", /* 3GPP TS 27.007 5.7 - Multiplexing mode */
162 "+CNMA", /* GSM07.05 3.4.4/4.6 - New message acknowledgement to terminal adapter */
163 "+CNMI", /* GSM07.05 3.4.1 - New message indications to terminal equipment */
164 "+CNUM", /* 3GPP TS 27.007 7.1 - Subscriber number */
165 "+COLP", /* 3GPP TS 27.007 7.8 - Connected line identification presentation */
166 "+COPN", /* 3GPP TS 27.007 7.21 - Read operator names */
167 "+COPS", /* 3GPP TS 27.007 7.3 - PLMN selection */
168 "+COS", /* IS-135 4.1.24 - Originating service */
169 "+COTDI", /* 3GPP TS 27.007 11.1.9 - Originator to Dispatcher Information */
170 "+CPAS", /* 3GPP TS 27.007 8.1 - Phone activity status */
171 "+CPBF", /* 3GPP TS 27.007 8.13 - Find phonebook entries */
172 "+CPBR", /* 3GPP TS 27.007 8.12 - Read phonebook entries */
173 "+CPBS", /* 3GPP TS 27.007 8.11 - Select phonebook memory storage */
174 "+CPBW", /* 3GPP TS 27.007 8.14 - Write phonebook entry */
175 "+CPIN", /* 3GPP TS 27.007 8.3 - Enter PIN */
176 "+CPLS", /* 3GPP TS 27.007 7.20 - Selection of preferred PLMN list */
177 "+CPMS", /* GSM07.05 3.2.2 - Preferred message storage */
178 "+CPOL", /* 3GPP TS 27.007 7.19 - Preferred PLMN list */
179 "+CPPS", /* 3GPP TS 27.007 7.23 - eMLPP subscriptions */
180 "+CPROT", /* 3GPP TS 27.007 8.42 - Enter protocol mode */
181 "+CPUC", /* 3GPP TS 27.007 8.27 - Price per unit and currency table */
182 "+CPWC", /* 3GPP TS 27.007 8.29 - Power class */
183 "+CPWD", /* 3GPP TS 27.007 7.5 - Change password */
184 "+CQD", /* IS-135 4.1.25 - Query disconnect timer */
185 "+CR", /* 3GPP TS 27.007 6.9 - Service reporting control */
186 "+CRC", /* 3GPP TS 27.007 6.11 - Cellular result codes */
187 "+CREG", /* 3GPP TS 27.007 7.2 - Network registration */
188 "+CRES", /* GSM07.05 3.3.6 - Restore Settings */
189 "+CRLP", /* 3GPP TS 27.007 6.8 - Radio link protocol */
190 "+CRM", /* IS-99 5.6 - Set rm interface protocol */
191 "+CRMC", /* 3GPP TS 27.007 8.34 - Ring Melody Control */
192 "+CRMP", /* 3GPP TS 27.007 8.35 - Ring Melody Playback */
193 "+CRSL", /* 3GPP TS 27.007 8.21 - Ringer sound level */
194 "+CRSM", /* 3GPP TS 27.007 8.18 - Restricted SIM access */
195 "+CSAS", /* GSM07.05 3.3.5 - Save settings */
196 "+CSCA", /* GSM07.05 3.3.1 - Service centre address */
197 "+CSCB", /* GSM07.05 3.3.4 - Select cell broadcast message types */
198 "+CSCC", /* 3GPP TS 27.007 8.19 - Secure control command */
199 "+CSCS", /* 3GPP TS 27.007 5.5 - Select TE character set */
200 "+CSDF", /* 3GPP TS 27.007 6.22 - Settings date format */
201 "+CSDH", /* GSM07.05 3.3.3 - Show text mode parameters */
202 "+CSGT", /* 3GPP TS 27.007 8.32 - Set Greeting Text */
203 "+CSIL", /* 3GPP TS 27.007 6.23 - Silence Command */
204 "+CSIM", /* 3GPP TS 27.007 8.17 - Generic SIM access */
205 "+CSMP", /* GSM07.05 3.3.2 - Set text mode parameters */
206 "+CSMS", /* GSM07.05 3.2.1 - Select Message Service */
207 "+CSNS", /* 3GPP TS 27.007 6.19 - Single numbering scheme */
208 "+CSQ", /* 3GPP TS 27.007 8.5 - Signal quality */
209 "+CSS", /* IS-135 4.1.28 - Serving system identification */
210 "+CSSN", /* 3GPP TS 27.007 7.17 - Supplementary service notifications */
211 "+CSTA", /* 3GPP TS 27.007 6.1 - Select type of address */
212 "+CSTF", /* 3GPP TS 27.007 6.24 - Settings time format */
213 "+CSVM", /* 3GPP TS 27.007 8.33 - Set Voice Mail Number */
214 "+CTA", /* IS-135 4.1.29 - MT-Terminated async. Data calls */
215 "+CTF", /* IS-135 4.1.30 - MT-Terminated FAX calls */
216 "+CTFR", /* 3GPP TS 27.007 7.14 - Call deflection */
217 "+CTZR", /* 3GPP TS 27.007 8.41 - Time Zone Reporting */
218 "+CTZU", /* 3GPP TS 27.007 8.40 - Automatic Time Zone Update */
219 "+CUSD", /* 3GPP TS 27.007 7.15 - Unstructured supplementary service data */
220 "+CUUS1", /* 3GPP TS 27.007 7.26 - User to User Signalling Service 1 */
221 "+CV120", /* 3GPP TS 27.007 6.21 - V.120 rate adaption protocol */
222 "+CVHU", /* 3GPP TS 27.007 6.20 - Voice Hangup Control */
223 "+CVIB", /* 3GPP TS 27.007 8.22 - Vibrator mode */
224 "+CXT", /* IS-99 5.6 - Cellular extension */
225 "+DR", /* V.250 6.6.2 - Data compression reporting */
226 "+DS", /* V.250 6.6.1 - Data compression */
227 "+DS44", /* V.250 6.6.2 - V.44 data compression */
228 "+EB", /* V.250 6.5.2 - Break handling in error control operation */
229 "+EFCS", /* V.250 6.5.4 - 32-bit frame check sequence */
230 "+EFRAM", /* V.250 6.5.8 - Frame length */
231 "+ER", /* V.250 6.5.5 - Error control reporting */
232 "+ES", /* V.250 6.5.1 - Error control selection */
233 "+ESR", /* V.250 6.5.3 - Selective repeat */
234 "+ETBM", /* V.250 6.5.6 - Call termination buffer management */
235 "+EWIND", /* V.250 6.5.7 - Window size */
236 "+FAA", /* T.32 8.5.2.5 - Adaptive Answer parameter */
237 "+FAP", /* T.32 8.5.1.12 - Addressing and polling capabilities parameter */
238 "+FAR", /* T.31 8.5.1 - Adaptive reception control */
239 "+FBO", /* T.32 8.5.3.4 - Phase C data bit order */
240 "+FBS", /* T.32 8.5.3.2 - Buffer Size, read only parameter */
241 "+FBU", /* T.32 8.5.1.10 - HDLC Frame Reporting parameter */
242 "+FCC", /* T.32 8.5.1.1 - DCE capabilities parameters */
243 "+FCL", /* T.31 8.5.2 - Carrier loss timeout */
244 "+FCLASS", /* T.31 8.2 - Capabilities identification and control */
245 "+FCQ", /* T.32 8.5.2.3 - Copy quality checking parameter */
246 "+FCR", /* T.32 8.5.1.9 - Capability to receive parameter */
247 "+FCS", /* T.32 8.5.1.3 - Current Session Results parameters */
248 "+FCT", /* T.32 8.5.2.6 - DTE phase C timeout parameter */
249 "+FDD", /* T.31 8.5.3 - Double escape character replacement */
250 "+FDR", /* T.32 8.3.4 - Data reception command */
251 "+FDT", /* T.32 8.3.3 - Data transmission command */
252 "+FEA", /* T.32 8.5.3.5 - Phase C received EOL alignment parameter */
253 "+FFC", /* T.32 8.5.3.6 - Format conversion parameter */
254 "+FFD", /* T.32 8.5.1.14 - File diagnostic message parameter */
255 "+FHS", /* T.32 8.5.2.7 - Call termination status parameter */
256 "+FIE", /* T.32 8.5.2.1 - Procedure interrupt enable parameter */
257 "+FIP", /* T.32 8.3.6 - Initialize facsimile parameters */
258 "+FIS", /* T.32 8.5.1.2 - Current session parameters */
259 "+FIT", /* T.31 8.5.4 - DTE inactivity timeout */
260 "+FKS", /* T.32 8.3.5 - Session termination command */
261 "+FLI", /* T.32 8.5.1.5 - Local ID string parameter, TSI or CSI */
262 "+FLO", /* T.31 says to implement something similar to +IFC */
263 "+FLP", /* T.32 8.5.1.7 - Indicate document to poll parameter */
264 "+FMI", /* T.31 says to duplicate +GMI */
265 "+FMM", /* T.31 says to duplicate +GMM */
266 "+FMR", /* T.31 says to duplicate +GMR */
267 "+FMS", /* T.32 8.5.2.9 - Minimum phase C speed parameter */
268 "+FND", /* T.32 8.5.2.10 - Non-Standard Message Data Indication parameter */
269 "+FNR", /* T.32 8.5.1.11 - Negotiation message reporting control parameters */
270 "+FNS", /* T.32 8.5.1.6 - Non-Standard Frame FIF parameter */
271 "+FPA", /* T.32 8.5.1.13 - Selective polling address parameter */
272 "+FPI", /* T.32 8.5.1.5 - Local Polling ID String parameter */
273 "+FPP", /* T.32 8.5.3 - Facsimile packet protocol */
274 "+FPR", /* T.31 says to implement something similar to +IPR */
275 "+FPS", /* T.32 8.5.2.2 - Page Status parameter */
276 "+FPW", /* T.32 8.5.1.13 - PassWord parameter (Sending or Polling) */
277 "+FRH", /* T.31 8.3.6 - HDLC receive */
278 "+FRM", /* T.31 8.3.4 - Facsimile receive */
279 "+FRQ", /* T.32 8.5.2.4 - Receive Quality Thresholds parameters */
280 "+FRS", /* T.31 8.3.2 - Receive silence */
281 "+FRY", /* T.32 8.5.2.8 - ECM Retry Value parameter */
282 "+FSA", /* T.32 8.5.1.13 - Subaddress parameter */
283 "+FSP", /* T.32 8.5.1.8 - Request to poll parameter */
284 "+FTH", /* T.31 8.3.5 - HDLC transmit */
285 "+FTM", /* T.31 8.3.3 - Facsimile transmit */
286 "+FTS", /* T.31 8.3.1 - Transmit silence */
287 "+GCAP", /* V.250 6.1.9 - Request complete capabilities list */
288 "+GCI", /* V.250 6.1.10 - Country of installation, */
289 "+GMI", /* V.250 6.1.4 - Request manufacturer identification */
290 "+GMM", /* V.250 6.1.5 - Request model identification */
291 "+GMR", /* V.250 6.1.6 - Request revision identification */
292 "+GOI", /* V.250 6.1.8 - Request global object identification */
293 "+GSN", /* V.250 6.1.7 - Request product serial number identification */
294 "+IBC", /* TIA-617 8.3 - Control of in-band control */
295 "+IBM", /* TIA-617 8.4 - In-Band MARK idle reporting control */
296 "+ICF", /* V.250 6.2.11 - DTE-DCE character framing */
297 "+ICLOK", /* V.250 6.2.14 - Select sync transmit clock source */
298 "+IDSR", /* V.250 6.2.16 - Select data set ready option */
299 "+IFC", /* V.250 6.2.12 - DTE-DCE local flow control */
300 "+ILRR", /* V.250 6.2.13 - DTE-DCE local rate reporting */
301 "+ILSD", /* V.250 6.2.15 - Select long space disconnect option */
302 "+IPR", /* V.250 6.2.10 - Fixed DTE rate */
303 "+IRTS", /* V.250 6.2.17 - Select synchronous mode RTS option */
304 "+MA", /* V.250 6.4.2 - Modulation automode control */
305 "+MR", /* V.250 6.4.3 - Modulation reporting control */
306 "+MS", /* V.250 6.4.1 - Modulation selection */
307 "+MSC", /* V.250 6.4.8 - Seamless rate change enable */
308 "+MV18AM", /* V.250 6.4.6 - V.18 answering message editing */
309 "+MV18P", /* V.250 6.4.7 - Order of probes */
310 "+MV18R", /* V.250 6.4.5 - V.18 reporting control */
311 "+MV18S", /* V.250 6.4.4 - V.18 selection */
312 "+PCW", /* V.250 6.8.1 - Call waiting enable (V.92 DCE) */
313 "+PIG", /* V.250 6.8.5 - PCM upstream ignore */
314 "+PMH", /* V.250 6.8.2 - Modem on hold enable */
315 "+PMHF", /* V.250 6.8.6 - V.92 Modem on hold hook flash */
316 "+PMHR", /* V.250 6.8.4 - Initiate modem on hold */
317 "+PMHT", /* V.250 6.8.3 - Modem on hold timer */
318 "+PQC", /* V.250 6.8.7 - V.92 Phase 1 and Phase 2 Control */
319 "+PSS", /* V.250 6.8.8 - V.92 Use Short Sequence */
320 "+SAC", /* V.252 3.4 - Audio transmit configuration */
321 "+SAM", /* V.252 3.5 - Audio receive mode */
322 "+SAR", /* V.252 5.3 - Audio receive channel indication */
323 "+SARR", /* V.252 3.9 - Audio indication reporting */
324 "+SAT", /* V.252 5.4 - Audio transmit channel indication */
325 "+SCRR", /* V.252 3.11 - Capabilities indication reporting */
326 "+SDC", /* V.252 3.3 - Data configuration */
327 "+SDI", /* V.252 5.2 - Data channel identification */
328 "+SDR", /* V.252 3.8 - Data indication reporting */
329 "+SRSC", /* V.252 5.1.2 - Remote terminal simultaneous capability indication */
330 "+STC", /* V.252 3.1 - Terminal configuration */
331 "+STH", /* V.252 3.2 - Close logical channel */
332 "+SVC", /* V.252 3.6 - Video transmit configuration */
333 "+SVM", /* V.252 3.7 - Video receive mode */
334 "+SVR", /* V.252 5.5 - Video receive channel indication */
335 "+SVRR", /* V.252 3.10 - Video indication reporting */
336 "+SVT", /* V.252 5.6 - Video transmit channel indication */
337 "+TADR", /* V.250 6.7.2.9 - Local V.54 address */
338 "+TAL", /* V.250 6.7.2.15 - Local analogue loop */
339 "+TALS", /* V.250 6.7.2.6 - Analogue loop status */
340 "+TDLS", /* V.250 6.7.2.7 - Local digital loop status */
341 "+TE140", /* V.250 6.7.2.1 - Enable ckt 140 */
342 "+TE141", /* V.250 6.7.2.2 - Enable ckt 141 */
343 "+TEPAL", /* V.250 6.7.2.5 - Enable front panel analogue loop */
344 "+TEPDL", /* V.250 6.7.2.4 - Enable front panel RDL */
345 "+TERDL", /* V.250 6.7.2.3 - Enable RDL from remote */
346 "+TLDL", /* V.250 6.7.2.13 - Local digital loop */
347 "+TMO", /* V.250 6.9 - V.59 command */
348 "+TMODE", /* V.250 6.7.2.10 - Set V.54 mode */
349 "+TNUM", /* V.250 6.7.2.12 - Errored bit and block counts */
350 "+TRDL", /* V.250 6.7.2.14 - Request remote digital loop */
351 "+TRDLS", /* V.250 6.7.2.8 - Remote digital loop status */
352 "+TRES", /* V.250 6.7.2.17 - Self test result */
353 "+TSELF", /* V.250 6.7.2.16 - Self test */
354 "+TTER", /* V.250 6.7.2.11 - Test error rate */
355 "+VAC", /* V.252 4.1 - Set audio code */
356 "+VACR", /* V.252 6.1 - Audio code report */
357 "+VBT", /* 3GPP TS 27.007 C.2.2 - Buffer threshold setting */
358 "+VCID", /* V.253 9.2.3 - Caller ID service */
359 "+VCIDR", /* V.252 6.2 - Caller ID report */
360 "+VDID", /* V.253 9.2.4 - DID service */
361 "+VDIDR", /* V.252 6.2 - DID report */
362 "+VDR", /* V.253 10.3.1 - Distinctive ring (ring cadence reporting) */
363 "+VDT", /* V.253 10.3.2 - Control tone cadence reporting */
364 "+VDX", /* V.253 10.5.6 - Speakerphone duplex mode */
365 "+VEM", /* V.253 10.5.7 - Deliver event reports */
366 "+VGM", /* V.253 10.5.2 - Microphone gain */
367 "+VGR", /* V.253 10.2.1 - Receive gain selection */
368 "+VGS", /* V.253 10.5.3 - Speaker gain */
369 "+VGT", /* V.253 10.2.2 - Volume selection */
370 "+VHC", /* V.252 4.12 - Telephony port hook control */
371 "+VIP", /* V.253 10.1.1 - Initialize voice parameters */
372 "+VIT", /* V.253 10.2.3 - DTE/DCE inactivity timer */
373 "+VLS", /* V.253 10.2.4 - Analogue source/destination selection */
374 "+VNH", /* V.253 9.2.5 - Automatic hangup control */
375 "+VPH", /* V.252 4.11 - Phone hookswitch status */
376 "+VPP", /* V.253 10.4.2 - Voice packet protocol */
377 "+VPR", /* IS-101 10.4.3 - Select DTE/DCE interface rate */
378 "+VRA", /* V.253 10.2.5 - Ringing tone goes away timer */
379 "+VRID", /* Extension - Find the originating and destination numbers */
380 "+VRL", /* V.253 10.1.2 - Ring local phone */
381 "+VRN", /* V.253 10.2.6 - Ringing tone never appeared timer */
382 "+VRX", /* V.253 10.1.3 - Voice receive state */
383 "+VSD", /* V.253 10.2.7 - Silence detection (QUIET and SILENCE) */
384 "+VSID", /* Extension - Set the originating number */
385 "+VSM", /* V.253 10.2.8 - Compression method selection */
386 "+VSP", /* V.253 10.5.1 - Voice speakerphone state */
387 "+VTA", /* V.253 10.5.4 - Train acoustic echo-canceller */
388 "+VTD", /* V.253 10.2.9 - Beep tone duration timer */
389 "+VTER", /* V.252 6.4 - Simple telephony event report */
390 "+VTH", /* V.253 10.5.5 - Train line echo-canceller */
391 "+VTR", /* V.253 10.1.4 - Voice duplex state */
392 "+VTS", /* V.253 10.1.5 - DTMF and tone generation in voice */
393 "+VTX", /* V.253 10.1.6 - Transmit data state */
394 "+VXT", /* IS-101 10.1.5 - Translate voice data */
395 "+W", /* TIA-678 5.2.4.1 - Compliance indication */
396 "+WBAG", /* TIA-678 C.5.6 Bias modem audio gain */
397 "+WCDA", /* TIA-678 B.3.2.5 Display data link address */
398 "+WCHG", /* TIA-678 B.3.2.4 Display battery charging status */
399 "+WCID", /* TIA-678 B.3.2.1 Display system ID (operator) */
400 "+WCLK", /* TIA-678 B.3.2.3 Lock/unlock DCE */
401 "+WCPN", /* TIA-678 B.3.2.2 Set personal identification number */
402 "+WCXF", /* TIA-678 B.3.2.6 Display supported annex B commands */
403 "+WDAC", /* TIA-678 C.5.1 Data over analogue cellular command query */
404 "+WDIR", /* TIA-678 C.5.8 Phone number directory selection */
405 "+WECR", /* TIA-678 C.5.3 Enable cellular result codes */
406 "+WFON", /* TIA-678 C.5.5 Phone specification */
407 "+WKPD", /* TIA-678 C.5.7 Keypad emulation */
408 "+WPBA", /* TIA-678 C.5.9 Phone battery query */
409 "+WPTH", /* TIA-678 C.5.10 Call path */
410 "+WRLK", /* TIA-678 C.5.4 Roam lockout */
411 "+WS45", /* TIA-678 5.2.4.2 DTE-side stack selection */
412 "+WS46", /* 3GPP TS 27.007 5.9 - PCCA STD-101 [17] select wireless network */
413 "+WS50", /* TIA-678 B.3.1.1 Normalized signal strength */
414 "+WS51", /* TIA-678 B.3.1.2 Carrier detect signal threshold */
415 "+WS52", /* TIA-678 B.3.1.3 Normalized battery level */
416 "+WS53", /* TIA-678 B.3.1.4 Normalized channel quality */
417 "+WS54", /* TIA-678 B.3.1.5 Carrier detect channel quality threshold */
418 "+WS57", /* TIA-678 B.3.1.7 Antenna preference */
419 "+WS58", /* TIA-678 B.3.1.8 Idle time-out value */
420 "+WSTL", /* TIA-678 C.5.2 Call session time limit */
421 ";", /* Dummy to absorb semi-colon delimiters in commands */
422 "A", /* V.250 6.3.5 - Answer */
423 "D", /* V.250 6.3.1 - Dial */
424 "E", /* V.250 6.2.4 - Command echo */
425 "H", /* V.250 6.3.6 - Hook control */
426 "I", /* V.250 6.1.3 - Request identification information */
427 "L", /* V.250 6.3.13 - Monitor speaker loudness */
428 "M", /* V.250 6.3.14 - Monitor speaker mode */
429 "O", /* V.250 6.3.7 - Return to online data state */
430 "P", /* V.250 6.3.3 - Select pulse dialling (command) */
431 "Q", /* V.250 6.2.5 - Result code suppression */
432 "S0", /* V.250 6.3.8 - Automatic answer */
433 "S10", /* V.250 6.3.12 - Automatic disconnect delay */
434 "S3", /* V.250 6.2.1 - Command line termination character */
435 "S4", /* V.250 6.2.2 - Response formatting character */
436 "S5", /* V.250 6.2.3 - Command line editing character */
437 "S6", /* V.250 6.3.9 - Pause before blind dialling */
438 "S7", /* V.250 6.3.10 - Connection completion timeout */
439 "S8", /* V.250 6.3.11 - Comma dial modifier time */
440 "T", /* V.250 6.3.2 - Select tone dialling (command) */
441 "V", /* V.250 6.2.6 - DCE response format */
442 "X", /* V.250 6.2.7 - Result code selection and call progress monitoring control */
443 "Z", /* V.250 6.1.1 - Reset to default configuration */
444 NULL
445 };
446
447 int packed_ptr = 0;
448
449 short int packed_trie[30000];
450
451 #define ALPHABET_SIZE 128
452
453 typedef struct trie_node_s
454 {
455 int first;
456 int last;
457 int node_no;
458 int entry;
459 /* Array of pointers to children */
460 struct trie_node_s *child_list[ALPHABET_SIZE];
461 } trie_node_t;
462
463 typedef struct
464 {
465 int entries;
466 /* The root of the trie */
467 trie_node_t *root;
468 } trie_t;
469
470 static trie_node_t *trie_node_create(void)
471 {
472 trie_node_t *s;
473
474 if ((s = malloc(sizeof(trie_node_t))))
475 {
476 memset(s, 0, sizeof(*s));
477 s->first = ALPHABET_SIZE - 1;
478 }
479 return s;
480 }
481 /*- End of function --------------------------------------------------------*/
482
483 static trie_t *trie_create(void)
484 {
485 trie_t *s;
486
487 if ((s = malloc(sizeof(trie_t))))
488 {
489 memset(s, 0, sizeof(*s));
490 s->root = trie_node_create();
491 }
492 return s;
493 }
494 /*- End of function --------------------------------------------------------*/
495
496 static void trie_recursive_add_node_numbers(trie_node_t *t)
497 {
498 int index;
499
500 if (t)
501 {
502 if (t->first <= t->last)
503 {
504 t->node_no = packed_ptr + 1;
505 packed_ptr += (t->last - t->first + 1 + 3);
506 for (index = 0; index < ALPHABET_SIZE; index++)
507 trie_recursive_add_node_numbers(t->child_list[index]);
508 }
509 else
510 {
511 t->node_no = packed_ptr + 1;
512 packed_ptr += 3;
513 }
514 }
515 }
516 /*- End of function --------------------------------------------------------*/
517
518 static void trie_recursive_build_packed_trie(trie_node_t *t)
519 {
520 int i;
521
522 if (t)
523 {
524 if (t->first <= t->last)
525 {
526 packed_trie[packed_ptr++] = t->first;
527 packed_trie[packed_ptr++] = t->last;
528 packed_trie[packed_ptr++] = t->entry;
529 for (i = t->first; i <= t->last; i++)
530 packed_trie[packed_ptr++] = (t->child_list[i]) ? t->child_list[i]->node_no : 0;
531 for (i = t->first; i <= t->last; i++)
532 trie_recursive_build_packed_trie(t->child_list[i]);
533 }
534 else
535 {
536 packed_trie[packed_ptr++] = 1;
537 packed_trie[packed_ptr++] = 0;
538 packed_trie[packed_ptr++] = t->entry;
539 }
540 }
541 }
542 /*- End of function --------------------------------------------------------*/
543
544 static void trie_add(trie_t *s, const char *u, size_t len)
545 {
546 int i;
547 int index;
548 trie_node_t *t;
549
550 s->entries++;
551 /* Loop over the length of the string to add and traverse the trie... */
552 for (t = s->root, i = 0; i < len; i++)
553 {
554 /* The character in u we are processing... */
555 index = (unsigned char) u[i];
556
557 /* Is there a child node for this character? */
558 if (t->child_list[index] == NULL)
559 {
560 t->child_list[index] = trie_node_create();
561 if (index < t->first)
562 t->first = index;
563 if (index > t->last)
564 t->last = index;
565 }
566
567 /* Move to the new node... and loop */
568 t = t->child_list[index];
569 }
570 t->entry = s->entries;
571 }
572 /*- End of function --------------------------------------------------------*/
573
574 static void dump_trie(void)
575 {
576 int i;
577
578 printf("\nstatic const at_cmd_service_t at_commands[] =\n{\n");
579 for (i = 0; wordlist[i]; i++)
580 {
581 switch (wordlist[i][0])
582 {
583 case ' ':
584 case ';':
585 printf(" at_cmd_dummy,\n");
586 break;
587 case '+':
588 printf(" at_cmd_plus_%s,\n", wordlist[i] + 1);
589 break;
590 case '&':
591 printf(" at_cmd_amp_%s,\n", wordlist[i] + 1);
592 break;
593 default:
594 printf(" at_cmd_%s,\n", wordlist[i]);
595 break;
596 }
597 }
598 printf("};\n");
599
600 printf("\nstatic const uint16_t command_trie[] =\n{");
601 for (i = 0; i < packed_ptr; i++)
602 {
603 if ((i & 7) == 0)
604 printf("\n ");
605 printf("0x%04X, ", packed_trie[i]);
606 }
607 printf("\n};\n");
608 printf("\n#define COMMAND_TRIE_LEN %d\n", packed_ptr);
609
610 }
611 /*- End of function --------------------------------------------------------*/
612
613 int main(int argc, char *argv[])
614 {
615 trie_t *s;
616 int i;
617
618 s = trie_create();
619
620 for (i = 0; wordlist[i]; i++)
621 trie_add(s, wordlist[i], strlen(wordlist[i]));
622 printf("// The trie contains %d entries\n", i);
623
624 packed_ptr = 0;
625 trie_recursive_add_node_numbers(s->root);
626 packed_ptr = 0;
627 trie_recursive_build_packed_trie(s->root);
628
629 dump_trie();
630
631 return 0;
632 }
633 /*- End of function --------------------------------------------------------*/
634 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.