1 /*************************************************************************/ 2 /* module: DeviceInf DTD related functions for the en-/decoder */ 3 /* file: xltdevinf.c */ 4 /* target system: all */ 5 /* target OS: all */ 6 /*************************************************************************/ 7 8 /* 9 * Copyright Notice 10 * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication 11 * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc., 12 * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). 13 * All Rights Reserved. 14 * Implementation of all or part of any Specification may require 15 * licenses under third party intellectual property rights, 16 * including without limitation, patent rights (such a third party 17 * may or may not be a Supporter). The Sponsors of the Specification 18 * are not responsible and shall not be held responsible in any 19 * manner for identifying or failing to identify any or all such 20 * third party intellectual property rights. 21 * 22 * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED 23 * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM, 24 * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA, 25 * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML 26 * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 27 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 28 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 29 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 30 * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO., 31 * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY 32 * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF 33 * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF 34 * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, 35 * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH 36 * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED 37 * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. 38 * 39 * The above notice and this paragraph must be included on all copies 40 * of this document that are made. 41 * 42 */ 43 44 #include "define.h" 45 #ifdef __USE_DEVINF__ 46 47 #include "smldevinfdtd.h" 48 #include "xlttags.h" 49 #include "xltdevinf.h" 50 #include "xlttagtbl.h" 51 #include "xltenc.h" 52 #include "xltencwbxml.h" 53 54 #include <libstr.h> 55 #include <smlerr.h> 56 #include <smldtd.h> 57 #include <libmem.h> 58 #include <libutil.h> 59 60 /* decoder callbacks */ 61 Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem); 62 Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem); 63 64 65 Ret_t buildDevInfDevInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 66 KCDBG("buildDevInfDevInfCmd: Enter\n"); 67 68 XltDecScannerPtr_t pScanner; 69 SmlDevInfDevInfPtr_t pElem = NULL; 70 Ret_t rc; 71 72 pScanner = pDecoder->scanner; 73 74 if (*ppElem != NULL) 75 return SML_ERR_XLT_INVAL_SYNCML_DOC; 76 77 if (IS_EMPTY(pScanner->curtok)) { 78 *ppElem = pElem; 79 return SML_ERR_OK; 80 } 81 82 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 83 smlLibFree(pElem); 84 return rc; 85 } 86 87 switch (pScanner->curtok->tagid) { 88 case TN_DEVINF_DEVINF: 89 rc = buildDevInfDevInfContent(pDecoder, (VoidPtr_t)&pElem); 90 break; 91 default: 92 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 93 } 94 if (rc != SML_ERR_OK) { 95 smlLibFree(pElem); 96 return rc; 97 } 98 *ppElem = pElem; 99 100 KCDBG("buildDevInfDevInfCmd: Leave\n"); 101 102 return SML_ERR_OK; 103 } 104 105 Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 106 XltDecScannerPtr_t pScanner; 107 SmlDevInfDevInfPtr_t pElem; 108 Ret_t rc; 109 /* Modified by Tomy to allow <UTC></UTC>, <SupportNumberOfChanges></SupportNumberOfChanges> and <SupportLargeObjs></SupportLargeObjs> */ 110 SmlPcdataPtr_t tmp_ptr; 111 /* End modified by Tomy */ 112 113 pScanner = pDecoder->scanner; 114 115 if (*ppElem != NULL) 116 return SML_ERR_XLT_INVAL_SYNCML_DOC; 117 118 if ((pElem = (SmlDevInfDevInfPtr_t)smlLibMalloc(sizeof(SmlDevInfDevInf_t))) == NULL) 119 return SML_ERR_NOT_ENOUGH_SPACE; 120 smlLibMemset(pElem, 0, sizeof(SmlDevInfDevInf_t)); 121 122 if (IS_EMPTY(pScanner->curtok)) { 123 *ppElem = pElem; 124 return SML_ERR_OK; 125 } 126 127 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 128 smlLibFree(pElem); 129 return rc; 130 } 131 132 while (pScanner->curtok->type != TOK_TAG_END) { 133 switch (pScanner->curtok->tagid) { 134 case TN_DEVINF_VERDTD: 135 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->verdtd); 136 break; 137 case TN_DEVINF_MAN: 138 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->man); 139 break; 140 case TN_DEVINF_MOD: 141 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->mod); 142 break; 143 case TN_DEVINF_OEM: 144 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->oem); 145 break; 146 case TN_DEVINF_FWV: 147 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->fwv); 148 break; 149 case TN_DEVINF_SWV: 150 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->swv); 151 break; 152 case TN_DEVINF_HWV: 153 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->hwv); 154 break; 155 case TN_DEVINF_DEVID: 156 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devid); 157 break; 158 case TN_DEVINF_DEVTYP: 159 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devtyp); 160 break; 161 case TN_DEVINF_DATASTORE: 162 rc = buildDevInfDataStoreList(pDecoder, (VoidPtr_t)&pElem->datastore); 163 break; 164 case TN_DEVINF_CTCAP: 165 rc = buildDevInfCtcap(pDecoder, (VoidPtr_t)&pElem->ctcap); 166 break; 167 case TN_DEVINF_EXT: 168 rc = buildDevInfExtList(pDecoder, (VoidPtr_t)&pElem->ext); 169 break; 170 /* SCTSTK - 18/03/2002 S.H. 2002-04-05 : SyncML 1.1 */ 171 case TN_DEVINF_UTC: 172 pElem->flags |= SmlDevInfUTC_f; 173 /* Modified by Tomy to allow <UTC></UTC> */ 174 tmp_ptr = NULL; 175 rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr); 176 if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 177 /* End modified by Tomy */ 178 break; 179 case TN_DEVINF_NOFM: 180 pElem->flags |= SmlDevInfNOfM_f; 181 /* Modified by Tomy to allow <SupportNumberOfChanges></SupportNumberOfChanges> */ 182 tmp_ptr = NULL; 183 rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr); 184 if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 185 /* End modified by Tomy */ 186 break; 187 case TN_DEVINF_LARGEOBJECT: 188 pElem->flags |= SmlDevInfLargeObject_f; 189 /* Modified by Tomy to allow <SupportLargeObjs></SupportLargeObjs> */ 190 tmp_ptr = NULL; 191 rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr); 192 if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 193 /* End modified by Tomy */ 194 break; 195 default: 196 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 197 } 198 if (rc != SML_ERR_OK) { 199 smlLibFree(pElem); 200 return rc; 201 } 202 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 203 smlLibFree(pElem); 204 return rc; 205 } 206 } 207 *ppElem = pElem; 208 209 return SML_ERR_OK; 210 } 211 212 Ret_t buildDevInfDataStoreCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 213 XltDecScannerPtr_t pScanner; 214 SmlDevInfDatastorePtr_t pElem; 215 Ret_t rc; 216 217 pScanner = pDecoder->scanner; 218 219 if (*ppElem != NULL) 220 return SML_ERR_XLT_INVAL_SYNCML_DOC; 221 222 if ((pElem = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t))) == NULL) 223 return SML_ERR_NOT_ENOUGH_SPACE; 224 smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastore_t)); 225 226 if (IS_EMPTY(pScanner->curtok)) { 227 *ppElem = pElem; 228 return SML_ERR_OK; 229 } 230 231 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 232 smlLibFree(pElem); 233 return rc; 234 } 235 236 while (pScanner->curtok->type != TOK_TAG_END) { 237 switch (pScanner->curtok->tagid) { 238 /* PCDATA elements */ 239 case TN_DEVINF_SOURCEREF: 240 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->sourceref); 241 break; 242 case TN_DEVINF_DISPLAYNAME: 243 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->displayname); 244 break; 245 case TN_DEVINF_MAXGUIDSIZE: 246 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxguidsize); 247 break; 248 case TN_DEVINF_RXPREF: 249 rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->rxpref); 250 break; 251 case TN_DEVINF_TXPREF: 252 rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->txpref); 253 break; 254 case TN_DEVINF_RX: 255 rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->rx); 256 break; 257 case TN_DEVINF_TX: 258 rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->tx); 259 break; 260 case TN_DEVINF_DSMEM: 261 rc = buildDevInfDSMemCmd(pDecoder, (VoidPtr_t)&pElem->dsmem); 262 break; 263 case TN_DEVINF_SYNCCAP: 264 rc = buildDevInfSyncCapCmd(pDecoder, (VoidPtr_t)&pElem->synccap); 265 break; 266 default: 267 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 268 } 269 if (rc != SML_ERR_OK) { 270 smlLibFree(pElem); 271 return rc; 272 } 273 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 274 smlLibFree(pElem); 275 return rc; 276 } 277 } 278 *ppElem = pElem; 279 280 return SML_ERR_OK; 281 } 282 283 Ret_t buildDevInfXmitCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 284 XltDecScannerPtr_t pScanner; 285 SmlDevInfXmitPtr_t pXmit; 286 Ret_t rc; 287 288 pScanner = pDecoder->scanner; 289 290 if (*ppElem != NULL) 291 return SML_ERR_XLT_INVAL_SYNCML_DOC; 292 293 if ((pXmit = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t))) == NULL) 294 return SML_ERR_NOT_ENOUGH_SPACE; 295 smlLibMemset(pXmit, 0, sizeof(SmlDevInfXmit_t)); 296 297 if (IS_EMPTY(pScanner->curtok)) { 298 *ppElem = pXmit; 299 return SML_ERR_OK; 300 } 301 302 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 303 smlLibFree(pXmit); 304 return rc; 305 } 306 307 while (pScanner->curtok->type != TOK_TAG_END) { 308 switch (pScanner->curtok->tagid) { 309 /* PCDATA elements */ 310 case TN_DEVINF_CTTYPE: 311 rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->cttype); 312 break; 313 case TN_DEVINF_VERCT: 314 rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->verct); 315 break; 316 default: 317 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 318 } 319 if (rc != SML_ERR_OK) { 320 smlLibFree(pXmit); 321 return rc; 322 } 323 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 324 smlLibFree(pXmit); 325 return rc; 326 } 327 } 328 *ppElem = pXmit; 329 330 return SML_ERR_OK; 331 } 332 333 Ret_t buildDevInfXmitList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 334 SmlDevInfXmitListPtr_t pElem = NULL, pPrev = NULL; 335 336 pElem = (SmlDevInfXmitListPtr_t) *ppElem; 337 338 /* advance to the end of the list, and create ther an empty list element */ 339 while (pElem != NULL) { 340 pPrev = pElem; 341 pElem = pPrev->next; 342 } 343 if ((pElem = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t))) == NULL) 344 return SML_ERR_NOT_ENOUGH_SPACE; 345 smlLibMemset(pElem, 0, sizeof(SmlDevInfXmitList_t)); 346 if (pPrev != NULL) /* we already had some entries in the list */ 347 pPrev->next = pElem; 348 else /* nope we created a new list */ 349 *ppElem = pElem; 350 pElem->data = NULL; 351 /* at this point pElem should point to an valid list element */ 352 return buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->data); 353 } 354 355 Ret_t buildDevInfDataStoreList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 356 SmlDevInfDatastoreListPtr_t pElem = NULL, pPrev = NULL; 357 358 pElem = (SmlDevInfDatastoreListPtr_t) *ppElem; 359 360 /* advance to the end of the list, and create ther an empty list element */ 361 while (pElem != NULL) { 362 pPrev = pElem; 363 pElem = pPrev->next; 364 } 365 if ((pElem = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t))) == NULL) 366 return SML_ERR_NOT_ENOUGH_SPACE; 367 smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastoreList_t)); 368 if (pPrev != NULL) /* we already had some entries in the list */ 369 pPrev->next = pElem; 370 else /* nope we created a new list */ 371 *ppElem = pElem; 372 pElem->data = NULL; 373 /* at this point pElem should point to an valid list element */ 374 return buildDevInfDataStoreCmd(pDecoder, (VoidPtr_t)&pElem->data); 375 } 376 377 Ret_t buildDevInfExtList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 378 SmlDevInfExtListPtr_t pElem = NULL, pPrev = NULL; 379 380 pElem = (SmlDevInfExtListPtr_t) *ppElem; 381 382 /* advance to the end of the list, and create ther an empty list element */ 383 while (pElem != NULL) { 384 pPrev = pElem; 385 pElem = pPrev->next; 386 } 387 if ((pElem = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t))) == NULL) 388 return SML_ERR_NOT_ENOUGH_SPACE; 389 smlLibMemset(pElem, 0, sizeof(SmlDevInfExtList_t)); 390 if (pPrev != NULL) /* we already had some entries in the list */ 391 pPrev->next = pElem; 392 else /* nope we created a new list */ 393 *ppElem = pElem; 394 pElem->data = NULL; 395 /* at this point pElem should point to an valid list element */ 396 return buildDevInfExtCmd(pDecoder, (VoidPtr_t)&pElem->data); 397 } 398 399 400 Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 401 SmlDevInfCtcapListPtr_t pCtcap = NULL, pPrev = NULL; 402 SmlDevInfCTDataPropListPtr_t pOldProp = NULL, pProp = NULL; 403 SmlDevInfCTDataListPtr_t pOldParam = NULL, pParam = NULL; 404 SmlDevInfCtcapListPtr_t pElem = NULL; 405 XltDecScannerPtr_t pScanner; 406 Ret_t rc; 407 408 pElem = (SmlDevInfCtcapListPtr_t) *ppElem; 409 pScanner = pDecoder->scanner; 410 411 if (IS_EMPTY(pScanner->curtok)) { 412 *ppElem = pElem; 413 return SML_ERR_OK; 414 } 415 416 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 417 smlLibFree(pElem); 418 return rc; 419 } 420 421 while (pScanner->curtok->type != TOK_TAG_END) { 422 switch (pScanner->curtok->tagid) { 423 case TN_DEVINF_CTTYPE: 424 pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem; 425 /* advance to the end of the list, and create ther an empty list element */ 426 while (pCtcap != NULL) { 427 pPrev = pCtcap; 428 pCtcap = pPrev->next; 429 } 430 if ((pCtcap = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t))) == NULL) 431 return SML_ERR_NOT_ENOUGH_SPACE; 432 smlLibMemset(pCtcap, 0, sizeof(SmlDevInfCtcapList_t)); 433 if (pPrev != NULL) /* we already had some entries in the list */ 434 pPrev->next = pCtcap; 435 else /* nope we created a new list */ 436 *ppElem = pCtcap; 437 pCtcap->data = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t)); 438 if (pCtcap->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE; 439 smlLibMemset(pCtcap->data, 0, sizeof(SmlDevInfCTCap_t)); 440 rc = buildPCData(pDecoder, (VoidPtr_t)&pCtcap->data->cttype); 441 break; 442 case TN_DEVINF_PROPNAME: 443 pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem; 444 if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 445 while (pCtcap->next != NULL) { 446 pPrev = pCtcap; 447 pCtcap = pCtcap->next; 448 } 449 /* here we are at the latest defined DevInfCTCapPtr_t */ 450 /* now we need to create a new DevInfCTDataPtr_t element, tostore the properties name */ 451 pOldProp = NULL; 452 pProp = pCtcap->data->prop; 453 while (pProp != NULL) { 454 pOldProp = pProp; 455 pProp = pProp->next; 456 } 457 pProp = (SmlDevInfCTDataPropListPtr_t) smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t)); 458 if (pProp == NULL) return SML_ERR_NOT_ENOUGH_SPACE; 459 smlLibMemset(pProp, 0, sizeof(SmlDevInfCTDataPropList_t)); 460 if (pOldProp != NULL) 461 pOldProp->next = pProp; 462 else 463 pCtcap->data->prop = pProp; 464 pProp->data = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t)); 465 if (pProp->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE; 466 smlLibMemset(pProp->data, 0, sizeof(SmlDevInfCTDataProp_t)); 467 pProp->data->prop = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t)); 468 if (pProp->data->prop == NULL) return SML_ERR_NOT_ENOUGH_SPACE; 469 smlLibMemset(pProp->data->prop, 0, sizeof(SmlDevInfCTData_t)); 470 rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->name); 471 break; 472 case TN_DEVINF_PARAMNAME: 473 pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem; 474 if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 475 while (pCtcap->next != NULL) { 476 pPrev = pCtcap; 477 pCtcap = pCtcap->next; 478 } 479 /* here we are at the latest defined DevInfCTCapPtr_t */ 480 pProp = pCtcap->data->prop; 481 if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 482 while (pProp->next != NULL) { 483 pProp = pProp->next; 484 } 485 /* here we are at the latest defined PropList Element in the latest defined CTCap element */ 486 /* now lets insert a new Param element into this property */ 487 pOldParam = NULL; 488 pParam = pProp->data->param; 489 while (pParam != NULL) { 490 pOldParam = pParam; 491 pParam = pParam->next; 492 } 493 pParam = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t)); 494 if (pParam == NULL) return SML_ERR_NOT_ENOUGH_SPACE; 495 smlLibMemset(pParam, 0, sizeof(SmlDevInfCTDataList_t)); 496 if (pOldParam != NULL) 497 pOldParam->next = pParam; 498 else 499 pProp->data->param = pParam; 500 pParam->data = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t)); 501 if (pParam->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE; 502 smlLibMemset(pParam->data, 0, sizeof(SmlDevInfCTData_t)); 503 rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->name); 504 break; 505 case TN_DEVINF_DISPLAYNAME: 506 case TN_DEVINF_VALENUM: 507 case TN_DEVINF_DATATYPE: 508 case TN_DEVINF_SIZE: 509 /* The code for the above 4 is basically the same. 510 * The hardpart is finding the right SmlDevInfCTDataPtr_t 511 * struct, as it can be either within a Property or an Parameter. 512 */ 513 pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem; 514 if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 515 while (pCtcap->next != NULL) { 516 pCtcap = pCtcap->next; 517 } 518 /* here we are at the latest defined DevInfCTCapPtr_t */ 519 pProp = pCtcap->data->prop; 520 if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 521 while (pProp->next != NULL) { 522 pProp = pProp->next; 523 } 524 525 if (pProp->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 526 if (pProp->data->prop == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 527 if (pProp->data->param == NULL) { 528 /* No Param's yet so we have Property fields to fill */ 529 switch(pScanner->curtok->tagid) { 530 case TN_DEVINF_DISPLAYNAME: 531 rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->dname); 532 break; 533 case TN_DEVINF_VALENUM: 534 rc = buildPCDataList(pDecoder, (VoidPtr_t)&pProp->data->prop->valenum); 535 break; 536 case TN_DEVINF_DATATYPE: 537 rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->datatype); 538 break; 539 case TN_DEVINF_SIZE: 540 rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->size); 541 break; 542 default: 543 break; 544 } 545 } else { 546 pParam = pProp->data->param; 547 while (pParam->next != NULL) { 548 pParam = pParam->next; 549 } 550 if (pParam->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC; 551 switch(pScanner->curtok->tagid) { 552 case TN_DEVINF_DISPLAYNAME: 553 rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->dname); 554 break; 555 case TN_DEVINF_VALENUM: 556 rc = buildPCDataList(pDecoder, (VoidPtr_t)&pParam->data->valenum); 557 break; 558 case TN_DEVINF_DATATYPE: 559 rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->datatype); 560 break; 561 case TN_DEVINF_SIZE: 562 rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->size); 563 break; 564 default: 565 break; 566 } 567 } 568 break; 569 default: 570 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 571 } 572 if (rc != SML_ERR_OK) { 573 smlLibFree(pElem); 574 return rc; 575 } 576 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 577 smlLibFree(pElem); 578 return rc; 579 } 580 } /* eof while */ 581 pElem = *ppElem; 582 return SML_ERR_OK; 583 } 584 585 Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 586 XltDecScannerPtr_t pScanner; 587 SmlDevInfDSMemPtr_t pElem; 588 Ret_t rc; 589 590 pScanner = pDecoder->scanner; 591 592 if (*ppElem != NULL) 593 return SML_ERR_XLT_INVAL_SYNCML_DOC; 594 595 if ((pElem = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t))) == NULL) 596 return SML_ERR_NOT_ENOUGH_SPACE; 597 smlLibMemset(pElem, 0, sizeof(SmlDevInfDSMem_t)); 598 599 if (IS_EMPTY(pScanner->curtok)) { 600 *ppElem = pElem; 601 return SML_ERR_OK; 602 } 603 604 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 605 smlLibFree(pElem); 606 return rc; 607 } 608 609 while (pScanner->curtok->type != TOK_TAG_END) { 610 switch (pScanner->curtok->tagid) { 611 /* PCDATA elements */ 612 case TN_DEVINF_SHAREDMEM: 613 // %%% luz:2003-04-28: made work as a flag 614 pElem->flags |= SmlDevInfSharedMem_f; 615 // rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->shared); 616 break; 617 case TN_DEVINF_MAXMEM: 618 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxmem); 619 break; 620 case TN_DEVINF_MAXID: 621 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxid); 622 break; 623 default: 624 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 625 } 626 if (rc != SML_ERR_OK) { 627 smlLibFree(pElem); 628 return rc; 629 } 630 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 631 smlLibFree(pElem); 632 return rc; 633 } 634 } 635 *ppElem = pElem; 636 637 return SML_ERR_OK; 638 } 639 640 Ret_t buildDevInfCTCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 641 XltDecScannerPtr_t pScanner; 642 SmlDevInfCTCapPtr_t pElem; 643 Ret_t rc; 644 645 pScanner = pDecoder->scanner; 646 647 if (*ppElem != NULL) 648 return SML_ERR_XLT_INVAL_SYNCML_DOC; 649 650 if ((pElem = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t))) == NULL) 651 return SML_ERR_NOT_ENOUGH_SPACE; 652 smlLibMemset(pElem, 0, sizeof(SmlDevInfCTCap_t)); 653 654 if (IS_EMPTY(pScanner->curtok)) { 655 *ppElem = pElem; 656 return SML_ERR_OK; 657 } 658 659 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 660 smlLibFree(pElem); 661 return rc; 662 } 663 664 while (pScanner->curtok->type != TOK_TAG_END) { 665 switch (pScanner->curtok->tagid) { 666 case TN_DEVINF_CTTYPE: 667 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->cttype); 668 break; 669 default: 670 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 671 } 672 if (rc != SML_ERR_OK) { 673 smlLibFree(pElem); 674 return rc; 675 } 676 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 677 smlLibFree(pElem); 678 return rc; 679 } 680 } 681 *ppElem = pElem; 682 683 return SML_ERR_OK; 684 } 685 686 Ret_t buildDevInfSyncCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 687 XltDecScannerPtr_t pScanner; 688 SmlDevInfSyncCapPtr_t pElem; 689 Ret_t rc; 690 691 pScanner = pDecoder->scanner; 692 693 if (*ppElem != NULL) 694 return SML_ERR_XLT_INVAL_SYNCML_DOC; 695 696 if ((pElem = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t))) == NULL) 697 return SML_ERR_NOT_ENOUGH_SPACE; 698 smlLibMemset(pElem, 0, sizeof(SmlDevInfSyncCap_t)); 699 700 if (IS_EMPTY(pScanner->curtok)) { 701 *ppElem = pElem; 702 return SML_ERR_OK; 703 } 704 705 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 706 smlLibFree(pElem); 707 return rc; 708 } 709 710 while (pScanner->curtok->type != TOK_TAG_END) { 711 switch (pScanner->curtok->tagid) { 712 case TN_DEVINF_SYNCTYPE: 713 rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->synctype); 714 break; 715 default: 716 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 717 } 718 if (rc != SML_ERR_OK) { 719 smlLibFree(pElem); 720 return rc; 721 } 722 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 723 smlLibFree(pElem); 724 return rc; 725 } 726 } 727 *ppElem = pElem; 728 729 return SML_ERR_OK; 730 } 731 732 Ret_t buildDevInfExtCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) { 733 XltDecScannerPtr_t pScanner; 734 SmlDevInfExtPtr_t pElem; 735 Ret_t rc; 736 737 pScanner = pDecoder->scanner; 738 739 if (*ppElem != NULL) 740 return SML_ERR_XLT_INVAL_SYNCML_DOC; 741 742 if ((pElem = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t))) == NULL) 743 return SML_ERR_NOT_ENOUGH_SPACE; 744 smlLibMemset(pElem, 0, sizeof(SmlDevInfExt_t)); 745 746 if (IS_EMPTY(pScanner->curtok)) { 747 *ppElem = pElem; 748 return SML_ERR_OK; 749 } 750 751 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 752 smlLibFree(pElem); 753 return rc; 754 } 755 756 while (pScanner->curtok->type != TOK_TAG_END) { 757 switch (pScanner->curtok->tagid) { 758 case TN_DEVINF_XNAM: 759 rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->xnam); 760 break; 761 case TN_DEVINF_XVAL: 762 rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->xval); 763 break; 764 default: 765 rc = SML_ERR_XLT_INVAL_SYNCML_DOC; 766 } 767 if (rc != SML_ERR_OK) { 768 smlLibFree(pElem); 769 return rc; 770 } 771 if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) { 772 smlLibFree(pElem); 773 return rc; 774 } 775 } 776 *ppElem = pElem; 777 778 return SML_ERR_OK; 779 } 780 781 782 /* see xltenc.c:XltEncBlock for description of parameters */ 783 Ret_t devinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) { 784 //Return variable 785 Ret_t _err; 786 SmlPcdataListPtr_t pList = NULL, p2List = NULL; 787 SmlDevInfDatastoreListPtr_t dsList = NULL; 788 SmlDevInfCtcapListPtr_t ctList = NULL; 789 SmlDevInfExtListPtr_t exList = NULL; 790 SmlDevInfXmitListPtr_t xmList = NULL; 791 SmlDevInfCTDataPropListPtr_t propList = NULL; 792 SmlDevInfCTDataListPtr_t paramList = NULL; 793 794 //Check if pContent of a required field is missing 795 if ((reqOptFlag == REQUIRED) && (pContent == NULL)) 796 return SML_ERR_XLT_MISSING_CONT; 797 //Check if pContent of a optional field is missing -> if yes we are done 798 else if (pContent == NULL) 799 return SML_ERR_OK; 800 801 //Generate the commands -> see DTD 802 switch (tagId) { 803 case TN_DEVINF_EXT: 804 if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 805 if ((_err = devinfEncBlock(TN_DEVINF_XNAM, REQUIRED, ((SmlDevInfExtPtr_t) pContent)->xnam, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 806 pList = ((SmlDevInfExtPtr_t)pContent)->xval; 807 while (pList != NULL) { 808 if ((_err = devinfEncBlock(TN_DEVINF_XVAL, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 809 pList = pList->next; 810 }; 811 if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 812 break; 813 case TN_DEVINF_SYNCCAP: 814 if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 815 pList = ((SmlDevInfSyncCapPtr_t)pContent)->synctype; 816 while (pList != NULL) { 817 if ((_err = devinfEncBlock(TN_DEVINF_SYNCTYPE, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 818 pList = pList->next; 819 }; 820 if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 821 break; 822 case TN_DEVINF_SHAREDMEM: 823 //set the flag in the (WB)XML document if the flag is in the pContent 824 if ((*((Flag_t *) pContent)) & (SmlDevInfSharedMem_f)) 825 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 826 break; 827 // %%% luz:2003-04-28 added missing 1.1 devinf tags here 828 case TN_DEVINF_UTC: 829 //set the flag in the (WB)XML document if the flag is in the pContent 830 if ((*((Flag_t *) pContent)) & (SmlDevInfUTC_f)) { 831 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 832 } 833 break; 834 case TN_DEVINF_NOFM: 835 //set the flag in the (WB)XML document if the flag is in the pContent 836 if ((*((Flag_t *) pContent)) & (SmlDevInfNOfM_f)) { 837 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 838 } 839 break; 840 case TN_DEVINF_LARGEOBJECT: 841 //set the flag in the (WB)XML document if the flag is in the pContent 842 if ((*((Flag_t *) pContent)) & (SmlDevInfLargeObject_f)) { 843 if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 844 } 845 break; 846 // %%% end luz 847 case TN_DEVINF_CTCAP: 848 if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 849 ctList = ((SmlDevInfCtcapListPtr_t)pContent); 850 if (ctList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 851 while (ctList != NULL) { 852 if (ctList->data == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 853 if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, OPTIONAL, ctList->data->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 854 /* now the propList */ 855 // %%% luz 2002-11-27: made property list optional (e.g. text/message of P800 has none) 856 propList = ctList->data->prop; 857 // %%% original: if (propList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 858 while (propList != NULL) { 859 if (propList->data == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 860 if (propList->data->prop == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 861 /* -- Propname */ 862 if ((_err = devinfEncBlock(TN_DEVINF_PROPNAME, REQUIRED, propList->data->prop->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 863 /* -- (ValEnum+ | (Datatype, Size?))? */ 864 //if (propList->data->prop->valenum == NULL && propList->data->prop->datatype == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 865 if (propList->data->prop->valenum != NULL && propList->data->prop->datatype != NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 866 if (propList->data->prop->valenum != NULL) { 867 // ValEnum+ 868 pList = propList->data->prop->valenum; 869 while (pList != NULL) { 870 if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 871 pList = pList->next; 872 }; 873 } else if (propList->data->prop->datatype != NULL) { 874 // Datatype, Size? 875 if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, propList->data->prop->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 876 if ((_err = devinfEncBlock(TN_DEVINF_SIZE, OPTIONAL, propList->data->prop->size, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 877 } 878 /* -- DisplayName ? */ 879 if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, propList->data->prop->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 880 /* -- now the paramList */ 881 paramList = propList->data->param; 882 while (paramList != NULL) { 883 if ((_err = devinfEncBlock(TN_DEVINF_PARAMNAME, REQUIRED, paramList->data->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 884 /* -- (ValEnum+ | (Datatype, Size?))? */ 885 //if (paramList->data->valenum == NULL && paramList->data->datatype == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 886 if (paramList->data->valenum != NULL && paramList->data->datatype != NULL) return SML_ERR_XLT_INVAL_INPUT_DATA; 887 if (paramList->data->valenum != NULL) { 888 // ValEnum+ 889 p2List = paramList->data->valenum; 890 while (p2List != NULL) { 891 if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, p2List->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 892 p2List = p2List->next; 893 }; 894 } else if (paramList->data->datatype != NULL) { 895 // Datatype, Size? 896 if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, paramList->data->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 897 if ((_err = devinfEncBlock(TN_DEVINF_SIZE, OPTIONAL, paramList->data->size, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 898 } 899 /* -- DisplayName ? */ 900 if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, paramList->data->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 901 paramList = paramList->next; 902 } 903 propList = propList->next; 904 } 905 /* eof propList */ 906 ctList = ctList->next; 907 }; 908 909 if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 910 break; 911 case TN_DEVINF_DSMEM: 912 if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 913 if ((_err = devinfEncBlock(TN_DEVINF_SHAREDMEM, OPTIONAL, &(((SmlDevInfDSMemPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 914 if ((_err = devinfEncBlock(TN_DEVINF_MAXMEM, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 915 if ((_err = devinfEncBlock(TN_DEVINF_MAXID, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 916 if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 917 break; 918 // special case, the following 4 have the same structure, only the tag name differs 919 case TN_DEVINF_RX: 920 case TN_DEVINF_TX: 921 case TN_DEVINF_RXPREF: 922 case TN_DEVINF_TXPREF: 923 if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 924 if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 925 if ((_err = devinfEncBlock(TN_DEVINF_VERCT, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->verct, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 926 if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 927 break; 928 case TN_DEVINF_DATASTORE: 929 if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 930 if ((_err = devinfEncBlock(TN_DEVINF_SOURCEREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->sourceref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 931 if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->displayname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 932 if ((_err = devinfEncBlock(TN_DEVINF_MAXGUIDSIZE, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->maxguidsize, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 933 if ((_err = devinfEncBlock(TN_DEVINF_RXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->rxpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 934 xmList = ((SmlDevInfDatastorePtr_t)pContent)->rx; 935 while (xmList != NULL) { 936 if ((_err = devinfEncBlock(TN_DEVINF_RX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 937 xmList = xmList->next; 938 }; 939 if ((_err = devinfEncBlock(TN_DEVINF_TXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->txpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 940 xmList = ((SmlDevInfDatastorePtr_t)pContent)->tx; 941 while (xmList != NULL) { 942 if ((_err = devinfEncBlock(TN_DEVINF_TX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 943 xmList = xmList->next; 944 }; 945 if ((_err = devinfEncBlock(TN_DEVINF_DSMEM, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->dsmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 946 if ((_err = devinfEncBlock(TN_DEVINF_SYNCCAP, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->synccap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 947 if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 948 break; 949 case TN_DEVINF_DEVINF: 950 if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 951 if ((_err = devinfEncBlock(TN_DEVINF_VERDTD, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->verdtd, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 952 if ((_err = devinfEncBlock(TN_DEVINF_MAN, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->man, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 953 if ((_err = devinfEncBlock(TN_DEVINF_MOD, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->mod, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 954 if ((_err = devinfEncBlock(TN_DEVINF_OEM, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->oem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 955 if ((_err = devinfEncBlock(TN_DEVINF_FWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->fwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 956 if ((_err = devinfEncBlock(TN_DEVINF_SWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->swv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 957 if ((_err = devinfEncBlock(TN_DEVINF_HWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->hwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 958 if ((_err = devinfEncBlock(TN_DEVINF_DEVID, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 959 if ((_err = devinfEncBlock(TN_DEVINF_DEVTYP, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devtyp, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 960 // %%% luz:2003-04-28 added missing SyncML 1.1 devinf tags 961 if ((_err = devinfEncBlock(TN_DEVINF_UTC, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 962 if ((_err = devinfEncBlock(TN_DEVINF_NOFM, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 963 if ((_err = devinfEncBlock(TN_DEVINF_LARGEOBJECT, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 964 // %%% end luz 965 966 dsList = ((SmlDevInfDevInfPtr_t)pContent)->datastore; 967 if (dsList == NULL) return SML_ERR_XLT_MISSING_CONT; 968 if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, REQUIRED, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 969 dsList = dsList->next; 970 while (dsList != NULL) { 971 if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, OPTIONAL, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 972 dsList = dsList->next; 973 }; 974 if ((_err = devinfEncBlock(TN_DEVINF_CTCAP, OPTIONAL, ((SmlDevInfDevInfPtr_t)pContent)->ctcap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 975 exList = ((SmlDevInfDevInfPtr_t)pContent)->ext; 976 while (exList != NULL) { 977 if ((_err = devinfEncBlock(TN_DEVINF_EXT, OPTIONAL, exList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 978 exList = exList->next; 979 }; 980 981 982 if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err; 983 break; 984 985 default: { // all leaf nodes (PCDATA#) 986 return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag); 987 } //* eof default statement from switch tagid 988 } // eof switch tagid 989 return SML_ERR_OK; 990 } 991 #endif /* __USE_DEVINF__ */ 992