X-Git-Url: https://git.ucc.asn.au/?p=matches%2Fswarm.git;a=blobdiff_plain;f=src%2Foptions.c;h=ddd2ddc1e612a2f40af186c9f319565e119a9ad3;hp=6ef6119cfbcf3baf63706f75d6b6fcfe4b5a2ba4;hb=4e2127d6576cea3f54c619d0bb20a22006567206;hpb=3237855ae8604fb19d058eef2797c850b37f5596 diff --git a/src/options.c b/src/options.c index 6ef6119..ddd2ddc 100644 --- a/src/options.c +++ b/src/options.c @@ -35,6 +35,8 @@ void close_out() fclose(stdout); } +char name[BUFSIZ]; + void Initialise(int argc, char ** argv, Options * o) { srand(time(NULL)); @@ -44,9 +46,7 @@ void Initialise(int argc, char ** argv, Options * o) o->logfile = NULL; o->outfile = NULL; o->verbosity = 2; - o->port = 4000 + rand() % 1000; - o->slavefile = "slaves.swarm"; - o->dummy_shell = false; + o->port = 0; o->append = NULL; o->prepend = NULL; o->end = "\a\a\a"; @@ -54,7 +54,9 @@ void Initialise(int argc, char ** argv, Options * o) o->daemon = false; o->encrypt = true; o->interactive = true; - + + gethostname(name, sizeof(name)); + o->name = strdup(name); o->master_pid = getpid(); @@ -140,11 +142,17 @@ void ParseArguments(int argc, char ** argv, Options * o) error("ParseArguments", "No argument following %s switch", argv[i]); o->nCPU = atoi(argv[++i]); } - else if (argv[i][1] == 'm') + else if (argv[i][1] == 'r') { if (i >= argc-1) error("ParseArguments", "No argument following %s switch", argv[i]); o->master_addr = argv[++i]; + char * p = strstr(o->master_addr, ":"); + if (p != NULL) + { + *(p-1) = '\0'; + o->port = atoi(p); + } } else if (argv[i][1] == 'c') {