Changeset - 03937b2315eb
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-06-25 18:57:43

Build-breaking goodness!
1 file changed with 45 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/client/distren.c
Show inline comments
 
@@ -37,13 +37,13 @@
 

	
 
int main(int argc, char *argv[])
 
{
 
  char *input;
 
  char *output;
 
  char *jobid;
 
  
 

	
 
  char curopt;
 

	
 
  distren_t distren;
 
  distren_job_t distren_job;
 

	
 
  input = NULL;
 
@@ -70,47 +70,47 @@ int main(int argc, char *argv[])
 
	  /*
 
	    don't return here because options_init will have an overall
 
	    options help page
 
	  */
 
	}
 
      else if(curopt == 'i')
 
	/* 
 
	   TODO: is strdup good or bad? what about 
 
	/*
 
	   TODO: is strdup good or bad? what about
 
	   the idea that all libs should allow plugging different
 
	   malloc/free implementations in?
 
	 */
 
	input = strdup(optarg);
 
      else if(curopt == 'o')
 
	output = strdup(optarg);
 
    } 
 
    }
 

	
 
  /* 
 
  /*
 
     give this error after the general arguments parsing so that
 
     the general help from options_init can have effect 
 
     the general help from options_init can have effect
 
  */
 
  if(!input
 
     || !output)
 
    {
 
      fprintf(stderr, "Input and output files must be specified\n");
 
      return 1;
 
    }
 

	
 
  fprintf(stderr, "reading from %s\nwriting to %s\n", input, output);
 
  
 

	
 
  if(distren_init_mf(&distren, &malloc, &free))
 
    {
 
      fprintf(stderr, "error initializing distren handle\n");
 
      return 1;
 
    }
 
  
 

	
 
  if(distren_submit_file(distren, &distren_job, input))
 
    {
 
      fprintf(stderr, "error submitting file\n");
 
      return 1;
 
    } 
 
  
 
    }
 

	
 
  if(distren_job_getid(distren_job, &jobid))
 
    {
 
      fprintf(stderr, "error retrieving job id\n");
 
      return 1;
 
    }
 
  fprintf(stdout, "jobid: %s\n", jobid);
 
@@ -120,24 +120,24 @@ int main(int argc, char *argv[])
 
      fprintf(stderr, "error retrieving output file\n");
 
      return 1;
 
    }
 

	
 
  /* if these following lines fail, it'll be reported as a core dump ;-) */
 
  distren_job_free(distren_job);
 
  
 
  distren_free(distren);
 
  
 

	
 
// !!! Killed for now because I'm doing other randomness !!! //
 
  // Please find a better way of doing this :( you can't strcat multiple strings.. meh
 
  // use something like sprintf
 
  //char *username = cfg_getstr(cfg, "username");
 
  //char *hostname = cfg_getstr(cfg, "hostname");
 
  //strcat(username, "@");
 
  //strcat(username, hostname);
 

	
 
  // SSH's to client machine with the username speficied.
 
  /*
 
    char buf[10];
 
    struct execio *testrem;
 
    char *execargv[] =
 
      {
 
	"ssh",
 
	"username", //cfg_getstr(cfg, "username") . "@" . cfg_getstr(cfg, "hostname"),
 
@@ -149,12 +149,14 @@ int main(int argc, char *argv[])
 
      };
 

	
 
    size_t readlen;
 
    fprintf(stderr, "execio madness is occuring!");
 
    fprintf(stderr, "execio_open returns %d\n", execio_open(&testrem, "ssh", execargv));
 
    buf[9] = '\0';
 
*/
 

	
 
    /*
 
    while(!execio_read(testrem, buf, 9, &readlen))
 
      {
 
	if(readlen > 9 )
 
	  {
 
	    fprintf(stderr, "execio_read doesn't set readlen correctly or read() is messed up\n");
 
@@ -166,14 +168,43 @@ int main(int argc, char *argv[])
 
    execio_close(testrem);
 
    */
 
  // Can we prune off some of this code up here^? I'm not exactly sure how execio returns output, but it seems like more could be happening in execio itself, and less happening where it is actually called.
 
  // We need some code to ssh, and if the SSH fails, tell the user to register.
 
  // Killed the user reg code, as the php interface will take care of this. Although it should check for users...
 

	
 
  
 
  return 0;
 

	
 

	
 
  // ------------------------------
 
  // Ok, this is just to do something to keep distren aliveish... Kill if needed/wanted/meh'd. Borrowed some code from matt's blender.c
 

	
 
    // We need calls to populate os. This is pretty rudimentary. Should be moved to shared, or use bultin something. Change on compiletime?
 
    char *os = "nix";
 
    if(os == 'win32'){char *bin = 'blender.exe'}
 
    else{char *bin = 'blender'} // mac/*nix
 

	
 
    // Placeholders? figure out what the last one is...
 
    char *format = "%s -b \"%s\" -o %s -f %d -F JPEG -x 1",bin,input,output; /* the format string to pass to sprintf */
 

	
 
     unsigned int frame_to_render; // initialize this somewhere else...
 
     size_t blenderstrlen;
 
     frame_to_render = 10; // temporary, the number 10 will be replaced with a function call
 

	
 
// This seems pretty ridik. Just sayin'. We gotta switch this up.
 
     blenderstrlen = strlen(format) - 2 * 2 /* format string minus placeholders */ + strlen(filename) + intstrlen(frame_to_render) + 1 /* NULL terminator */;
 
     blendercmd = malloc(blenderstrlen);
 
     snprintf(blendercmd, blenderstrlen, format, filename, frame_to_render);
 

	
 
     fprintf(stderr, "will run job num. %d ``%s''\n",jobid,blendercmd);
 
     free(blendercmd);
 

	
 

	
 
  // -------------End cruddy code that will eventually compose blender.c-----------------
 

	
 

	
 

	
 
 return 0;
 
};
 

	
 

	
 

	
 

	
 

	
0 comments (0 inline, 0 general)