diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -170,7 +170,7 @@ int curlget(char *url, char *out){ } /** Posts a file to a url with cUrl */ -int curlpost(char *filename, char *url){ +int curlpost(char *filename, char *url, int jobnum, int framenum, int slavekey){ char *targetname = "uploadedfile"; // Name of the target in the php file on the server (Don't change me unless you have different PHP code) CURL *curl; CURLcode res; @@ -181,6 +181,21 @@ int curlpost(char *filename, char *url){ curl_global_init(CURL_GLOBAL_ALL); + /* jobnum field... */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "jobnum", + CURLFORM_COPYCONTENTS, jobnum, CURLFORM_END); + /* framenum field... */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "framenum", + CURLFORM_COPYCONTENTS, framenum, CURLFORM_END); + /* slavekey field... */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "slavekey", + CURLFORM_COPYCONTENTS, slavekey, CURLFORM_END); /* upload field... */ curl_formadd(&formpost, &lastptr, @@ -368,8 +383,8 @@ int downloadTar(char *url, char *destina } -int uploadOutput(char *pathtoOutput, char *urltoOutput){ - if( !curlpost(pathtoOutput, urltoOutput)) // Uploads output +int uploadOutput(char *pathtoOutput, char *urltoOutput, int jobnum, int framenum, int slavekey){ + if( !curlpost(pathtoOutput, urltoOutput, jobnum, framenum, slavekey)) // Uploads output { fprintf(stderr,"Upload successful, removing old output...\n"); remove(pathtoOutput); // Delete the file after its uploaded @@ -379,7 +394,7 @@ int uploadOutput(char *pathtoOutput, cha { fprintf(stderr,"Upload failed. Check your network connection. Retrying upload...\n"); int tries=1; - while(tries<=10 && curlpost(pathtoOutput, urltoOutput)) + while(tries<=10 && curlpost(pathtoOutput, urltoOutput, jobnum, framenum, slavekey)) { fprintf(stderr, "Upload failed. Trying again in 10 seconds... (attempt %d of 10)\n", tries); tries++; @@ -484,6 +499,8 @@ void slaveTest(){ int command; int test = 1; int jobnum = 0; + int framenum = 0; + int slavekey = 0; fprintf(stderr,"Hello!\n"); char tmpString1[100] = ""; char tmpString2[100] = ""; @@ -503,9 +520,15 @@ void slaveTest(){ switch(command) { case 1: - fprintf(stderr,"Path to file to upload: "); + fprintf(stderr,"Path to output file to upload: "); scanf("%99s", tmpString1); - uploadOutput(tmpString1, uploadURL); + fprintf(stderr,"Framenum that is being uploaded: "); + scanf("%d", &framenum); + fprintf(stderr,"Jobnum that frame belongs to: "); + scanf("%d", &jobnum); + fprintf(stderr,"Slavekey that rendered this output: "); + scanf("%d", &slavekey); + uploadOutput(tmpString1, uploadURL, jobnum, framenum, slavekey); break; case 2: fprintf(stderr,"Remotio not implemented yet!\n");