日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

给asterisk写app供CLI调用

發布時間:2023/12/10 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 给asterisk写app供CLI调用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境:CentOS6.2 + Asterisk 1.8.7.1

一、添加源文件

復制app_verbose.capp_testApp.c

復制app_verbose.exportsapp_testApp.exports

主要是修改一些標識,編譯不會出錯就行,這里列出我進行的主要修改。

1、添加頭文件

#include "asterisk/cli.h"

2、修改變量

static char *app_testApp = "testApp"; static char *app_testApplog = "testAppLog";

3、在load_module中進行注冊

res |= ast_register_application_xml(app_testApp, testApp_exec);

4、添加功能函數

static int testApp_exec(struct ast_channel *chan, const char *data) { ast_verb(2,"testApp_exec : %s\r\n",data); return0; }

5、添加cli調用接口

注冊commande->command = "testApp {print}";

調用command

if (!strcasecmp(a->argv[1], "print")) {

testApp_exec(chan, a->argv[2]); }

6、在unload_module中進行反注冊

res = ast_unregister_application(app_testApp);

二、編譯并安裝

asterisk -rx "core stop now" && make && make install && asterisk && asterisk -rvvvvvvvvvvvvv?

三、測試

運行asterisk -rvvvvvvvv進入CLI模式

輸入:core show help testApp

會輸出幫助文檔

輸入:core show help testApp "something to test!"

會輸出:something to test!?

好,就這些了,希望對你有幫助。

轉載于:https://www.cnblogs.com/MikeZhang/archive/2012/04/14/asteriskCLIAppTest20120414.html

總結

以上是生活随笔為你收集整理的给asterisk写app供CLI调用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。