sfree (fm);
} /* void fs_match_free */
-static int fs_config_add_match_dstype (int *dstype_ret, oconfig_item_t *ci)
+static void fs_command_free (fs_command_t *fc)
{
- DEBUG ("freeswitch plugin: in fs_config_add_match_dstype");
+ if (fc == NULL)
+ return;
+ sfree (fc->line);
+ sfree (fc->instance);
+ sfree (fc->buffer);
+ fs_match_free (fc->matches);
+ fs_command_free (fc->next);
+ sfree (fc);
+} /* void fs_command_free */
+
+static int fs_config_add_match_dstype (int *dstype_ret, oconfig_item_t *ci)
+{
int dstype;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
static int fs_config_add_match (fs_command_t *fs_command, oconfig_item_t *ci)
{
- DEBUG ("freeswitch plugin: in fs_config_add_match");
-
fs_match_t *fs_match;
int status;
int i;
static int fs_config_add_command (oconfig_item_t *ci)
{
- DEBUG ("freeswitch plugin: in fs_config_add_command");
-
fs_command_t *command;
int status;
int i;
command->line = NULL;
command->line = strdup (ci->values[0].value.string);
+
if (command->line == NULL)
{
ERROR ("freeswitch plugin: strdup failed.");
break;
}
+ if (status != 0)
+ {
+ fs_command_free (command);
+ return (status);
+ }
+
/* Add the new command to the linked list */
if (fs_commands_g == NULL)
fs_commands_g = command;
int status;
int i;
- DEBUG ("freeswitch plugin: reading config");
-
success = 0;
errors = 0;
} /* int fs_complex_config */
static void fs_submit (const fs_command_t *fc,
- const fs_match_t *fm, const cu_match_value_t *fmv)
+ const fs_match_t *fm, const cu_match_value_t *mv)
{
DEBUG ("freeswitch plugin: in fs_submit");
DEBUG ("fm->type");
DEBUG (fm->type);
- DEBUG ("fmv->value");
- DEBUG (fmv->value);
+ DEBUG ("mv->value");
+ //DEBUG (mv->value);
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = fmv->value;
+ values[0] = mv->value;
vl.values = values;
vl.values_len = 1;
static int fs_read_command (fs_command_t *fc)
{
- DEBUG ("freeswitch plugin: in fs_read_command");
-
fs_match_t *fm;
int status;
/* can't the following be done nicer ? */
char *line;
- line = (char *) malloc (strlen(fc->line)+2);
- snprintf(line, strlen(fc->line)+2, "%s\n\n", fc->line);
+ line = (char *) malloc (strlen(fc->line)+3);
+ snprintf(line, strlen(fc->line)+3, "%s\n\n", fc->line);
esl_send_recv(&esl_handle, line);
fc->buffer_fill = 0;
DEBUG ("freeswitch plugin: output from esl (truncated):\n%s\n\n", esl_handle.last_sr_event->body);
sfree(fc->buffer);
fc->buffer = strdup(esl_handle.last_sr_event->body);
- fc->buffer_fill = 1; // ??
+ fc->buffer_size = strlen(fc->buffer);
+ fc->buffer_fill = 1;
}
for (fm = fc->matches; fm != NULL; fm = fm->next)
{
fs_command_t *fc;
- DEBUG ("freeswitch plugin: read poll");
-
for (fc = fs_commands_g; fc != NULL; fc = fc->next)
fs_read_command (fc);
{
DEBUG ("freeswitch plugin: disconnecting");
esl_disconnect(&esl_handle);
+ fs_command_free (fs_commands_g);
+ fs_commands_g = NULL;
return (0);
} /* int fs_shutdown */