Lines Matching defs:ctx
15 static xml_node_t * get_node_uri_iter(struct xml_node_ctx *ctx,
27 xml_node_for_each_sibling(ctx, node) {
28 xml_node_for_each_check(ctx, node);
29 name = xml_node_get_localname(ctx, node);
38 return get_node_uri_iter(ctx, xml_node_first_child(ctx, node),
46 xml_node_t * get_node_uri(struct xml_node_ctx *ctx, xml_node_t *root,
56 node = get_node_uri_iter(ctx, root, search);
63 static xml_node_t * get_node_iter(struct xml_node_ctx *ctx,
74 xml_node_for_each_child(ctx, node, root) {
75 xml_node_for_each_check(ctx, node);
76 name = xml_node_get_localname(ctx, node);
84 return get_node_iter(ctx, node, end);
89 xml_node_t * get_node(struct xml_node_ctx *ctx, xml_node_t *root,
99 node = get_node_iter(ctx, root, search);
106 xml_node_t * get_child_node(struct xml_node_ctx *ctx, xml_node_t *root,
112 xml_node_for_each_child(ctx, node, root) {
113 xml_node_for_each_check(ctx, node);
114 match = get_node(ctx, node, path);
123 xml_node_t * node_from_file(struct xml_node_ctx *ctx, const char *name)
162 node = xml_node_from_buf(ctx, buf);
169 int node_to_file(struct xml_node_ctx *ctx, const char *fname, xml_node_t *node)
174 str = xml_node_to_str(ctx, node);
192 static char * get_val(struct xml_node_ctx *ctx, xml_node_t *node)
196 val = xml_node_get_text(ctx, node);
227 static void node_to_tnds(struct xml_node_ctx *ctx, xml_node_t *out,
236 xml_node_for_each_child(ctx, node, in) {
237 xml_node_for_each_check(ctx, node);
238 name = xml_node_get_localname(ctx, node);
240 tnds = xml_node_create(ctx, out, NULL, "Node");
243 xml_node_create_text(ctx, tnds, NULL, "NodeName", name);
246 xml_node_create_text(ctx, tnds, NULL, "Path", uri);
248 val = get_val(ctx, node);
249 if (val || !xml_node_first_child(ctx, node))
250 xml_node_create_text(ctx, tnds, NULL, "Value",
252 xml_node_get_text_free(ctx, val);
255 node_to_tnds(ctx, new_uri ? out : tnds, node, new_uri);
261 static int add_ddfname(struct xml_node_ctx *ctx, xml_node_t *parent,
266 node = xml_node_create(ctx, parent, NULL, "RTProperties");
269 node = xml_node_create(ctx, node, NULL, "Type");
272 xml_node_create_text(ctx, node, NULL, "DDFName", urn);
277 xml_node_t * mo_to_tnds(struct xml_node_ctx *ctx, xml_node_t *mo,
284 root = xml_node_create_root(ctx, ns_uri, NULL, NULL, "MgmtTree");
288 xml_node_create_text(ctx, root, NULL, "VerDTD", "1.2");
290 name = xml_node_get_localname(ctx, mo);
292 node = xml_node_create(ctx, root, NULL, "Node");
295 xml_node_create_text(ctx, node, NULL, "NodeName", name);
297 add_ddfname(ctx, node, urn);
299 node_to_tnds(ctx, use_path ? root : node, mo, use_path ? name : NULL);
304 xml_node_free(ctx, root);
309 static xml_node_t * get_first_child_node(struct xml_node_ctx *ctx,
316 xml_node_for_each_child(ctx, child, node) {
317 xml_node_for_each_check(ctx, child);
318 lname = xml_node_get_localname(ctx, child);
327 static char * get_node_text(struct xml_node_ctx *ctx, xml_node_t *node,
330 node = get_first_child_node(ctx, node, node_name);
333 return xml_node_get_text(ctx, node);
337 static xml_node_t * add_mo_node(struct xml_node_ctx *ctx, xml_node_t *root,
343 nodename = get_node_text(ctx, node, "NodeName");
346 value = get_node_text(ctx, node, "Value");
349 root = xml_node_create_root(ctx, NULL, NULL, NULL,
352 xml_node_set_text(ctx, root, value);
355 xml_node_get_text_free(ctx, nodename);
356 xml_node_get_text_free(ctx, value);
359 path = get_node_text(ctx, node, "Path");
362 parent = get_node_uri(ctx, root, uri);
363 xml_node_get_text_free(ctx, path);
366 xml_node_get_text_free(ctx, nodename);
367 xml_node_get_text_free(ctx, value);
371 xml_node_create_text(ctx, parent, NULL, nodename,
374 xml_node_create(ctx, parent, NULL, nodename);
377 xml_node_get_text_free(ctx, nodename);
378 xml_node_get_text_free(ctx, value);
384 static xml_node_t * tnds_to_mo_iter(struct xml_node_ctx *ctx, xml_node_t *root,
391 xml_node_for_each_sibling(ctx, node) {
392 xml_node_for_each_check(ctx, node);
394 nodename = get_node_text(ctx, node, "NodeName");
398 name = xml_node_get_localname(ctx, node);
403 xml_node_get_text_free(ctx, nodename);
406 root = add_mo_node(ctx, root, node, uri);
409 child = get_first_child_node(ctx, node, "Node");
412 tnds_to_mo_iter(ctx, root, child, nodename);
416 tnds_to_mo_iter(ctx, root, child, new_uri);
420 xml_node_get_text_free(ctx, nodename);
427 xml_node_t * tnds_to_mo(struct xml_node_ctx *ctx, xml_node_t *tnds)
432 name = xml_node_get_localname(ctx, tnds);
436 node = get_first_child_node(ctx, tnds, "Node");
439 return tnds_to_mo_iter(ctx, NULL, node, NULL);
443 xml_node_t * soap_build_envelope(struct xml_node_ctx *ctx, xml_node_t *node)
449 ctx, "http://www.w3.org/2003/05/soap-envelope", "soap12", &ns,
453 body = xml_node_create(ctx, envelope, ns, "Body");
454 xml_node_add_child(ctx, body, node);
459 xml_node_t * soap_get_body(struct xml_node_ctx *ctx, xml_node_t *soap)
463 body = get_node_uri(ctx, soap, "Envelope/Body");
466 xml_node_for_each_child(ctx, child, body) {
467 xml_node_for_each_check(ctx, child);