|
@@ -31,6 +31,7 @@ MYSQL_ROW g_row; // 字符串数组,mysql 记录行
|
|
|
#define EXTEN_INBOUND_FILE "/etc/asterisk/extensions_inbound_custom.conf"
|
|
|
#define EXTEN_GLOBAL_FILE "/etc/asterisk/extensions_global_custom.conf"
|
|
|
#define EXTEN_CALLTRIGGER_FILE "/etc/asterisk/extensions_call_trigger_custom.conf"
|
|
|
+#define EXTEN_FEATURECODES_FILE "/etc/asterisk/extensions_featurecodes_custom.conf"
|
|
|
#define KEYVALLEN 100
|
|
|
#define VERSION "V1.0.1"
|
|
|
|
|
@@ -376,7 +377,7 @@ fputs("[CallingRule_OutCall]\n",conf_dialrule_fp);
|
|
|
}
|
|
|
|
|
|
memset(dialrule,0,sizeof(dialrule));
|
|
|
- sprintf(dialrule, "exten => _%s,1,Macro(trunkdial-failover,${EXTEN},%s/",g_row[1], g_row[0]);
|
|
|
+ sprintf(dialrule, "exten => _%s,1,Macro(trunkdial-failover,${EXTEN},${%s}",g_row[1], g_row[0]);
|
|
|
if(g_row[3] != NULL){
|
|
|
strcat(dialrule,g_row[3]);
|
|
|
}
|
|
@@ -403,6 +404,7 @@ g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,my
|
|
|
FILE *conf_inbound_fp = fopen(EXTEN_INBOUND_FILE, "w+");
|
|
|
FILE *conf_global_fp = fopen(EXTEN_GLOBAL_FILE, "w+");
|
|
|
FILE *conf_calltrigger_fp = fopen(EXTEN_CALLTRIGGER_FILE, "w+");
|
|
|
+FILE *conf_featurecodes_fp = fopen(EXTEN_FEATURECODES_FILE, "w+");
|
|
|
|
|
|
if (conf_inbound_fp == NULL){
|
|
|
perror("Open paging conf file Error: ");
|
|
@@ -419,6 +421,11 @@ if (conf_calltrigger_fp == NULL){
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
+if (conf_featurecodes_fp == NULL){
|
|
|
+ perror("Open paging conf file Error: ");
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+
|
|
|
fprintf(conf_inbound_fp, ";!\n\
|
|
|
;! Automatically generated configuration file\n\
|
|
|
;! Filename: extensions_inbound_custom.conf (/etc/asterisk/extensions_inbound_custom.conf)\n\
|
|
@@ -438,17 +445,34 @@ mytime()\
|
|
|
",\
|
|
|
mytime()\
|
|
|
);
|
|
|
+fprintf(conf_global_fp, "\
|
|
|
+AGISERVERHOST = %s\n\
|
|
|
+AGISERVERPORT = %s\n\
|
|
|
+",\
|
|
|
+getenv("BROADCAST_GATEWAY"),\
|
|
|
+getenv("AGI_SERVER_PORT")\
|
|
|
+);
|
|
|
|
|
|
fprintf(conf_calltrigger_fp, ";!\n\
|
|
|
;! Automatically generated configuration file\n\
|
|
|
;! Filename: extensions_call_trigger_custom.conf (/etc/asterisk/extensions_call_trigger_custom.conf)\n\
|
|
|
-;! Generator: Generator GLOBAL\n\
|
|
|
+;! Generator: Generator TRIGGER\n\
|
|
|
;! Creation Date: %s\n\
|
|
|
;!\n\n\
|
|
|
",\
|
|
|
mytime()\
|
|
|
);
|
|
|
|
|
|
+ fprintf(conf_featurecodes_fp, ";!\n\
|
|
|
+;! Automatically generated configuration file\n\
|
|
|
+;! Filename: extensions_featurecodes_custom.conf (/etc/asterisk/extensions_featurecodes_custom.conf)\n\
|
|
|
+;! Generator: Generator FEATURECODES\n\
|
|
|
+;! Creation Date: %s\n\
|
|
|
+;!\n\n\
|
|
|
+[featurecodes]\n",\
|
|
|
+mytime()\
|
|
|
+);
|
|
|
+
|
|
|
//t_pbx_users_voiptrunk.trunk as trunk,rule,del_prefix,add_before,add_after
|
|
|
while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
|
|
|
if (g_row[0] == NULL || g_row[1] == NULL || g_row[2] == NULL){
|
|
@@ -511,11 +535,57 @@ cJSON_GetObjectItem(pJson, "start")->valuestring,\
|
|
|
cJSON_GetObjectItem(pJson, "end")->valuestring\
|
|
|
);
|
|
|
}
|
|
|
+ else if(strcmp(g_row[1],"paging.featurecodes.config") == 0){
|
|
|
+ pJson = cJSON_Parse(g_row[2]);
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "bargein");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-barge,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "clear");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(exten-clear,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "syp");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-normal,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "whisper");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-whisper,${EXTEN:%d},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "wakeup");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = %s,1,Macro(wakeup-call,${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "dnd");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-dnd-on,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "cf-alway");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Goto(app-cf-on,cf-${EXTEN:%d},1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-cf-off,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "cf-busy");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Goto(app-cfb-on,cf-${EXTEN:%d},1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-cfb-off,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
|
+ }
|
|
|
+ pSub = cJSON_GetObjectItem(pJson, "cf-noanswer");
|
|
|
+ if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Goto(app-cfu-on,cf-${EXTEN:%d},1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = %s,1,Goto(app-cfu-off,s,1)\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
fclose(conf_dialrule_fp);
|
|
|
fclose(conf_ivr_fp);
|
|
|
+fclose(conf_inbound_fp);
|
|
|
+fclose(conf_global_fp);
|
|
|
+fclose(conf_calltrigger_fp);
|
|
|
+fclose(conf_featurecodes_fp);
|
|
|
mysql_free_result(g_res); // 释放结果集
|
|
|
mysql_close(g_conn); // 关闭链接
|
|
|
cJSON_Delete(pJson);
|