MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_do_open_instance

Function xo_do_open_instance

tools/libxo/libxo/libxo.c:7355–7408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7353}
7354
7355static int
7356xo_do_open_instance (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
7357{
7358 xop = xo_default(xop);
7359
7360 ssize_t rc = 0;
7361 const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
7362 const char *pre_nl = "";
7363
7364 if (name == NULL) {
7365 xo_failure(xop, "NULL passed for instance name");
7366 name = XO_FAILURE_NAME;
7367 }
7368
7369 const char *leader = xo_xml_leader(xop, name);
7370 flags |= xop->xo_flags;
7371
7372 switch (xo_style(xop)) {
7373 case XO_STYLE_XML:
7374 rc = xo_printf(xop, "%*s<%s%s", xo_indent(xop), "", leader, name);
7375
7376 if (xop->xo_attrs.xb_curp != xop->xo_attrs.xb_bufp) {
7377 rc += xop->xo_attrs.xb_curp - xop->xo_attrs.xb_bufp;
7378 xo_data_append(xop, xop->xo_attrs.xb_bufp,
7379 xop->xo_attrs.xb_curp - xop->xo_attrs.xb_bufp);
7380 xop->xo_attrs.xb_curp = xop->xo_attrs.xb_bufp;
7381 }
7382
7383 rc += xo_printf(xop, ">%s", ppn);
7384 break;
7385
7386 case XO_STYLE_JSON:
7387 xo_stack_set_flags(xop);
7388
7389 if (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
7390 pre_nl = XOF_ISSET(xop, XOF_PRETTY) ? ",\n" : ", ";
7391 xop->xo_stack[xop->xo_depth].xs_flags |= XSF_NOT_FIRST;
7392
7393 rc = xo_printf(xop, "%s%*s{%s",
7394 pre_nl, xo_indent(xop), "", ppn);
7395 break;
7396
7397 case XO_STYLE_SDPARAMS:
7398 break;
7399
7400 case XO_STYLE_ENCODER:
7401 rc = xo_encoder_handle(xop, XO_OP_OPEN_INSTANCE, name, NULL, flags);
7402 break;
7403 }
7404
7405 xo_depth_change(xop, name, 1, 1, XSS_OPEN_INSTANCE, xo_stack_flags(flags));
7406
7407 return rc;
7408}
7409
7410xo_ssize_t
7411xo_open_instance_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)

Callers 2

xo_transitionFunction · 0.85
xo_explicit_transitionFunction · 0.85

Calls 11

xo_defaultFunction · 0.85
xo_failureFunction · 0.85
xo_xml_leaderFunction · 0.85
xo_styleFunction · 0.85
xo_printfFunction · 0.85
xo_indentFunction · 0.85
xo_data_appendFunction · 0.85
xo_stack_set_flagsFunction · 0.85
xo_encoder_handleFunction · 0.85
xo_depth_changeFunction · 0.85
xo_stack_flagsFunction · 0.85

Tested by

no test coverage detected