diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -403,3 +403,41 @@ int unpackJob(char *pathtoTar, int jobnu free(outdir); return 0; } + +void prepareJobPaths(int jobnum,char *datadir, char **urltoTar,char **pathtoTar,char **pathtoJobfile,char **urltoOutput,char **pathtoXml){ + // Variable Preparation + char *jobdatapath; + _distren_asprintf(&jobdatapath, "job%d", jobnum); + _distren_asprintf(urltoTar, "http://data.distren.org/job%d/job%d.tar.gz", jobnum); // Prepares URL to download from + _distren_asprintf(pathtoTar, "%s/stor/jobdata/job%d.tar.gz", datadir, jobnum); // Prepares destination to save to + _distren_asprintf(pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile + _distren_asprintf(urltoOutput, "http://data.distren.org/tmp/", jobdatapath ); // Prepares the URL where output is posted + _distren_asprintf(pathtoXml, "%s/job%d/job%d.xml", datadir, jobnum ); // Prepares the path to the job's XML file + free(jobdatapath); +} + +int checkUsername(char *username){ + if(username == NULL || strcmp(username, "!username") == 0 ) { + fprintf(stderr, "\nPlease ensure that your username is present in distrenslave.conf\n"); + return 0; + } + else + if( username != NULL || strcmp(username, "!username") != 0 ) + { + // Log in the user + if(login_user(username) == 1){ + fprintf(stderr, "You should now be logged into distren.\n"); + return 0; + } + else + { + fprintf(stderr, "Login failed, please check your username. If you have not registered, please do so on the DistRen website.\n"); + return 1; + } + } + else + { + fprintf(stderr, "Please check your distrenslave.conf, it appears to be incorrectly formatted.\n"); + return 1; + } +}