Write an app to Asterisk for CLI call

Source: Internet
Author: User

Environment:Centos6.2 + asterisk 1.8.7.1

1. Add source files

CopyApp_verbose.cIsApp_testapp.c

CopyApp_verbose.exportsIsApp_testapp.exports

It mainly modifies some identifiers and does not cause compilation errors. The main modifications I made are listed here.

1Add header files

 
# Include"Asterisk/CLI. H"

2Modify Variables

 
Static Char* App_testapp ="Testapp";Static Char* App_testapplog ="Testapplog";

3InLoad_module.

Res | = ast_register_application_xml (app_testapp, testapp_exec );

4Add function

 Static IntTestapp_exec (StructAst_channel * Chan,Const Char* Data)  { Ast_verb (2,"Testapp_exec:% S \ r \ n", Data );  Return0; } 

5, AddCLICall Interface

RegisterCommand:E-> command ="Testapp {print }";

CallCommand:

If (! Strcasecmp (a-> argv [ 1 ], " print " ) {

Testapp_exec (Chan, a-> argv [2]);}

6InUnload_moduleFor anti-registration

Res = ast_unregister_application (app_testapp );

2. Compile and install

Asterisk-Rx "core stop now" & make install & asterisk-rvvvvvvvvvvvvv 

Iii. Test

Run asterisk-rvvvvvvvv to enter CLI Mode

Input:Core show help testapp

Will output help document

Input:Core show help testapp "Something To test! "

Will output: Something to test! 

Okay, that's all. I hope it will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.