Changeset - f31a1535a11a
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-10-10 17:12:35

Formatting fixes, and a few code fixes
1 file changed with 7 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -9,78 +9,77 @@
 
  (at your option) any later version.
 

	
 
  DistRen is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU Affero General Public License for more details.
 

	
 
  You should have received a copy of the GNU Affero General Public License
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
 */
 

	
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal) in the minds of your average joe
 
#include "protocol.h"
 
#include "options.h" // Confuse, etc.
 
#include "slavefuncs.h" // Slave functions
 
#include "asprintf.h"
 
#include "remoteio.h"
 

	
 
#include <string.h>
 
#include <stdio.h>
 
#include <unistd.h>
 
#include <sys/stat.h> /*< mkdir() */
 
#include <sys/stat.h>
 
#include <stdlib.h>
 

	
 
int slavestatus = 0; // Ugh global vars
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 
int counter;
 

	
 
/* Parses arguments, skips if there are no args */
 
for(counter=0; counter<argc; counter++){
 
	if(strcmp(argv[counter], "-h") == 0) {
 
		fprintf(stderr, "Usage: distrenslave [option] <username> <emailaddr>\nStarts a distren slave\n\t-h\tshow this help\n\t-c\tregisters a user with [username] and [emailaddr] \n");
 
		return 2;
 
	}
 
}
 
	if(argc>1
 
		&& (strcmp("-c", argv[1]) == 0))
 

	
 
if(argc>1 && (strcmp("-c", argv[1]) == 0))
 
	{
 
		char *username;
 
		char *email;
 

	
 
		if(argc != 4)
 
		{
 
			fprintf(stderr, "I need more arguments!\n%d is not enough!\n Invoke 'distrenslave -c <username> <emailaddr> to register. \n Already registered? Edit your distrenslave.conf file!\n'", argc - 1);
 
			return 234;
 
		}
 

	
 
		username = argv[2];
 
		email = argv[3];
 

	
 
		if(!strchr(email, '@'))
 
		{
 
			fprintf(stderr, "I want to see an '@' in your email address!\n%s may be good enough for you, but I need more!\n", email);
 
			return 235;
 
		}
 
		if( register_user(username, email) == 1){
 
    if( register_user(username, email) == 1)
 
      {
 
		  // register_user generates a key, too */
 
                  curlpost(SYSCONFDIR "/distren.id_rsa","http://protofusion.org/distren/keys");
 
		  fprintf(stderr,"Registration successful. You may now invoke distrenslave with no arguments.\n");
 
		  return 0;
 
		}
 
		else{
 
    else
 
      {
 
			fprintf(stderr,"Please try again! :D\n");
 
			return 0;
 
		}
 
	}
 
/* End arg parser */
 

	
 
/* Option getter: Creates vars to grab stuff from conf, uses the options include to grab this data */
 
char *username;
 
char *datadir;
 
cfg_t * my_cfg;
 
cfg_opt_t myopts[] = {
 
		CFG_SIMPLE_STR("username", &username),
 
@@ -155,25 +154,24 @@ if(gotframe ==1)
 
    char *outdir;
 
    char *jobdatapath;
 

	
 
    fprintf(stderr, "Received %d in job %d, preparing to render...\n",framenum,jobnum);
 

	
 
    /**
 
       Variable Preparation
 
       @todo find where to free() all of these
 
    */
 
    _distren_asprintf(&jobdatapath, "job%d", jobnum);
 
    _distren_asprintf(&urltoTar, "http://protofusion.org/distren/stor/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://protofusion.org/distren/stor/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
 

	
 
      // Downloads the job tar if it isn't  present. @TODO: Delete old job data
 
      struct stat buffer;
 
      int fstatus = stat(pathtoJobfile, &buffer);
 

	
 
      // If stat'ing the jobfile shows that the jobfile doesn't exist, we'll download it.
 
      if(fstatus == -1){
 
              // Downloads the Tar @TODO: add progress bar
 
              if( curlget(urltoTar, pathtoTar) == 0){
0 comments (0 inline, 0 general)