New application, new function

Hello,

I add new application, new function.

new appliaction
app_cnTest.c source code

/*** MODULEINFO
	<support_level>extended</support_level>
 ***/

#include "asterisk.h"

ASTERISK_FILE_VERSION(__FILE__, "$Revision: 144571 $")

#include "asterisk/config.h"
#include "asterisk/module.h"


#include "asterisk/cnTemp.h"


static char *app = "cnTest";


static int cnTest_exec(struct ast_channel *chan, void *data)
{
	ast_log(LOG_NOTICE,"Sample cnTest_exec\n");
	ast_stream_and_wait((struct ast_channel *)chan, "beep", AST_DIGIT_ANY);
	cn_Play(chan);
	return 0;
}

static int reload(void)
{
	return 0;
}

static int unload_module(void)
{
	int res;

	res = ast_unregister_application(app);
	return res;	
}

static int load_module(void)
{
	return ast_register_application_xml(app, cnTest_exec);
}

AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "CN TEST Application",
		.load = load_module,
		.unload = unload_module,
		.reload = reload,
	       

new header file code

cnTemp.h


#ifndef _CN_TEMP_H_
#define _CN_TEMP_H_

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif


#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"

int cnPlay(struct ast_channel * chan);

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif

new source code


/*** MODULEINFO
	<support_level>extended</support_level>
 ***/


#include "asterisk.h"

ASTERISK_FILE_VERSION(__FILE__, "$Revision: 144572 $")

#include "asterisk/cnTemp.h"



int cnPlay(struct ast_channel * chan)
{

	char ast[100];
	strcpy(ast,"cnPlay\n");
	ast_log(LOG_NOTICE,ast);
	ast_stream_and_wait((struct ast_channel *)chan, "beep", AST_DIGIT_ANY);
	return 0;
	
}

extensions.conf is

exten => 1001,1,Ringing()
exten => 1001,2,Answer()
exten => 1001,3,cnTest()
exten => 1001,4,Hangup()

error message

-- Executing [1001@CNSAMPLE:1] Ringing("SIP/3001-00000000", "") in new stack
    -- Executing [1001@CNSAMPLE:2] Answer("SIP/3001-00000000", "") in new stack
[Jan 29 15:44:30] WARNING[3271][C-00000000]: pbx.c:4864 pbx_extension_helper: No application 'cnTest' for extension (CNSAMPLE, 1001, 3)
  == Spawn extension (CNSAMPLE, 1001, 3) exited non-zero on 'SIP/3001-00000000'

if application code is

/*** MODULEINFO
	<support_level>extended</support_level>
 ***/

#include "asterisk.h"

ASTERISK_FILE_VERSION(__FILE__, "$Revision: 144571 $")

#include "asterisk/config.h"
#include "asterisk/module.h"

static char *app = "cnTest";


static int cnTest_exec(struct ast_channel *chan, void *data)
{
	ast_log(LOG_NOTICE,"Sample cnTest_exec\n");
	ast_stream_and_wait((struct ast_channel *)chan, "beep", AST_DIGIT_ANY);
	return 0;
}

static int reload(void)
{
	return 0;
}

static int unload_module(void)
{
	int res;

	res = ast_unregister_application(app);
	return res;	
}

static int load_module(void)
{
	return ast_register_application_xml(app, cnTest_exec);
}

AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "CN TEST Application",
		.load = load_module,
		.unload = unload_module,
		.reload = reload,
	       

message is

    -- Executing [1001@CNSAMPLE:1] Ringing("SIP/3001-00000000", "") in new stack
    -- Executing [1001@CNSAMPLE:2] Answer("SIP/3001-00000000", "") in new stack
    -- Executing [1001@CNSAMPLE:3] cnTest("SIP/3001-00000000", "") in new stack
[Jan 29 15:42:47] NOTICE[1298][C-00000000]: app_cnTest.c:21 cnTest_exec: Sample cnTest_exec
[Jan 29 15:42:47] NOTICE[1298][C-00000000]: file.c:1620 ast_stream_and_wait: ast_stream_and_wait
    -- <SIP/3001-00000000> Playing 'beep.gsm' (language 'en')
    -- Executing [1001@CNSAMPLE:4] Hangup("SIP/3001-00000000", "") in new stack
  == Spawn extension (CNSAMPLE, 1001, 4) exited non-zero on 'SIP/3001-00000000'

asterisk version is 12.0

Please see the sticky posting about developer questions.