From: Florian Forster Date: Tue, 21 Jul 2009 06:45:25 +0000 (+0200) Subject: freeswitch plugin: Some coding style changes. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=refs%2Fheads%2Fldr%2Ffreeswitch;p=collectd.git freeswitch plugin: Some coding style changes. --- diff --git a/src/freeswitch.c b/src/freeswitch.c index b4e40ea0..83097899 100644 --- a/src/freeswitch.c +++ b/src/freeswitch.c @@ -67,11 +67,11 @@ struct fs_command_s; typedef struct fs_command_s fs_command_t; struct fs_command_s { - char *line; // "api sofia status profile res-public" - char *instance; // "profile-sofia-res-public" - char *buffer; // - size_t buffer_size; // strlen(*buffer)+3 - size_t buffer_fill; // 0 or 1 + char *line; /* "api sofia status profile res-public" */ + char *instance; /* "profile-sofia-res-public" */ + char *buffer; /* */ + size_t buffer_size; /* strlen(*buffer)+3 */ + size_t buffer_fill; /* 0 or 1 */ fs_match_t *matches; fs_command_t *next; }; @@ -83,7 +83,7 @@ static char *fs_port = NULL; static char *fs_pass = NULL; static esl_handle_t esl_handle = {{0}}; -// static int thread_running = 0; // for when subscribing to esl events +/* static int thread_running = 0; for when subscribing to esl events */ /* * Private functions @@ -249,7 +249,7 @@ static int fs_config_add_match (fs_command_t *fs_command, oconfig_item_t *ci) } /* while (status == 0) */ if (status != 0) - return (status); + return (status); fs_match->match = match_create_simple (fs_match->regex, fs_match->dstype); if (fs_match->match == NULL) @@ -361,19 +361,24 @@ static int fs_complex_config (oconfig_item_t *ci) { oconfig_item_t *child = ci->children + i; + /* FIXME: Don't simply dereference the + * child->values[0].value.string pointer! */ if (strcasecmp ("Host", child->key) == 0) { - if (fs_host != NULL) free (fs_host); + if (fs_host != NULL) + free (fs_host); fs_host = strdup(child->values[0].value.string); } else if (strcasecmp ("Port", child->key) == 0) { - if (fs_port != NULL) free (fs_port); + if (fs_port != NULL) + free (fs_port); fs_port = strdup(child->values[0].value.string); } else if (strcasecmp ("Password", child->key) == 0) { - if (fs_pass != NULL) free (fs_pass); + if (fs_pass != NULL) + free (fs_pass); fs_pass = strdup(child->values[0].value.string); } else if (strcasecmp ("Command", child->key) == 0) @@ -384,9 +389,11 @@ static int fs_complex_config (oconfig_item_t *ci) else errors++; } + /* FIXME: This plugin should have a `Interval' option. */ else { - WARNING ("freeswitch plugin: Option '%s' not allowed here.", child->key); + WARNING ("freeswitch plugin: Option '%s' not allowed here.", + child->key); errors++; } } @@ -476,21 +483,23 @@ static int fs_read (void) return (0); } /* int fs_read */ -/* +#if 0 static void *msg_thread_run(esl_thread_t *me, void *obj) { esl_handle_t *esl_handle = (esl_handle_t *) obj; thread_running = 1; - // Maybe do some more in this loop later, like receive subscribed events, - // and create statistics of them - // see fs_cli.c function static void *msg_thread_run(), around line 198 + /* Maybe do some more in this loop later, like receive subscribed + * events, and create statistics of them see fs_cli.c function static + * void *msg_thread_run(), around line 198 */ while (thread_running && esl_handle->connected) { esl_status_t status = esl_recv_event_timed(esl_handle, 10, 1, NULL); if (status == ESL_FAIL) { - //DEBUG ("Disconnected [%s]\n", ESL_LOG_WARNING); // todo fixit + /* TODO FIXME + DEBUG ("Disconnected [%s]\n", ESL_LOG_WARNING); + */ DEBUG ("Disconnected [%s]\n", "ESL_LOG_WARNING"); thread_running = 0; } @@ -500,6 +509,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj) thread_running = 0; return (NULL); } */ /* void *msg_thread_run */ +#endif static int fs_init (void) { @@ -509,15 +519,17 @@ static int fs_init (void) if (fs_pass == NULL) fs_pass = FS_DEF_PASS; /* Connect to FreeSWITCH over ESL */ - DEBUG ("freeswitch plugin: making ESL connection to %s %s %s\n", fs_host, fs_port, fs_pass); + DEBUG ("freeswitch plugin: making ESL connection to %s %s %s\n", + fs_host, fs_port, fs_pass); if (esl_connect(&esl_handle, fs_host, atoi(fs_port), fs_pass)) { - ERROR ("freeswitch plugin: connection failed [%s]", esl_handle.err); + ERROR ("freeswitch plugin: connection failed [%s]", + esl_handle.err); return (-1); } /* Start a seperate thread for incoming events here */ - //esl_thread_create_detached(msg_thread_run, &esl_handle); + /* esl_thread_create_detached(msg_thread_run, &esl_handle); */ return(0); } /* int fs_init */ @@ -525,7 +537,8 @@ static int fs_init (void) static int fs_shutdown (void) { DEBUG ("freeswitch plugin: disconnecting"); - if (esl_handle.connected) esl_disconnect(&esl_handle); + if (esl_handle.connected) + esl_disconnect(&esl_handle); fs_command_free (fs_commands_g); fs_commands_g = NULL; return (0);