WFTK_EXPORT int repos_report_start (XML * repository, const char * list, const char * name)
{
XML * rep;
XML * obj;
if (!name) name = list;
if (!name) return 1;
rep = xml_locf (repository, ".report[%s]", name);
if (rep) return 1;
rep = xml_create ("report");
xml_set (rep, "id", name);
xml_append (repository, rep);
obj = xml_create ("record");
xml_set (obj, "list", list);
repos_mark_time (obj, "start");
xml_setbin (rep, obj, (XML_SETBIN_FREE_FN *) xml_free);
return 0;
}
WFTK_EXPORT int repos_report_close (XML * repository, const char * report)
{
XML * rep;
XML * obj;
rep = xml_locf (repository, ".report[%s]", report);
if (!rep) return 1;
obj = xml_getbin (rep);
xml_unset (obj, "content");
xml_setbin (rep, NULL, NULL);
xml_delete (rep);
repos_add (repository, xml_attrval (obj, "list"), obj);
xml_delete (obj);
return 0;
}
WFTK_EXPORT int repos_report_cancel (XML * repository, const char * report)
{
XML * rep;
rep = xml_locf (repository, ".report[%s]", report);
if (!rep) return 1;
xml_delete (rep);
return 0;
}
WFTK_EXPORT XML * repos_report_getobj (XML * repository, const char * report)
{
XML * rep;
rep = xml_locf (repository, ".report[%s]", report);
if (!rep) return NULL;
return (xml_getbin (rep));
}
|
WFTK_EXPORT int repos_report_log (XML * repository, const char * report, const char * format, ...)
{
XML * rep;
XML * obj;
const char * content;
XML * list;
XML * mark;
va_list args;
char * colon;
char * strarg;
int intarg;
char numbuf[sizeof (int) * 3 + 1];
rep = xml_locf (repository, ".report[%s]", report);
if (!rep) return 1;
obj = xml_getbin (rep);
if (!obj) return 1;
content = xml_attrval (obj, "content");
if (!*content) {
list = repos_defn (repository, xml_attrval (obj, "list"));
if (list) {
mark = xml_search (list, "field", "special", "content");
xml_set (obj, "content", xml_attrval (mark, "id"));
content = xml_attrval (obj, "content");
}
if (!*content) {
xml_set (obj, "content", "content");
content = xml_attrval (obj, "content");
}
}
mark = xmlobj_field (obj, NULL, content);
va_start (args, format);
while (colon = strchr (format, '%')) {
xml_attrncat (mark, "value", format, colon-format);
format = colon;
format ++;
switch (*format) {
case 's':
strarg = va_arg (args, char *);
xml_attrcat (mark, "value", strarg);
break;
case 'd':
intarg = va_arg (args, int);
sprintf (numbuf, "%d", intarg);
xml_attrcat (mark, "value", numbuf);
break;
default:
xml_attrncat (mark, "value", format, 1);
break;
}
format ++;
}
va_end (args);
xml_attrcat (mark, "value", format);
xml_attrcat (mark, "value", "\n");
}
|
| This code and documentation are released under the terms of the GNU license. They are copyright (c) 2001-2005, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. |