Files @ b4e8e519214d
Branch filter:

Location: DistRen/src/client/distren.c - annotation

binki
added libcurl to DISTLIBS
7f09dcee58f4
86e255a6e35e
7f09dcee58f4
aaedffb71a83
aaedffb71a83
aaedffb71a83
7f09dcee58f4
7f09dcee58f4
7f09dcee58f4
aaedffb71a83
aaedffb71a83
7f09dcee58f4
7f09dcee58f4
7f09dcee58f4
aaedffb71a83
7f09dcee58f4
aaedffb71a83
7f09dcee58f4
7f09dcee58f4
2aa1075cee71
d6e050f635ca
d6e050f635ca
d6e050f635ca
2aa1075cee71
2aa1075cee71
2aa1075cee71
2aa1075cee71
2e10900d91d9
2aa1075cee71
2aa1075cee71
2aa1075cee71
3b998819751e
3b998819751e
d643c8d1d8a8
d643c8d1d8a8
2b98f7dd04fc
eee9474aa604
0a8f68f3d17f
32011f71cbbb
627c64f1fd14
627c64f1fd14
627c64f1fd14
d6e050f635ca
d6e050f635ca
2b98f7dd04fc
2b98f7dd04fc
60d3bb17d7d3
03937b2315eb
2b98f7dd04fc
2b98f7dd04fc
60d3bb17d7d3
60d3bb17d7d3
60d3bb17d7d3
2b98f7dd04fc
2b98f7dd04fc
72489034987c
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
d6e050f635ca
d6e050f635ca
d6e050f635ca
d6e050f635ca
2b98f7dd04fc
2b98f7dd04fc
d6e050f635ca
d6e050f635ca
d6e050f635ca
d6e050f635ca
d6e050f635ca
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
03937b2315eb
2b98f7dd04fc
d6e050f635ca
d6e050f635ca
d6e050f635ca
d6e050f635ca
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
2b98f7dd04fc
ad5012647934
ad5012647934
32011f71cbbb
2b98f7dd04fc
03937b2315eb
815127c2345a
815127c2345a
815127c2345a
815127c2345a
815127c2345a
03937b2315eb
815127c2345a
815127c2345a
815127c2345a
815127c2345a
03937b2315eb
03937b2315eb
815127c2345a
815127c2345a
815127c2345a
815127c2345a
815127c2345a
60d3bb17d7d3
3fcf567f92be
815127c2345a
815127c2345a
815127c2345a
815127c2345a
815127c2345a
3fcf567f92be
d6e050f635ca
60d3bb17d7d3
60d3bb17d7d3
3f7a5dbb61b6
03937b2315eb
03937b2315eb
03937b2315eb
94aafba083ee
94aafba083ee
94aafba083ee
94aafba083ee
94aafba083ee
94aafba083ee
/*
  Copyright 2009 Nathan Phillip Brink, Ethan Zonca, Matthew Orlando

  This file is a part of DistRen.

  DistRen is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (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/>.
*/


/* 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
 * the user must enter on the site. Apache should be running mod_peruser for safety, and I'm
 * thinking zserver2 for web serving for convenience...
 */


#include <distren.h>

#include <stdio.h> /* sprintf, printf */
#include <stdlib.h> /* malloc, free */
#include <unistd.h> /* getopt */
#include <confuse.h>
#include <string.h> // for strcat


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


  char *input;
  char *output;
  char *jobid;

  char curopt;

  distren_t distren;
  distren_job_t distren_job;

  input = NULL;
  output = NULL;

  while(-1 != (curopt = getopt(argc, argv, "i:o:h")))
    {
      if(curopt == ':')
	{
	  fprintf(stderr, "-%c: is missing an argument\n", optopt);
	  return 1;
	}
      else if(curopt == '?')
	{
	  fprintf(stderr, "-%c: invalid option specified\n", optopt);
	  return 1;
	}
      else if(curopt == 'h')
	{
	  fprintf(stderr, "Usage: %s -i <inputfile> -o <outputfile>\n", argv[0]);
	  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
	  
	}
      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?
	 
	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
  
  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);

  if(distren_job_retrieve_file(distren_job, output))
    {
      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);



 return 0;
};