"Enter voicemail system";
static char *descrip_vmain =
-" VoiceMailMain(): Enters the main voicemail system for the checking of voicemail. The mailbox\n"
-"can be passed as the option, which will stop the voicemail system from prompting the user\n"
-"for the mailbox. If the mailbox is preceeded by 's' then the passsword check will be skipped.\n"
-"Returns -1 if the user hangs up or 0 otherwise.\n";
+" VoiceMailMain(): Enters the main voicemail system for the checking of\n"
+"voicemail. The mailbox can be passed as the option, which will stop the\n"
+"voicemail system from prompting the user for the mailbox. If the mailbox\n"
+"is preceded by 's' then the password check will be skipped. Returns -1 if\n"
+"the user hangs up or 0 otherwise.\n";
/* Leave a message */
static char *app = "VoiceMail";
char fname[256];
char dur[256];
time_t t;
- struct tm *tm;
+ struct tm tm;
char *astattach;
struct ast_config *cfg;
p = popen(SENDMAIL, "w");
}
snprintf(dur, sizeof(dur), "%ld:%02ld", duration / 60, duration % 60);
time(&t);
- tm = localtime(&t);
- strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", tm);
+ localtime_r(&t,&tm);
+ strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm);
fprintf(p, "Date: %s\n", date);
fprintf(p, "From: Asterisk PBX <%s>\n", who);
fprintf(p, "To: %s <%s>\n", name, email);
fprintf(p, "--%s\n", bound);
}
fprintf(p, "Content-Type: TEXT/PLAIN; charset=US-ASCII\n\n");
- strftime(date, sizeof(date), "%A, %B %d, %Y at %r", tm);
+ strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
fprintf(p, "Dear %s:\n\n\tJust wanted to let you know you were just left a %s long message (number %d)\n"
"in mailbox %s from %s, on %s so you might\n"
static int get_date(char *s, int len)
{
- struct tm *tm;
+ struct tm tm;
time_t t;
t = time(0);
- tm = localtime(&t);
- return strftime(s, len, "%a %b %e %r %Z %Y", tm);
+ localtime_r(&t,&tm);
+ return strftime(s, len, "%a %b %e %r %Z %Y", &tm);
}
static int invent_message(struct ast_channel *chan, char *ext, int busy, char *ecodes)
static char *synopsis = "Block telemarketers with SIT";
static char *descrip =
-" Zapateller(options): Generates special information tone to block telemarketers\n"
-"from calling you. Returns 0 normally or -1 on hangup. Options is a pipe-delimited\n"
-"list of options. The following options are available: 'answer' causes the line to\n"
-"be answered before playing the tone, 'nocallerid' causes Zapateller to only play\n"
-"the tone if there is no callerid information available. Options should be\n"
-"seperated by | characters.\n";
+" Zapateller(options): Generates special information tone to block\n"
+"telemarketers from calling you. Returns 0 normally or -1 on hangup.\n"
+"Options is a pipe-delimited list of options. The following options\n"
+"are available: 'answer' causes the line to be answered before playing\n"
+"the tone, 'nocallerid' causes Zapateller to only play the tone if there\n"
+"is no callerid information available. Options should be separated by |\n"
+"characters\n";
STANDARD_LOCAL_USER;
static int callerid_genmsg(char *msg, int size, char *number, char *name, int flags)
{
time_t t;
- struct tm *tm;
+ struct tm tm;
char *ptr;
int res;
int i,x;
/* Get the time */
time(&t);
- tm = localtime(&t);
+ localtime_r(&t,&tm);
ptr = msg;
/* Format time and message header */
- res = snprintf(ptr, size, "\001\010%02d%02d%02d%02d", tm->tm_mon + 1,
- tm->tm_mday, tm->tm_hour, tm->tm_min);
+ res = snprintf(ptr, size, "\001\010%02d%02d%02d%02d", tm.tm_mon + 1,
+ tm.tm_mday, tm.tm_hour, tm.tm_min);
size -= res;
ptr += res;
if (!number || !strlen(number) || (flags & CID_UNKNOWN_NUMBER)) {
static int append_date(char *buf, struct timeval tv, int len)
{
char tmp[80];
- struct tm *tm;
+ struct tm tm;
time_t t;
t = tv.tv_sec;
if (strlen(buf) > len - 3)
strncat(buf, ",", len);
return 0;
}
- tm = localtime(&t);
- strftime(tmp, sizeof(tmp), DATE_FORMAT, tm);
+ localtime_r(&t,&tm);
+ strftime(tmp, sizeof(tmp), DATE_FORMAT, &tm);
return append_string(buf, tmp, len);
}
static int mysql_log(struct ast_cdr *cdr)
{
- struct tm *tm;
+ struct tm tm;
struct timeval tv;
struct timezone tz;
char *sqlcmd, timestr[128];
gettimeofday(&tv,&tz);
t = tv.tv_sec;
- tm = localtime(&t);
- strftime(timestr,128,DATE_FORMAT,tm);
+ localtime_r(&t,&tm);
+ strftime(timestr,128,DATE_FORMAT,&tm);
ast_log(LOG_DEBUG,"cdr_mysql: inserting a CDR record.\n");
char tone2[256];
char *l, *n;
time_t t;
- struct tm *tm;
+ struct tm tm;
time(&t);
- tm = localtime(&t);
+ localtime_r(&t,&tm);
if (callerid)
strncpy(cid, callerid, sizeof(cid) - 1);
else
if (!l)
l = "";
snprintf(tone2, sizeof(tone2), "%s,L/ci(%02d/%02d/%02d/%02d,%s,%s)", tone,
- tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, l, n);
+ tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, l, n);
strncpy(p->curtone, tone, sizeof(p->curtone) - 1);
reqprep(&resp, p, "RQNT");
add_header(&resp, "X", p->txident);
PHONE_CID cid;
time_t UtcTime;
- struct tm *t;
+ struct tm tm;
if (ast->callerid) {
time(&UtcTime);
- t = localtime(&UtcTime);
+ localtime_r(&UtcTime,&tm);
- if(t != NULL) {
- sprintf(cid.month, "%02d",(t->tm_mon + 1));
- sprintf(cid.day, "%02d", t->tm_mday);
- sprintf(cid.hour, "%02d", t->tm_hour);
- sprintf(cid.min, "%02d", t->tm_min);
+ if(&tm != NULL) {
+ sprintf(cid.month, "%02d",(tm.tm_mon + 1));
+ sprintf(cid.day, "%02d", tm.tm_mday);
+ sprintf(cid.hour, "%02d", tm.tm_hour);
+ sprintf(cid.min, "%02d", tm.tm_min);
}
strcpy(cid.name, "Unknown");
sprintf(cid.number,"%s",ast->callerid);
/* Interface lookup code courtesy Tilghman of DrunkCoder.com. Thanks! */
struct my_ifreq {
- union
- {
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
- } ifr_ifrn;
-
- union
- {
struct sockaddr_in ifru_addr;
- char ifru_data[512];
- } ifr_ifru;
};
struct in_addr *lookup_iface(char *iface) {
int res;
static struct my_ifreq ifreq;
memset(&ifreq, 0, sizeof(ifreq));
- strncpy(ifreq.ifr_ifrn.ifrn_name,iface,sizeof(ifreq.ifr_ifrn.ifrn_name) - 1);
+ strncpy(ifreq.ifrn_name,iface,sizeof(ifreq.ifrn_name) - 1);
mysock = socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
res = ioctl(mysock,SIOCGIFADDR,&ifreq);
ast_log(LOG_WARNING, "Unable to get IP of %s: %s\n", iface, strerror(errno));
return &__ourip;
}
- return( (struct in_addr *) &ifreq.ifr_ifru.ifru_addr.sin_addr );
+ return( (struct in_addr *) &ifreq.ifru_addr.sin_addr );
}
static struct in_addr *myaddrfor(struct in_addr *them)
char tmp4[80];
char linestr[80];
time_t t;
- struct tm *tm;
+ struct tm tm;
struct logfile *f;
va_list ap;
ast_pthread_mutex_lock(&loglock);
if (level == 1 /* Event */) {
time(&t);
- tm = localtime(&t);
- if (tm) {
+ localtime_r(&t,&tm);
+ if (&tm) {
/* Log events into the event log file, with a different format */
- strftime(date, sizeof(date), "%b %e %T", tm);
+ strftime(date, sizeof(date), "%b %e %T", &tm);
fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
va_start(ap, fmt);
vfprintf(eventlog, fmt, ap);
if (f->logflags & (1 << level) && f->f) {
if ((f->f != stdout) && (f->f != stderr)) {
time(&t);
- tm = localtime(&t);
- strftime(date, sizeof(date), "%b %e %T", tm);
+ localtime_r(&t,&tm);
+ strftime(date, sizeof(date), "%b %e %T", &tm);
fprintf(f->f, "%s %s[%ld]: File %s, Line %d (%s): ", date, levels[level], pthread_self(), file, line, function);
} else {
sprintf(linestr, "%d", line);
static inline int include_valid(struct ast_include *i)
{
- struct tm *tm;
+ struct tm tm;
time_t t;
if (!i->hastime)
return 1;
time(&t);
- tm = localtime(&t);
- if (!tm) {
+ localtime_r(&t,&tm);
+ if (!&tm) {
ast_log(LOG_WARNING, "Failed to get local time\n");
return 0;
}
/* If it's not the right month, return */
- if (!(i->monthmask & (1 << tm->tm_mon))) {
+ if (!(i->monthmask & (1 << tm.tm_mon))) {
return 0;
}
/* If it's not that time of the month.... */
/* Warning, tm_mday has range 1..31! */
- if (!(i->daymask & (1 << (tm->tm_mday-1))))
+ if (!(i->daymask & (1 << (tm.tm_mday-1))))
return 0;
/* If it's not the right day of the week */
- if (!(i->dowmask & (1 << tm->tm_wday)))
+ if (!(i->dowmask & (1 << tm.tm_wday)))
return 0;
/* Sanity check the hour just to be safe */
- if ((tm->tm_hour < 0) || (tm->tm_hour > 23)) {
+ if ((tm.tm_hour < 0) || (tm.tm_hour > 23)) {
ast_log(LOG_WARNING, "Insane time...\n");
return 0;
}
/* Now the tough part, we calculate if it fits
in the right time based on min/hour */
- if (!(i->minmask[tm->tm_hour] & (1 << (tm->tm_min / 2))))
+ if (!(i->minmask[tm.tm_hour] & (1 << (tm.tm_min / 2))))
return 0;
/* If we got this far, then we're good */
}
int ast_say_date(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
- struct tm *tm;
+ struct tm tm;
char fn[256];
int res = 0;
- tm = localtime(&t);
- if (!tm) {
+ localtime_r(&t,&tm);
+ if (!&tm) {
ast_log(LOG_WARNING, "Unable to derive local time\n");
return -1;
}
if (!res) {
- snprintf(fn, sizeof(fn), "digits/day-%d", tm->tm_wday);
+ snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
- snprintf(fn, sizeof(fn), "digits/mon-%d", tm->tm_mon);
+ snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
- res = ast_say_number(chan, tm->tm_mday, ints, lang);
+ res = ast_say_number(chan, tm.tm_mday, ints, lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- res = ast_say_number(chan, tm->tm_year + 1900, ints, lang);
+ res = ast_say_number(chan, tm.tm_year + 1900, ints, lang);
return res;
}
int ast_say_time(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
- struct tm *tm;
+ struct tm tm;
int res = 0;
int hour, pm=0;
- tm = localtime(&t);
- if (!tm) {
+ localtime_r(&t,&tm);
+ if (!&tm) {
ast_log(LOG_WARNING, "Unable to derive local time\n");
return -1;
}
- hour = tm->tm_hour;
+ hour = tm.tm_hour;
if (!hour)
hour = 12;
else if (hour == 12)
if (!res)
res = ast_say_number(chan, hour, ints, lang);
- if (tm->tm_min > 9) {
+ if (tm.tm_min > 9) {
if (!res)
- res = ast_say_number(chan, tm->tm_min, ints, lang);
- } else if (tm->tm_min) {
+ res = ast_say_number(chan, tm.tm_min, ints, lang);
+ } else if (tm.tm_min) {
if (!res)
res = ast_streamfile(chan, "digits/oh", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- res = ast_say_number(chan, tm->tm_min, ints, lang);
+ res = ast_say_number(chan, tm.tm_min, ints, lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/oclock", lang);
int ast_say_datetime(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
- struct tm *tm;
+ struct tm tm;
char fn[256];
int res = 0;
int hour, pm=0;
- tm = localtime(&t);
- if (!tm) {
+ localtime_r(&t,&tm);
+ if (!&tm) {
ast_log(LOG_WARNING, "Unable to derive local time\n");
return -1;
}
if (!res) {
- snprintf(fn, sizeof(fn), "digits/day-%d", tm->tm_wday);
+ snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
- snprintf(fn, sizeof(fn), "digits/mon-%d", tm->tm_mon);
+ snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
- res = ast_say_number(chan, tm->tm_mday, ints, lang);
+ res = ast_say_number(chan, tm.tm_mday, ints, lang);
- hour = tm->tm_hour;
+ hour = tm.tm_hour;
if (!hour)
hour = 12;
else if (hour == 12)
if (!res)
res = ast_say_number(chan, hour, ints, lang);
- if (tm->tm_min > 9) {
+ if (tm.tm_min > 9) {
if (!res)
- res = ast_say_number(chan, tm->tm_min, ints, lang);
- } else if (tm->tm_min) {
+ res = ast_say_number(chan, tm.tm_min, ints, lang);
+ } else if (tm.tm_min) {
if (!res)
res = ast_streamfile(chan, "digits/oh", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- res = ast_say_number(chan, tm->tm_min, ints, lang);
+ res = ast_say_number(chan, tm.tm_min, ints, lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/oclock", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
- res = ast_say_number(chan, tm->tm_year + 1900, ints, lang);
+ res = ast_say_number(chan, tm.tm_year + 1900, ints, lang);
return res;
}
int res=0;
time_t nowt;
int daydiff;
- struct tm *tm;
- struct tm tm2;
- struct tm *now;
+ struct tm tm;
+ struct tm now;
char fn[256];
time(&nowt);
- tm = localtime(&t);
- if (!tm) {
+ localtime_r(&t,&tm);
+ if (!&tm) {
ast_log(LOG_WARNING, "Unable to derive local time\n");
return -1;
}
- memcpy(&tm2, tm, sizeof(struct tm));
- tm = &tm2;
- now = localtime(&nowt);
- daydiff = now->tm_yday - tm->tm_yday;
+ localtime_r(&nowt,&now);
+ daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
if (!res) {
- snprintf(fn, sizeof(fn), "digits/mon-%d", tm->tm_mon);
+ snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
- res = ast_say_number(chan, tm->tm_mday, ints, lang);
+ res = ast_say_number(chan, tm.tm_mday, ints, lang);
} else if (daydiff) {
/* Just what day of the week */
if (!res) {
- snprintf(fn, sizeof(fn), "digits/day-%d", tm->tm_wday);
+ snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);