TS-2457 Protocol.c: change usage of atoi to strtol.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/47982165 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/47982165 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/47982165 Branch: refs/heads/5.0.x Commit: 47982165a1f1beb0bb3d8145fcdf8447f59dbcad Parents: a407f5f Author: Radim Kolar <h...@sendmail.cz> Authored: Tue Dec 31 13:43:27 2013 -0700 Committer: Leif Hedstrom <zw...@apache.org> Committed: Tue Dec 31 13:43:27 2013 -0700 ---------------------------------------------------------------------- example/protocol/Protocol.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47982165/example/protocol/Protocol.c ---------------------------------------------------------------------- diff --git a/example/protocol/Protocol.c b/example/protocol/Protocol.c index 5d71430..1258294 100644 --- a/example/protocol/Protocol.c +++ b/example/protocol/Protocol.c @@ -104,6 +104,7 @@ void TSPluginInit(int argc, const char *argv[]) { TSPluginRegistrationInfo info; + char *end; info.plugin_name = "output-header"; info.vendor_name = "MyCompany"; @@ -124,8 +125,9 @@ TSPluginInit(int argc, const char *argv[]) printf("[protocol_plugin] Usage: protocol.so accept_port server_port\n"); printf("[protocol_plugin] Wrong arguments. Using deafult ports.\n"); } else { - if (!isnan(atoi(argv[1]))) { - accept_port = atoi(argv[1]); + strtol(argv[1], &end, 10); + if (*end == '\0') { + accept_port = strtol(argv[1], &end, 10); TSDebug("protocol", "using accept_port %d", accept_port); printf("[protocol_plugin] using accept_port %d\n", accept_port); } else { @@ -133,8 +135,9 @@ TSPluginInit(int argc, const char *argv[]) printf("Using deafult port %d\n", accept_port); } - if (!isnan(atoi(argv[2]))) { - server_port = atoi(argv[2]); + strtol(argv[2], &end, 10); + if (*end == '\0') { + server_port = strtol(argv[2], &end, 10); TSDebug("protocol", "using server_port %d", server_port); printf("[protocol_plugin] using server_port %d\n", server_port); } else {