Bug Summary

File:libsynthesis/src/syncml_tk/src/sml/xlt/all/xltdevinf.c
Warning:line 281, column 3
Value stored to 'ppListElem' is never read

Annotated Source Code

1/**
2 * @file
3 * DeviceInf DTD related functions for the en-/decoder
4 *
5 * @target_system all
6 * @target_os all
7 */
8
9/*
10 * Copyright Notice
11 * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
12 * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
13 * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
14 * All Rights Reserved.
15 * Implementation of all or part of any Specification may require
16 * licenses under third party intellectual property rights,
17 * including without limitation, patent rights (such a third party
18 * may or may not be a Supporter). The Sponsors of the Specification
19 * are not responsible and shall not be held responsible in any
20 * manner for identifying or failing to identify any or all such
21 * third party intellectual property rights.
22 *
23 * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
24 * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
25 * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
26 * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
27 * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
28 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
29 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
30 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
31 * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
32 * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
33 * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
34 * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
35 * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
36 * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
37 * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
38 * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
39 *
40 * The above notice and this paragraph must be included on all copies
41 * of this document that are made.
42 *
43 */
44#include "syncml_tk_prefix_file.h" // %%% luz: needed for precompiled headers in eVC++
45
46#include "define.h"
47#ifdef __USE_DEVINF__
48
49#include "smldevinfdtd.h"
50#include "smlmetinfdtd.h"
51#include "xlttags.h"
52#include "xltdevinf.h"
53#include "xlttagtbl.h"
54#include "xltenc.h"
55#include "xltencwbxml.h"
56
57#include <libstr.h>
58#include <smlerr.h>
59#include <smldtd.h>
60#include <libmem.h>
61#include <libutil.h>
62#include <mgrutil.h>
63
64/* decoder callbacks */
65Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
66Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem, Boolean_t datastoreLocal);
67
68
69Ret_t buildDevInfDevInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
70 XltDecScannerPtr_t pScanner;
71 SmlDevInfDevInfPtr_t pElem = NULL((void*)0);
72 Ret_t rc;
73
74 pScanner = pDecoder->scanner;
75
76 if (*ppElem != NULL((void*)0))
77 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDevInfCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDevInfCmd"
)
;
78
79 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
80 *ppElem = pElem;
81 return SML_ERR_OK0x00;
82 }
83
84 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
85 smlLibFree(pElem);
86 return rc;
87 }
88
89 switch (pScanner->curtok->tagid) {
90 case TN_DEVINF_DEVINF:
91 rc = buildDevInfDevInfContent(pDecoder, (VoidPtr_t)&pElem);
92 break;
93 default:
94 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDevInfCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDevInfCmd"
)
;
95 }
96 if (rc != SML_ERR_OK0x00) {
97 smlLibFree(pElem);
98 return rc;
99 }
100 *ppElem = pElem;
101
102 return SML_ERR_OK0x00;
103}
104
105Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
106 XltDecScannerPtr_t pScanner;
107 SmlDevInfDevInfPtr_t pElem;
108 Ret_t rc;
109
110 pScanner = pDecoder->scanner;
111
112 if (*ppElem != NULL((void*)0))
113 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDevInfContent")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDevInfContent"
)
;
114
115 if ((pElem = (SmlDevInfDevInfPtr_t)smlLibMalloc(sizeof(SmlDevInfDevInf_t))) == NULL((void*)0))
116 return SML_ERR_NOT_ENOUGH_SPACE0x11;
117 smlLibMemset(pElem, 0, sizeof(SmlDevInfDevInf_t));
118
119 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
120 *ppElem = pElem;
121 return SML_ERR_OK0x00;
122 }
123
124 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
125 smlLibFree(pElem);
126 return rc;
127 }
128
129 while (pScanner->curtok->type != TOK_TAG_END) {
130 switch (pScanner->curtok->tagid) {
131 case TN_DEVINF_VERDTD:
132 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->verdtd);
133 break;
134 case TN_DEVINF_MAN:
135 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->man);
136 break;
137 case TN_DEVINF_MOD:
138 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->mod);
139 break;
140 case TN_DEVINF_OEM:
141 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->oem);
142 break;
143 case TN_DEVINF_FWV:
144 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->fwv);
145 break;
146 case TN_DEVINF_SWV:
147 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->swv);
148 break;
149 case TN_DEVINF_HWV:
150 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->hwv);
151 break;
152 case TN_DEVINF_DEVID:
153 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devid);
154 break;
155 case TN_DEVINF_DEVTYP:
156 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devtyp);
157 break;
158 case TN_DEVINF_DATASTORE:
159 rc = buildDevInfDataStoreList(pDecoder, (VoidPtr_t)&pElem->datastore);
160 break;
161 case TN_DEVINF_CTCAP:
162 rc = buildDevInfCtcap(pDecoder, (VoidPtr_t)&pElem->ctcap,FALSE0); // CTCap which is global in devInf itself (pre-DS 1.2)
163 break;
164 case TN_DEVINF_EXT:
165 rc = buildDevInfExtList(pDecoder, (VoidPtr_t)&pElem->ext);
166 break;
167 /* SCTSTK - 18/03/2002 S.H. 2002-04-05 : SyncML 1.1 */
168 case TN_DEVINF_UTC:
169 pElem->flags |= SmlDevInfUTC_f0x0001;
170 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
171 break;
172 case TN_DEVINF_NOFM:
173 pElem->flags |= SmlDevInfNOfM_f0x0002;
174 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
175 break;
176 case TN_DEVINF_LARGEOBJECT:
177 pElem->flags |= SmlDevInfLargeObject_f0x0008;
178 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
179 break;
180 default:
181 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDevInfContent")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDevInfContent"
)
;
182 }
183 if (rc != SML_ERR_OK0x00) {
184 smlLibFree(pElem);
185 return rc;
186 }
187 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
188 smlLibFree(pElem);
189 return rc;
190 }
191 }
192 *ppElem = pElem;
193
194 return SML_ERR_OK0x00;
195}
196
197
198static Ret_t buildDevInfFilterCapList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
199{
200 SmlDevInfFilterCapListPtr_t *ppListElem = NULL((void*)0);
201 SmlDevInfFilterCapListPtr_t pFiltercap = NULL((void*)0);
202 SmlPcdataListPtr_t *ppList = NULL((void*)0);
203 SmlPcdataListPtr_t pList = NULL((void*)0);
204 XltDecScannerPtr_t pScanner = pDecoder->scanner;
205
206 Ret_t rc;
207
208 // if empty, that's ok and treated as NOP: <FilterCap/>
209 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
210 return SML_ERR_OK0x00;
211 }
212 // get next token
213 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
214 return rc;
215 }
216 // get pointer to where we'd insert the next list element
217 ppListElem = (SmlDevInfFilterCapListPtr_t *) ppElem;
218 while (*ppListElem!=NULL((void*)0)) {
219 ppListElem = &((*ppListElem)->next);
220 }
221 // create new list element now
222 pFiltercap = (SmlDevInfFilterCapListPtr_t)smlLibMalloc(sizeof(SmlDevInfFilterCapList_t));
223 if (pFiltercap == NULL((void*)0)) return SML_ERR_NOT_ENOUGH_SPACE0x11;
224 smlLibMemset(pFiltercap, 0, sizeof(SmlDevInfFilterCapList_t));
225 pFiltercap->data = (SmlDevInfFilterCapPtr_t)smlLibMalloc(sizeof(SmlDevInfFilterCap_t));
226 if (pFiltercap->data == NULL((void*)0)) {
227 smlFreeDevInfFilterCapList(pFiltercap);
228 return SML_ERR_NOT_ENOUGH_SPACE0x11;
229 }
230 smlLibMemset(pFiltercap->data, 0, sizeof(SmlDevInfFilterCap_t));
231 // scan until we hit end of enclosure (</FilterCap>)
232 while (pScanner->curtok->type != TOK_TAG_END) {
233 // process tags
234 switch (pScanner->curtok->tagid) {
235 /* PCDATA elements */
236 case TN_DEVINF_CTTYPE:
237 rc = buildPCData(pDecoder, (VoidPtr_t)&pFiltercap->data->cttype);
238 break;
239 case TN_DEVINF_VERCT:
240 rc = buildPCData(pDecoder, (VoidPtr_t)&pFiltercap->data->verct);
241 break;
242 case TN_DEVINF_FILTERKEYWORD:
243 ppList = &pFiltercap->data->filterkeyword;
244 goto keywordOrPropname;
245 case TN_DEVINF_PROPNAME:
246 ppList = &pFiltercap->data->propname;
247 goto keywordOrPropname;
248 keywordOrPropname:
249 // find last existing valenum
250 while (*ppList!=NULL((void*)0))
251 ppList=&((*ppList)->next);
252 // create new list element
253 pList = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t));
254 if (pList == NULL((void*)0)) return SML_ERR_NOT_ENOUGH_SPACE0x11;
255 smlLibMemset(pList, 0, sizeof(SmlPcdataList_t));
256 // insert contents
257 rc = buildPCData(pDecoder, (VoidPtr_t)&pList->data);
258 if (rc==SML_ERR_OK0x00) {
259 // ok, add element to list
260 *ppList = pList;
261 ppList = &(pList->next);
262 }
263 else
264 smlFreePcdataList(pList); // invalid, get rid of it
265 break;
266 default:
267 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfFilterCapList")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfFilterCapList"
)
;
268 }
269 if (rc != SML_ERR_OK0x00) {
270 smlFreeDevInfFilterCapList(pFiltercap);
271 return rc;
272 }
273 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
274 smlFreeDevInfFilterCapList(pFiltercap);
275 return rc;
276 }
277 } /* while we do not see an end tag */
278 // link into list
279 *ppListElem = pFiltercap;
280 // set elem link to where we must link in next element
281 ppListElem = &(pFiltercap->next);
Value stored to 'ppListElem' is never read
282 // done ok
283 return SML_ERR_OK0x00;
284}
285
286
287Ret_t buildDevInfDataStoreCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
288 XltDecScannerPtr_t pScanner;
289 SmlDevInfDatastorePtr_t pElem;
290 Ret_t rc;
291
292 pScanner = pDecoder->scanner;
293
294 if (*ppElem != NULL((void*)0))
295 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDataStoreCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDataStoreCmd"
)
;
296
297 if ((pElem = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t))) == NULL((void*)0))
298 return SML_ERR_NOT_ENOUGH_SPACE0x11;
299 smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastore_t));
300
301 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
302 *ppElem = pElem;
303 return SML_ERR_OK0x00;
304 }
305
306 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
307 smlLibFree(pElem);
308 return rc;
309 }
310
311 while (pScanner->curtok->type != TOK_TAG_END) {
312 switch (pScanner->curtok->tagid) {
313 /* PCDATA elements */
314 case TN_DEVINF_SOURCEREF:
315 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->sourceref);
316 break;
317 case TN_DEVINF_DISPLAYNAME:
318 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->displayname);
319 break;
320 case TN_DEVINF_MAXGUIDSIZE:
321 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxguidsize);
322 break;
323 /* other elements */
324 case TN_DEVINF_RXPREF:
325 if (pElem->rxpref!=NULL((void*)0)) {
326 // we already have a RxPref - simply ignore further ones
327 // (in DS 1.2, some implementations send an other rx-pref for the folder object apart from the main type)
328 SmlDevInfXmitPtr_t dummyP = NULL((void*)0);
329 rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&dummyP);
330 smlFreeDevInfXmit(dummyP); // simply discard after parsing
331 }
332 else
333 rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->rxpref);
334 break;
335 case TN_DEVINF_TXPREF:
336 if (pElem->txpref!=NULL((void*)0)) {
337 // we already have a txpref - simply ignore further ones
338 // (in DS 1.2, some implementations send an other tx-pref for the folder object apart from the main type)
339 SmlDevInfXmitPtr_t dummyP = NULL((void*)0);
340 rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&dummyP);
341 smlFreeDevInfXmit(dummyP); // simply discard after parsing
342 }
343 else
344 rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->txpref);
345 break;
346 case TN_DEVINF_RX:
347 rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->rx);
348 break;
349 case TN_DEVINF_TX:
350 rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->tx);
351 break;
352 case TN_DEVINF_CTCAP:
353 rc = buildDevInfCtcap(pDecoder, (VoidPtr_t)&pElem->ctcap,TRUE1); // CTCap which is local to datastore (DS 1.2 style)
354 break;
355 case TN_DEVINF_DSMEM:
356 rc = buildDevInfDSMemCmd(pDecoder, (VoidPtr_t)&pElem->dsmem);
357 break;
358 case TN_DEVINF_SYNCCAP:
359 rc = buildDevInfSyncCapCmd(pDecoder, (VoidPtr_t)&pElem->synccap);
360 break;
361
362
363
364 /* SyncML DS 1.2, Synthesis/luz 2005-08-25 */
365 case TN_DEVINF_FILTERCAP:
366 rc = buildDevInfFilterCapList(pDecoder, (VoidPtr_t)&pElem->filtercap);
367 break;
368 case TN_DEVINF_FILTERRX:
369 rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->filterrx);
370 break;
371 case TN_DEVINF_HIERARCHICAL:
372 pElem->flags |= SmlDevInfHierarchical_f0x0040;
373 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
374 break;
375 case TN_DEVINF_FIELDLEVEL:
376 pElem->flags |= SmlDevInfFieldLevel_f0x0010;
377 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
378 break;
379
380 default:
381 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDataStoreCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDataStoreCmd"
)
;
382 }
383 if (rc != SML_ERR_OK0x00) {
384 smlLibFree(pElem);
385 return rc;
386 }
387 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
388 smlLibFree(pElem);
389 return rc;
390 }
391 }
392 *ppElem = pElem;
393
394 return SML_ERR_OK0x00;
395}
396
397Ret_t buildDevInfXmitCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
398 XltDecScannerPtr_t pScanner;
399 SmlDevInfXmitPtr_t pXmit;
400 Ret_t rc;
401
402 pScanner = pDecoder->scanner;
403
404 if (*ppElem != NULL((void*)0))
405 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfXmitCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfXmitCmd"
)
;
406
407 if ((pXmit = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t))) == NULL((void*)0))
408 return SML_ERR_NOT_ENOUGH_SPACE0x11;
409 smlLibMemset(pXmit, 0, sizeof(SmlDevInfXmit_t));
410
411 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
412 *ppElem = pXmit;
413 return SML_ERR_OK0x00;
414 }
415
416 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
417 smlLibFree(pXmit);
418 return rc;
419 }
420
421 while (pScanner->curtok->type != TOK_TAG_END) {
422 switch (pScanner->curtok->tagid) {
423 /* PCDATA elements */
424 case TN_DEVINF_CTTYPE:
425 rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->cttype);
426 break;
427 case TN_DEVINF_VERCT:
428 rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->verct);
429 break;
430 default:
431 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfXmitCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfXmitCmd"
)
;
432 }
433 if (rc != SML_ERR_OK0x00) {
434 smlLibFree(pXmit);
435 return rc;
436 }
437 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
438 smlLibFree(pXmit);
439 return rc;
440 }
441 }
442 *ppElem = pXmit;
443
444 return SML_ERR_OK0x00;
445}
446
447Ret_t buildDevInfXmitList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
448 SmlDevInfXmitListPtr_t pElem = NULL((void*)0), pPrev = NULL((void*)0);
449
450 pElem = (SmlDevInfXmitListPtr_t) *ppElem;
451
452 /* advance to the end of the list, and create ther an empty list element */
453 while (pElem != NULL((void*)0)) {
454 pPrev = pElem;
455 pElem = pPrev->next;
456 }
457 if ((pElem = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t))) == NULL((void*)0))
458 return SML_ERR_NOT_ENOUGH_SPACE0x11;
459 smlLibMemset(pElem, 0, sizeof(SmlDevInfXmitList_t));
460 if (pPrev != NULL((void*)0)) /* we already had some entries in the list */
461 pPrev->next = pElem;
462 else /* nope we created a new list */
463 *ppElem = pElem;
464 pElem->data = NULL((void*)0);
465 /* at this point pElem should point to an valid list element */
466 return buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->data);
467}
468
469Ret_t buildDevInfDataStoreList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
470 SmlDevInfDatastoreListPtr_t pElem = NULL((void*)0), pPrev = NULL((void*)0);
471
472 pElem = (SmlDevInfDatastoreListPtr_t) *ppElem;
473
474 /* advance to the end of the list, and create ther an empty list element */
475 while (pElem != NULL((void*)0)) {
476 pPrev = pElem;
477 pElem = pPrev->next;
478 }
479 if ((pElem = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t))) == NULL((void*)0))
480 return SML_ERR_NOT_ENOUGH_SPACE0x11;
481 smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastoreList_t));
482 if (pPrev != NULL((void*)0)) /* we already had some entries in the list */
483 pPrev->next = pElem;
484 else /* nope we created a new list */
485 *ppElem = pElem;
486 pElem->data = NULL((void*)0);
487 /* at this point pElem should point to an valid list element */
488 return buildDevInfDataStoreCmd(pDecoder, (VoidPtr_t)&pElem->data);
489}
490
491Ret_t buildDevInfExtList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
492 SmlDevInfExtListPtr_t pElem = NULL((void*)0), pPrev = NULL((void*)0);
493
494 pElem = (SmlDevInfExtListPtr_t) *ppElem;
495
496 /* advance to the end of the list, and create ther an empty list element */
497 while (pElem != NULL((void*)0)) {
498 pPrev = pElem;
499 pElem = pPrev->next;
500 }
501 if ((pElem = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t))) == NULL((void*)0))
502 return SML_ERR_NOT_ENOUGH_SPACE0x11;
503 smlLibMemset(pElem, 0, sizeof(SmlDevInfExtList_t));
504 if (pPrev != NULL((void*)0)) /* we already had some entries in the list */
505 pPrev->next = pElem;
506 else /* nope we created a new list */
507 *ppElem = pElem;
508 pElem->data = NULL((void*)0);
509 /* at this point pElem should point to an valid list element */
510 return buildDevInfExtCmd(pDecoder, (VoidPtr_t)&pElem->data);
511}
512
513
514/// @brief scans common elements of Properties and PropParams
515/// @return SML_ERR_XLT_INVAL_PROTO_ELEM if unknown tag is encountered
516static Ret_t scanPropOrParamElement(XltDecoderPtr_t pDecoder, SmlDevInfCTDataPtr_t pPropOrParam)
517{
518 SmlPcdataListPtr_t *ppValenums = &(pPropOrParam->valenum);
519 SmlPcdataListPtr_t pValenum;
520 XltDecScannerPtr_t pScanner = pDecoder->scanner;
521 Ret_t rc;
522
523 // process tags
524 switch (pScanner->curtok->tagid) {
525 case TN_DEVINF_DISPLAYNAME:
526 rc = buildPCData(pDecoder, (VoidPtr_t)&pPropOrParam->dname);
527 break;
528 case TN_DEVINF_DATATYPE:
529 rc = buildPCData(pDecoder, (VoidPtr_t)&pPropOrParam->datatype);
530 break;
531 case TN_DEVINF_MAXSIZE:
532 case TN_DEVINF_SIZE:
533 rc = buildPCData(pDecoder, (VoidPtr_t)&pPropOrParam->maxsize);
534 break;
535 case TN_DEVINF_MAXOCCUR:
536 rc = buildPCData(pDecoder, (VoidPtr_t)&pPropOrParam->maxoccur);
537 break;
538 /* Flags */
539 case TN_DEVINF_NOTRUNCATE:
540 pPropOrParam->flags |= SmlDevInfNoTruncate_f0x0020;
541 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
542 break;
543 /* Valenum* */
544 case TN_DEVINF_VALENUM:
545 // find last existing valenum
546 while (*ppValenums!=NULL((void*)0))
547 ppValenums=&((*ppValenums)->next);
548 // create new list element
549 pValenum = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t));
550 if (pValenum == NULL((void*)0)) return SML_ERR_NOT_ENOUGH_SPACE0x11;
551 smlLibMemset(pValenum, 0, sizeof(SmlPcdataList_t));
552 // insert contents
553 rc = buildPCData(pDecoder, (VoidPtr_t)&pValenum->data);
554 if (rc==SML_ERR_OK0x00) {
555 // ok, add element to list
556 *ppValenums = pValenum;
557 ppValenums = &(pValenum->next);
558 }
559 else
560 smlFreePcdataList(pValenum); // invalid, get rid of it
561 break;
562 default:
563 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_PROTO_ELEM,pScanner,"scanPropOrParamElement")show_decode_error(0x2008,(XltDecScannerPtr_t)pScanner,"scanPropOrParamElement"
)
;
564 }
565 return rc;
566}
567
568
569// @brief scan a single <PropParam></PropParam> bracket, or a <1.2 type list where a new <PropName> implies end of current PropParam and start of a new one
570static Ret_t buildDevInfPropParam(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem, int datastoreLocal) {
571 SmlDevInfCTDataListPtr_t *ppListElem = NULL((void*)0);
572 SmlDevInfCTDataListPtr_t pParam = NULL((void*)0);
573 Boolean_t newElement = FALSE0;
574 XltDecScannerPtr_t pScanner = pDecoder->scanner;
575 Ret_t rc;
576
577 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
578 return SML_ERR_OK0x00;
579 }
580
581 if (datastoreLocal) {
582 // DS 1.2: we have no initial tag to process right away, get next tag now
583 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
584 return rc;
585 }
586 newElement=TRUE1; // new <property> has already started here
587 }
588
589 // get pointer to where we'd insert the next list element
590 ppListElem = (SmlDevInfCTDataListPtr_t *)ppElem;
591 while (*ppListElem!=NULL((void*)0)) {
592 ppListElem = &((*ppListElem)->next);
593 }
594 pParam=NULL((void*)0);
595 // now ppListElem points to a SmlDevInfCTDataListPtr_t which is NULL and
596 // can be overwritten with the link to a new element
597
598 // scan until we hit end of enclosure (</PropParam>) or an unknown other tag
599 while (pScanner->curtok->type != TOK_TAG_END) {
600 if (!datastoreLocal && pScanner->curtok->tagid==TN_DEVINF_PARAMNAME) {
601 // DS 1.1-style CTCap, seeing <ParamName> implies new element
602 newElement=TRUE1;
603 }
604 // create new element if needed
605 if (newElement) {
606 newElement=FALSE0;
607 pParam = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t));
608 if (pParam == NULL((void*)0)) return SML_ERR_NOT_ENOUGH_SPACE0x11;
609 smlLibMemset(pParam, 0, sizeof(SmlDevInfCTDataList_t));
610 pParam->data = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
611 if (pParam->data == NULL((void*)0)) {
612 smlFreeDevInfCTDataList(pParam);
613 return SML_ERR_NOT_ENOUGH_SPACE0x11;
614 }
615 smlLibMemset(pParam->data, 0, sizeof(SmlDevInfCTData_t));
616 // link into list
617 *ppListElem = pParam;
618 // set elem link to where we must link in next element
619 ppListElem = &(pParam->next);
620 }
621 // now, if we don't have a pParam, this is an invalid <DS 1.2 devinf
622 if (pParam==NULL((void*)0))
623 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfPropParam")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfPropParam"
)
;
624
625 // process tags
626 switch (pScanner->curtok->tagid) {
627 /* PCDATA */
628 case TN_DEVINF_PARAMNAME:
629 rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->name);
630 break;
631 default:
632 rc = scanPropOrParamElement(pDecoder, pParam->data);
633 if (rc==SML_ERR_XLT_INVAL_PROTO_ELEM0x2008 && !datastoreLocal)
634 return SML_ERR_OK0x00; // parser signals unknown tag, this is ok for pre-1.2
635 break;
636 }
637 if (rc != SML_ERR_OK0x00)
638 return rc;
639 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00))
640 return rc;
641 } /* while we do not see an end tag */
642 return SML_ERR_OK0x00;
643}
644
645
646// @brief scan a single <Property></Property> bracket, or a <1.2 type list where a new <PropName> implies end of current property and start of a new one
647static Ret_t buildDevInfProperty(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem, int datastoreLocal) {
648 SmlDevInfCTDataPropListPtr_t *ppListElem = NULL((void*)0);
649 SmlDevInfCTDataPropListPtr_t pProp = NULL((void*)0);
650 Boolean_t newElement = FALSE0;
651 XltDecScannerPtr_t pScanner = pDecoder->scanner;
652 Ret_t rc;
653
654 /* Do not return immediately for <1.2 style, the outer loop ends only meeting an end tag
655 * which will lead to an infinite loop*/
656 if (datastoreLocal && IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
657 return SML_ERR_OK0x00;
658 }
659
660 if (datastoreLocal) {
661 // DS 1.2: we have no initial tag to process right away, get next tag now
662 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
663 return rc;
664 }
665 newElement=TRUE1; // new <property> has already started here
666 }
667
668 // get pointer to where we'd insert the next list element
669 ppListElem = (SmlDevInfCTDataPropListPtr_t *) ppElem;
670 while (*ppListElem!=NULL((void*)0)) {
671 ppListElem = &((*ppListElem)->next);
672 }
673 pProp=NULL((void*)0);
674 // now ppListElem points to a SmlDevInfCTDataPropListPtr_t which is NULL and
675 // can be overwritten with the link to a new element
676
677 // scan until we hit end of enclosure (</Property>) or an unknown other tag
678 while (pScanner->curtok->type != TOK_TAG_END) {
679 if (!datastoreLocal && pScanner->curtok->tagid==TN_DEVINF_PROPNAME) {
680 // DS 1.1-style CTCap, seeing <PropName> implies new element
681 newElement=TRUE1;
682 }
683 // create new element if needed
684 if (newElement) {
685 newElement=FALSE0;
686 pProp = (SmlDevInfCTDataPropListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t));
687 if (pProp == NULL((void*)0)) return SML_ERR_NOT_ENOUGH_SPACE0x11;
688 smlLibMemset(pProp, 0, sizeof(SmlDevInfCTDataPropList_t));
689 pProp->data = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t));
690 if (pProp->data == NULL((void*)0)) {
691 smlFreeDevInfCTDataPropList(pProp);
692 return SML_ERR_NOT_ENOUGH_SPACE0x11;
693 }
694 smlLibMemset(pProp->data, 0, sizeof(SmlDevInfCTDataProp_t));
695 pProp->data->prop = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
696 if (pProp->data->prop == NULL((void*)0)) {
697 smlFreeDevInfCTDataPropList(pProp);
698 return SML_ERR_NOT_ENOUGH_SPACE0x11;
699 }
700 smlLibMemset(pProp->data->prop, 0, sizeof(SmlDevInfCTData_t));
701 // link into list
702 *ppListElem = pProp;
703 // set elem link to where we must link in next element
704 ppListElem = &(pProp->next);
705 }
706 // now, if we don't have a pProp, this is an invalid <DS 1.2 devinf
707 if (pProp==NULL((void*)0))
708 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfProperty")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfProperty"
)
;
709
710 // process tags
711 switch (pScanner->curtok->tagid) {
712 case TN_DEVINF_PROPPARAM:
713 // DS 1.2 case: only </PropParam> ends the param building process
714 rc = buildDevInfPropParam(pDecoder, (VoidPtr_t)&pProp->data->param,datastoreLocal);
715 break;
716 case TN_DEVINF_PARAMNAME:
717 // <DS 1.2 case: current token TN_DEVINF_PARAMNAME is processed by builder
718 if (datastoreLocal) {
719 // found <ParamName> directly within <Property> (instead of enclosed in a <PropParam>) - Nokia 2630 style
720 // -> do not reject it but try to process in DS 1.1 style even if this is a DS 1.2 devInf
721 rc = buildDevInfPropParam(pDecoder, (VoidPtr_t)&pProp->data->param,FALSE0); // force DS 1.1 style
722 if (rc==SML_ERR_OK0x00)
723 continue; // re-evaluate current tag (tag that caused buildDevInfPropParam() to end, either next <PropName>, unknown or closing </CTCap>
724 }
725 else {
726 rc = buildDevInfPropParam(pDecoder, (VoidPtr_t)&pProp->data->param,datastoreLocal);
727 if (rc==SML_ERR_OK0x00)
728 continue; // re-evaluate current tag (tag that caused buildDevInfPropParam() to end, either next <PropName>, unknown or closing </CTCap>
729 }
730 break;
731
732 /* PCDATA */
733 case TN_DEVINF_PROPNAME:
734 rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->name);
735 break;
736
737 default:
738 rc = scanPropOrParamElement(pDecoder, pProp->data->prop);
739 if (rc==SML_ERR_XLT_INVAL_PROTO_ELEM0x2008 && !datastoreLocal)
740 return SML_ERR_OK0x00; // parser signals unknown tag, this is ok for pre-1.2
741 }
742 if (rc != SML_ERR_OK0x00)
743 return rc;
744 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00))
745 return rc;
746 } /* while we do not see an end tag */
747 return SML_ERR_OK0x00;
748}
749
750
751
752// @brief scan a single <ctcap></ctcap> bracket, which may contain serveral ctcaps for <DS 1.2, and only one single ctcap for >=DS 1.2
753Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem, Boolean_t datastoreLocal)
754{
755 SmlDevInfCtcapListPtr_t *ppListElem = NULL((void*)0);
756 SmlDevInfCtcapListPtr_t pCtcap = NULL((void*)0);
757 Boolean_t newElement = FALSE0;
758 XltDecScannerPtr_t pScanner = pDecoder->scanner;
759 Ret_t rc;
760
761 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
762 return SML_ERR_OK0x00;
763 }
764
765 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
766 return rc;
767 }
768
769 // get pointer to where we'd insert the next list element
770 ppListElem = (SmlDevInfCtcapListPtr_t *)ppElem;
771 while (*ppListElem!=NULL((void*)0)) {
772 ppListElem = &((*ppListElem)->next);
773 }
774 pCtcap=NULL((void*)0);
775 // now ppListElem points to a SmlDevInfCtcapListPtr_t which is NULL and
776 // can be overwritten with the link to a new element
777
778 // datastore local CTCap is DS 1.2 or later, and implies that every type description has its own <CTCap></CTCap>
779 // So starting a CTCap implies creating a new element
780 newElement=datastoreLocal;
781
782 while (pScanner->curtok->type != TOK_TAG_END) {
783 if (!datastoreLocal && pScanner->curtok->tagid==TN_DEVINF_CTTYPE) {
784 // DS 1.1-style CTCap, seeing CTTYPE implies new element
785 newElement=TRUE1;
786 }
787 // create new element if needed
788 if (newElement) {
789 newElement=FALSE0;
790 pCtcap = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t));
791 if (pCtcap == NULL((void*)0)) return SML_ERR_NOT_ENOUGH_SPACE0x11;
792 smlLibMemset(pCtcap, 0, sizeof(SmlDevInfCtcapList_t));
793 pCtcap->data = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t));
794 if (pCtcap->data == NULL((void*)0)) {
795 smlFreeDevInfCtcapList(pCtcap);
796 return SML_ERR_NOT_ENOUGH_SPACE0x11;
797 }
798 smlLibMemset(pCtcap->data, 0, sizeof(SmlDevInfCTCap_t));
799 // link into list
800 *ppListElem = pCtcap;
801 // set elem link to where we must link in next element
802 ppListElem = &(pCtcap->next);
803 }
804 // now, if we don't have a pCtcap, this is an invalid <DS 1.2 devinf where another tag than <CTType> follows <CTCap>
805 if (pCtcap==NULL((void*)0))
806 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfCtcap")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfCtcap"
)
;
807 // process tags
808 switch (pScanner->curtok->tagid) {
809 case TN_DEVINF_CTTYPE:
810 rc = buildPCData(pDecoder, (VoidPtr_t)&pCtcap->data->cttype);
811 break;
812 case TN_DEVINF_VERCT:
813 rc = buildPCData(pDecoder, (VoidPtr_t)&pCtcap->data->verct);
814 break;
815 case TN_DEVINF_PROPERTY:
816 // DS 1.2 case: only </Property> ends the property building process, next token must be read first
817 // If there is a Property tag, let's take it as DS 1.2 Property Decoding even if the CTCAP is globally
818 // This is found from some Nokia phones (eg. N900, which will send a DevInf v1.2 but the CTCAP
819 // was not inside the datastore as DevInf v1.1)
820 rc = buildDevInfProperty(pDecoder, (VoidPtr_t)&pCtcap->data->prop,TRUE1);
821 break;
822 case TN_DEVINF_PROPNAME:
823 // <DS 1.2 case: current token TN_DEVINF_PROPNAME is processed by builder, next occurence of TN_DEVINF_PROPNAME ends property as well
824 if (datastoreLocal)
825 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfCtcap")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfCtcap"
)
; // <PropName> must be inside <Property>
826 else {
827 rc = buildDevInfProperty(pDecoder, (VoidPtr_t)&pCtcap->data->prop,datastoreLocal);
828 if (rc==SML_ERR_OK0x00)
829 continue; // re-evaluate current tag (tag that caused buildDevInfProperty() to end, either unknown or closing </CTCap>
830 // this means do not return SML_ERR_OK unless this is an unknow tag or closing </CTCcap>, otherwise it will trigger an infinite loop
831 }
832 break;
833
834 default:
835 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfCtcap")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfCtcap"
)
;
836 }
837 if (rc != SML_ERR_OK0x00) {
838 return rc;
839 }
840 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
841 return rc;
842 }
843 } /* eof while */
844 return SML_ERR_OK0x00;
845}
846
847
848Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
849 XltDecScannerPtr_t pScanner;
850 SmlDevInfDSMemPtr_t pElem;
851 Ret_t rc;
852
853 pScanner = pDecoder->scanner;
854
855 if (*ppElem != NULL((void*)0))
856 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDSMemCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDSMemCmd"
)
;
857
858 if ((pElem = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t))) == NULL((void*)0))
859 return SML_ERR_NOT_ENOUGH_SPACE0x11;
860 smlLibMemset(pElem, 0, sizeof(SmlDevInfDSMem_t));
861
862 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
863 *ppElem = pElem;
864 return SML_ERR_OK0x00;
865 }
866
867 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
868 smlLibFree(pElem);
869 return rc;
870 }
871
872 while (pScanner->curtok->type != TOK_TAG_END) {
873 switch (pScanner->curtok->tagid) {
874 /* PCDATA elements */
875 case TN_DEVINF_SHAREDMEM:
876 // %%% luz:2003-04-28: made work as a flag
877 pElem->flags |= SmlDevInfSharedMem_f0x0004;
878 rc = buildEmptyTag(pDecoder); // allow for <tag></tag> instead of <tag/>
879 break;
880 case TN_DEVINF_MAXMEM:
881 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxmem);
882 break;
883 case TN_DEVINF_MAXID:
884 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxid);
885 break;
886 default:
887 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfDSMemCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfDSMemCmd"
)
;
888 }
889 if (rc != SML_ERR_OK0x00) {
890 smlLibFree(pElem);
891 return rc;
892 }
893 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
894 smlLibFree(pElem);
895 return rc;
896 }
897 }
898 *ppElem = pElem;
899
900 return SML_ERR_OK0x00;
901}
902
903Ret_t buildDevInfCTCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
904 XltDecScannerPtr_t pScanner;
905 SmlDevInfCTCapPtr_t pElem;
906 Ret_t rc;
907
908 pScanner = pDecoder->scanner;
909
910 if (*ppElem != NULL((void*)0))
911 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfCTCapCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfCTCapCmd"
)
;
912
913 if ((pElem = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t))) == NULL((void*)0))
914 return SML_ERR_NOT_ENOUGH_SPACE0x11;
915 smlLibMemset(pElem, 0, sizeof(SmlDevInfCTCap_t));
916
917 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
918 *ppElem = pElem;
919 return SML_ERR_OK0x00;
920 }
921
922 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
923 smlLibFree(pElem);
924 return rc;
925 }
926
927 while (pScanner->curtok->type != TOK_TAG_END) {
928 switch (pScanner->curtok->tagid) {
929 case TN_DEVINF_CTTYPE:
930 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->cttype);
931 break;
932 default:
933 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfCTCapCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfCTCapCmd"
)
;
934 }
935 if (rc != SML_ERR_OK0x00) {
936 smlLibFree(pElem);
937 return rc;
938 }
939 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
940 smlLibFree(pElem);
941 return rc;
942 }
943 }
944 *ppElem = pElem;
945
946 return SML_ERR_OK0x00;
947}
948
949Ret_t buildDevInfSyncCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
950 XltDecScannerPtr_t pScanner;
951 SmlDevInfSyncCapPtr_t pElem;
952 Ret_t rc;
953
954 pScanner = pDecoder->scanner;
955
956 if (*ppElem != NULL((void*)0))
957 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfSyncCapCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfSyncCapCmd"
)
;
958
959 if ((pElem = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t))) == NULL((void*)0))
960 return SML_ERR_NOT_ENOUGH_SPACE0x11;
961 smlLibMemset(pElem, 0, sizeof(SmlDevInfSyncCap_t));
962
963 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
964 *ppElem = pElem;
965 return SML_ERR_OK0x00;
966 }
967
968 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
969 smlLibFree(pElem);
970 return rc;
971 }
972
973 while (pScanner->curtok->type != TOK_TAG_END) {
974 switch (pScanner->curtok->tagid) {
975 case TN_DEVINF_SYNCTYPE:
976 rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->synctype);
977 break;
978 default:
979 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfSyncCapCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfSyncCapCmd"
)
;
980 }
981 if (rc != SML_ERR_OK0x00) {
982 smlLibFree(pElem);
983 return rc;
984 }
985 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
986 smlLibFree(pElem);
987 return rc;
988 }
989 }
990 *ppElem = pElem;
991
992 return SML_ERR_OK0x00;
993}
994
995Ret_t buildDevInfExtCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
996 XltDecScannerPtr_t pScanner;
997 SmlDevInfExtPtr_t pElem;
998 Ret_t rc;
999
1000 pScanner = pDecoder->scanner;
1001
1002 if (*ppElem != NULL((void*)0))
1003 return SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfExtCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfExtCmd"
)
;
1004
1005 if ((pElem = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t))) == NULL((void*)0))
1006 return SML_ERR_NOT_ENOUGH_SPACE0x11;
1007 smlLibMemset(pElem, 0, sizeof(SmlDevInfExt_t));
1008
1009 if (IS_EMPTY(pScanner->curtok)((pScanner->curtok)->type == TOK_TAG_EMPTY)) {
1010 *ppElem = pElem;
1011 return SML_ERR_OK0x00;
1012 }
1013
1014 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
1015 smlLibFree(pElem);
1016 return rc;
1017 }
1018
1019 while (pScanner->curtok->type != TOK_TAG_END) {
1020 switch (pScanner->curtok->tagid) {
1021 case TN_DEVINF_XNAM:
1022 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->xnam);
1023 break;
1024 case TN_DEVINF_XVAL:
1025 rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->xval);
1026 break;
1027 default:
1028 rc = SML_DECODEERROR(SML_ERR_XLT_INVAL_SYNCML_DOC,pScanner,"buildDevInfExtCmd")show_decode_error(0x200B,(XltDecScannerPtr_t)pScanner,"buildDevInfExtCmd"
)
;
1029 }
1030 if (rc != SML_ERR_OK0x00) {
1031 smlLibFree(pElem);
1032 return rc;
1033 }
1034 if (((rc = nextToken(pDecoder)) != SML_ERR_OK0x00)) {
1035 smlLibFree(pElem);
1036 return rc;
1037 }
1038 }
1039 *ppElem = pElem;
1040
1041 return SML_ERR_OK0x00;
1042}
1043
1044
1045/* see xltenc.c:XltEncBlock for description of parameters */
1046Ret_t devinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
1047 //Return variable
1048 Ret_t _err;
1049 SmlPcdataListPtr_t pList = NULL((void*)0);
1050 SmlDevInfDatastoreListPtr_t dsList = NULL((void*)0);
1051 SmlDevInfCtcapListPtr_t ctList = NULL((void*)0);
1052 SmlDevInfExtListPtr_t exList = NULL((void*)0);
1053 SmlDevInfXmitListPtr_t xmList = NULL((void*)0);
1054 SmlDevInfFilterCapListPtr_t fcapList = NULL((void*)0);
1055 SmlDevInfCTDataPropListPtr_t propList = NULL((void*)0);
1056 SmlDevInfCTDataListPtr_t paramList = NULL((void*)0);
1057 XltTagID_t nameTagID = TN_UNDEF;
1058 SmlDevInfCTDataPtr_t pPropOrParam = NULL((void*)0);
1059
1060
1061 //Check if pContent of a required field is missing
1062 if ((reqOptFlag == REQUIRED) && (pContent == NULL((void*)0)))
1063 return SML_ERR_XLT_MISSING_CONT0x2001;
1064 //Check if pContent of a optional field is missing -> if yes we are done
1065 else if (pContent == NULL((void*)0))
1066 return SML_ERR_OK0x00;
1067
1068 //Generate the commands -> see DTD
1069 switch (tagId) {
1070 case TN_DEVINF_EXT:
1071 if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1072 if ((_err = devinfEncBlock(TN_DEVINF_XNAM, REQUIRED, ((SmlDevInfExtPtr_t) pContent)->xnam, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1073 pList = ((SmlDevInfExtPtr_t)pContent)->xval;
1074 while (pList != NULL((void*)0)) {
1075 if ((_err = devinfEncBlock(TN_DEVINF_XVAL, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1076 pList = pList->next;
1077 };
1078 if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1079 break;
1080 case TN_DEVINF_SYNCCAP:
1081 if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1082 pList = ((SmlDevInfSyncCapPtr_t)pContent)->synctype;
1083 while (pList != NULL((void*)0)) {
1084 if ((_err = devinfEncBlock(TN_DEVINF_SYNCTYPE, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1085 pList = pList->next;
1086 };
1087 if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1088 break;
1089 case TN_DEVINF_SHAREDMEM:
1090 //set the flag in the (WB)XML document if the flag is in the pContent
1091 if ((*((Flag_t *) pContent)) & (SmlDevInfSharedMem_f0x0004))
1092 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1093 break;
1094 // %%% luz:2003-04-28 added missing 1.1 devinf tags here
1095 case TN_DEVINF_UTC:
1096 //set the flag in the (WB)XML document if the flag is in the pContent
1097 if ((*((Flag_t *) pContent)) & (SmlDevInfUTC_f0x0001)) {
1098 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1099 }
1100 break;
1101 case TN_DEVINF_NOFM:
1102 //set the flag in the (WB)XML document if the flag is in the pContent
1103 if ((*((Flag_t *) pContent)) & (SmlDevInfNOfM_f0x0002)) {
1104 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1105 }
1106 break;
1107 case TN_DEVINF_LARGEOBJECT:
1108 //set the flag in the (WB)XML document if the flag is in the pContent
1109 if ((*((Flag_t *) pContent)) & (SmlDevInfLargeObject_f0x0008)) {
1110 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1111 }
1112 break;
1113
1114 /* SyncML DS 1.2, Synthesis/luz 2005-08-24 */
1115 case TN_DEVINF_FIELDLEVEL:
1116 //set the flag in the (WB)XML document if the flag is in the pContent
1117 if ((*((Flag_t *) pContent)) & (SmlDevInfFieldLevel_f0x0010)) {
1118 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1119 }
1120 break;
1121 case TN_DEVINF_HIERARCHICAL:
1122 //set the flag in the (WB)XML document if the flag is in the pContent
1123 if ((*((Flag_t *) pContent)) & (SmlDevInfHierarchical_f0x0040)) {
1124 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1125 }
1126 break;
1127 case TN_DEVINF_NOTRUNCATE:
1128 //set the flag in the (WB)XML document if the flag is in the pContent
1129 if ((*((Flag_t *) pContent)) & (SmlDevInfNoTruncate_f0x0020)) {
1130 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1131 }
1132 break;
1133
1134 case TN_DEVINF_PROPERTY:
1135 // pContent is SmlDevInfCTDataPropPtr_t
1136 paramList = ((SmlDevInfCTDataPropPtr_t)pContent)->param; // get param list
1137 // modify pContent
1138 pPropOrParam = ((SmlDevInfCTDataPropPtr_t)pContent)->prop; // common property/propparam description record
1139 // set the tag to be used for name
1140 nameTagID=TN_DEVINF_PROPNAME; // is a property, use <PropName>
1141 goto param_or_property;
1142 case TN_DEVINF_PROPPARAM:
1143 // pContent is SmlDevInfCTDataPtr_t (common data structure for <Property> and <PropParam>)
1144 paramList=NULL((void*)0);
1145 // set the tag to be used for name
1146 nameTagID=TN_DEVINF_PARAMNAME; // is a propparam, use <ParamName>
1147 // set content
1148 pPropOrParam = (SmlDevInfCTDataPtr_t)pContent;
1149 goto param_or_property;
1150 param_or_property:
1151 // - pPropOrParam is SmlDevInfCTDataPtr_t (common data structure for <Property> and <PropParam>)
1152 // - paramList is either NULL (for params, which do not have params themselves) or SmlDevInfCTDataListPtr_t (for properties)
1153 // DS 1.2 or higher : open <Property>/<PropParam> to properly group all property related elements
1154 if (pBufMgr->vers>=SML_VERS_1_2) {
1155 if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1156 }
1157 /* -- Propname or ParamName */
1158 if ((_err = devinfEncBlock(nameTagID, REQUIRED, pPropOrParam->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1159 /* -- (ValEnum+ | (Datatype, Size?))? */
1160 //%%% luz 2007-08-14 empty datatype is allowed as well (as this is what e.g. Nokia E90 sends, and when using SML to translate back to XML, we'd failed here before)
1161 if (pPropOrParam->valenum != NULL((void*)0) && pPropOrParam->datatype != NULL((void*)0) && pPropOrParam->datatype->length!=0)
1162 return SML_ERR_XLT_INVAL_INPUT_DATA0x2018;
1163 if (pPropOrParam->valenum != NULL((void*)0)) {
1164 // ValEnum+
1165 pList = pPropOrParam->valenum;
1166 while (pList != NULL((void*)0)) {
1167 if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1168 pList = pList->next;
1169 };
1170 } else if (pPropOrParam->datatype != NULL((void*)0)) {
1171 // Datatype?
1172 if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, pPropOrParam->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1173 }
1174 /* (Max)Size? (note, in <1.2, the tag was called "Size", in >=1.2, the tag is called "MaxSize" - but both have the same WBXML token) */
1175 if ((_err = devinfEncBlock(pBufMgr->vers>=SML_VERS_1_2 ? TN_DEVINF_MAXSIZE : TN_DEVINF_SIZE, OPTIONAL, pPropOrParam->maxsize, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1176 /* -- DS 1.2: MaxOccur?, is valid for Properties only, not for PropParams */
1177 if ((_err = devinfEncBlock(TN_DEVINF_MAXOCCUR, OPTIONAL, pPropOrParam->maxoccur, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1178 /* -- DS 1.2: (NoTruncate?), is valid for Properties only, not for PropParams */
1179 if ((_err = devinfEncBlock(TN_DEVINF_NOTRUNCATE, OPTIONAL, &(pPropOrParam->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1180
1181 /* -- DisplayName ? */
1182 if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, pPropOrParam->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1183
1184 /* -- now the paramList */
1185 while (paramList != NULL((void*)0)) {
1186 /* Synthesis/luz 2005-08-24 : separated generation of <PropParam> element into own case */
1187 if ((_err = devinfEncBlock(TN_DEVINF_PROPPARAM, REQUIRED, paramList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1188 paramList = paramList->next;
1189 }
1190 // DS 1.2 or higher : close </Property>/</PropParam> encapsulation
1191 if (pBufMgr->vers>=SML_VERS_1_2) {
1192 if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1193 }
1194 break;
1195
1196 case TN_DEVINF_CTCAP:
1197 ctList = ((SmlDevInfCtcapListPtr_t)pContent);
1198 if (ctList == NULL((void*)0))
1199 break; // empty CTCap - is ok, do not output anything
1200 // before DS 1.2 : all types are encapsulated in a single CTCap
1201 if (pBufMgr->vers<SML_VERS_1_2) {
1202 if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1203 }
1204 while (ctList != NULL((void*)0)) {
1205 if (ctList->data == NULL((void*)0)) return SML_ERR_XLT_INVAL_INPUT_DATA0x2018;
1206 // DS 1.2 or higher : every content type is separately enclosed in a CTCap
1207 if (pBufMgr->vers>=SML_VERS_1_2) {
1208 if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1209 }
1210 if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, REQUIRED, ctList->data->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1211 /* SyncML DS 1.2, Synthesis/luz 2005-09-28, required for DS 1.2 only, therefore OPTIONAL here */
1212 if ((_err = devinfEncBlock(TN_DEVINF_VERCT, OPTIONAL, ctList->data->verct, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1213 /* SyncML DS 1.2, Synthesis/luz 2005-08-24 */
1214 if ((_err = devinfEncBlock(TN_DEVINF_FIELDLEVEL, OPTIONAL, &(ctList->data->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1215
1216 /* now the propList */
1217 // %%% luz 2002-11-27: made property list optional (e.g. text/message of P800 has none)
1218 propList = ctList->data->prop;
1219 // %%% original: if (propList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
1220 while (propList != NULL((void*)0)) {
1221 if (propList->data == NULL((void*)0)) return SML_ERR_XLT_INVAL_INPUT_DATA0x2018;
1222 if (propList->data->prop == NULL((void*)0)) return SML_ERR_XLT_INVAL_INPUT_DATA0x2018;
1223 /* Synthesis/luz 2005-08-24 : separated generation of <property> element into own case */
1224 if ((_err = devinfEncBlock(TN_DEVINF_PROPERTY, REQUIRED, propList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1225 propList = propList->next;
1226 }
1227 // DS 1.2 or higher : every content type is separately enclosed in a CTCap
1228 if (pBufMgr->vers>=SML_VERS_1_2) {
1229 if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1230 }
1231 /* eof propList */
1232 ctList = ctList->next;
1233 };
1234 // before DS 1.2 : all types are encapsulated in a single CTCap
1235 if (pBufMgr->vers<SML_VERS_1_2) {
1236 if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1237 }
1238 break;
1239
1240 case TN_DEVINF_DSMEM:
1241 if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1242 if ((_err = devinfEncBlock(TN_DEVINF_SHAREDMEM, OPTIONAL, &(((SmlDevInfDSMemPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1243 if ((_err = devinfEncBlock(TN_DEVINF_MAXMEM, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1244 if ((_err = devinfEncBlock(TN_DEVINF_MAXID, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1245 if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1246 break;
1247
1248 // special case, the following 5 have the same structure, only the tag name differs
1249 case TN_DEVINF_RX:
1250 case TN_DEVINF_TX:
1251 case TN_DEVINF_RXPREF:
1252 case TN_DEVINF_TXPREF:
1253 case TN_DEVINF_FILTERRX: /* SyncML DS 1.2, Synthesis/luz 2005-08-24 */
1254 if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1255 if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1256 if ((_err = devinfEncBlock(TN_DEVINF_VERCT, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->verct, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1257 if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1258 break;
1259
1260 /* SyncML DS 1.2, Synthesis/luz 2005-08-24 */
1261 case TN_DEVINF_FILTERCAP:
1262 if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1263 if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, REQUIRED, ((SmlDevInfFilterCapPtr_t) pContent)->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1264 if ((_err = devinfEncBlock(TN_DEVINF_VERCT, REQUIRED, ((SmlDevInfFilterCapPtr_t) pContent)->verct, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1265 pList = ((SmlDevInfFilterCapPtr_t) pContent)->filterkeyword;
1266 while (pList != NULL((void*)0)) {
1267 if ((_err = devinfEncBlock(TN_DEVINF_FILTERKEYWORD, REQUIRED, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1268 pList=pList->next;
1269 }
1270 pList = ((SmlDevInfFilterCapPtr_t) pContent)->propname;
1271 while (pList != NULL((void*)0)) {
1272 if ((_err = devinfEncBlock(TN_DEVINF_PROPNAME, REQUIRED, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1273 pList=pList->next;
1274 }
1275 if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1276 break;
1277
1278
1279 case TN_DEVINF_DATASTORE:
1280 if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1281 if ((_err = devinfEncBlock(TN_DEVINF_SOURCEREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->sourceref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1282 if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->displayname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1283 if ((_err = devinfEncBlock(TN_DEVINF_MAXGUIDSIZE, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->maxguidsize, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1284 if ((_err = devinfEncBlock(TN_DEVINF_RXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->rxpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1285 xmList = ((SmlDevInfDatastorePtr_t)pContent)->rx;
1286 while (xmList != NULL((void*)0)) {
1287 if ((_err = devinfEncBlock(TN_DEVINF_RX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1288 xmList = xmList->next;
1289 };
1290 if ((_err = devinfEncBlock(TN_DEVINF_TXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->txpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1291 xmList = ((SmlDevInfDatastorePtr_t)pContent)->tx;
1292 while (xmList != NULL((void*)0)) {
1293 if ((_err = devinfEncBlock(TN_DEVINF_TX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1294 xmList = xmList->next;
1295 };
1296 /* For SyncML DS 1.2, CTCaps are local to datastore, no longer global in DevInf */
1297 if ((_err = devinfEncBlock(TN_DEVINF_CTCAP, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->ctcap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1298
1299 if ((_err = devinfEncBlock(TN_DEVINF_DSMEM, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->dsmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1300 /* SyncML DS 1.2, Synthesis/luz 2005-08-24 */
1301 if ((_err = devinfEncBlock(TN_DEVINF_HIERARCHICAL, OPTIONAL, &(((SmlDevInfDatastorePtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1302
1303 if ((_err = devinfEncBlock(TN_DEVINF_SYNCCAP, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->synccap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1304
1305 /* SyncML DS 1.2, Synthesis/luz 2005-08-24 */
1306 xmList = ((SmlDevInfDatastorePtr_t)pContent)->filterrx;
1307 while (xmList != NULL((void*)0)) {
1308 if ((_err = devinfEncBlock(TN_DEVINF_FILTERRX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1309 xmList = xmList->next;
1310 };
1311 /* SyncML DS 1.2, Synthesis/luz 2005-08-25 */
1312 fcapList = ((SmlDevInfDatastorePtr_t)pContent)->filtercap;
1313 while (fcapList != NULL((void*)0)) {
1314 if ((_err = devinfEncBlock(TN_DEVINF_FILTERCAP, OPTIONAL, fcapList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1315 fcapList = fcapList->next;
1316 };
1317
1318 if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1319 break;
1320
1321 case TN_DEVINF_DEVINF:
1322 if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1323 if ((_err = devinfEncBlock(TN_DEVINF_VERDTD, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->verdtd, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1324 if ((_err = devinfEncBlock(TN_DEVINF_MAN, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->man, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1325 if ((_err = devinfEncBlock(TN_DEVINF_MOD, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->mod, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1326 if ((_err = devinfEncBlock(TN_DEVINF_OEM, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->oem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1327 if ((_err = devinfEncBlock(TN_DEVINF_FWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->fwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1328 if ((_err = devinfEncBlock(TN_DEVINF_SWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->swv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1329 if ((_err = devinfEncBlock(TN_DEVINF_HWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->hwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1330 if ((_err = devinfEncBlock(TN_DEVINF_DEVID, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1331 if ((_err = devinfEncBlock(TN_DEVINF_DEVTYP, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devtyp, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1332 if ((_err = devinfEncBlock(TN_DEVINF_UTC, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1333 if ((_err = devinfEncBlock(TN_DEVINF_NOFM, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1334 if ((_err = devinfEncBlock(TN_DEVINF_LARGEOBJECT, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1335 // According to SyncML standard, the dsList must not be empty. However as some implementations send such devInf,
1336 // and the RTK is also used to convert WBXML to XML for human readable message dumps, we now allow
1337 // generating such devInf (for the XML log output).
1338 dsList = ((SmlDevInfDevInfPtr_t)pContent)->datastore;
1339 //if (dsList == NULL) return SML_ERR_XLT_MISSING_CONT;
1340 if(dsList != NULL((void*)0)) {
1341 if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, REQUIRED, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1342 dsList = dsList->next;
1343 while (dsList != NULL((void*)0)) {
1344 if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, OPTIONAL, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1345 dsList = dsList->next;
1346 };
1347 }
1348 // for pre DS 1.2, CTCaps are global (i.e at the devInf level):
1349 if ((_err = devinfEncBlock(TN_DEVINF_CTCAP, OPTIONAL, ((SmlDevInfDevInfPtr_t)pContent)->ctcap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1350 // extensions
1351 exList = ((SmlDevInfDevInfPtr_t)pContent)->ext;
1352 while (exList != NULL((void*)0)) {
1353 if ((_err = devinfEncBlock(TN_DEVINF_EXT, OPTIONAL, exList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1354 exList = exList->next;
1355 };
1356
1357 if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK0x00) return _err;
1358 break;
1359
1360 default: { // all leaf nodes (PCDATA#)
1361 return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
1362 } //* eof default statement from switch tagid
1363 } // eof switch tagid
1364 return SML_ERR_OK0x00;
1365}
1366#endif /* __USE_DEVINF__ */