diff --git a/src/client/distren.c b/src/client/distren.c --- a/src/client/distren.c +++ b/src/client/distren.c @@ -40,12 +40,15 @@ int main(int argc, char *argv[]) { - + int doLogin = 0; char *input; char *output; char *jobid; + char *username; + char *password; + char curopt; distren_t distren; @@ -54,7 +57,7 @@ int main(int argc, char *argv[]) input = NULL; output = NULL; - while(-1 != (curopt = getopt(argc, argv, "i:o:h"))) + while(-1 != (curopt = getopt(argc, argv, "i:o:u:p:h"))) { if(curopt == ':') { @@ -68,7 +71,7 @@ int main(int argc, char *argv[]) } else if(curopt == 'h') { - fprintf(stderr, "Usage: %s -i -o \n", argv[0]); + fprintf(stderr, "Usage: %s -i -o [ -u -p ]\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"); @@ -77,6 +80,14 @@ int main(int argc, char *argv[]) // options help page } + else if(curopt == 'u') { + doLogin = 1; + username = strdup(optarg); + } + else if(curopt == 'p') { + doLogin = 1; + password = strdup(optarg); + } else if(curopt == 'i') // TODO: is strdup good or bad? what about @@ -91,7 +102,14 @@ int main(int argc, char *argv[]) // give this error after the general arguments parsing so that // the general help from options_init can have effect - + if(!username || !password){ + fprintf(stderr, "Username and password must be specified"); + return 1; + } + if(doLogin == 1){ + fprintf(stderr, "Trying username and password on server..."); + return 0; + } if(!input || !output) {