From 19cce523f7b5ff3f919a266146f55fafc901fb4a Mon Sep 17 00:00:00 2001 From: zfl9 Date: Fri, 30 Aug 2019 21:46:48 +0800 Subject: update dns2tcp.c --- dns2tcp.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dns2tcp.c b/dns2tcp.c index 7267f69..50a5f14 100644 --- a/dns2tcp.c +++ b/dns2tcp.c @@ -3,6 +3,8 @@ #include #undef _GNU_SOURCE +static bool g_verbose = false; + static void print_command_help(void) { printf("usage: dns2tcp <-L LISTEN_ADDR> <-R REMOTE_ADDR> [-vVh]\n" " -L udp listen address, it is required\n" @@ -14,6 +16,29 @@ static void print_command_help(void) { ); } +static void parse_command_args(int argc, char *argv[]) { + opterr = 0; + int shortopt = -1; + char *bindaddr_optarg = NULL; + char *servaddr_optarg = NULL; + const char *optstr = ":L:R:vVh"; + while ((shortopt = getopt(argc, argv, optstr)) != -1) { + switch (shortopt) { + case 'L': + bindaddr_optarg = optarg; + break; + case 'R': + servaddr_optarg = optarg; + case 'v': + g_verbose = true; + } + } + return; +PRINT_HELP_AND_EXIT: + print_command_help(); + exit(1); +} + int main() { print_command_help(); return 0; -- cgit v1.2.3