diff --git a/c/pong.c b/c/pong.c index fb0e569..d5fd80e 100644 --- a/c/pong.c +++ b/c/pong.c @@ -17,7 +17,9 @@ int err(void *ctx, char *msg) { return 1; } -int main(void) { +int main(int argc, char **argv, char** env) { + argc = argc; + argv = argv; int ret = 0; int servicefd = 0; char message[MAX_MSG_SIZE]; @@ -29,6 +31,15 @@ int main(void) { int newfd = 0; void *ctx = NULL; + char *service = SERVICE; + size_t i = 0; + while(env[i] != NULL) { + if(0 == memcmp(env[i], "SERVICE", strlen("SERVICE"))) { + service = env[i] + strlen("SERVICE") + 1; + } + i++; + } + printf ("Init context.\n"); ret = ipc_context_init (&ctx); @@ -37,8 +48,8 @@ int main(void) { return 1; } - printf ("Connect to a 'pong' service.\n"); - ret = ipc_connect_service (ctx, &servicefd, SERVICE, SERVICE_LEN); + printf ("Connect to a '%s' service.\n", service); + ret = ipc_connect_service (ctx, &servicefd, service, strlen(service)); if (ret != 0) { return err(ctx, "Cannot connect to a service.");