3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef PROTOCOL_BINDER_UTIL_H_
19 #define PROTOCOL_BINDER_UTIL_H_
23 #include "definition.h"
24 #include "interface.h"
28 #endif /* __cplusplus */
32 * @brief Provides protocol binder utility operation
35 /** @addtogroup protocol_binder
39 /* protocol binder property managing functions */
41 * @brief Change protocol
45 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
46 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
48 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
49 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
50 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
51 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
53 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
54 * (sync_agent_pb_function_info_s*)binder_function_info,
55 * &pBinder_function_set);
56 * if (err != SYNC_AGENT_PB_RETURN_OK) {
60 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
61 * false, true, false, true, true, NULL, NULL,
62 * pBinder_function_set);
63 * if (pOutBinder == NULL) {
67 * err = sync_agent_switch_protocol(pBinder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
68 * if (err != SYNC_AGENT_PB_RETURN_OK) {
73 * @param[in] binder Structure(sync_agent_pb_protocol_binder_info_s)
74 * @param[in] protocol Enum value that means specific protocol
75 * @return 0 on success, otherwise a negative error value.
76 * @retval SYNC_AGENT_PB_RETURN_OK Successful
77 * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
78 * @retval SYNC_AGENT_PB_RETURN_INVALID_PROTOCOL Invalid parameter(protocol)
79 * @retval SYNC_AGENT_PB_RETURN_ALREADY_SWITCH_PROTOCOL Operation failed
80 * @see sync_agent_init_protocol_binder, sync_agent_undo_switch_protocol
82 sync_agent_pb_error_e sync_agent_switch_protocol(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_protocol_e protocol);
85 * @brief Go back to previous protocol
89 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
90 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
92 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
93 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
94 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
95 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
97 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
98 * (sync_agent_pb_function_info_s*)binder_function_info,
99 * &pBinder_function_set);
100 * if (err != SYNC_AGENT_PB_RETURN_OK) {
104 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
105 * false, true, false, true, true, NULL, NULL,
106 * pBinder_function_set);
107 * if (pOutBinder == NULL) {
111 * err = sync_agent_switch_protocol(pBinder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
112 * if (err != SYNC_AGENT_PB_RETURN_OK) {
117 * err = sync_agent_undo_switch_protocol(pBinder);
118 * if (err != SYNC_AGENT_PB_RETURN_OK) {
123 * @param[in] binder Structure(sync_agent_pb_protocol_binder_info_s)
124 * @return 0 on success, otherwise a negative error value.
125 * @retval SYNC_AGENT_PB_RETURN_OK Successful
126 * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
127 * @retval SYNC_AGENT_PB_RETURN_HAS_NO_UNDO_SWITCH_PROTOCOL Operation failed
128 * @see sync_agent_switch_protocol
130 sync_agent_pb_error_e sync_agent_undo_switch_protocol(sync_agent_pb_protocol_binder_info_s * binder);
132 /* wbxml dom tree building functions */
134 * @brief Create WBXMLTree using information in sync_agent_pb_protocol_binder_info_s structure
138 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
139 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
141 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
142 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
143 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
144 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
146 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
147 * (sync_agent_pb_function_info_s*)binder_function_info,
148 * &pBinder_function_set);
149 * if (err != SYNC_AGENT_PB_RETURN_OK) {
153 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
154 * false, true, false, true, true, NULL, NULL,
155 * pBinder_function_set);
156 * if (pOutBinder == NULL) {
160 * WBXMLTree *tree = sync_agent_create_wbxml_tree(pBinder);
161 * if (tree == NULL) {
168 * @param[in] binder Structure(sync_agent_pb_protocol_binder_info_s)
169 * @return WBXMLTree on success, NULL on fail
170 * @see sync_agent_init_protocol_binder
172 WBXMLTree *sync_agent_create_wbxml_tree(const sync_agent_pb_protocol_binder_info_s * binder);
175 * @brief Add WBXMLTree to WBXMLTreeNode as a subree
179 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
180 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
182 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
183 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
184 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
185 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
187 * char *element_name = "header";
189 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
190 * (sync_agent_pb_function_info_s*)binder_function_info,
191 * &pBinder_function_set);
192 * if (err != SYNC_AGENT_PB_RETURN_OK) {
196 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
197 * false, true, false, true, true, NULL, NULL,
198 * pBinder_function_set);
199 * if (pOutBinder == NULL) {
203 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
204 * if (header_node == NULL) {
205 * err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
209 * WBXMLTree *tree = sync_agent_create_wbxml_tree(pBinder);
210 * if (tree == NULL) {
215 * err = sync_agent_add_wbxml_tree_to_wbxml_node(header_node, tree);
216 * if (err != SYNC_AGENT_PB_RETURN_OK) {
223 * @param[in] parent_node WBXMLTreeNode
224 * @param[in] tree WBXMLTree
225 * @return 0 on success, otherwise a negative error value.
226 * @retval SYNC_AGENT_PB_RETURN_OK Successful
227 * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter(parent_node, tree)
228 * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
229 * @see sync_agent_init_protocol_binder, sync_agent_create_node, sync_agent_create_wbxml_tree
231 sync_agent_pb_error_e sync_agent_add_wbxml_tree_to_wbxml_node(WBXMLTreeNode * parent_node, WBXMLTree * tree);
234 * @brief Set root node of WBXMLTree
238 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
239 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
241 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
242 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
243 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
244 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
246 * char *element_name = "header";
248 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
249 * (sync_agent_pb_function_info_s*)binder_function_info,
250 * &pBinder_function_set);
251 * if (err != SYNC_AGENT_PB_RETURN_OK) {
255 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
256 * false, true, false, true, true, NULL, NULL,
257 * pBinder_function_set);
258 * if (pOutBinder == NULL) {
262 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
263 * if (header_node == NULL) {
264 * err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
268 * WBXMLTree *root_tree = sync_agent_create_wbxml_tree(pBinder);
269 * if (tree == NULL) {
274 * err = sync_agent_set_wbxml_tree_root(root_tree, header_node);
275 * if (err != SYNC_AGENT_PB_RETURN_OK) {
282 * @param[in] tree WBXMLTree
283 * @param[in] node WBXMLTreeNode
284 * @return 0 on success, otherwise a negative error value.
285 * @retval SYNC_AGENT_PB_RETURN_OK Successful
286 * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter(parent_node, tree)
287 * @retval SYNC_AGENT_PB_RETURN_TREE_ALREADY_HAS_ROOT
288 * @see sync_agent_init_protocol_binder, sync_agent_create_wbxml_tree
290 sync_agent_pb_error_e sync_agent_set_wbxml_tree_root(WBXMLTree * tree, WBXMLTreeNode * node);
293 * @brief Create WBXMLTreeNode using XML element name
297 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
298 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
300 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
301 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
302 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
303 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
305 * char *element_name = "header";
307 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
308 * (sync_agent_pb_function_info_s*)binder_function_info,
309 * &pBinder_function_set);
310 * if (err != SYNC_AGENT_PB_RETURN_OK) {
314 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
315 * false, true, false, true, true, NULL, NULL,
316 * pBinder_function_set);
317 * if (pOutBinder == NULL) {
321 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
322 * if (header_node == NULL) {
327 * @param[in] binder sync_agent_pb_protocol_binder_info_s
328 * @param[in] xml_name XML element name
329 * @return WBXMLTreeNode on success, NULL on fail
330 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
332 WBXMLTreeNode *sync_agent_create_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name);
335 * @brief Create WBXMLTreeNode using XML element name and XML name space
339 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
340 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
342 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
343 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
344 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
345 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
347 * char *element_name = "header";
348 * char *name_space = "name_space";
350 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
351 * (sync_agent_pb_function_info_s*)binder_function_info,
352 * &pBinder_function_set);
353 * if (err != SYNC_AGENT_PB_RETURN_OK) {
357 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
358 * false, true, false, true, true, NULL, NULL,
359 * pBinder_function_set);
360 * if (pOutBinder == NULL) {
364 * WBXMLTreeNode *header_node = sync_agent_create_node_with_namespace(pBinder, element_name, name_space);
365 * if (header_node == NULL) {
370 * @param[in] binder sync_agent_pb_protocol_binder_info_s
371 * @param[in] xml_name XML element name
372 * @param[in] name_space XML name space
373 * @return WBXMLTreeNode on success, NULL on fail
374 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
376 WBXMLTreeNode *sync_agent_create_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *name_space);
379 * @brief Create WBXMLTreeNode using XML element name with text content
383 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
384 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
386 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
387 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
388 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
389 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
391 * char *element_name = "header";
392 * char *text_data = "data";
393 * unsigned int text_len = strlen(text_data);;
395 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
396 * (sync_agent_pb_function_info_s*)binder_function_info,
397 * &pBinder_function_set);
398 * if (err != SYNC_AGENT_PB_RETURN_OK) {
402 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
403 * false, true, false, true, true, NULL, NULL,
404 * pBinder_function_set);
405 * if (pOutBinder == NULL) {
409 * WBXMLTreeNode *header_node = sync_agent_create_text_node(pBinder, element_name, text_data, text_len);
410 * if (header_node == NULL) {
415 * @param[in] binder sync_agent_pb_protocol_binder_info_s
416 * @param[in] xml_name XML element name
417 * @param[in] text Content
418 * @param[in] text_len Length of Content
419 * @return WBXMLTreeNode on success, NULL on fail
420 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
422 WBXMLTreeNode *sync_agent_create_text_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *text, unsigned int text_len);
425 * @brief Create WBXMLTreeNode using XML element name and XML name space with text content
429 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
430 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
432 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
433 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
434 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
435 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
437 * char *element_name = "header";
438 * char *name_space = "name_space";
439 * char *text_data = "data";
440 * unsigned int text_len = strlen(text_data);
442 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
443 * (sync_agent_pb_function_info_s*)binder_function_info,
444 * &pBinder_function_set);
445 * if (err != SYNC_AGENT_PB_RETURN_OK) {
449 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
450 * false, true, false, true, true, NULL, NULL,
451 * pBinder_function_set);
452 * if (pOutBinder == NULL) {
456 * WBXMLTreeNode *header_node = sync_agent_create_text_node_with_namespace(pBinder, element_name, name_space, text_data, text_len);
457 * if (header_node == NULL) {
462 * @param[in] binder sync_agent_pb_protocol_binder_info_s
463 * @param[in] xml_name XML element name
464 * @param[in] name_space XML name space
465 * @param[in] text Content
466 * @param[in] text_len Length of Content
467 * @return WBXMLTreeNode on success, NULL on fail
468 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
470 WBXMLTreeNode *sync_agent_create_text_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *name_space, const char *text, unsigned int text_len);
473 * @brief Create WBXMLTreeNode using XML element name with cdata content
477 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
478 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
480 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
481 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
482 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
483 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
485 * char *element_name = "header";
486 * char *name_space = "name_space";
487 * char *cdata = "data";
488 * unsigned int cdata_len = strlen(cdata);
490 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
491 * (sync_agent_pb_function_info_s*)binder_function_info,
492 * &pBinder_function_set);
493 * if (err != SYNC_AGENT_PB_RETURN_OK) {
497 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
498 * false, true, false, true, true, NULL, NULL,
499 * pBinder_function_set);
500 * if (pOutBinder == NULL) {
504 * WBXMLTreeNode *header_node = sync_agent_create_cdata_node(pBinder, element_name, name_space, cdata, cdata_len);
505 * if (header_node == NULL) {
510 * @param[in] binder sync_agent_pb_protocol_binder_info_s
511 * @param[in] xml_name XML element name
512 * @param[in] text Content
513 * @param[in] text_len Length of Content
514 * @return WBXMLTreeNode on success, NULL on fail
515 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
517 WBXMLTreeNode *sync_agent_create_cdata_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *text, unsigned int text_len);
520 * @brief Create WBXMLTreeNode using XML element name, and add WBXMLTreeNode to parent node as a child node
524 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
525 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
527 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
528 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
529 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
530 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
532 * char *element_name = "header";
533 * char *child_element_name = "child";
535 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
536 * (sync_agent_pb_function_info_s*)binder_function_info,
537 * &pBinder_function_set);
538 * if (err != SYNC_AGENT_PB_RETURN_OK) {
542 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
543 * false, true, false, true, true, NULL, NULL,
544 * pBinder_function_set);
545 * if (pOutBinder == NULL) {
549 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
550 * if (header_node == NULL) {
554 * WBXMLTreeNode *child_node = sync_agent_add_child_node(pBinder, header_node, child_element_name);
555 * if (child_node == NULL) {
560 * @param[in] binder sync_agent_pb_protocol_binder_info_s
561 * @param[in] parent_node Parent node
562 * @param[in] xml_name XML element name
563 * @return WBXMLTreeNode on success, NULL on fail
564 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
566 WBXMLTreeNode *sync_agent_add_child_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name);
569 * @brief Create WBXMLTreeNode using XML element name and XML name space, and add WBXMLTreeNode to parent node as a child node
573 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
574 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
576 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
577 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
578 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
579 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
581 * char *element_name = "header";
582 * char *child_element_name = "child";
583 * char *child_namespace = "child_namespace";
585 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
586 * (sync_agent_pb_function_info_s*)binder_function_info,
587 * &pBinder_function_set);
588 * if (err != SYNC_AGENT_PB_RETURN_OK) {
592 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
593 * false, true, false, true, true, NULL, NULL,
594 * pBinder_function_set);
595 * if (pOutBinder == NULL) {
599 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
600 * if (header_node == NULL) {
604 * WBXMLTreeNode *child_node = sync_agent_add_child_node_with_namespace(pBinder, header_node, child_element_name, child_namespace);
605 * if (child_node == NULL) {
610 * @param[in] binder sync_agent_pb_protocol_binder_info_s
611 * @param[in] parent_node Parent node
612 * @param[in] xml_name XML element name
613 * @param[in] name_space XML name space
614 * @return WBXMLTreeNode on success, NULL on fail
615 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
617 WBXMLTreeNode *sync_agent_add_child_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space);
620 * @brief Create WBXMLTreeNode using XML element name with text content, and add WBXMLTreeNode to parent node as a child node
624 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
625 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
627 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
628 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
629 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
630 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
632 * char *element_name = "header";
633 * char *child_element_name = "child";
634 * char *child_data = "child_data";
635 * unsigned int child_data_len = strlen(child_data);
637 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
638 * (sync_agent_pb_function_info_s*)binder_function_info,
639 * &pBinder_function_set);
640 * if (err != SYNC_AGENT_PB_RETURN_OK) {
644 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
645 * false, true, false, true, true, NULL, NULL,
646 * pBinder_function_set);
647 * if (pOutBinder == NULL) {
651 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
652 * if (header_node == NULL) {
656 * WBXMLTreeNode *child_node = sync_agent_add_child_text_node(pBinder, header_node, child_element_name, child_data, child_data_len);
657 * if (child_node == NULL) {
662 * @param[in] binder sync_agent_pb_protocol_binder_info_s
663 * @param[in] parent_node Parent node
664 * @param[in] xml_name XML element name
665 * @param[in] text Content
666 * @param[in] text_len Length of Content
667 * @return WBXMLTreeNode on success, NULL on fail
668 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
670 WBXMLTreeNode *sync_agent_add_child_text_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *text, unsigned int text_len);
673 * @brief Create WBXMLTreeNode using XML element name and XML name space with text content, and add WBXMLTreeNode to parent node as a child node
677 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
678 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
680 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
681 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
682 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
683 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
685 * char *element_name = "header";
686 * char *child_element_name = "child";
687 * char *child_namespace = "child_namespace";
688 * char *child_data = "child_data";
689 * unsigned int child_data_len = strlen(child_data);
691 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
692 * (sync_agent_pb_function_info_s*)binder_function_info,
693 * &pBinder_function_set);
694 * if (err != SYNC_AGENT_PB_RETURN_OK) {
698 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
699 * false, true, false, true, true, NULL, NULL,
700 * pBinder_function_set);
701 * if (pOutBinder == NULL) {
705 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
706 * if (header_node == NULL) {
710 * WBXMLTreeNode *child_node = sync_agent_add_child_text_node_with_namespace(pBinder, header_node, child_element_name, child_namespace, child_data, child_data_len);
711 * if (child_node == NULL) {
716 * @param[in] binder sync_agent_pb_protocol_binder_info_s
717 * @param[in] parent_node Parent node
718 * @param[in] xml_name XML element name
719 * @param[in] name_space XML name space
720 * @param[in] text Content
721 * @param[in] text_len Length of Content
722 * @return WBXMLTreeNode on success, NULL on fail
723 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
725 WBXMLTreeNode *sync_agent_add_child_text_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const char *text, unsigned int text_len);
728 * @brief Create WBXMLTreeNode using XML element name with cdata content, and add WBXMLTreeNode to parent node as a child node
732 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
733 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
735 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
736 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
737 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
738 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
740 * char *element_name = "header";
741 * char *child_element_name = "child";
742 * char *child_cdata = "child_cdata";
743 * unsigned int child_cdata_len = strlen(child_cdata);
745 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
746 * (sync_agent_pb_function_info_s*)binder_function_info,
747 * &pBinder_function_set);
748 * if (err != SYNC_AGENT_PB_RETURN_OK) {
752 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
753 * false, true, false, true, true, NULL, NULL,
754 * pBinder_function_set);
755 * if (pOutBinder == NULL) {
759 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
760 * if (header_node == NULL) {
764 * WBXMLTreeNode *child_node = sync_agent_add_child_cdata_node(pBinder, header_node, child_element_name, child_cdata, child_cdata_len);
765 * if (child_node == NULL) {
770 * @param[in] binder sync_agent_pb_protocol_binder_info_s
771 * @param[in] parent_node Parent node
772 * @param[in] xml_name XML element name
773 * @param[in] text Content
774 * @param[in] text_len Length of Content
775 * @return WBXMLTreeNode on success, NULL on fail
776 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
778 WBXMLTreeNode *sync_agent_add_child_cdata_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *text, unsigned int text_len);
781 * @brief Create WBXMLTreeNode using XML element name with int content, and add WBXMLTreeNode to parent node as a child node
785 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
786 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
788 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
789 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
790 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
791 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
793 * char *element_name = "header";
794 * char *child_element_name = "child";
797 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
798 * (sync_agent_pb_function_info_s*)binder_function_info,
799 * &pBinder_function_set);
800 * if (err != SYNC_AGENT_PB_RETURN_OK) {
804 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
805 * false, true, false, true, true, NULL, NULL,
806 * pBinder_function_set);
807 * if (pOutBinder == NULL) {
811 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
812 * if (header_node == NULL) {
816 * WBXMLTreeNode *child_node = sync_agent_add_child_cdata_node(pBinder, header_node, child_element_name, data);
817 * if (child_node == NULL) {
822 * @param[in] binder sync_agent_pb_protocol_binder_info_s
823 * @param[in] parent_node Parent node
824 * @param[in] xml_name XML element name
825 * @param[in] num Content
826 * @return WBXMLTreeNode on success, NULL on fail
827 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
829 WBXMLTreeNode *sync_agent_add_child_int_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const int num);
832 * @brief Create WBXMLTreeNode using XML element name with int content, and add WBXMLTreeNode to parent node as a child node
836 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
837 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
839 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
840 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
841 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
842 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
844 * char *element_name = "header";
845 * char *child_element_name = "child";
846 * char *child_namespace = "child_namespace";
849 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
850 * (sync_agent_pb_function_info_s*)binder_function_info,
851 * &pBinder_function_set);
852 * if (err != SYNC_AGENT_PB_RETURN_OK) {
856 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
857 * false, true, false, true, true, NULL, NULL,
858 * pBinder_function_set);
859 * if (pOutBinder == NULL) {
863 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
864 * if (header_node == NULL) {
868 * WBXMLTreeNode *child_node = sync_agent_add_child_cdata_node(pBinder, header_node, child_element_name, child_namespace, data);
869 * if (child_node == NULL) {
874 * @param[in] binder sync_agent_pb_protocol_binder_info_s
875 * @param[in] parent_node Parent node
876 * @param[in] xml_name XML element name
877 * @param[in] name_space XML name space
878 * @param[in] num Content
879 * @return WBXMLTreeNode on success, NULL on fail
880 * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
882 WBXMLTreeNode *sync_agent_add_child_int_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const int num);
884 /* wbxml dom tree getter functions */
887 * @brief Get XML element name from WBXMLTreeNode
891 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
892 * WBXMLTreeNode node = NULL;
893 * char *element_xml_name = NULL;
897 * err = sync_agent_get_name_from_element_node(node, &element_xml_name);
898 * if (err != SYNC_AGENT_PB_RETURN_OK) {
904 * @param[in] element_node WBXMLTreeNode
905 * @param[out] element_xml_name XML element name
906 * @return 0 on success, otherwise a negative error value.
907 * @retval SYNC_AGENT_PB_RETURN_OK Successful
908 * @retval SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE Invalid parameter(element_node)
910 sync_agent_pb_error_e sync_agent_get_name_from_element_node(const WBXMLTreeNode * element_node, char **element_xml_name);
913 * @brief Get XML name space from WBXMLTreeNode
917 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
918 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
919 * WBXMLTreeNode node = NULL;
920 * char *name_space = NULL;
924 * err = sync_agent_get_namespace_from_element_node(pBinder, node, &name_space);
925 * if (err != SYNC_AGENT_PB_RETURN_OK) {
931 * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
932 * @param[in] element_node WBXMLTreeNode
933 * @param[out] name_space XML name space
934 * @return 0 on success, otherwise a negative error value.
935 * @retval SYNC_AGENT_PB_RETURN_OK Successful
936 * @retval SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE Invalid parameter(element_node)
938 sync_agent_pb_error_e sync_agent_get_namespace_from_element_node(const sync_agent_pb_protocol_binder_reverse_info_s * binder, const WBXMLTreeNode * element_node, char **name_space);
941 * @brief Get pointer of text content from WBXMLTreeNode
945 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
946 * WBXMLTreeNode node = NULL;
951 * err = sync_agent_get_text_from_node(node, &text);
952 * if (err != SYNC_AGENT_PB_RETURN_OK) {
958 * @param[in] element_node WBXMLTreeNode
959 * @param[out] text_pointer Pointer of text content
960 * @return 0 on success, otherwise a negative error value.
961 * @retval SYNC_AGENT_PB_RETURN_OK Successful
963 sync_agent_pb_error_e sync_agent_get_text_from_node(WBXMLTreeNode * element_node, char **text_pointer);
966 * @brief Get pointer of binary content from WBXMLTreeNode
970 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
971 * WBXMLTreeNode node = NULL;
972 * char *binary = NULL;
973 * unsigned int binary_size = 0;
977 * err = sync_agent_get_text_from_node(node, &binary, &binary_size);
978 * if (err != SYNC_AGENT_PB_RETURN_OK) {
984 * @param[in] element_node WBXMLTreeNode
985 * @param[out] binary_pointer Pointer of binary content
986 * @param[out] binary_size Size of binary content
987 * @return 0 on success, otherwise a negative error value.
988 * @retval SYNC_AGENT_PB_RETURN_OK Successful
989 * @retval SYNC_AGENT_PB_RETURN_UTIL_NO_BINARY_VALUE Invalid parameter(element_node)
991 sync_agent_pb_error_e sync_agent_get_binary_from_node(WBXMLTreeNode * element_node, char **binary_pointer, unsigned int *binary_size);
994 * @brief Get int content from WBXMLTreeNode
998 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
999 * WBXMLTreeNode node = NULL;
1004 * err = sync_agent_get_int_from_node(node, &value);
1005 * if (err != SYNC_AGENT_PB_RETURN_OK) {
1011 * @param[in] element_node WBXMLTreeNode
1012 * @param[out] value Int content
1013 * @return 0 on success, otherwise a negative error value.
1014 * @retval SYNC_AGENT_PB_RETURN_OK Successful
1015 * @retval SYNC_AGENT_PB_RETURN_UTIL_NO_INT_VALUE Invalid parameter(element_node)
1017 sync_agent_pb_error_e sync_agent_get_int_from_node(WBXMLTreeNode * element_node, int *value);
1020 * @brief Get pointer of text content from WBXMLTreeNode(cdata node)
1024 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1025 * WBXMLTreeNode node = NULL;
1030 * err = sync_agent_get_text_from_cdata_node(node, &text);
1031 * if (err != SYNC_AGENT_PB_RETURN_OK) {
1037 * @param[in] element_node WBXMLTreeNode
1038 * @param[out] text_pointer Pointer of text content
1039 * @return 0 on success, otherwise a negative error value.
1040 * @retval SYNC_AGENT_PB_RETURN_OK Successful
1042 sync_agent_pb_error_e sync_agent_get_text_from_cdata_node(WBXMLTreeNode * element_node, char **text_pointer);
1045 * @brief Destroy WBXMLTreeNode
1049 * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
1050 * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
1052 * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
1053 * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
1054 * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
1055 * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
1057 * char *element_name = "header";
1059 * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
1060 * (sync_agent_pb_function_info_s*)binder_function_info,
1061 * &pBinder_function_set);
1062 * if (err != SYNC_AGENT_PB_RETURN_OK) {
1066 * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
1067 * false, true, false, true, true, NULL, NULL,
1068 * pBinder_function_set);
1069 * if (pOutBinder == NULL) {
1073 * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
1074 * if (header_node == NULL) {
1080 * err = sync_agent_destroy_wbxml_node(header_node);
1081 * if (err != SYNC_AGENT_PB_RETURN_OK) {
1087 * @param[in] node WBXMLTreeNode
1088 * @return 0 on success, otherwise a negative error value
1089 * @retval SYNC_AGENT_PB_RETURN_OK Successful
1090 * @see sync_agent_create_node, sync_agent_create_node_with_namespace, sync_agent_create_text_node, sync_agent_create_text_node_with_namespace, sync_agent_create_cdata_node, sync_agent_add_child_node, sync_agent_add_child_node_with_namespace, sync_agent_add_child_text_node, sync_agent_add_child_text_node_with_namespace, sync_agent_add_child_cdata_node, sync_agent_add_child_int_node, sync_agent_add_child_int_node_with_namespace
1092 sync_agent_pb_error_e sync_agent_destroy_wbxml_node(WBXMLTreeNode * node);
1100 #endif /* __cplusplus */
1101 #endif /* PROTOCOL_BINDER_UTIL_H_ */