X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela.c;h=737766aa3cc8818c94b760826d7ff2e37b8b2136;hb=a6e0eb4c5e06bb6107acf40eb9f6a89e691d585e;hp=3262aee68c5cd5a9e3f72bf6cb37e0cdab4b420c;hpb=70e0a8eeafcf4beee40306b3a3e6c0bc4fafd7bc;p=gacela.git diff --git a/src/gacela.c b/src/gacela.c index 3262aee..737766a 100644 --- a/src/gacela.c +++ b/src/gacela.c @@ -15,6 +15,8 @@ along with this program. If not, see . */ +#include +#include #include #include #include @@ -231,20 +233,40 @@ main (int argc, char *argv[]) { char *arg; int mode = 0; // shell: 1, server: 2, client: 3 - int port = 2; + char *host; + int port = 0; int i; - for (i = 1; i < argc; i++) + // Checking arguments + for (i = 1; i < argc; i++) { if (strcmp (argv[i], "--shell-mode") == 0) mode = 1; else if (strncmp (argv[i], "--server", 8) == 0) { - arg = strdup (argv[i]); - port = 1234; + mode = 2; + arg = strtok (argv[i], "="); + arg = strtok (NULL, "="); + if (arg != NULL) + port = atoi (arg); + } + else if (strncmp (argv[i], "--client", 8) == 0) { + mode = 3; + arg = strtok (argv[i], "="); + arg = strtok (NULL, "="); + if (arg != NULL) { + host = strtok (arg, ":"); + arg = strtok (NULL, ":"); + if (arg != NULL) + port = atoi (arg); + } + } + } if (mode == 1) start_single (dirname (argv[0])); - else - printf ("Puerto: %d\n", port); + else if (mode == 2 && port != 0) + start_server (dirname (argv[0]), port); + else if (mode == 3 && port != 0) + start_client (host, port); /* if (fork () == 0) start_server ();