Changeset - 7d6ab92dff30
[Not reviewed]
default
0 1 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-09-13 20:08:02
e@ethanzonca.com
commit for binki
1 file changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/server/slavefuncs.c
Show inline comments
 
@@ -25,56 +25,63 @@
 
#include "common/asprintf.h"
 
#include "common/execio.h"
 
#include "common/protocol.h"
 
#include "common/remoteio.h"
 

	
 
#include <curl/curl.h>
 
#include <curl/easy.h>
 
#include <curl/types.h>
 

	
 
#include <archive.h>
 
#include <archive_entry.h>
 

	
 
#include <ctype.h>
 
#include <errno.h>
 
#include <stdio.h>
 
#include <string.h>
 
#include <unistd.h>
 
#include <stdlib.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 

	
 
#include <time.h>
 

	
 
// Function debug
 
#define DEBUG 0
 
#define DEBUG 1
 

	
 

	
 
/*
 
void stringToUpper(char *string){
 
  while(*string != '\0') {
 
    *string = toupper((unsigned char)*string);
 
  }
 
}
 
*/
 

	
 
void stringToUpper(char *buffer){
 
    for(; *buffer; buffer ++)
 
      *buffer = toupper(*buffer);
 
}
 

	
 

	
 
/**
 
   Grabs the xml DOM node reached by an XPath.
 

	
 
   @param path an XPath that lead to DOM node
 
   @return the first node associated with the path or NULL if there is no match
 
 */
 
xmlNodePtr xml_quickxpath(xmlXPathContextPtr xpathctxt, xmlChar *path)
 
{
 
  xmlNodePtr toreturn;
 

	
 
  xmlXPathObjectPtr xmlxpathobjptr;
 
  xmlxpathobjptr = xmlXPathEval(path, xpathctxt);
 
  if(!xmlxpathobjptr
 
     || !xmlxpathobjptr->nodesetval->nodeNr)
 
    {
 
      fprintf(stderr, "XPath resolution failed for ``%s'' in ``%s'' (``%s'')\n", path, xpathctxt->doc->name, xpathctxt->doc->URL);
 
      return (xmlNodePtr)NULL;
 
    }
 

	
 
  toreturn = *(xmlxpathobjptr->nodesetval->nodeTab);
 

	
 
  xmlXPathFreeObject(xmlxpathobjptr);
 

	
 
@@ -697,48 +704,50 @@ int _web_getwork(int slavekey, char *sla
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *framenum = atoi(tmp); // Grab framenum
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      serverversion = tmp;
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *xres = atoi(tmp);
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      *yres = atoi(tmp);
 

	
 
      tmp = strtok (NULL, ",");
 
      if(tmp == NULL)
 
        return 0; // no work
 
      outputext = tmp;
 
      if(DEBUG)
 
        fprintf(stderr,"GETWORK Debug output - Job: %d | Frame: %d | Xres: %d | Yres: %d | Outformat: %s\n", *jobnum, *framenum, *xres, *yres, outputext);
 

	
 
      // @FIXME: Setting outputext and serverversion = temp; will this cause issues as these are pointers to parts of the original temp var?
 

	
 
      // @TODO: This should be called every time, not just on fail.
 
      if(strcmp(PACKAGE_VERSION,serverversion)){
 
        fprintf(stderr,"Your distren package is out of date! Please acquire a newer version. (%s local vs %s remote)\n", PACKAGE_VERSION, serverversion);
 
        return 0;
 
      }
 
      if(DEBUG)
 
        fprintf(stderr,"Software versions: %s local vs %s remote\n", PACKAGE_VERSION, serverversion);
 

	
 

	
 
      free(data.memory);
 
      return 1;
 
    }
 
    else
 
      return 0; // error
 
  }
 
}
 

	
 
void _web_setrenderpower(int slavekey, char *slavepass, int renderpower){
 
  fprintf(stderr,"Setting render power on server... ");
 
  char *url;
 
  _distren_asprintf(&url,"http://distren.org/slave/act.php?mode=setrenderpower&slavekey=%d&slavepass=%s&renderpower=%d", slavekey, slavepass, renderpower);
0 comments (0 inline, 0 general)