-static int parse_service_name (const char *service_name)
-{
- struct addrinfo *ai_list;
- struct addrinfo *ai_ptr;
- struct addrinfo ai_hints;
- int status;
- int service_number;
-
- ai_list = NULL;
- memset (&ai_hints, 0, sizeof (ai_hints));
- ai_hints.ai_family = AF_UNSPEC;
-
- status = getaddrinfo (/* node = */ NULL, service_name,
- &ai_hints, &ai_list);
- if (status != 0)
- {
- ERROR ("tokyotyrant plugin: getaddrinfo failed: %s",
- gai_strerror (status));
- return (-1);
- }
-
- service_number = -1;
- for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
- {
- if (ai_ptr->ai_family == AF_INET)
- {
- struct sockaddr_in *sa;
-
- sa = (void *) ai_ptr->ai_addr;
- service_number = (int) ntohs (sa->sin_port);
- }
- else if (ai_ptr->ai_family == AF_INET6)
- {
- struct sockaddr_in6 *sa;
-
- sa = (void *) ai_ptr->ai_addr;
- service_number = (int) ntohs (sa->sin6_port);
- }
-
- if ((service_number > 0) && (service_number <= 65535))
- break;
- }
-
- freeaddrinfo (ai_list);
-
- if ((service_number > 0) && (service_number <= 65535))
- return (service_number);
- return (-1);
-} /* int parse_service_name */
-
-static int tt_config (const char *key, const char *value)
-{
- if (strcasecmp ("Host", key) == 0)
- {
- char *temp;
-
- temp = strdup (value);
- if (temp == NULL)
- {
- ERROR("tokyotyrant plugin: Host strdup failed.");
- return (1);
- }
- sfree (config_host);
- config_host = temp;
- }
- else if (strcasecmp ("Port", key) == 0)
- {
- char *temp;
-
- temp = strdup (value);
- if (temp == NULL)
- {
- ERROR("tokyotyrant plugin: Port strdup failed.");
- return (1);
- }
- sfree (config_port);
- config_port = temp;
- }
- else
- {
- ERROR ("tokyotyrant plugin: error: unrecognized configuration key %s", key);
- return (-1);
- }
-
- return (0);
+static int tt_config(const char *key, const char *value) {
+ if (strcasecmp("Host", key) == 0) {
+ char *temp;
+
+ temp = strdup(value);
+ if (temp == NULL) {
+ ERROR("tokyotyrant plugin: Host strdup failed.");
+ return (1);
+ }
+ sfree(config_host);
+ config_host = temp;
+ } else if (strcasecmp("Port", key) == 0) {
+ char *temp;
+
+ temp = strdup(value);
+ if (temp == NULL) {
+ ERROR("tokyotyrant plugin: Port strdup failed.");
+ return (1);
+ }
+ sfree(config_port);
+ config_port = temp;
+ } else {
+ ERROR("tokyotyrant plugin: error: unrecognized configuration key %s", key);
+ return (-1);
+ }
+
+ return (0);