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

Function xo_do_open_container

tools/libxo/libxo/libxo.c:6942–6998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6940}
6941
6942static ssize_t
6943xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
6944{
6945 ssize_t rc = 0;
6946 const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
6947 const char *pre_nl = "";
6948
6949 if (name == NULL) {
6950 xo_failure(xop, "NULL passed for container name");
6951 name = XO_FAILURE_NAME;
6952 }
6953
6954 const char *leader = xo_xml_leader(xop, name);
6955 flags |= xop->xo_flags; /* Pick up handle flags */
6956
6957 switch (xo_style(xop)) {
6958 case XO_STYLE_XML:
6959 rc = xo_printf(xop, "%*s<%s%s", xo_indent(xop), "", leader, name);
6960
6961 if (xop->xo_attrs.xb_curp != xop->xo_attrs.xb_bufp) {
6962 rc += xop->xo_attrs.xb_curp - xop->xo_attrs.xb_bufp;
6963 xo_data_append(xop, xop->xo_attrs.xb_bufp,
6964 xop->xo_attrs.xb_curp - xop->xo_attrs.xb_bufp);
6965 xop->xo_attrs.xb_curp = xop->xo_attrs.xb_bufp;
6966 }
6967
6968 rc += xo_printf(xop, ">%s", ppn);
6969 break;
6970
6971 case XO_STYLE_JSON:
6972 xo_stack_set_flags(xop);
6973
6974 if (!XOF_ISSET(xop, XOF_NO_TOP)
6975 && !XOIF_ISSET(xop, XOIF_TOP_EMITTED))
6976 xo_emit_top(xop, ppn);
6977
6978 if (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
6979 pre_nl = XOF_ISSET(xop, XOF_PRETTY) ? ",\n" : ", ";
6980 xop->xo_stack[xop->xo_depth].xs_flags |= XSF_NOT_FIRST;
6981
6982 rc = xo_printf(xop, "%s%*s\"%s\": {%s",
6983 pre_nl, xo_indent(xop), "", name, ppn);
6984 break;
6985
6986 case XO_STYLE_SDPARAMS:
6987 break;
6988
6989 case XO_STYLE_ENCODER:
6990 rc = xo_encoder_handle(xop, XO_OP_OPEN_CONTAINER, name, NULL, flags);
6991 break;
6992 }
6993
6994 xo_depth_change(xop, name, 1, 1, XSS_OPEN_CONTAINER,
6995 xo_stack_flags(flags));
6996
6997 return rc;
6998}
6999

Callers 1

xo_transitionFunction · 0.85

Calls 11

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_emit_topFunction · 0.85
xo_encoder_handleFunction · 0.85
xo_depth_changeFunction · 0.85
xo_stack_flagsFunction · 0.85

Tested by

no test coverage detected