Ejemplo n.º 1
0
MINIXML_API void
mxmlEntityRemoveCallback(
    mxml_entity_cb_t cb)		/* I - Callback function to remove */
{
  int		i;			/* Looping var */
  _mxml_global_t *global = _mxml_global();
					/* Global data */


  for (i = 0; i < global->num_entity_cbs; i ++)
    if (cb == global->entity_cbs[i])
    {
     /*
      * Remove the callback...
      */

      global->num_entity_cbs --;

      if (i < global->num_entity_cbs)
        memmove(global->entity_cbs + i, global->entity_cbs + i + 1,
	        (global->num_entity_cbs - i) * sizeof(global->entity_cbs[0]));

      return;
    }
}
Ejemplo n.º 2
0
MINIXML_API int					/* O - Character value or -1 on error */
mxmlEntityGetValue(const char *name)	/* I - Entity name */
{
  int		i;			/* Looping var */
  int		ch;			/* Character value */
  _mxml_global_t *global = _mxml_global();
					/* Global data */


  for (i = 0; i < global->num_entity_cbs; i ++)
    if ((ch = (global->entity_cbs[i])(name)) >= 0)
      return (ch);

  return (-1);
}
Ejemplo n.º 3
0
MINIXML_API int					/* O - 0 on success, -1 on failure */
mxmlEntityAddCallback(
    mxml_entity_cb_t cb)		/* I - Callback function to add */
{
  _mxml_global_t *global = _mxml_global();
					/* Global data */


  if (global->num_entity_cbs < (int)(sizeof(global->entity_cbs) / sizeof(global->entity_cbs[0])))
  {
    global->entity_cbs[global->num_entity_cbs] = cb;
    global->num_entity_cbs ++;

    return (0);
  }
  else
  {
    mxml_error("Unable to add entity callback!");

    return (-1);
  }
}
Ejemplo n.º 4
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[1024];        /* Message string */
    _mxml_global_t* global = _mxml_global();
    /* Global data */


    /*
     * Range check input...
     */

    if (!format) {
        return;
    }

    /*
     * Format the error message string...
     */

    va_start(ap, format);

    vsnprintf(s, sizeof(s), format, ap);

    va_end(ap);

    /*
     * And then display the error message...
     */

    if (global->error_cb) {
        (*global->error_cb)(s);
    } else {
        fprintf(stderr, "mxml: %s\n", s);
    }
}