/* I - Additional arguments as needed */
char *_mxml_strdupf(const char *format,...)			
{
  va_list	ap;			/* Pointer to additional arguments */
  char		*s;			/* Pointer to formatted string */


 /*
  * Get a pointer to the additional arguments, format the string,
  * and return it...
  */

  va_start(ap, format);
  s = _mxml_vstrdupf(format, ap);
  va_end(ap);

  return (s);
}
Exemple #2
0
char *					/* O - New string pointer */
_mxml_strdupf(const char *format,	/* I - Printf-style format string */
              ...)			/* I - Additional arguments as needed */
{
  va_list	ap;			/* Pointer to additional arguments */
  char		*s;			/* Pointer to formatted string */


 /*
  * Get a pointer to the additional arguments, format the string,
  * and return it...
  */

  va_start(ap, format);
  s = _mxml_vstrdupf(format, ap);
  va_end(ap);

  return (s);
}
Exemple #3
0
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_vstrdupf(format, ap);

    va_end(ap);
  }

  return (node);
}
Exemple #4
0
void
mxmlElementSetAttrf(mxml_node_t* node,  /* I - Element node */
                    const char*  name,  /* I - Name of attribute */
                    const char*  format,/* I - Printf-style attribute value */
                    ...) {      /* I - Additional arguments as needed */
    va_list   ap;         /* Argument pointer */
    char*      value;         /* Value */


#ifdef DEBUG
    fprintf(stderr,
            "mxmlElementSetAttrf(node=%p, name=\"%s\", format=\"%s\", ...)\n",
            node, name ? name : "(null)", format ? format : "(null)");
#endif /* DEBUG */

    /*
     * Range check input...
     */

    if (!node || node->type != MXML_ELEMENT || !name || !format) {
        return;
    }

    /*
     * Format the value...
     */

    va_start(ap, format);
    value = _mxml_vstrdupf(format, ap);
    va_end(ap);

    if (!value)
        mxml_error("Unable to allocate memory for attribute '%s' in element %s!",
                   name, node->value.element.name);
    else if (mxml_set_attr(node, name, value)) {
        free(value);
    }
}