TS-1314: Remove global TS_ARG_MAX usage
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/02506c08 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/02506c08 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/02506c08 Branch: refs/heads/master Commit: 02506c0852d7f515c794acd01ac54031e00668b2 Parents: c00f951 Author: James Peach <[email protected]> Authored: Thu Jun 28 20:54:28 2012 -0700 Committer: James Peach <[email protected]> Committed: Tue Jul 10 08:48:06 2012 -0700 ---------------------------------------------------------------------- lib/ts/ink_args.cc | 7 ++++++- lib/ts/ink_args.h | 1 + proxy/Main.cc | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/02506c08/lib/ts/ink_args.cc ---------------------------------------------------------------------- diff --git a/lib/ts/ink_args.cc b/lib/ts/ink_args.cc index a27bc63..c4ac0d6 100644 --- a/lib/ts/ink_args.cc +++ b/lib/ts/ink_args.cc @@ -83,7 +83,12 @@ process_arg(const ArgumentDescription * argument_descriptions, *(int64_t *) argument_descriptions[i].location = ink_atoi64(arg); break; case 'S': - ink_strlcpy((char *) argument_descriptions[i].location, arg, atoi(argument_descriptions[i].type + 1)); + if (argument_descriptions[i].type[1] == '*') { + char ** out = (char **)argument_descriptions[i].location; + *out = ats_strdup(arg); + } else { + ink_strlcpy((char *) argument_descriptions[i].location, arg, atoi(argument_descriptions[i].type + 1)); + } break; default: ink_fatal(1, (char *) "bad argument description"); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/02506c08/lib/ts/ink_args.h ---------------------------------------------------------------------- diff --git a/lib/ts/ink_args.h b/lib/ts/ink_args.h index 6686a93..7e19fab 100644 --- a/lib/ts/ink_args.h +++ b/lib/ts/ink_args.h @@ -49,6 +49,7 @@ struct ArgumentDescription "f" = set flag to FALSE (default is TRUE) "T" = toggle "S80" = read string, 80 chars max + "S*" = read unbounded string, allocating */ const char *description; const char *type; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/02506c08/proxy/Main.cc ---------------------------------------------------------------------- diff --git a/proxy/Main.cc b/proxy/Main.cc index d200e52..4bb6573 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -129,8 +129,7 @@ static int num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS; static int num_accept_threads = DEFAULT_NUM_ACCEPT_THREADS; static int num_task_threads = DEFAULT_NUM_TASK_THREADS; static int run_test_hook = 0; -static char http_accept_port_descriptor[TS_ARG_MAX + 1]; -#define TS_ARG_MAX_STR_FMT "S" TS_ARG_MAX_STR +static char * http_accept_port_descriptor; int http_accept_file_descriptor = NO_FD; static char core_file[255] = ""; static bool enable_core_file_p = false; // Enable core file dump? @@ -196,8 +195,8 @@ static const ArgumentDescription argument_descriptions[] = { "PROXY_ACCEPT_THREAD", NULL}, {"accept_till_done", 'b', "Accept Till Done", "T", &accept_till_done, "PROXY_ACCEPT_TILL_DONE", NULL}, - {"httpport", 'p', "Port descriptor for HTTP Accept", TS_ARG_MAX_STR_FMT, - http_accept_port_descriptor, "PROXY_HTTP_ACCEPT_PORT", NULL}, + {"httpport", 'p', "Port descriptor for HTTP Accept", "S*", + &http_accept_port_descriptor, "PROXY_HTTP_ACCEPT_PORT", NULL}, {"cluster_port", 'P', "Cluster Port Number", "I", &cluster_port_number, "PROXY_CLUSTER_PORT", NULL}, {"dprintf_level", 'o', "Debug output level", "I", &cmd_line_dprintf_level,
