X-Git-Url: http://git.eversberg.eu/gitweb.cgi?a=blobdiff_plain;f=extension.c;h=46cb2cfc98235fc955245a6c5f8ce3a223ce53ef;hb=bf61575a94ec0e4e02824b7bfe8b1063ddf3daa5;hp=d8d17b471cc8deeca8719332032457cfb0147230;hpb=31aff20175a3bc9b4bb41d080452ae1d063e267a;p=lcr.git diff --git a/extension.c b/extension.c index d8d17b4..46cb2cf 100644 --- a/extension.c +++ b/extension.c @@ -13,7 +13,7 @@ /* extension */ -char *ext_rights[] = { +const char *ext_rights[] = { "none", "internal", "local", @@ -22,7 +22,7 @@ char *ext_rights[] = { NULL }; -char *ext_yesno[] = { +const char *ext_yesno[] = { "no", "yes", NULL @@ -51,10 +51,11 @@ int read_extension(struct extension *ext, char *num) if (number[0] == '\0') return(0); - SPRINT(filename, "%s/%s/%s/settings", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/settings", EXTENSION_DATA, number); if (!(fp = fopen(filename, "r"))) { + printf("the given extension doesn't exist: \"%s\"\n", filename); PDEBUG(DEBUG_CONFIG, "the given extension doesn't exist: \"%s\"\n", filename); return(0); } @@ -151,7 +152,7 @@ int read_extension(struct extension *ext, char *num) SCPY(ext->name, param); if (param2[0]) { - SCAT(ext->name, " "); + SCAT(ext->name, (char *)" "); SCAT(ext->name, param2); } @@ -396,24 +397,6 @@ int read_extension(struct extension *ext, char *num) PDEBUG(DEBUG_CONFIG, "unknown parameter given keypad: %s\n", param); } } else - if (!strcmp(option,"centrex")) - { - i=0; - while(ext_yesno[i]) - { - if (!strcasecmp(param,ext_yesno[i])) - break; - i++; - } - if (ext_yesno[i]) - { - ext->centrex = i; - PDEBUG(DEBUG_CONFIG, "use centrex to display name %s\n", ext_yesno[i]); - } else - { - PDEBUG(DEBUG_CONFIG, "unknown parameter given centrex: %s\n", param); - } - } else if (!strcmp(option,"rights")) { i=0; @@ -468,21 +451,23 @@ int read_extension(struct extension *ext, char *num) PDEBUG(DEBUG_CONFIG, "given noknocking param unknown: %s\n", param); } } else - if (!strcmp(option,"rxvol")) + if (!strcmp(option,"rx_gain") + || !strcmp(option,"rxvol")) { - ext->rxvol = atoi(param); - if (ext->rxvol<-8 || ext->rxvol>8) - ext->rxvol = 0; + ext->rx_gain = atoi(param); + if (ext->rx_gain<-8 || ext->rx_gain>8) + ext->rx_gain = 0; - PDEBUG(DEBUG_CONFIG, "receive volume: %d\n",ext->rxvol); + PDEBUG(DEBUG_CONFIG, "receive volume: %d\n",ext->rx_gain); } else - if (!strcmp(option,"txvol")) + if (!strcmp(option,"tx_gain") + || !strcmp(option,"txvol")) { - ext->txvol = atoi(param); - if (ext->txvol<-8 || ext->txvol>8) - ext->txvol = 0; + ext->tx_gain = atoi(param); + if (ext->tx_gain<-8 || ext->tx_gain>8) + ext->tx_gain = 0; - PDEBUG(DEBUG_CONFIG, "transmit volume: %d\n",ext->txvol); + PDEBUG(DEBUG_CONFIG, "transmit volume: %d\n",ext->tx_gain); } else if (!strcmp(option,"own_setup")) { @@ -939,7 +924,7 @@ int write_extension(struct extension *ext, char *number) if (number[0] == '\0') return(0); - SPRINT(filename, "%s/%s/%s/settings", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/settings", EXTENSION_DATA, number); if (!(fp = fopen(filename, "w"))) { @@ -964,7 +949,7 @@ int write_extension(struct extension *ext, char *number) fprintf(fp,"# Interface(s) to ring on calls to extension (as named in interface.conf)\n"); fprintf(fp,"# Seperate multiple interfaces by using komma without spaces\n"); - fprintf(fp,"# Example: Int would ring on the interface with the name \"Int\""); + fprintf(fp,"# Example: Int would ring on the interface with the name \"Int\"\n"); fprintf(fp,"# Int1,Int2 would ring incoming calls on both interfaces Int1 and Int2.\n"); fprintf(fp,"interfaces %s\n\n",ext->interfaces); @@ -1080,7 +1065,7 @@ int write_extension(struct extension *ext, char *number) } fprintf(fp,"# CLIP Prefix\n"); - fprintf(fp,"# Adds a prefix to incomming caller IDs, so telephones will be able to respond\n"); + fprintf(fp,"# Adds a prefix to incoming caller IDs, so telephones will be able to respond\n"); fprintf(fp,"# to unanswered calls from their list. The prefix must be the digit(s) to get\n"); fprintf(fp,"# an external line. The caller ID will then be extendet so that they can be\n"); fprintf(fp,"# dialed from internal telephones. Many telephones have this feature, but some\n"); @@ -1092,11 +1077,6 @@ int write_extension(struct extension *ext, char *number) fprintf(fp,"# DTMF tone, but the digit is transmitted via D-channel diaing info.\n"); fprintf(fp,"keypad %s\n\n",(ext->keypad)?"yes":"no"); - fprintf(fp,"# Called Name Identification Presentation (CNIP/CONP)\n"); - fprintf(fp,"# If supported by telephone, special information element on the d-channel are\n"); - fprintf(fp,"# used to show name of caller. It is supported by newer Siemens telephones\n# (Centrex).\n"); - fprintf(fp,"centrex %s #this is currently not working!!!\n\n",(ext->centrex)?"yes":"no"); - fprintf(fp,"# Ignore restriction of COLP and CLIP\n"); fprintf(fp,"# In this case even restricted numbers are presented to this extension.\n"); fprintf(fp,"# This also works for incoming external anonymous calls IF:\n"); @@ -1120,11 +1100,11 @@ int write_extension(struct extension *ext, char *number) fprintf(fp,"# 1 = double, 2 = quadrupel, 8 = 256 times (amplitude)\n"); fprintf(fp,"# -1 = half, -2 = quarter, 8 = 1/256th (amplitude)\n"); fprintf(fp,"# Audio data is limited to the maximum value when exceeds limit.\n"); - fprintf(fp,"txvol %d\n\n",ext->txvol); + fprintf(fp,"tx_gain %d\n\n",ext->tx_gain); fprintf(fp,"# Receive volume (-8 .. 8)\n"); - fprintf(fp,"# (see txvol)\n"); - fprintf(fp,"rxvol %d\n\n",ext->rxvol); + fprintf(fp,"# (see tx_gain)\n"); + fprintf(fp,"rx_gain %d\n\n",ext->rx_gain); fprintf(fp,"# Force to use tones and announcements generated by the pbx.\n"); @@ -1350,15 +1330,15 @@ int write_extension(struct extension *ext, char *number) */ int write_log(char *number, char *callerid, char *calledid, time_t start, time_t stop, int aoce, int cause, int location) { - char *mon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + const char *mon[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; FILE *fp=NULL; char filename[256]; struct tm *tm; if (callerid[0] == '\0') - callerid = ""; + callerid = (char *)""; - SPRINT(filename, "%s/%s/%s/log", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/log", EXTENSION_DATA, number); if (!(fp = fopen(filename, "a"))) { @@ -1369,7 +1349,7 @@ int write_log(char *number, char *callerid, char *calledid, time_t start, time_t tm = localtime(&start); fprintf(fp,"%s %2d %04d %02d:%02d:%02d %s", mon[tm->tm_mon], tm->tm_mday, tm->tm_year+1900, tm->tm_hour, tm->tm_min, tm->tm_sec, number); if (stop) - fprintf(fp," %2ld:%02ld:%02ld", (stop-start)/3600, (((unsigned long)(stop-start))/60)%60, ((unsigned long)(stop-start))%60); + fprintf(fp," %2ld:%02d:%02d", (stop-start)/3600, (((unsigned int)(stop-start))/60)%60, ((unsigned int)(stop-start))%60); else fprintf(fp," --:--:--"); fprintf(fp," %s -> %s", callerid, calledid); @@ -1399,7 +1379,7 @@ int parse_phonebook(char *number, char **abbrev_pointer, char **phone_pointer, c char buffer[1024]; int found = 0, found_if_more_digits = 0; - SPRINT(filename, "%s/%s/%s/phonebook", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/phonebook", EXTENSION_DATA, number); if (!(fp = fopen(filename, "r"))) { @@ -1539,7 +1519,7 @@ int parse_secrets(char *number, char *remote_id, char **auth_pointer, char **cry char buffer[4096]; int found = 0; - SPRINT(filename, "%s/%s/%s/secrets", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/secrets", EXTENSION_DATA, number); if (!(fp = fopen(filename, "r"))) { @@ -1682,7 +1662,7 @@ char *parse_directory(char *number, int type) char buffer[256]; int found = 0; - SPRINT(filename, "%s/directory.list", INSTALL_DATA); + SPRINT(filename, "%s/directory.list", CONFIG_DATA); if (!(fp = fopen(filename, "r"))) { @@ -1838,7 +1818,7 @@ int parse_callbackauth(char *number, struct caller_info *callerinfo) static char caller_type[32], caller_id[64]; int found = 0; - SPRINT(filename, "%s/%s/%s/callbackauth", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/callbackauth", EXTENSION_DATA, number); if (!(fp = fopen(filename, "r"))) { @@ -1930,7 +1910,7 @@ void append_callbackauth(char *number, struct caller_info *callerinfo) FILE *fp = NULL; char filename[256]; - SPRINT(filename, "%s/%s/%s/callbackauth", INSTALL_DATA, options.extensions_dir, number); + SPRINT(filename, "%s/%s/callbackauth", EXTENSION_DATA, number); if (callerinfo->id[0]=='\0') {