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

Function xo_buf_append_div

tools/libxo/libxo/libxo.c:3826–4062  ·  view source on GitHub ↗

* Html mode: append a to the output buffer contain a field * along with all the supporting information indicated by the flags. */

Source from the content-addressed store, hash-verified

3824 * along with all the supporting information indicated by the flags.
3825 */
3826static void
3827xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
3828 const char *name, ssize_t nlen,
3829 const char *value, ssize_t vlen,
3830 const char *fmt, ssize_t flen,
3831 const char *encoding, ssize_t elen)
3832{
3833 static char div_start[] = "<div class=\"";
3834 static char div_tag[] = "\" data-tag=\"";
3835 static char div_xpath[] = "\" data-xpath=\"";
3836 static char div_key[] = "\" data-key=\"key";
3837 static char div_end[] = "\">";
3838 static char div_close[] = "</div>";
3839
3840 /* The encoding format defaults to the normal format */
3841 if (encoding == NULL && fmt != NULL) {
3842 char *enc = alloca(flen + 1);
3843 memcpy(enc, fmt, flen);
3844 enc[flen] = '\0';
3845 encoding = xo_fix_encoding(xop, enc);
3846 elen = strlen(encoding);
3847 }
3848
3849 /*
3850 * To build our XPath predicate, we need to save the va_list before
3851 * we format our data, and then restore it before we format the
3852 * xpath expression.
3853 * Display-only keys implies that we've got an encode-only key
3854 * elsewhere, so we don't use them from making predicates.
3855 */
3856 int need_predidate =
3857 (name && (flags & XFF_KEY) && !(flags & XFF_DISPLAY_ONLY)
3858 && XOF_ISSET(xop, XOF_XPATH)) ? 1 : 0;
3859
3860 if (need_predidate) {
3861 va_list va_local;
3862
3863 va_copy(va_local, xop->xo_vap);
3864 if (xop->xo_checkpointer)
3865 xop->xo_checkpointer(xop, xop->xo_vap, 0);
3866
3867 /*
3868 * Build an XPath predicate expression to match this key.
3869 * We use the format buffer.
3870 */
3871 xo_buffer_t *pbp = &xop->xo_predicate;
3872 pbp->xb_curp = pbp->xb_bufp; /* Restart buffer */
3873
3874 xo_buf_append(pbp, "[", 1);
3875 xo_buf_escape(xop, pbp, name, nlen, 0);
3876 if (XOF_ISSET(xop, XOF_PRETTY))
3877 xo_buf_append(pbp, " = '", 4);
3878 else
3879 xo_buf_append(pbp, "='", 2);
3880
3881 xo_xff_flags_t pflags = flags | XFF_XML | XFF_ATTR;
3882 pflags &= ~(XFF_NO_OUTPUT | XFF_ENCODE_ONLY);
3883 xo_do_format_field(xop, pbp, encoding, elen, pflags);

Callers 5

xo_message_hcvFunction · 0.85
xo_format_textFunction · 0.85
xo_format_valueFunction · 0.85
xo_format_contentFunction · 0.85
xo_errorn_hvFunction · 0.85

Calls 15

xo_fix_encodingFunction · 0.85
xo_buf_appendFunction · 0.85
xo_buf_escapeFunction · 0.85
xo_do_format_fieldFunction · 0.85
xo_simple_fieldFunction · 0.85
xo_line_ensure_openFunction · 0.85
xo_buf_indentFunction · 0.85
xo_data_appendFunction · 0.85
xo_buf_is_emptyFunction · 0.85
xo_data_escapeFunction · 0.85
xo_info_findFunction · 0.85
xo_format_humanizeFunction · 0.85

Tested by

no test coverage detected