/* The callback argument specifies a function that returns a whitespace string or NULL before and after each element. If MXML_NO_CALLBACK is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags.  */
int mxmlSaveString(mxml_node_t *node, char *buffer, int bufsize, mxml_save_cb_t cb)
/* The callback argument specifies a function that returns a whitespace string or NULL before and after each element. If MXML_NO_CALLBACK is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags.  */
int mxmlSaveString(mxml_node_t *node, char *buffer, int bufsize, mxml_save_cb_t cb)
{
  int	col;
  char	*ptr[2];
  _mxml_global_t *global = _mxml_global();
  ptr[0] = buffer;
  ptr[1] = buffer + bufsize;
  if ((col = mxml_write_node(node, ptr, cb, 0, mxml_string_putc, global)) < 0)
    return (-1);
  if (col > 0)
    mxml_string_putc('\n', ptr);
  if (ptr[0] >= ptr[1])
    buffer[bufsize - 1] = '\0';
  else
    ptr[0][0] = '\0';
  return (ptr[0] - buffer);
}