int /* O - 0 on success, -1 on failure */ mxmlSetTextf(mxml_node_t *node, /* I - Node to set */ int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */ const char *format, /* I - Printf-style format string */ ...) /* I - Additional arguments as needed */ { va_list ap; /* Pointer to arguments */ /* * Range check input... */ if (!node || node->type != MXML_TEXT || !format) return (-1); /* * Free any old string value and set the new value... */ if (node->value.text.string) free(node->value.text.string); va_start(ap, format); node->value.text.whitespace = whitespace; node->value.text.string = mxml_strdupf(format, ap); va_end(ap); return (0); }
void mxml_error(const char *format, /* I - Printf-style format string */ ...) /* I - Additional arguments as needed */ { va_list ap; /* Pointer to arguments */ char *s; /* Message string */ /* * Range check input... */ if (!format) return; /* * Format the error message string... */ va_start(ap, format); s = mxml_strdupf(format, ap); va_end(ap); /* * And then display the error message... */ if (mxml_error_cb) (*mxml_error_cb)(s); else fprintf(stderr, "mxml: %s\n", s); /* * Free the string... */ free(s); }
mxml_node_t * /* O - New node */ mxmlNewTextf(mxml_node_t *parent, /* I - Parent node or MXML_NO_PARENT */ int whitespace, /* I - 1 = leading whitespace, 0 = no whitespace */ const char *format, /* I - Printf-style frmat string */ ...) /* I - Additional args as needed */ { mxml_node_t *node; /* New node */ va_list ap; /* Pointer to arguments */ #ifdef DEBUG fprintf(stderr, "mxmlNewTextf(parent=%p, whitespace=%d, format=\"%s\", ...)\n", parent, whitespace, format ? format : "(null)"); #endif /* DEBUG */ /* * Range check input... */ if (!format) return (NULL); /* * Create the node and set the text value... */ if ((node = mxml_new(parent, MXML_TEXT)) != NULL) { va_start(ap, format); node->value.text.whitespace = whitespace; node->value.text.string = mxml_strdupf(format, ap); va_end(ap); } return (node); }