]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
forbrun: Support --serverid command line switch
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 22 Feb 2011 11:41:22 +0000 (12:41 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 22 Feb 2011 11:44:48 +0000 (12:44 +0100)
src/forbrun/forbrun.c

index 2319cf0ef2f3543ff335538b998e2a89e057010b..81e815471104f48094a90e9b01831842f692bbc7 100644 (file)
 #include <dlfcn.h>
 #include <forb/forb-internal.h>
 #include <pthread.h>
+#include <forb/server_id.h>
 
 static struct option long_opts[] = {
     { "daemon",   optional_argument, NULL, 'd' },
     { "id",      required_argument, NULL, 'i' },
     { "loglevel", required_argument, NULL, 'l' },
     { "port",            required_argument, NULL, 'p' },
+    { "serverid", required_argument, NULL, 's' },
     { 0, 0, 0, 0}
 };
 
@@ -27,6 +29,7 @@ usage(void)
        printf("  -i, --id <textual orb id>\n");
        printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
        printf("  -p, --port <number>       listen on a fixed port number\n");
+       printf("  -s, --serverid <serverid> fixed server id of this server\n");
 }
 
 int print_log_domain(ul_log_domain_t *domain, void *context)
@@ -61,6 +64,7 @@ int main(int argc, char *argv[])
        bool opt_daemon = false;
        char *opt_pidfile = NULL;
        int i, ret;
+       forb_server_id *server_id;
        forb_init_attr_t attr = {
                .orb_id = "",
                .peer_discovery_callback = NULL, /* TODO */
@@ -73,7 +77,7 @@ int main(int argc, char *argv[])
        };
        int  opt;
 
-       while ((opt = getopt_long(argc, argv, "d::hi:l:p:", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "d::hi:l:p:s:", &long_opts[0], NULL)) != EOF) {
                switch (opt) {
                        case 'l':
                                if (*optarg == '?') {
@@ -101,6 +105,11 @@ int main(int argc, char *argv[])
                        case 'p':
                                attr.fixed_tcp_port = atol(optarg);
                                break;
+                       case 's':
+                               server_id = forb_server_id_from_string(&attr.fixed_server_id, optarg);
+                               if (!server_id)
+                                       error(1, 0, "Invalid server id: '%s'\n", optarg);
+                               break;
                }
        }