diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -36,10 +36,12 @@ #include #include +#include #include #include #include #include +#include /* ******************* Structs ************************ */ @@ -545,6 +547,53 @@ int updateJobListXML(struct distrenjob * return 1; } +// returns 1 if completed successfully, 0 if not +// this reads a list of jobs in the queue before DistRen was shut down +// and then adds the jobs to the queue, as if it were never shut down +int createQueueFromXML(struct distrenjob *head) +{ + xmlChar *tmp2; + xmlDocPtr doc; // holds xml document in memory + xmlNodePtr cur; // points to the current xml element node + + // load xml document + doc = xmlParseFile("job_list.xml"); + if(doc == NULL) + { + fprintf(stderr, "createQueueFromXML: document not found\n"); + return 0; + } + + // have cur point to the root element of the xml document pointed to by doc + cur = xmlDocGetRootElement(doc); + if(cur == NULL) + { + fprintf(stderr, "createQueueFromXML: document empty\n"); + return 0; + } + + if(xmlStrcmp(cur->name, (const xmlChar*)"job_list")) + { + fprintf(stderr, "createQueueFromXML: incorrect root element (%s)", (char*)cur->name); + } + + // moves into the children elements of job_list + cur = cur->xmlChildrenNode; + + // scans the list of all jobs that were in queue before DistRen shutdown + while(cur != NULL) + { + tmp2 = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + fprintf(stderr, "adding job: %s", tmp2); + // add job from job number @TODO create function with parameters (struct distrenjob *head, int job_number) + // LordOfWar calls dibs on above todo + + cur = cur->next; // go to next child element of job_list element + } + + return 1; +} + /* ************************** Test Functions ************************* */ void printFrameInfo(struct frameset *frame) {