Files
@ a255abd6e6f8
Branch filter:
Location: DistRen/src/server/distrenjob.c - annotation
a255abd6e6f8
4.0 KiB
text/plain
Conf replacer made more flexible, conf issue fixed (causes segfault now), fixed style, updated comments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 d6d0d0d26d0b d6d0d0d26d0b 12f4253fa8db 45bf3be8fb93 45bf3be8fb93 d6d0d0d26d0b 45bf3be8fb93 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 5bee5e566377 5bee5e566377 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 734207e4d1f8 734207e4d1f8 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a d7b349e0d490 122fb7609b63 1aeb6d2aebd0 e469bd961670 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 12f4253fa8db 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 25ea5b51c17a 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 45bf3be8fb93 | /*
Copyright 2009 Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
#include "asprintf.h"
#include "distrenjob.h"
#include "slavefuncs.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
void distrenjob_free(struct distrenjob **distrenjob)
{
struct distrenjob *dj;
dj = *distrenjob;
xmlFree(dj->name);
xmlFree(dj->submitter);
xmlFree(dj->email);
free(dj->frameset);
free(dj);
*distrenjob = NULL;
}
int distrenjob_new(struct distrenjob **distrenjob)
{
struct distrenjob *dj;
dj = malloc(sizeof(struct distrenjob));
if(!dj)
{
/* try to catch code that doesn't respect return values
faster: */
*distrenjob = NULL;
return 1;
}
*distrenjob = dj;
dj->next = NULL;
dj->name = (char *)NULL;
dj->submitter = (char *)NULL;
dj->email = (char *)NULL;
dj->jobnum = 0; /*< @todo there should be a central jobnum allocator and a way to save the maximum jobnumber allocated */
dj->priority = 0;
dj->width = 0;
dj->height = 0;
dj->completed_frames = 0;
dj->assigned_frames = 0;
dj->total_render_time = 0;
dj->hibernate = 0;
dj->prev_frame_index = -1;
dj->assigned_render_power = 0;
dj->watchdog_forgiveness = 3600; // initialize watchdog forgiveness at 1 hour
dj->frameset = (struct frameset *)NULL; /*< @todo does frameset need to be initialized here? */
return 0;
}
/**
writes struct from xml
*/
int xml2distrenjob(struct distrenjob **distrenjob, char *pathtoxml)
{
struct distrenjob *dj;
xmlDocPtr xmldoc;
xmlNodePtr xmlnode;
xmlChar *xmlchar;
xmlXPathContextPtr xmlxpathcontext;
int tmp;
if(distrenjob_new(distrenjob))
return 1;
dj = *distrenjob;
xmldoc = xmlReadFile(pathtoxml, NULL, XML_PARSE_PEDANTIC);
if(!xmldoc)
{
/**
@todo are we able to depend on libxml2's printed errors or
channel them into syslog output (eventually)? Currently,
this error is repetitious of a libxml2 error printed on stderr
for us.
*/
fprintf(stderr, "error reading XML file ``%s''\n", pathtoxml);
distrenjob_free(distrenjob);
return 2;
}
xmlxpathcontext = xmlXPathNewContext(xmldoc);
xmlnode = xml_quickxpath(xmlxpathcontext, (xmlChar *)"/distren/job");
if(!xmlnode)
{
distrenjob_free(distrenjob);
return 3;
}
/*< @todo should we use xmlChar everywhere too? */
dj->name = (char *)xmlGetProp(xmlnode, (xmlChar *)"name");
if(!dj->name)
{
distrenjob_free(distrenjob);
return 4;
}
/*< @todo validation needs to be done on usernames. e.g., currently, they shouldn't contain the '"' char */
dj->submitter = (char *)xmlGetProp(xmlnode, (xmlChar *)"submitter");
if(!dj->submitter)
{
distrenjob_free(distrenjob);
return 5;
}
tmp = _distren_asprintf((char **)&xmlchar, "/distren/submitters/submitter[attribute::name=\"%s\"]", dj->submitter);
if(tmp <= 0
|| !xmlchar)
{
fprintf(stderr, "error using _distren_asprintf\n");
distrenjob_free(distrenjob);
return 6;
}
xmlnode = xml_quickxpath(xmlxpathcontext, xmlchar);
free(xmlchar);
dj->email = (char *)xmlGetProp(xmlnode, (xmlChar *)"email");
if(!dj->email)
{
fprintf(stderr, "error getting email for user ``%s'' from ``%s''\n",
dj->submitter, pathtoxml);
distrenjob_free(distrenjob);
return 7;
}
xmlXPathFreeContext(xmlxpathcontext);
xmlFreeDoc(xmldoc);
return 0;
}
|