From e14b8e1e04fe911f3393ae1f2f8e9163a1e02765 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 27 Apr 2024 14:36:35 +0900 Subject: [PATCH] modify main-s.c to act as both server and client --- bin/main-s.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/bin/main-s.c b/bin/main-s.c index 85b57f5..860082b 100644 --- a/bin/main-s.c +++ b/bin/main-s.c @@ -498,7 +498,7 @@ static int handle_incpath (hcl_server_t* server, const char* str) #define MIN_WORKER_STACK_SIZE 512000ul #define MIN_ACTOR_HEAP_SIZE 512000ul -int main (int argc, char* argv[]) +int server_main (const char* outer, int argc, char* argv[]) { hcl_bci_t c; static hcl_bopt_lng_t lopt[] = @@ -674,3 +674,36 @@ oops: if (server) hcl_server_close (server); return -1; } + +/* -------------------------------------------------------------- */ + +static void print_main_usage (const char* argv0) +{ + fprintf (stderr, "USAGE: %s server|client\n"); +} + +int main (int argc, char* argv[]) +{ + int n; + + if (argc < 2) + { + print_main_usage (argv[0]); + n = -1; + } + else if (strcmp(argv[1], "server") == 0) + { + n = server_main(argv[0], argc -1, &argv[1]); + } + else if (strcmp(argv[1], "client") == 0) + { + n = client_main(argv[0], argc -1, &argv[1]); + } + else + { + print_main_usage (argv[0]); + n = -1; + } + + return n; +}