|  | void xml_set (XML * xml, const char * name, const char * value)
{
   ATTR * attr;
   attr = xml->attrs;
   while (attr) {
      if (!strcmp (attr->name, name)) break;
      attr = attr->next;
   }
   if (attr) {
      free ((void *) (attr->value));
      attr->value = (char *) malloc (strlen (value) + 1);
      strcpy (attr->value, value);
      return;
   }
   if (xml->attrs == NULL) {
      attr = (ATTR *) malloc (sizeof (struct _attr));
      xml->attrs = attr;
   } else {
      attr = xml->attrs;
      while (attr->next) attr = attr->next;
      attr->next = (ATTR *) malloc (sizeof (struct _attr));
      attr = attr->next;
   }
   attr->next = NULL;
   attr->name = (char *) malloc (strlen (name) + 1);
   strcpy (attr->name, name);
   attr->value = (char *) malloc (strlen (value) + 1);
   strcpy (attr->value, value);
}
void xml_setnum (XML * xml, const char *attr, int number)
{
   char buf[sizeof(number) * 3 + 1];
   sprintf (buf, "%d", number);
   xml_set (xml, attr, buf);
}
 |