Changeset - 249d80ebb87a
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-10-09 13:52:38

createQueueFromXML() now cleans up after itself like a good little function
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -519,13 +519,13 @@ int updateJobListXML(struct distrenjob *
 
  char *tmp;
 
  char *tmp2;
 
  int counter;
 

	
 
  _distren_asprintf(&tmp, "job_list.xml");
 
  writer = xmlNewTextWriterFilename(tmp, 0);
 
  xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
 
  xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
 

	
 
  // create root element job_list
 
  xmlTextWriterStartElement(writer, (xmlChar*)"job_list");
 

	
 
  _distren_asprintf(&tmp, "%d", general_info.jobs_in_queue);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"amount", (xmlChar*)tmp);
 
@@ -549,13 +549,13 @@ int updateJobListXML(struct distrenjob *
 

	
 
// 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;
 
  xmlChar *tmp;
 
  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)
 
@@ -580,22 +580,22 @@ int createQueueFromXML(struct distrenjob
 
  // 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);
 
      tmp = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 
      fprintf(stderr, "adding job: %s", tmp);
 
      // add job from job number @TODO create function with parameters (struct distrenjob *head, int job_number)
 
      // LordOfWar calls dibs on above todo
 

	
 
      xmlFree(tmp);
 
      cur = cur->next; // go to next child element of job_list element
 
    }
 

	
 
  xmlFreeDoc(doc);
 
  xmlFree(tmp2);
 

	
 
  return 1;
 
}
 

	
 
/* ************************** Test Functions ************************* */
 
void printFrameInfo(struct frameset *frame)
0 comments (0 inline, 0 general)