]> git.sesse.net Git - jam/commitdiff
Start parsing options.
authorsgunderson@bigfoot.com <>
Wed, 31 Jan 2007 17:20:22 +0000 (18:20 +0100)
committersgunderson@bigfoot.com <>
Wed, 31 Jan 2007 17:20:22 +0000 (18:20 +0100)
jam.c

diff --git a/jam.c b/jam.c
index b4330f7d4e20cb8d50106b91bba6719f5410e370..9f9a10dbe7de611899f8fc9ce9bbe7c93d7ab3e9 100644 (file)
--- a/jam.c
+++ b/jam.c
@@ -1,10 +1,40 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <getopt.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 
+const static struct option longopts[] = {
+       { "destination-file", required_argument, NULL, 'd' },
+       { NULL, 0, NULL, 0 }
+};
+
+void read_destination_list(char *filename)
+{
+       
+}
+
+void parse_options(int argc, char **argv)
+{
+       int option_index = 0;
+
+       for ( ;; ) {
+               int c = getopt_long(argc, argv, "d:", longopts, &option_index); 
+               switch (c) {
+               case 'd':
+                       read_destination_list(optarg);
+                       break;
+               case -1:
+                       return;       // end of argument list
+               default:
+                       fprintf(stderr, "Invalid option\n");
+                       exit(1);
+               }
+       }
+}
+
 void *receiver_worker(void *arg)
 {
        int sock = (int)arg;
@@ -64,9 +94,12 @@ int get_server_socket(unsigned short port)
        return server_sock;
 }
 
-int main()
+int main(int argc, char **argv)
 {
-       int server_sock = get_server_socket(2007);
+       int server_sock;
+
+       parse_options(argc, argv);
+       server_sock = get_server_socket(2007);
 
        // FIXME: fire off sender workers here