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

Function xo_format_title

tools/libxo/libxo/libxo.c:4078–4188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4076}
4077
4078static void
4079xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip,
4080 const char *value, ssize_t vlen)
4081{
4082 const char *fmt = xfip->xfi_format;
4083 ssize_t flen = xfip->xfi_flen;
4084 xo_xff_flags_t flags = xfip->xfi_flags;
4085
4086 static char div_open[] = "<div class=\"title";
4087 static char div_middle[] = "\">";
4088 static char div_close[] = "</div>";
4089
4090 if (flen == 0) {
4091 fmt = "%s";
4092 flen = 2;
4093 }
4094
4095 switch (xo_style(xop)) {
4096 case XO_STYLE_XML:
4097 case XO_STYLE_JSON:
4098 case XO_STYLE_SDPARAMS:
4099 case XO_STYLE_ENCODER:
4100 /*
4101 * Even though we don't care about text, we need to do
4102 * enough parsing work to skip over the right bits of xo_vap.
4103 */
4104 xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags);
4105 return;
4106 }
4107
4108 xo_buffer_t *xbp = &xop->xo_data;
4109 ssize_t start = xbp->xb_curp - xbp->xb_bufp;
4110 ssize_t left = xbp->xb_size - start;
4111 ssize_t rc;
4112
4113 if (xo_style(xop) == XO_STYLE_HTML) {
4114 xo_line_ensure_open(xop, 0);
4115 if (XOF_ISSET(xop, XOF_PRETTY))
4116 xo_buf_indent(xop, xop->xo_indent_by);
4117 xo_buf_append(&xop->xo_data, div_open, sizeof(div_open) - 1);
4118 xo_color_append_html(xop);
4119 xo_buf_append(&xop->xo_data, div_middle, sizeof(div_middle) - 1);
4120 }
4121
4122 start = xbp->xb_curp - xbp->xb_bufp; /* Reset start */
4123 if (vlen) {
4124 char *newfmt = alloca(flen + 1);
4125 memcpy(newfmt, fmt, flen);
4126 newfmt[flen] = '\0';
4127
4128 /* If len is non-zero, the format string apply to the name */
4129 char *newstr = alloca(vlen + 1);
4130 memcpy(newstr, value, vlen);
4131 newstr[vlen] = '\0';
4132
4133 if (newstr[vlen - 1] == 's') {
4134 char *bp;
4135

Callers 1

xo_do_emit_fieldsFunction · 0.85

Calls 13

xo_styleFunction · 0.85
xo_simple_fieldFunction · 0.85
xo_line_ensure_openFunction · 0.85
xo_buf_indentFunction · 0.85
xo_buf_appendFunction · 0.85
xo_color_append_htmlFunction · 0.85
snprintfFunction · 0.85
xo_data_append_contentFunction · 0.85
xo_buf_has_roomFunction · 0.85
xo_do_format_fieldFunction · 0.85
xo_escape_xmlFunction · 0.85
xo_data_appendFunction · 0.85

Tested by

no test coverage detected