Bug Summary

File:libs/spandsp/src/../src/make_at_dictionary.c
Location:line 627, column 5
Description:Potential leak of memory pointed to by 's'

Annotated Source Code

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