What condition does the myapp_exec function run?

#include “asterisk.h”

#include “asterisk/file.h”
#include “asterisk/channel.h”
#include “asterisk/pbx.h”
#include “asterisk/module.h”
#include “asterisk/lock.h”
#include “asterisk/app.h”

ASTERISK_FILE_VERSION(FILE, “$Revision$”)

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>

static char *app = “helloapp”

static int myapp_exec(struct ast_channel *chan, const char *data)
{
int res=0;

	FILE *fp=NULL;
             int i=123;

	fp=fopen("netc.txt","w+");
	
	fprintf(fp,"%d\n",i);
	i=111;
	fprintf(fp,"%d\n",i);
	i=222;
	fprintf(fp,"%d\n",i);
	i=333;
	fprintf(fp,"%d\n",i);
	i=666;
	fprintf(fp,"%d\n",i);

	fclose(fp);     

  return  res;

}

static int load_module(void)
{

return ast_register_application_xml(app,myapp_exec);

}

static int unload_module(void)
{

return ast_unregister_application(app);

}

AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, “MY OWN helloapp”);

// end

What condition does the myapp_exec function run ?
or When call the myapp_exec function ?

Any help ?

It is executed when the ‘helloapp’ dialplan application is used in the dialplan.

Could you give an example to call the myapp_exec function ?

Any help ?

  1. This is a developer question, so off topic.

  2. There are dozens of examples of how to call applications available on the web and in the sample configuration file,together with the source code of at least all the built-in ones.

  3. This reads rather like a homework question.