void mxmlElementSetAttr(mxml_node_t *node, /* I - Element node */ const char *name, /* I - Name of attribute */ const char *value) /* I - Attribute value */ { char *valuec; /* Copy of value */ #ifdef DEBUG fprintf(stderr, "mxmlElementSetAttr(node=%p, name=\"%s\", value=\"%s\")\n", node, name ? name : "(null)", value ? value : "(null)"); #endif /* DEBUG */ /* * Range check input... */ if (!node || node->type != MXML_ELEMENT || !name) return; if (value) valuec = PhDuplicateBytesZSafe((char *)value); else valuec = NULL; if (mxml_set_attr(node, name, valuec)) PhFree(valuec); }
void mxmlElementSetAttr(mxml_node_t* node, /* I - Element node */ const char* name, /* I - Name of attribute */ const char* value) { /* I - Attribute value */ char* valuec; /* Copy of value */ #ifdef DEBUG fprintf(stderr, "mxmlElementSetAttr(node=%p, name=\"%s\", value=\"%s\")\n", node, name ? name : "(null)", value ? value : "(null)"); #endif /* DEBUG */ /* * Range check input... */ if (!node || node->type != MXML_ELEMENT || !name) { return; } if (value) { valuec = strdup(value); } else { valuec = NULL; } if (mxml_set_attr(node, name, valuec)) { free(valuec); } }
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); } }