static void prv_get_tree_to_list(internals_t * internP, const char * uri, SmlItemListPtr_t * listP) { int code = OMADM_SYNCML_ERROR_COMMAND_FAILED; dmtree_node_t node; memset(&node, 0, sizeof(dmtree_node_t)); node.uri = strdup(uri); if (NULL == node.uri) { return; } if (OMADM_SYNCML_ERROR_NONE == dmtree_get(internP->dmtreeH, &node)) { SmlItemPtr_t itemP; itemP = smlAllocItem(); if (itemP) { code = prv_fill_item(itemP, node); if (OMADM_SYNCML_ERROR_SUCCESS == code) { code = prv_add_item_to_list(itemP, listP); } if (OMADM_SYNCML_ERROR_SUCCESS != code) { smlFreeItemPtr(itemP); } } if (!strcmp(node.format, "node") && 0 != node.data_size) { char ** childList; int i = 0; childList = strArray_buildChildList(uri, node.data_buffer, node.data_size); if (NULL != childList) { while (NULL != childList[i]) { prv_get_tree_to_list(internP, childList[i], listP); i++; } } strArray_free(childList); } } dmtree_node_clean(&node, true); }
SML_API SmlItemListPtr_t smlAllocItemList() { SmlItemListPtr_t p = (SmlItemListPtr_t)smlLibMalloc(sizeof(SmlItemList_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlItemList_t)); p->item = smlAllocItem(); if (p->item == NULL) { smlFreeItemList(p); return NULL; } return p; }
SML_API SmlExecPtr_t smlAllocExec() { SmlExecPtr_t p = (SmlExecPtr_t)smlLibMalloc(sizeof(SmlExec_t)); if (p == NULL) return NULL; smlLibMemset(p, 0, sizeof(SmlExec_t)); p->elementType = SML_PE_EXEC; p->cmdID = smlAllocPcdata(); if (p->cmdID == NULL) { smlFreeExec(p); return NULL; } p->item = smlAllocItem(); if (p->item == NULL) { smlFreeExec(p); return NULL; } return p; }
static int prv_get_to_list(internals_t * internP, const char * uri, SmlItemListPtr_t * listP) { int code = OMADM_SYNCML_ERROR_COMMAND_FAILED; SmlItemPtr_t itemP = NULL; itemP = smlAllocItem(); if (itemP) { code = prv_get(internP, uri, itemP); if (OMADM_SYNCML_ERROR_SUCCESS == code) { code = prv_add_item_to_list(itemP, listP); } if (OMADM_SYNCML_ERROR_SUCCESS != code) { smlFreeItemPtr(itemP); } } return code; }