Hello,

I am in the process of writing an application for my server. Compilation and 
installation run without a hitch. However at runtime the application provokes a 
"Segmentation fault (core dumped)" which shuts down my server. I am clueless as 
to what sends the error and even more so on how to fix it so any help would be 
appreciated. Below is a copy of my code.

Thanks in advance for any help.
Yukio


/***
* Send File (app_sendfile.c) by Yukio Tanaka (yu...@starcb.com)
*
 * Use at the end of the dialplan in a monitored call. This will:
*   a) Add call metadatas to the monitor file.
*   b) Send the file to the specified server using ssh.
*
 ******
* Version 0.1 - 2017.07
*
 * - Testing metadata hard writing for the moment
* /!\ At runtime encountering error: Segmentation fault (core dumped)
***/

#include "asterisk.h"
/*ASTERISK_FILE_VERSION(__FILE__, "$Revision$")*/

#include "asterisk/cdr.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/pbx.h"

/* Use id3v2 application to add an author metadata */
const char ID3V2_COMMAND[]= "id3v2 -a \"Algernopp Krieger\" ";

static int sendfile_exec(struct ast_channel *chan, const char *data)
{
   size_t fnameLength= strlen(pbx_builtin_getvar_helper(chan, 
"MIXMONITOR_FILENAME"));
   char fileName[fnameLength];
   strcpy(fileName, pbx_builtin_getvar_helper(chan, "MIXMONITOR_FILENAME"));
   char fullCommand[1]= "\0";
   strcat(fullCommand, ID3V2_COMMAND);
   strcat(fullCommand, fileName);
  system(fullCommand);

   return 1;
}

static int load_module(void)
{
  ast_register_application("SendFile", sendfile_exec, "Send a recorded call to 
a server.", "Some description.");


  return AST_MODULE_LOAD_SUCCESS;
}

static int unload_module(void)
{
  ast_cdr_unregister("SendFile");
  return 0;
}

AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "SendFile")
-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to