diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/app.c work/asterisk-current/app.c --- /usr/ports/distfiles/ast-curr/asterisk/app.c Wed Nov 16 12:52:46 2005 +++ work/asterisk-current/app.c Fri Nov 25 17:47:14 2005 @@ -1006,7 +1006,7 @@ int ast_play_and_prepend(struct ast_chan /* Channel group core functions */ -int ast_app_group_split_group(char *data, char *group, int group_max, char *category, int category_max) +int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max) { int res=0; char tmp[256]; @@ -1035,7 +1035,7 @@ int ast_app_group_split_group(char *data return res; } -int ast_app_group_set_channel(struct ast_channel *chan, char *data) +int ast_app_group_set_channel(struct ast_channel *chan, const char *data) { int res=0; char group[80] = ""; @@ -1049,13 +1049,13 @@ int ast_app_group_set_channel(struct ast return res; } -int ast_app_group_get_count(char *group, char *category) +int ast_app_group_get_count(const char *group, const char *category) { struct ast_channel *chan; int count = 0; - char *test; + const char *test; char cat[80]; - char *s; + const char *s; if (ast_strlen_zero(group)) return 0; @@ -1074,14 +1074,14 @@ int ast_app_group_get_count(char *group, return count; } -int ast_app_group_match_get_count(char *groupmatch, char *category) +int ast_app_group_match_get_count(const char *groupmatch, const char *category) { regex_t regexbuf; struct ast_channel *chan; int count = 0; - char *test; + const char *test; char cat[80]; - char *s; + const char *s; if (ast_strlen_zero(groupmatch)) return 0; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_chanspy.c work/asterisk-current/apps/app_chanspy.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_chanspy.c Fri Nov 11 03:48:28 2005 +++ work/asterisk-current/apps/app_chanspy.c Fri Nov 25 18:21:12 2005 @@ -439,7 +439,7 @@ static int chanspy_exec(struct ast_chann if (recbase) { char filename[512]; - snprintf(filename,sizeof(filename),"%s/%s.%ld.raw",ast_config_AST_MONITOR_DIR, recbase, time(NULL)); + snprintf(filename,sizeof(filename),"%s/%s.%d.raw",ast_config_AST_MONITOR_DIR, recbase, (int)time(NULL)); if ((fd = open(filename, O_CREAT | O_WRONLY, O_TRUNC)) <= 0) { ast_log(LOG_WARNING, "Cannot open %s for recording\n", filename); fd = 0; @@ -468,7 +468,7 @@ static int chanspy_exec(struct ast_chann prev=NULL; while(peer) { if (peer != chan) { - char *group = NULL; + const char *group = NULL; int igrp = 1; if (peer == prev && !chosen) { diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_groupcount.c work/asterisk-current/apps/app_groupcount.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_groupcount.c Mon Nov 7 22:01:21 2005 +++ work/asterisk-current/apps/app_groupcount.c Fri Nov 25 18:03:50 2005 @@ -56,7 +56,6 @@ static int group_count_exec(struct ast_c char group[80] = ""; char category[80] = ""; char ret[80] = ""; - char *grp; static int deprecation_warning = 0; LOCAL_USER_ADD(u); @@ -69,7 +68,7 @@ static int group_count_exec(struct ast_c ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)); if (ast_strlen_zero(group)) { - grp = pbx_builtin_getvar_helper(chan, category); + const char *grp = pbx_builtin_getvar_helper(chan, category); strncpy(group, grp, sizeof(group) - 1); } diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_macro.c work/asterisk-current/apps/app_macro.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_macro.c Tue Nov 8 04:48:00 2005 +++ work/asterisk-current/apps/app_macro.c Fri Nov 25 18:02:54 2005 @@ -87,8 +87,15 @@ STANDARD_LOCAL_USER; LOCAL_USER_DECL; +static char *safe_strdup(const char *s) +{ + return s ? strdup(s) : NULL; +} + static int macro_exec(struct ast_channel *chan, void *data) { + const char *s; + char *tmp; char *cur, *rest; char *macro; @@ -101,8 +108,7 @@ static int macro_exec(struct ast_channel int oldpriority; char pc[80], depthc[12]; char oldcontext[AST_MAX_CONTEXT] = ""; - char *offsets; - int offset, depth; + int offset, depth = 0; int setmacrocontext=0; int autoloopflag; @@ -120,13 +126,9 @@ static int macro_exec(struct ast_channel LOCAL_USER_ADD(u); /* Count how many levels deep the rabbit hole goes */ - tmp = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH"); - if (tmp) { - sscanf(tmp, "%d", &depth); - } else { - depth = 0; - } - + s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH"); + if (s) + sscanf(s, "%d", &depth); if (depth >= 7) { ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n"); LOCAL_USER_REMOVE(u); @@ -165,25 +167,17 @@ static int macro_exec(struct ast_channel } argc = 1; /* Save old macro variables */ - save_macro_exten = pbx_builtin_getvar_helper(chan, "MACRO_EXTEN"); - if (save_macro_exten) - save_macro_exten = strdup(save_macro_exten); + save_macro_exten = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_EXTEN")); pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", oldexten); - save_macro_context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"); - if (save_macro_context) - save_macro_context = strdup(save_macro_context); + save_macro_context = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT")); pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", oldcontext); - save_macro_priority = pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY"); - if (save_macro_priority) - save_macro_priority = strdup(save_macro_priority); + save_macro_priority = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY")); snprintf(pc, sizeof(pc), "%d", oldpriority); pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", pc); - save_macro_offset = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"); - if (save_macro_offset) - save_macro_offset = strdup(save_macro_offset); + save_macro_offset = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_OFFSET")); pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL); /* Setup environment for new run */ @@ -193,12 +187,13 @@ static int macro_exec(struct ast_channel chan->priority = 1; while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) { + const char *s; /* Save copy of old arguments if we're overwriting some, otherwise let them pass through to the other macro */ snprintf(varname, sizeof(varname), "ARG%d", argc); - oldargs[argc] = pbx_builtin_getvar_helper(chan, varname); - if (oldargs[argc]) - oldargs[argc] = strdup(oldargs[argc]); + s = pbx_builtin_getvar_helper(chan, varname); + if (s) + oldargs[argc] = strdup(s); pbx_builtin_setvar_helper(chan, varname, cur); argc++; } @@ -286,6 +281,7 @@ static int macro_exec(struct ast_channel ast_copy_string(chan->context, oldcontext, sizeof(chan->context)); if (!(chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO)) { /* Copy the extension, so long as we're not in softhangup, where we could be given an asyncgoto */ + const char *offsets; ast_copy_string(chan->exten, oldexten, sizeof(chan->exten)); if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) { /* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_meetme.c work/asterisk-current/apps/app_meetme.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_meetme.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/apps/app_meetme.c Fri Nov 25 18:23:48 2005 @@ -143,8 +143,8 @@ static struct ast_conference { int locked; /* Is the conference locked? */ pthread_t recordthread; /* thread for recording */ pthread_attr_t attr; /* thread attribute */ - char *recordingfilename; /* Filename to record the Conference into */ - char *recordingformat; /* Format to record the Conference in */ + const char *recordingfilename; /* Filename to record the Conference into */ + const char *recordingformat; /* Format to record the Conference in */ char pin[AST_MAX_EXTENSION]; /* If protected by a PIN */ char pinadmin[AST_MAX_EXTENSION]; /* If protected by a admin PIN */ struct ast_conference *next; @@ -813,8 +813,8 @@ static int conf_run(struct ast_channel * int duration=20; struct ast_dsp *dsp=NULL; struct ast_app *app; - char *agifile; - char *agifiledefault = "conf-background.agi"; + const char *agifile; + const char *agifiledefault = "conf-background.agi"; char meetmesecs[30] = ""; char exitcontext[AST_MAX_CONTEXT] = ""; char recordingtmp[AST_MAX_EXTENSION] = ""; @@ -1086,7 +1086,8 @@ static int conf_run(struct ast_channel * /* Find a pointer to the agi app and execute the script */ app = pbx_findapp("agi"); if (app) { - ret = pbx_exec(chan, app, agifile, 1); + char *s = ast_strdupa(agifile); + ret = pbx_exec(chan, app, s, 1); } else { ast_log(LOG_WARNING, "Could not find application (agi)\n"); ret = -2; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_queue.c work/asterisk-current/apps/app_queue.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_queue.c Thu Nov 10 23:22:37 2005 +++ work/asterisk-current/apps/app_queue.c Fri Nov 25 17:52:54 2005 @@ -484,11 +484,11 @@ static void *changethread(void *data) "Membership: %s\r\n" "Penalty: %d\r\n" "CallsTaken: %d\r\n" - "LastCall: %ld\r\n" + "LastCall: %d\r\n" "Status: %d\r\n" "Paused: %d\r\n", q->name, cur->interface, cur->dynamic ? "dynamic" : "static", - cur->penalty, cur->calls, cur->lastcall, cur->status, cur->paused); + cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused); } } } @@ -1261,11 +1261,11 @@ static int update_status(struct ast_call "Membership: %s\r\n" "Penalty: %d\r\n" "CallsTaken: %d\r\n" - "LastCall: %ld\r\n" + "LastCall: %d\r\n" "Status: %d\r\n" "Paused: %d\r\n", q->name, cur->interface, cur->dynamic ? "dynamic" : "static", - cur->penalty, cur->calls, cur->lastcall, cur->status, cur->paused); + cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused); } break; } @@ -1992,7 +1992,6 @@ static int try_calling(struct queue_ent char oldcontext[AST_MAX_CONTEXT]=""; char queuename[256]=""; char *newnum; - char *monitorfilename; struct ast_channel *peer; struct ast_channel *which; struct localuser *lpeer; @@ -2209,7 +2208,7 @@ static int try_calling(struct queue_ent } /* Begin Monitoring */ if (qe->parent->monfmt && *qe->parent->monfmt) { - monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME"); + const char *monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME"); if (pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC") || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS")) which = qe->chan; else @@ -2421,11 +2420,11 @@ static int add_to_queue(char *queuename, "Membership: %s\r\n" "Penalty: %d\r\n" "CallsTaken: %d\r\n" - "LastCall: %ld\r\n" + "LastCall: %d\r\n" "Status: %d\r\n" "Paused: %d\r\n", q->name, new_member->interface, new_member->dynamic ? "dynamic" : "static", - new_member->penalty, new_member->calls, new_member->lastcall, new_member->status, new_member->paused); + new_member->penalty, new_member->calls, (int)new_member->lastcall, new_member->status, new_member->paused); if (dump) dump_queue_members(q); @@ -2845,7 +2844,7 @@ static int queue_exec(struct ast_channel char *options = NULL; char *url = NULL; char *announceoverride = NULL; - char *user_priority; + const char *user_priority; int prio; char *queuetimeoutstr = NULL; enum queue_result reason = QUEUE_UNKNOWN; @@ -3435,13 +3434,13 @@ static int manager_queues_status( struct "Membership: %s\r\n" "Penalty: %d\r\n" "CallsTaken: %d\r\n" - "LastCall: %ld\r\n" + "LastCall: %d\r\n" "Status: %d\r\n" "Paused: %d\r\n" "%s" "\r\n", q->name, mem->interface, mem->dynamic ? "dynamic" : "static", - mem->penalty, mem->calls, mem->lastcall, mem->status, mem->paused, idText); + mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText); } } /* List Queue Entries */ diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_sayunixtime.c work/asterisk-current/apps/app_sayunixtime.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_sayunixtime.c Mon Nov 7 22:01:22 2005 +++ work/asterisk-current/apps/app_sayunixtime.c Mon Nov 21 18:07:14 2005 @@ -74,48 +74,34 @@ static int sayunixtime_exec(struct ast_c struct localuser *u; char *s,*zone=NULL,*timec,*format; time_t unixtime; - struct timeval tv; LOCAL_USER_ADD(u); - tv = ast_tvnow(); - unixtime = (time_t)tv.tv_sec; + unixtime = time(NULL); - if( !strcasecmp(chan->language, "da" ) ) { - format = "A dBY HMS"; - } else if ( !strcasecmp(chan->language, "de" ) ) { - format = "A dBY HMS"; - } else { - format = "ABdY 'digits/at' IMp"; - } + format = "c"; /* default datetime */ if (data) { - s = data; - s = ast_strdupa(s); - if (s) { - timec = strsep(&s,"|"); - if ((timec) && (*timec != '\0')) { - long timein; - if (sscanf(timec,"%ld",&timein) == 1) { - unixtime = (time_t)timein; - } - } - if (s) { - zone = strsep(&s,"|"); - if (zone && (*zone == '\0')) - zone = NULL; - if (s) { - format = s; - } - } - } else { + s = ast_strdupa(data); + if (s == NULL) ast_log(LOG_ERROR, "Out of memory error\n"); + timec = strsep(&s,"|"); + if (!ast_strlen_zero(timec)) { + long timein; + if (sscanf(timec,"%ld",&timein) == 1) + unixtime = timein; + } + if (s) { + zone = strsep(&s,"|"); + if (ast_strlen_zero(zone)) + zone = NULL; } + if (s) /* override format */ + format = s; } - if (chan->_state != AST_STATE_UP) { + if (chan->_state != AST_STATE_UP) res = ast_answer(chan); - } if (!res) res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY, chan->language, format, zone); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_sms.c work/asterisk-current/apps/app_sms.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_sms.c Tue Nov 8 04:48:00 2005 +++ work/asterisk-current/apps/app_sms.c Mon Nov 21 18:07:14 2005 @@ -694,7 +694,7 @@ static void sms_readfile (sms_t * h, cha } while (fgets (line, sizeof (line), s)) { /* process line in file */ - char *p; + unsigned char *p; for (p = line; *p && *p != '\n' && *p != '\r'; p++); *p = 0; /* strip eoln */ p = line; @@ -1379,8 +1379,8 @@ static int sms_exec (struct ast_channel ast_copy_string (h.cli, chan->cid.cid_num, sizeof (h.cli)); { - char *d = data, - *p, + unsigned char *p; + unsigned char *d = data, answer = 0; if (!*d || *d == '|') { ast_log (LOG_ERROR, "Requires queue name\n"); @@ -1449,7 +1449,7 @@ static int sms_exec (struct ast_channel d = p; h.udl = 0; while (*p && h.udl < SMSLEN) - h.ud[h.udl++] = utf8decode((unsigned char **)&p); + h.ud[h.udl++] = utf8decode(&p); if (is7bit (h.dcs) && packsms7 (0, h.udhl, h.udh, h.udl, h.ud) < 0) ast_log (LOG_WARNING, "Invalid 7 bit GSM data\n"); if (is8bit (h.dcs) && packsms8 (0, h.udhl, h.udh, h.udl, h.ud) < 0) diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_stack.c work/asterisk-current/apps/app_stack.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_stack.c Tue Nov 8 23:37:53 2005 +++ work/asterisk-current/apps/app_stack.c Fri Nov 25 18:21:33 2005 @@ -82,7 +82,7 @@ static int pop_exec(struct ast_channel * static int return_exec(struct ast_channel *chan, void *data) { - char *label = pbx_builtin_getvar_helper(chan, STACKVAR); + const char *label = pbx_builtin_getvar_helper(chan, STACKVAR); if (ast_strlen_zero(label)) { ast_log(LOG_ERROR, "Return without Gosub: stack is empty\n"); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_voicemail.c work/asterisk-current/apps/app_voicemail.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_voicemail.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/apps/app_voicemail.c Fri Nov 25 17:51:54 2005 @@ -1598,10 +1598,44 @@ static void prep_email_sub_vars(struct a pbx_builtin_setvar_helper(ast, "VM_DATE", date); } +/* + * fill in *tm for current time according to the proper timezone, if any. + * Return tm so it can be used as a function argument. + */ +static const struct tm *vmu_tm(const struct ast_vm_user *vmu, struct tm *tm) +{ + const struct vm_zone *z = NULL; + time_t t = time(NULL); + + /* Does this user have a timezone specified? */ + if (!ast_strlen_zero(vmu->zonetag)) { + /* Find the zone in the list */ + for (z = zones; z ; z = z->next) + if (!strcmp(z->name, vmu->zonetag)) + break; + } + ast_localtime(&t, tm, z ? z->timezone : NULL); + return tm; +} + +/* same as mkstemp, but return a FILE * */ +static FILE *mkftemp(char *template) +{ + FILE *p = NULL; + int pfd = mkstemp(template); + if (pfd > -1) { + p = fdopen(pfd, "w"); + if (!p) { + close(pfd); + pfd = -1; + } + } + return p; +} + static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail) { FILE *p=NULL; - int pfd; char date[256]; char host[MAXHOSTNAMELEN] = ""; char who[256]; @@ -1610,9 +1644,8 @@ static int sendmail(char *srcemail, stru char dur[256]; char tmp[80] = "/tmp/astmail-XXXXXX"; char tmp2[256]; - time_t t; struct tm tm; - struct vm_zone *the_zone = NULL; + if (vmu && ast_strlen_zero(vmu->email)) { ast_log(LOG_WARNING, "E-mail address missing for mailbox [%s]. E-mail will not be sent.\n", vmu->mailbox); return(0); @@ -1622,15 +1655,11 @@ static int sendmail(char *srcemail, stru ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH)); /* Make a temporary file instead of piping directly to sendmail, in case the mail command hangs */ - pfd = mkstemp(tmp); - if (pfd > -1) { - p = fdopen(pfd, "w"); - if (!p) { - close(pfd); - pfd = -1; - } - } - if (p) { + p = mkftemp(tmp); + if (p == NULL) { + ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd); + return -1; + } else { gethostname(host, sizeof(host)-1); if (strchr(srcemail, '@')) ast_copy_string(who, srcemail, sizeof(who)); @@ -1638,27 +1667,7 @@ static int sendmail(char *srcemail, stru snprintf(who, sizeof(who), "%s@%s", srcemail, host); } snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60); - time(&t); - - /* Does this user have a timezone specified? */ - if (!ast_strlen_zero(vmu->zonetag)) { - /* Find the zone in the list */ - struct vm_zone *z; - z = zones; - while (z) { - if (!strcmp(z->name, vmu->zonetag)) { - the_zone = z; - break; - } - z = z->next; - } - } - - if (the_zone) - ast_localtime(&t,&tm,the_zone->timezone); - else - ast_localtime(&t,&tm,NULL); - strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm); + strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm)); fprintf(p, "Date: %s\n", date); /* Set date format for voicemail mail */ @@ -1753,37 +1762,25 @@ static int sendmail(char *srcemail, stru snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); ast_safe_system(tmp2); ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); - } else { - ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd); - return -1; } return 0; } static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, int duration, struct ast_vm_user *vmu) { - FILE *p=NULL; - int pfd; char date[256]; char host[MAXHOSTNAMELEN]=""; char who[256]; char dur[256]; char tmp[80] = "/tmp/astmail-XXXXXX"; char tmp2[256]; - time_t t; struct tm tm; - struct vm_zone *the_zone = NULL; - pfd = mkstemp(tmp); + FILE *p = mkftemp(tmp); - if (pfd > -1) { - p = fdopen(pfd, "w"); - if (!p) { - close(pfd); - pfd = -1; - } - } - - if (p) { + if (p == NULL) { + ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd); + return -1; + } else { gethostname(host, sizeof(host)-1); if (strchr(srcemail, '@')) ast_copy_string(who, srcemail, sizeof(who)); @@ -1791,28 +1788,7 @@ static int sendpage(char *srcemail, char snprintf(who, sizeof(who), "%s@%s", srcemail, host); } snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60); - time(&t); - - /* Does this user have a timezone specified? */ - if (!ast_strlen_zero(vmu->zonetag)) { - /* Find the zone in the list */ - struct vm_zone *z; - z = zones; - while (z) { - if (!strcmp(z->name, vmu->zonetag)) { - the_zone = z; - break; - } - z = z->next; - } - } - - if (the_zone) - ast_localtime(&t,&tm,the_zone->timezone); - else - ast_localtime(&t,&tm,NULL); - - strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm); + strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm)); fprintf(p, "Date: %s\n", date); if (*pagerfromstring) { @@ -1869,9 +1845,6 @@ static int sendpage(char *srcemail, char snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); ast_safe_system(tmp2); ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd); - } else { - ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd); - return -1; } return 0; } @@ -2355,23 +2328,20 @@ static int leave_voicemail(struct ast_ch char tmp[256] = "", *tmpptr; struct ast_vm_user *vmu; struct ast_vm_user svm; - char *category = NULL; + const char *category; ast_copy_string(tmp, ext, sizeof(tmp)); ext = tmp; context = strchr(tmp, '@'); if (context) { - *context = '\0'; - context++; + *context++ = '\0'; tmpptr = strchr(context, '&'); } else { tmpptr = strchr(ext, '&'); } - if (tmpptr) { - *tmpptr = '\0'; - tmpptr++; - } + if (tmpptr) + *tmpptr++ = '\0'; category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY"); @@ -4748,8 +4718,7 @@ static int vm_tempgreeting(struct ast_ch unsigned char buf[256]; int bytes=0; - if (adsi_available(chan)) - { + if (adsi_available(chan)) { bytes += adsi_logo(buf + bytes); bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Temp Greeting Menu", ""); bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", ""); @@ -4758,10 +4727,13 @@ static int vm_tempgreeting(struct ast_ch adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); } snprintf(prefile,sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username); - while((cmd >= 0) && (cmd != 't')) { + while(cmd >= 0 && cmd != 't') { if (cmd) retries = 0; - if (ast_fileexists(prefile, NULL, NULL) > 0) { + if (ast_fileexists(prefile, NULL, NULL) <= 0) { + play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain); + cmd = 't'; + } else { switch (cmd) { case '1': cmd = play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain); @@ -4775,21 +4747,16 @@ static int vm_tempgreeting(struct ast_ch cmd = 't'; break; default: - if (ast_fileexists(prefile, NULL, NULL) > 0) { - cmd = ast_play_and_wait(chan,"vm-tempgreeting2"); - } else { - cmd = ast_play_and_wait(chan,"vm-tempgreeting"); - } if (!cmd) { + cmd = ast_play_and_wait(chan, + ast_fileexists(prefile, NULL, NULL) > 0 ? /* XXX always true ? */ + "vm-tempgreeting2" : "vm-tempgreeting"); + if (!cmd) cmd = ast_waitfordigit(chan,6000); - } if (!cmd) { + if (!cmd) retries++; - } if (retries > 3) { + if (retries > 3) cmd = 't'; - } } - } else { - play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain); - cmd = 't'; } } if (cmd == 't') diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_while.c work/asterisk-current/apps/app_while.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_while.c Tue Nov 8 04:48:00 2005 +++ work/asterisk-current/apps/app_while.c Fri Nov 25 18:20:44 2005 @@ -122,7 +122,7 @@ static int execif_exec(struct ast_channe #define VAR_SIZE 64 -static char *get_index(struct ast_channel *chan, const char *prefix, int index) { +static const char *get_index(struct ast_channel *chan, const char *prefix, int index) { char varname[VAR_SIZE]; snprintf(varname, VAR_SIZE, "%s_%d", prefix, index); @@ -209,15 +209,15 @@ static int _while_exec(struct ast_channe { int res=0; struct localuser *u; - char *while_pri = NULL; - char *goto_str = NULL, *my_name = NULL; - char *condition = NULL, *label = NULL; + const char *while_pri = NULL; + char *my_name = NULL; + const char *condition = NULL, *label = NULL; char varname[VAR_SIZE], end_varname[VAR_SIZE]; const char *prefix = "WHILE"; size_t size=0; int used_index_i = -1, x=0; char used_index[VAR_SIZE] = "0", new_index[VAR_SIZE] = "0"; - + if (!chan) { /* huh ? */ return -1; @@ -271,6 +271,7 @@ static int _while_exec(struct ast_channe if (!end && !ast_true(condition)) { /* Condition Met (clean up helper vars) */ + const char *goto_str; pbx_builtin_setvar_helper(chan, varname, NULL); pbx_builtin_setvar_helper(chan, my_name, NULL); snprintf(end_varname,VAR_SIZE,"END_%s",varname); @@ -291,6 +292,7 @@ static int _while_exec(struct ast_channe } if (!end && !while_pri) { + char *goto_str; size = strlen(chan->context) + strlen(chan->exten) + 32; goto_str = alloca(size); memset(goto_str, 0, size); @@ -302,6 +304,7 @@ static int _while_exec(struct ast_channe /* END of loop */ snprintf(end_varname, VAR_SIZE, "END_%s", varname); if (! pbx_builtin_getvar_helper(chan, end_varname)) { + char *goto_str; size = strlen(chan->context) + strlen(chan->exten) + 32; goto_str = alloca(size); memset(goto_str, 0, size); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/apps/app_zapscan.c work/asterisk-current/apps/app_zapscan.c --- /usr/ports/distfiles/ast-curr/asterisk/apps/app_zapscan.c Tue Nov 8 04:48:00 2005 +++ work/asterisk-current/apps/app_zapscan.c Fri Nov 25 18:24:43 2005 @@ -296,7 +296,6 @@ static int conf_exec(struct ast_channel char confstr[80] = "", *tmp = NULL; struct ast_channel *tempchan = NULL, *lastchan = NULL,*ichan = NULL; struct ast_frame *f; - char *mygroup; char *desired_group; int input=0,search_group=0; @@ -335,6 +334,7 @@ static int conf_exec(struct ast_channel break; if (tempchan && search_group) { + const char *mygroup; if((mygroup = pbx_builtin_getvar_helper(tempchan, "GROUP")) && (!strcmp(mygroup, desired_group))) { ast_verbose(VERBOSE_PREFIX_3 "Found Matching Channel %s in group %s\n", tempchan->name, desired_group); } else { diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/asterisk.c work/asterisk-current/asterisk.c --- /usr/ports/distfiles/ast-curr/asterisk/asterisk.c Wed Nov 16 12:52:46 2005 +++ work/asterisk-current/asterisk.c Mon Nov 21 18:07:15 2005 @@ -680,8 +680,10 @@ static int ast_makesocket(void) ast_log(LOG_WARNING, "Unable to change ownership of %s: %s\n", ast_config_AST_SOCKET, strerror(errno)); if (!ast_strlen_zero(ast_config_AST_CTL_PERMISSIONS)) { + int p1; mode_t p; - sscanf(ast_config_AST_CTL_PERMISSIONS, "%o", (int *) &p); + sscanf(ast_config_AST_CTL_PERMISSIONS, "%o", &p1); + p = p1; if ((chmod(ast_config_AST_SOCKET, p)) < 0) ast_log(LOG_WARNING, "Unable to change file permissions of %s: %s\n", ast_config_AST_SOCKET, strerror(errno)); } @@ -1252,7 +1254,7 @@ static char *cli_prompt(EditLine *el) if (*t == '%') { char hostname[MAXHOSTNAMELEN]=""; int i; - struct timeval tv; + time_t ts; struct tm tm; #ifdef linux FILE *LOADAVG; @@ -1280,8 +1282,8 @@ static char *cli_prompt(EditLine *el) break; case 'd': /* date */ memset(&tm, 0, sizeof(struct tm)); - tv = ast_tvnow(); - if (localtime_r(&(tv.tv_sec), &tm)) { + time(&ts); + if (localtime_r(&ts, &tm)) { strftime(p, sizeof(prompt) - strlen(prompt), "%Y-%m-%d", &tm); } break; @@ -1337,8 +1339,8 @@ static char *cli_prompt(EditLine *el) #endif case 't': /* time */ memset(&tm, 0, sizeof(struct tm)); - tv = ast_tvnow(); - if (localtime_r(&(tv.tv_sec), &tm)) { + time(&ts); + if (localtime_r(&ts, &tm)) { strftime(p, sizeof(prompt) - strlen(prompt), "%H:%M:%S", &tm); } break; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/cdr.c work/asterisk-current/cdr.c --- /usr/ports/distfiles/ast-curr/asterisk/cdr.c Wed Nov 16 12:52:46 2005 +++ work/asterisk-current/cdr.c Fri Nov 25 16:50:42 2005 @@ -327,7 +327,7 @@ int ast_cdr_copy_vars(struct ast_cdr *to { struct ast_var_t *variables, *newvariable = NULL; struct varshead *headpa, *headpb; - char *var, *val; + const char *var, *val; int x = 0; headpa = &from_cdr->varshead; @@ -349,7 +349,7 @@ int ast_cdr_copy_vars(struct ast_cdr *to int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur) { struct ast_var_t *variables; - char *var, *val; + const char *var, *val; char *tmp; char workspace[256]; int total = 0, x = 0, i; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/channel.c work/asterisk-current/channel.c --- /usr/ports/distfiles/ast-curr/asterisk/channel.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/channel.c Fri Nov 25 17:34:58 2005 @@ -2760,7 +2726,7 @@ void ast_change_name(struct ast_channel void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child) { struct ast_var_t *current, *newvar; - char *varname; + const char *varname; AST_LIST_TRAVERSE(&parent->varshead, current, entries) { int vartype = 0; @@ -3149,7 +3115,7 @@ struct ast_channel *ast_bridged_channel( return bridged; } -static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, char *sound, int remain) +static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain) { int res=0, min=0, sec=0,check=0; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/channels/chan_agent.c work/asterisk-current/channels/chan_agent.c --- /usr/ports/distfiles/ast-curr/asterisk/channels/chan_agent.c Tue Nov 8 04:02:35 2005 +++ work/asterisk-current/channels/chan_agent.c Fri Nov 25 17:29:10 2005 @@ -1685,7 +1682,7 @@ static int __login_exec(struct ast_chann AST_APP_ARG(options); AST_APP_ARG(extension); ); - char *tmpoptions = NULL; + const char *tmpoptions = NULL; char *context = NULL; int play_announcement = 1; char agent_goodbye[AST_MAX_FILENAME_LEN]; @@ -2230,7 +2227,7 @@ static int agentmonitoroutgoing_exec(str int nowarnings = 0; int changeoutgoing = 0; int res = 0; - char agent[AST_MAX_AGENT], *tmp; + char agent[AST_MAX_AGENT]; if (data) { if (strchr(data, 'd')) @@ -2241,6 +2238,7 @@ static int agentmonitoroutgoing_exec(str changeoutgoing = 1; } if (chan->cid.cid_num) { + const char *tmp; char agentvar[AST_MAX_BUF]; snprintf(agentvar, sizeof(agentvar), "%s_%s", GETAGENTBYCALLERID, chan->cid.cid_num); if ((tmp = pbx_builtin_getvar_helper(NULL, agentvar))) { diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/channels/chan_iax2.c work/asterisk-current/channels/chan_iax2.c --- /usr/ports/distfiles/ast-curr/asterisk/channels/chan_iax2.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/channels/chan_iax2.c Fri Nov 25 17:30:29 2005 @@ -9135,7 +9135,6 @@ static int iax2_exec(struct ast_channel char odata[256]; char req[256]; char *ncontext; - char *dialstatus; struct iax2_dpcache *dp; struct ast_app *dial; #if 0 @@ -9143,7 +9142,7 @@ static int iax2_exec(struct ast_channel #endif if (priority == 2) { /* Indicate status, can be overridden in dialplan */ - dialstatus = pbx_builtin_getvar_helper(chan, "DIALSTATUS"); + const char *dialstatus = pbx_builtin_getvar_helper(chan, "DIALSTATUS"); if (dialstatus) { dial = pbx_findapp(dialstatus); if (dial) diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/channels/chan_mgcp.c work/asterisk-current/channels/chan_mgcp.c --- /usr/ports/distfiles/ast-curr/asterisk/channels/chan_mgcp.c Sun Nov 6 15:09:46 2005 +++ work/asterisk-current/channels/chan_mgcp.c Fri Nov 25 17:29:41 2005 @@ -889,7 +889,7 @@ static int mgcp_call(struct ast_channel struct mgcp_endpoint *p; struct mgcp_subchannel *sub; char tone[50] = ""; - char *distinctive_ring = NULL; + const char *distinctive_ring = NULL; struct varshead *headp; struct ast_var_t *current; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/channels/chan_sip.c work/asterisk-current/channels/chan_sip.c --- /usr/ports/distfiles/ast-curr/asterisk/channels/chan_sip.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/channels/chan_sip.c Fri Nov 25 17:27:56 2005 @@ -462,11 +462,11 @@ struct sip_pkt; /*! \brief Parameters to the transmit_invite function */ struct sip_invite_param { - char *distinctive_ring; /*!< Distinctive ring header */ + const char *distinctive_ring; /*!< Distinctive ring header */ char *osptoken; /*!< OSP token for this call */ int addsipheaders; /*!< Add extra SIP headers */ - char *uri_options; /*!< URI options to add to the URI */ - char *vxml_url; /*!< VXML url for Cisco phones */ + const char *uri_options; /*!< URI options to add to the URI */ + const char *vxml_url; /*!< VXML url for Cisco phones */ char *auth; /*!< Authentication */ char *authheader; /*!< Auth header */ enum sip_auth_type auth_type; /*!< Authentication type */ @@ -2478,7 +2481,7 @@ static int sip_hangup(struct ast_channel static int sip_answer(struct ast_channel *ast) { int res = 0,fmt; - char *codec; + const char *codec; struct sip_pvt *p = ast->tech_pvt; ast_mutex_lock(&p->lock); @@ -12758,13 +12741,10 @@ static int sip_dtmfmode(struct ast_chann /*! \brief sip_addheader: Add a SIP header ---*/ static int sip_addheader(struct ast_channel *chan, void *data) { - int arglen; - int no = 0; - int ok = 0; - char *content = (char *) NULL; +#define N_MAX 50 /* max number of SIP headers */ char varbuf[128]; - - arglen = strlen(data); + int no; + int arglen = strlen(data); if (!arglen) { ast_log(LOG_WARNING, "This application requires the argument: Header\n"); return 0; @@ -12772,20 +12752,17 @@ static int sip_addheader(struct ast_chan ast_mutex_lock(&chan->lock); /* Check for headers */ - while (!ok && no <= 50) { - no++; + for (no = 1; no <= N_MAX; no++) { snprintf(varbuf, sizeof(varbuf), "_SIPADDHEADER%.2d", no); - content = pbx_builtin_getvar_helper(chan, varbuf); - - if (!content) - ok = 1; + if (pbx_builtin_getvar_helper(chan, varbuf)) + break; } - if (ok) { + if (no <= N_MAX) { pbx_builtin_setvar_helper (chan, varbuf, data); if (sipdebug) ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", (char *) data, varbuf); } else { - ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n"); + ast_log(LOG_WARNING, "Too many SIP headers added, max %d\n", N_MAX); } ast_mutex_unlock(&chan->lock); return 0; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/channels/chan_zap.c work/asterisk-current/channels/chan_zap.c --- /usr/ports/distfiles/ast-curr/asterisk/channels/chan_zap.c Fri Nov 11 18:00:07 2005 +++ work/asterisk-current/channels/chan_zap.c Fri Nov 25 17:31:30 2005 @@ -1932,7 +1932,7 @@ static int zt_call(struct ast_channel *a break; case SIG_FEATDMF_TA: { - char *cic = NULL, *ozz = NULL; + const char *cic, *ozz; /* If you have to go through a Tandem Access point you need to use this */ ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ"); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/chanvars.c work/asterisk-current/chanvars.c --- /usr/ports/distfiles/ast-curr/asterisk/chanvars.c Mon Oct 24 20:12:04 2005 +++ work/asterisk-current/chanvars.c Fri Nov 25 16:53:24 2005 @@ -59,31 +59,27 @@ void ast_var_delete(struct ast_var_t *va free(var); } -char *ast_var_name(struct ast_var_t *var) +const char *ast_var_name(const struct ast_var_t *var) { - char *name; + const char *name; - if (var == NULL) - return NULL; - if (var->name == NULL) + if (var == NULL || (name = var->name) == NULL) return NULL; /* Return the name without the initial underscores */ - if (var->name[0] == '_') { - if (var->name[1] == '_') - name = (char*)&(var->name[2]); - else - name = (char*)&(var->name[1]); - } else - name = var->name; + if (name[0] == '_') { + name++; + if (name[0] == '_') + name++; + } return name; } -char *ast_var_full_name(struct ast_var_t *var) +const char *ast_var_full_name(const struct ast_var_t *var) { return (var ? var->name : NULL); } -char *ast_var_value(struct ast_var_t *var) +const char *ast_var_value(const struct ast_var_t *var) { return (var ? var->value : NULL); } diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/cli.c work/asterisk-current/cli.c --- /usr/ports/distfiles/ast-curr/asterisk/cli.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/cli.c Mon Nov 21 18:07:15 2005 diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/frame.c work/asterisk-current/frame.c --- /usr/ports/distfiles/ast-curr/asterisk/frame.c Wed Nov 16 12:52:46 2005 +++ work/asterisk-current/frame.c Fri Nov 25 17:22:05 2005 @@ -539,7 +539,7 @@ static struct ast_codec_alias_table { {"g723.1","g723"}, }; -static char *ast_expand_codec_alias(char *in) { +static const char *ast_expand_codec_alias(const char *in) { int x = 0; for (x = 0; x < sizeof(ast_codec_alias_table) / sizeof(struct ast_codec_alias_table) ; x++) { @@ -549,7 +549,7 @@ static char *ast_expand_codec_alias(char return in; } -int ast_getformatbyname(char *name) +int ast_getformatbyname(const char *name) { int x = 0, all = 0, format = 0; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/funcs/func_groupcount.c work/asterisk-current/funcs/func_groupcount.c --- /usr/ports/distfiles/ast-curr/asterisk/funcs/func_groupcount.c Tue Nov 8 04:48:00 2005 +++ work/asterisk-current/funcs/func_groupcount.c Fri Nov 25 18:25:27 2005 @@ -40,7 +40,7 @@ static char *group_count_function_read(s int count; char group[80] = ""; char category[80] = ""; - char *grp; + const char *grp; ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)); @@ -101,7 +101,7 @@ struct ast_custom_function group_match_c static char *group_function_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { char varname[256]; - char *group; + const char *group; if (!ast_strlen_zero(data)) { snprintf(varname, sizeof(varname), "%s_%s", GROUP_CATEGORY_PREFIX, data); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/funcs/func_strings.c work/asterisk-current/funcs/func_strings.c --- /usr/ports/distfiles/ast-curr/asterisk/funcs/func_strings.c Tue Nov 8 04:48:00 2005 +++ work/asterisk-current/funcs/func_strings.c Mon Nov 21 18:07:15 2005 @@ -142,8 +142,8 @@ struct ast_custom_function len_function static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { char *format, *epoch, *timezone = NULL; - long epochi; - struct tm time; + time_t epochi; + struct tm tm; buf[0] = '\0'; @@ -161,18 +161,17 @@ static char *acf_strftime(struct ast_cha epoch = strsep(&format, "|"); timezone = strsep(&format, "|"); - if (ast_strlen_zero(epoch) || !sscanf(epoch, "%ld", &epochi)) { - struct timeval tv = ast_tvnow(); - epochi = tv.tv_sec; + if (ast_strlen_zero(epoch) || !sscanf(epoch, "%d", (int *)&epochi)) { + epochi = time(NULL); } - ast_localtime(&epochi, &time, timezone); + ast_localtime(&epochi, &tm, timezone); if (!format) { format = "%c"; } - if (!strftime(buf, len, format, &time)) { + if (!strftime(buf, len, format, &tm)) { ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n"); } buf[len - 1] = '\0'; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/app.h work/asterisk-current/include/asterisk/app.h --- /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/app.h Thu Nov 10 23:08:00 2005 +++ work/asterisk-current/include/asterisk/app.h Fri Nov 25 17:47:42 2005 @@ -167,16 +167,16 @@ char *ast_read_textfile(const char *file #define GROUP_CATEGORY_PREFIX "GROUP" /*! Split a group string into group and category, returning a default category if none is provided. */ -int ast_app_group_split_group(char *data, char *group, int group_max, char *category, int category_max); +int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max); /*! Set the group for a channel, splitting the provided data into group and category, if specified. */ -int ast_app_group_set_channel(struct ast_channel *chan, char *data); +int ast_app_group_set_channel(struct ast_channel *chan, const char *data); /*! Get the current channel count of the specified group and category. */ -int ast_app_group_get_count(char *group, char *category); +int ast_app_group_get_count(const char *group, const char *category); /*! Get the current channel count of all groups that match the specified pattern and category. */ -int ast_app_group_match_get_count(char *groupmatch, char *category); +int ast_app_group_match_get_count(const char *groupmatch, const char *category); /*! \brief Define an application argument diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/channel.h work/asterisk-current/include/asterisk/channel.h --- /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/channel.h Fri Nov 11 03:48:28 2005 +++ work/asterisk-current/include/asterisk/channel.h Fri Nov 25 17:33:19 2005 @@ -454,9 +475,9 @@ struct ast_bridge_config { long timelimit; long play_warning; long warning_freq; - char *warning_sound; - char *end_sound; - char *start_sound; + const char *warning_sound; + const char *end_sound; + const char *start_sound; int firstpass; unsigned int flags; }; diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/chanvars.h work/asterisk-current/include/asterisk/chanvars.h --- /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/chanvars.h Mon Oct 31 15:34:11 2005 +++ work/asterisk-current/include/asterisk/chanvars.h Fri Nov 25 16:53:53 2005 @@ -35,8 +35,8 @@ AST_LIST_HEAD_NOLOCK(varshead, ast_var_t struct ast_var_t *ast_var_assign(const char *name, const char *value); void ast_var_delete(struct ast_var_t *var); -char *ast_var_name(struct ast_var_t *var); -char *ast_var_full_name(struct ast_var_t *var); -char *ast_var_value(struct ast_var_t *var); +const char *ast_var_name(const struct ast_var_t *var); +const char *ast_var_full_name(const struct ast_var_t *var); +const char *ast_var_value(const struct ast_var_t *var); #endif /* _ASTERISK_CHANVARS_H */ diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/frame.h work/asterisk-current/include/asterisk/frame.h --- /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/frame.h Sun Nov 6 15:09:47 2005 +++ work/asterisk-current/include/asterisk/frame.h Fri Nov 25 17:19:01 2005 @@ -389,7 +389,7 @@ extern char* ast_getformatname_multiple( * \param name string of format * \return This returns the form of the format in binary on success, 0 on error. */ -extern int ast_getformatbyname(char *name); +extern int ast_getformatbyname(const char *name); /*! \brief Get a name from a format * Gets a name from a format diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/pbx.h work/asterisk-current/include/asterisk/pbx.h --- /usr/ports/distfiles/ast-curr/asterisk/include/asterisk/pbx.h Tue Nov 8 23:37:53 2005 +++ work/asterisk-current/include/asterisk/pbx.h Fri Nov 25 17:38:14 2005 @@ -605,7 +605,7 @@ struct ast_ignorepat *ast_walk_context_i struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw); int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size); -extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name); +extern const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name); extern void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value); extern void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value); extern void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp); @@ -620,11 +620,11 @@ int ast_extension_patmatch(const char *p set to 1, sets to auto fall through. If newval set to 0, sets to no auto fall through (reads extension instead). Returns previous value. */ extern int pbx_set_autofallthrough(int newval); -int ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority); +int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority); /* I can find neither parsable nor parseable at dictionary.com, but google gives me 169000 hits for parseable and only 49,800 for parsable */ int ast_parseable_goto(struct ast_channel *chan, const char *goto_string); int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority); -int ast_async_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority); +int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority); struct ast_custom_function* ast_custom_function_find(char *name); int ast_custom_function_unregister(struct ast_custom_function *acf); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/manager.c work/asterisk-current/manager.c --- /usr/ports/distfiles/ast-curr/asterisk/manager.c Wed Nov 16 12:52:46 2005 +++ work/asterisk-current/manager.c Fri Nov 25 16:51:12 2005 @@ -726,7 +726,7 @@ static int action_getvar(struct mansessi char *name = astman_get_header(m, "Channel"); char *varname = astman_get_header(m, "Variable"); char *id = astman_get_header(m,"ActionID"); - char *varval; + const char *varval; char *varval2=NULL; if (!strlen(varname)) { diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/pbx.c work/asterisk-current/pbx.c --- /usr/ports/distfiles/ast-curr/asterisk/pbx.c Mon Nov 21 17:43:46 2005 +++ work/asterisk-current/pbx.c Fri Nov 25 17:37:37 2005 @@ -1129,9 +1129,9 @@ icky: ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables)); #endif if (strcasecmp(ast_var_name(variables),var)==0) { - *ret=ast_var_value(variables); - if (*ret) { - ast_copy_string(workspace, *ret, workspacelen); + const char *s = ast_var_value(variables); + if (s) { + ast_copy_string(workspace, s, workspacelen); *ret = workspace; } break; @@ -1145,9 +1145,9 @@ icky: ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables)); #endif if (strcasecmp(ast_var_name(variables),var)==0) { - *ret = ast_var_value(variables); - if (*ret) { - ast_copy_string(workspace, *ret, workspacelen); + const char *s = ast_var_value(variables); + if (s) { + ast_copy_string(workspace, s, workspacelen); *ret = workspace; } } @@ -1670,7 +1670,8 @@ static int pbx_extension_helper(struct a pbx_builtin_setvar_helper(c, atmp, atmp2); } if (option_verbose > 2) - ast_verbose( VERBOSE_PREFIX_3 "Executing %s(\"%s\", \"%s\") %s\n", + ast_verbose( VERBOSE_PREFIX_3 "Executing [%s:%d] %s(\"%s\", \"%s\") %s\n", + context, priority, term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)), term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)), term_color(tmp3, passdata, COLOR_BRMAGENTA, 0, sizeof(tmp3)), @@ -2413,7 +2414,7 @@ static int __ast_pbx_run(struct ast_chan ast_cdr_update(c); } } else { - char *status; + const char *status; status = pbx_builtin_getvar_helper(c, "DIALSTATUS"); if (!status) @@ -5846,7 +5847,7 @@ static int pbx_builtin_goto(struct ast_c int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size) { struct ast_var_t *variables; - char *var, *val; + const char *var, *val; int total = 0; if (!chan) @@ -5870,7 +5871,7 @@ int pbx_builtin_serialize_variables(stru return total; } -char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name) +const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name) { struct ast_var_t *variables; struct varshead *headp; @@ -6383,7 +6384,7 @@ int ast_context_verify_includes(struct a } -static int __ast_goto_if_exists(struct ast_channel *chan, char *context, char *exten, int priority, int async) +static int __ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, int async) { int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority); @@ -6400,11 +6401,11 @@ static int __ast_goto_if_exists(struct a return -3; } -int ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority) { +int ast_goto_if_exists(struct ast_channel *chan, const char* context, const char *exten, int priority) { return __ast_goto_if_exists(chan, context, exten, priority, 0); } -int ast_async_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority) { +int ast_async_goto_if_exists(struct ast_channel *chan, const char * context, const char *exten, int priority) { return __ast_goto_if_exists(chan, context, exten, priority, 1); } diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/res/res_features.c work/asterisk-current/res/res_features.c --- /usr/ports/distfiles/ast-curr/asterisk/res/res_features.c Thu Nov 10 23:26:40 2005 +++ work/asterisk-current/res/res_features.c Fri Nov 25 17:14:03 2005 @@ -180,18 +180,14 @@ struct ast_bridge_thread_obj static void check_goto_on_transfer(struct ast_channel *chan) { struct ast_channel *xferchan; - char *goto_on_transfer; - - goto_on_transfer = pbx_builtin_getvar_helper(chan, "GOTO_ON_BLINDXFR"); + const char *val = pbx_builtin_getvar_helper(chan, "GOTO_ON_BLINDXFR"); + char *x, *goto_on_transfer; + struct ast_frame *f; - if (!ast_strlen_zero(goto_on_transfer) && (xferchan = ast_channel_alloc(0))) { - char *x; - struct ast_frame *f; - + if (!ast_strlen_zero(val) && (goto_on_transfer = ast_strdupa(val)) && (xferchan = ast_channel_alloc(0))) { for (x = goto_on_transfer; x && *x; x++) if (*x == '^') *x = '|'; - strcpy(xferchan->name, chan->name); /* Make formats okay */ xferchan->readformat = chan->readformat; @@ -446,7 +442,7 @@ int ast_masq_park_call(struct ast_channe static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense) { - char *touch_monitor = NULL, *caller_chan_id = NULL, *callee_chan_id = NULL, *args = NULL, *touch_format = NULL; + char *caller_chan_id = NULL, *callee_chan_id = NULL, *args = NULL; int x = 0; size_t len; struct ast_channel *caller_chan = NULL, *callee_chan = NULL; @@ -494,24 +490,24 @@ static int builtin_automonitor(struct as } if (caller_chan && callee_chan) { - touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT"); + const char * touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT"); + const char *touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR"); + if (!touch_format) touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT"); - - touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR"); if (!touch_monitor) touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR"); if (touch_monitor) { len = strlen(touch_monitor) + 50; args = alloca(len); - snprintf(args, len, "%s|auto-%ld-%s|m", (touch_format) ? touch_format : "wav", time(NULL), touch_monitor); + snprintf(args, len, "%s|auto-%d-%s|m", (touch_format) ? touch_format : "wav", (int)time(NULL), touch_monitor); } else { caller_chan_id = ast_strdupa(caller_chan->cid.cid_num ? caller_chan->cid.cid_num : caller_chan->name); callee_chan_id = ast_strdupa(callee_chan->cid.cid_num ? callee_chan->cid.cid_num : callee_chan->name); len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50; args = alloca(len); - snprintf(args, len, "%s|auto-%ld-%s-%s|m", (touch_format) ? touch_format : "wav", time(NULL), caller_chan_id, callee_chan_id); + snprintf(args, len, "%s|auto-%d-%s-%s|m", (touch_format) ? touch_format : "wav", (int)time(NULL), caller_chan_id, callee_chan_id); } for( x = 0; x < strlen(args); x++) @@ -541,7 +537,7 @@ static int builtin_blindtransfer(struct { struct ast_channel *transferer; struct ast_channel *transferee; - char *transferer_real_context; + const char *transferer_real_context; char newext[256]; int res; @@ -670,7 +666,7 @@ static int builtin_atxfer(struct ast_cha struct ast_channel *newchan, *xferchan=NULL; int outstate=0; struct ast_bridge_config bconfig; - char *transferer_real_context; + const char *transferer_real_context; char xferto[256],dialstr[265]; char *cid_num; char *cid_name; @@ -981,7 +977,7 @@ static int ast_feature_interpret(struct struct ast_flags features; int res = FEATURE_RETURN_PASSDIGITS; struct ast_call_feature *feature; - char *dynamic_features=pbx_builtin_getvar_helper(chan,"DYNAMIC_FEATURES"); + const char *dynamic_features=pbx_builtin_getvar_helper(chan,"DYNAMIC_FEATURES"); if (sense == FEATURE_SENSE_CHAN) ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL); @@ -1047,9 +1043,7 @@ static void set_config_flags(struct ast_ } if (chan && peer && !(ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_0) && ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_1))) { - char *dynamic_features; - - dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"); + const char *dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"); if (dynamic_features) { char *tmp = ast_strdupa(dynamic_features); @@ -1261,7 +1255,6 @@ int ast_bridge_call(struct ast_channel * struct ast_option_header *aoh; struct timeval start = { 0 , 0 }; struct ast_bridge_config backup_config; - char *monitor_exec; memset(&backup_config, 0, sizeof(backup_config)); @@ -1274,14 +1267,19 @@ int ast_bridge_call(struct ast_channel * pbx_builtin_setvar_helper(chan, "BLINDTRANSFER", NULL); if (monitor_ok) { + const char *monitor_exec; + struct ast_channel *src = NULL; if (!monitor_app) { if (!(monitor_app = pbx_findapp("Monitor"))) monitor_ok=0; } if ((monitor_exec = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR"))) - pbx_exec(chan, monitor_app, monitor_exec, 1); + src = chan; else if ((monitor_exec = pbx_builtin_getvar_helper(peer, "AUTO_MONITOR"))) - pbx_exec(peer, monitor_app, monitor_exec, 1); + src = peer; + /* XXX here the ast_strdupa() might be unnecessary if we had a better type for pbx_exec */ + if (src) + pbx_exec(src, monitor_app, ast_strdupa(monitor_exec), 1); } set_config_flags(chan, peer, config); diff -upr --exclude CVS --exclude say.c --exclude say --exclude config.guess --exclude config.sub /usr/ports/distfiles/ast-curr/asterisk/res/res_monitor.c work/asterisk-current/res/res_monitor.c --- /usr/ports/distfiles/ast-curr/asterisk/res/res_monitor.c Tue Nov 8 01:55:31 2005 +++ work/asterisk-current/res/res_monitor.c Fri Nov 25 16:55:33 2005 @@ -150,8 +150,8 @@ int ast_monitor_start( struct ast_channe while((p = strchr(channel_name, '/'))) { *p = '-'; } - snprintf(monitor->filename_base, FILENAME_MAX, "%s/%ld-%s", - ast_config_AST_MONITOR_DIR, time(NULL),channel_name); + snprintf(monitor->filename_base, FILENAME_MAX, "%s/%d-%s", + ast_config_AST_MONITOR_DIR, (int)time(NULL),channel_name); monitor->filename_changed = 1; } else { ast_log(LOG_ERROR,"Failed to allocate Memory\n"); @@ -212,7 +212,6 @@ int ast_monitor_start( struct ast_channe /* Stop monitoring a channel */ int ast_monitor_stop(struct ast_channel *chan, int need_lock) { - char *execute, *execute_args; int delfiles = 0; if (need_lock) { @@ -261,6 +260,7 @@ int ast_monitor_stop(struct ast_channel char *name = chan->monitor->filename_base; int directory = strchr(name, '/') ? 1 : 0; char *dir = directory ? "" : ast_config_AST_MONITOR_DIR; + const char *execute, *execute_args; /* Set the execute application */ execute = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC");