diff --git a/src/client/distren.c b/src/client/distren.c --- a/src/client/distren.c +++ b/src/client/distren.c @@ -18,6 +18,9 @@ */ +/* This code is meant to submit files to the distren server(s). Let's say server for now. And let's state file purpose in each file just so we don't get screwed up! */ + + /* Ideas for php-side stuff: * * PHP adds the users... has captcha and email confirmation wth a pseudo-random number that @@ -37,6 +40,8 @@ int main(int argc, char *argv[]) { + + char *input; char *output; char *jobid; @@ -67,26 +72,26 @@ int main(int argc, char *argv[]) fprintf(stderr, "\t-i\tSpecifies the input file\n\ \t-o\tSpecifies the output file\n\ \t-h\tShows this help message\n"); - /* - don't return here because options_init will have an overall - options help page - */ + + // 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 - the idea that all libs should allow plugging different - malloc/free implementations in? - */ + + // 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 - */ + + // give this error after the general arguments parsing so that + // the general help from options_init can have effect + if(!input || !output) { @@ -121,88 +126,11 @@ int main(int argc, char *argv[]) return 1; } - /* if these following lines fail, it'll be reported as a core dump ;-) */ + // 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"), - "-i guest.rsa", //yeaaaah any better ideas? - "sh", - "-c", - "\"echo hello from ${HOSTNAME}\"", // "\"useradd -M -c" strcat( cfg_getstr(cfg, "name") cfg_getstr(cfg, "email")) "-d /home/distren --gid 537" cfg_getstr(cfg, "username") "\"", - (char *)NULL - }; - - 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"); - return 1; - } - buf[readlen] = '\0'; - fprintf(stderr, "read \"%s\"\n", buf); - } - 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... - - - - // ------------------------------ - // 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 - - -// Vars to fill: - int os=1; - unsigned int frame_to_render; // initialize this somewhere else... - frame_to_render = 10; // temporary, the number 10 will be replaced with a function call - char *filename; - - - if(os == 1){char *bin[44] = "blender.exe";} - else{char *bin[28] = "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 */ - size_t blenderstrlen; - - // 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 */; - char *blendercmd = malloc(blenderstrlen); - snprintf(blendercmd, blenderstrlen, format, filename, frame_to_render); - - fprintf(stderr, "will run job num. %s ``%s''\n",jobid,blendercmd); - free(blendercmd); - - - // -------------End cruddy code that will eventually compose blender.c----------------- - - return 0; };