BSD portability enhancements (bug #234)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1486 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Mark Spencer 22 years ago
parent 1e19f72077
commit 479a67e629

@ -13,9 +13,9 @@
#include <string.h> #include <string.h>
#include <sys/select.h> #include <sys/select.h>
#include <fcntl.h> #include <fcntl.h>
#include <arpa/inet.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#define AUDIO_FILENO (STDERR_FILENO + 1) #define AUDIO_FILENO (STDERR_FILENO + 1)
@ -44,7 +44,7 @@ static int connect_sphinx(void)
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
sin.sin_port = htons(SPHINX_PORT); sin.sin_port = htons(SPHINX_PORT);
memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr)); memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
if (connect(sphinx_sock, &sin, sizeof(sin))) { if (connect(sphinx_sock, (struct sockaddr *)&sin, sizeof(sin))) {
fprintf(stderr, "Unable to connect on socket: %s\n", strerror(errno)); fprintf(stderr, "Unable to connect on socket: %s\n", strerror(errno));
close(sphinx_sock); close(sphinx_sock);
sphinx_sock = -1; sphinx_sock = -1;

@ -23,7 +23,7 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/signal.h> #include <signal.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
@ -152,7 +152,7 @@ static int launch_script(char *script, char *args, int *fds, int *efd, int *opid
for (x=STDERR_FILENO + 2;x<1024;x++) for (x=STDERR_FILENO + 2;x<1024;x++)
close(x); close(x);
/* Execute script */ /* Execute script */
execl(script, script, args, NULL); execl(script, script, args, (char *)NULL);
/* Can't use ast_log since FD's are closed */ /* Can't use ast_log since FD's are closed */
fprintf(stderr, "Failed to execute '%s': %s\n", script, strerror(errno)); fprintf(stderr, "Failed to execute '%s': %s\n", script, strerror(errno));
exit(1); exit(1);

@ -61,9 +61,9 @@ static int mp3play(char *filename, int fd)
} }
/* Execute mpg123, but buffer if it's a net connection */ /* Execute mpg123, but buffer if it's a net connection */
if (strncmp(filename, "http://", 7)) if (strncmp(filename, "http://", 7))
execl(MPG_123, MPG_123, "-q", "-s", "-b", "1024", "--mono", "-r", "8000", filename, NULL); execl(MPG_123, MPG_123, "-q", "-s", "-b", "1024", "--mono", "-r", "8000", filename, (char *)NULL);
else else
execl(MPG_123, MPG_123, "-q", "-s", "--mono", "-r", "8000", filename, NULL); execl(MPG_123, MPG_123, "-q", "-s", "--mono", "-r", "8000", filename, (char *)NULL);
ast_log(LOG_WARNING, "Execute of mpg123 failed\n"); ast_log(LOG_WARNING, "Execute of mpg123 failed\n");
return -1; return -1;
} }

@ -1372,7 +1372,7 @@ static int queues_show(int fd, int argc, char **argv)
strcat(max, " (dynamic)"); strcat(max, " (dynamic)");
if (mem->calls) { if (mem->calls) {
snprintf(calls, sizeof(calls), " has taken %d calls (last was %ld secs ago)", snprintf(calls, sizeof(calls), " has taken %d calls (last was %ld secs ago)",
mem->calls, time(NULL) - mem->lastcall); mem->calls, (long)(time(NULL) - mem->lastcall));
} else } else
strcpy(calls, " has taken no calls yet"); strcpy(calls, " has taken no calls yet");
ast_cli(fd, " %s/%s%s%s\n", mem->tech, mem->loc, max, calls); ast_cli(fd, " %s/%s%s%s\n", mem->tech, mem->loc, max, calls);

@ -643,7 +643,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
chan->priority, chan->priority,
chan->name, chan->name,
chan->callerid ? chan->callerid : "Unknown", chan->callerid ? chan->callerid : "Unknown",
date, time(NULL)); date, (long) time(NULL));
fclose(txt); fclose(txt);
} else } else
ast_log(LOG_WARNING, "Error opening text file for output\n"); ast_log(LOG_WARNING, "Error opening text file for output\n");
@ -809,7 +809,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
txt = fopen(txtfile, "a"); txt = fopen(txtfile, "a");
if (txt) { if (txt) {
time(&end); time(&end);
fprintf(txt, "duration=%ld\n", end-start); fprintf(txt, "duration=%ld\n", (long)(end-start));
fclose(txt); fclose(txt);
} }
/* Send e-mail if applicable */ /* Send e-mail if applicable */

@ -1095,7 +1095,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
chan->priority, chan->priority,
chan->name, chan->name,
chan->callerid ? chan->callerid : "Unknown", chan->callerid ? chan->callerid : "Unknown",
date, time(NULL)); date, (long)time(NULL));
fclose(txt); fclose(txt);
} else } else
ast_log(LOG_WARNING, "Error opening text file for output\n"); ast_log(LOG_WARNING, "Error opening text file for output\n");
@ -1105,7 +1105,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
txt = fopen(txtfile, "a"); txt = fopen(txtfile, "a");
if (txt) { if (txt) {
time(&end); time(&end);
fprintf(txt, "duration=%ld\n", end-start); fprintf(txt, "duration=%ld\n", (long)(end-start));
fclose(txt); fclose(txt);
} }
stringp = fmt; stringp = fmt;
@ -2100,10 +2100,11 @@ static int play_datetime_format(struct ast_channel *chan, time_t time, struct vm
{ {
struct timeval now; struct timeval now;
struct tm tmnow; struct tm tmnow;
time_t beg_today; time_t beg_today, tnow;
gettimeofday(&now,NULL); gettimeofday(&now,NULL);
localtime_r(&now.tv_sec,&tmnow); tnow = now.tv_sec;
localtime_r(&tnow,&tmnow);
tmnow.tm_hour = 0; tmnow.tm_hour = 0;
tmnow.tm_min = 0; tmnow.tm_min = 0;
tmnow.tm_sec = 0; tmnow.tm_sec = 0;
@ -2127,10 +2128,11 @@ static int play_datetime_format(struct ast_channel *chan, time_t time, struct vm
{ {
struct timeval now; struct timeval now;
struct tm tmnow; struct tm tmnow;
time_t beg_today; time_t beg_today, tnow;
gettimeofday(&now,NULL); gettimeofday(&now,NULL);
localtime_r(&now.tv_sec,&tmnow); tnow = now.tv_sec;
localtime_r(&tnow,&tmnow);
tmnow.tm_hour = 0; tmnow.tm_hour = 0;
tmnow.tm_min = 0; tmnow.tm_min = 0;
tmnow.tm_sec = 0; tmnow.tm_sec = 0;
@ -2184,9 +2186,10 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
char filename[256], *origtime, temp[256]; char filename[256], *origtime, temp[256];
struct vm_zone *the_zone = NULL; struct vm_zone *the_zone = NULL;
struct ast_config *msg_cfg; struct ast_config *msg_cfg;
time_t t; time_t t, tnow;
struct timeval tv_now; struct timeval tv_now;
struct tm time_now, time_then; struct tm time_now, time_then;
long tin;
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg); make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
snprintf(filename,sizeof(filename), "%s.txt", vms->fn2); snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
@ -2198,10 +2201,11 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime")))
return 0; return 0;
if (sscanf(origtime,"%ld",&t) < 1) { if (sscanf(origtime,"%ld",&tin) < 1) {
ast_log(LOG_WARNING, "Couldn't find origtime in %s\n", filename); ast_log(LOG_WARNING, "Couldn't find origtime in %s\n", filename);
return 0; return 0;
} }
t = tin;
ast_destroy(msg_cfg); ast_destroy(msg_cfg);
/* Does this user have a timezone specified? */ /* Does this user have a timezone specified? */
@ -2228,7 +2232,8 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
/* Set the DIFF_* variables */ /* Set the DIFF_* variables */
localtime_r(&t, &time_now); localtime_r(&t, &time_now);
gettimeofday(&tv_now,NULL); gettimeofday(&tv_now,NULL);
localtime_r(&tv_now.tv_sec,&time_then); tnow = tv_now.tv_sec;
localtime_r(&tnow,&time_then);
/* Day difference */ /* Day difference */
if (time_now.tm_year == time_then.tm_year) if (time_now.tm_year == time_then.tm_year)

@ -505,7 +505,7 @@ static void __quit_handler(int num)
quit_handler(num, 0, 1, 0); quit_handler(num, 0, 1, 0);
} }
static pthread_t consolethread = -1; static pthread_t consolethread = (pthread_t) -1;
static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp) static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
{ {
@ -538,7 +538,7 @@ static void console_verboser(const char *s, int pos, int replace, int complete)
fflush(stdout); fflush(stdout);
if (complete) if (complete)
/* Wake up a select()ing console */ /* Wake up a select()ing console */
if (consolethread > -1) if (consolethread != (pthread_t) -1)
pthread_kill(consolethread, SIGURG); pthread_kill(consolethread, SIGURG);
} }

@ -44,7 +44,7 @@ struct asent {
}; };
static struct asent *aslist = NULL; static struct asent *aslist = NULL;
static pthread_t asthread = -1; static pthread_t asthread = (pthread_t) -1;
static void *autoservice_run(void *ign) static void *autoservice_run(void *ign)
{ {
@ -80,7 +80,7 @@ static void *autoservice_run(void *ign)
ast_frfree(f); ast_frfree(f);
} }
} }
asthread = -1; asthread = (pthread_t) -1;
return NULL; return NULL;
} }
@ -90,7 +90,7 @@ int ast_autoservice_start(struct ast_channel *chan)
struct asent *as; struct asent *as;
int needstart; int needstart;
ast_mutex_lock(&autolock); ast_mutex_lock(&autolock);
needstart = (asthread == -1) ? 1 : 0 /* aslist ? 0 : 1 */; needstart = (asthread == (pthread_t) -1) ? 1 : 0 /* aslist ? 0 : 1 */;
as = aslist; as = aslist;
while(as) { while(as) {
if (as->chan == chan) if (as->chan == chan)
@ -142,7 +142,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
if (!chan->_softhangup) if (!chan->_softhangup)
res = 0; res = 0;
} }
if (asthread != -1) if (asthread != (pthread_t) -1)
pthread_kill(asthread, SIGURG); pthread_kill(asthread, SIGURG);
ast_mutex_unlock(&autolock); ast_mutex_unlock(&autolock);
/* Wait for it to un-block */ /* Wait for it to un-block */

@ -86,23 +86,26 @@ static int mysql_log(struct ast_cdr *cdr)
} }
if (connected) { if (connected) {
char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL, *uniqueid=NULL; char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL;
#ifdef MYSQL_LOGUNIQUEID
char *uniqueid=NULL;
#endif
/* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */ /* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
if (clid = alloca(strlen(cdr->clid) * 2 + 1)) if ((clid = alloca(strlen(cdr->clid) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, clid, cdr->clid, strlen(cdr->clid)); mysql_real_escape_string(&mysql, clid, cdr->clid, strlen(cdr->clid));
if (dcontext = alloca(strlen(cdr->dcontext) * 2 + 1)) if ((dcontext = alloca(strlen(cdr->dcontext) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, dcontext, cdr->dcontext, strlen(cdr->dcontext)); mysql_real_escape_string(&mysql, dcontext, cdr->dcontext, strlen(cdr->dcontext));
if (channel = alloca(strlen(cdr->channel) * 2 + 1)) if ((channel = alloca(strlen(cdr->channel) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, channel, cdr->channel, strlen(cdr->channel)); mysql_real_escape_string(&mysql, channel, cdr->channel, strlen(cdr->channel));
if (dstchannel = alloca(strlen(cdr->dstchannel) * 2 + 1)) if ((dstchannel = alloca(strlen(cdr->dstchannel) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, dstchannel, cdr->dstchannel, strlen(cdr->dstchannel)); mysql_real_escape_string(&mysql, dstchannel, cdr->dstchannel, strlen(cdr->dstchannel));
if (lastapp = alloca(strlen(cdr->lastapp) * 2 + 1)) if ((lastapp = alloca(strlen(cdr->lastapp) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, lastapp, cdr->lastapp, strlen(cdr->lastapp)); mysql_real_escape_string(&mysql, lastapp, cdr->lastapp, strlen(cdr->lastapp));
if (lastdata = alloca(strlen(cdr->lastdata) * 2 + 1)) if ((lastdata = alloca(strlen(cdr->lastdata) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, lastdata, cdr->lastdata, strlen(cdr->lastdata)); mysql_real_escape_string(&mysql, lastdata, cdr->lastdata, strlen(cdr->lastdata));
#ifdef MYSQL_LOGUNIQUEID #ifdef MYSQL_LOGUNIQUEID
if (uniqueid = alloca(strlen(cdr->uniqueid) * 2 + 1)) if ((uniqueid = alloca(strlen(cdr->uniqueid) * 2 + 1)) != NULL)
mysql_real_escape_string(&mysql, uniqueid, cdr->uniqueid, strlen(cdr->uniqueid)); mysql_real_escape_string(&mysql, uniqueid, cdr->uniqueid, strlen(cdr->uniqueid));
#endif #endif
@ -141,7 +144,7 @@ char *description(void)
return desc; return desc;
} }
int my_unload_module(void) static int my_unload_module(void)
{ {
if (connected) { if (connected) {
mysql_close(&mysql); mysql_close(&mysql);
@ -177,7 +180,7 @@ int my_unload_module(void)
return 0; return 0;
} }
int my_load_module(void) static int my_load_module(void)
{ {
int res; int res;
struct ast_config *cfg; struct ast_config *cfg;

@ -318,7 +318,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
tmp->data = NULL; tmp->data = NULL;
tmp->fin = 0; tmp->fin = 0;
tmp->fout = 0; tmp->fout = 0;
snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", time(NULL), uniqueint++); snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", (long)time(NULL), uniqueint++);
headp=&tmp->varshead; headp=&tmp->varshead;
ast_mutex_init(&tmp->lock); ast_mutex_init(&tmp->lock);
AST_LIST_HEAD_INIT(headp); AST_LIST_HEAD_INIT(headp);
@ -653,7 +653,7 @@ int ast_hangup(struct ast_channel *chan)
if (chan->blocking) { if (chan->blocking) {
ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
"is blocked by thread %ld in procedure %s! Expect a failure\n", "is blocked by thread %ld in procedure %s! Expect a failure\n",
pthread_self(), chan->name, chan->blocker, chan->blockproc); (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
CRASH; CRASH;
} }
if (!chan->zombie) { if (!chan->zombie) {

@ -194,7 +194,7 @@ static struct agent_pvt *add_agent(char *agent, int pending)
strncpy(p->agent, tmp, sizeof(p->agent) -1); strncpy(p->agent, tmp, sizeof(p->agent) -1);
ast_mutex_init( &p->lock ); ast_mutex_init( &p->lock );
ast_mutex_init( &p->app_lock ); ast_mutex_init( &p->app_lock );
p->owning_app = -1; p->owning_app = (pthread_t) -1;
p->app_sleep_cond = 1; p->app_sleep_cond = 1;
p->group = group; p->group = group;
p->pending = pending; p->pending = pending;

@ -3576,7 +3576,9 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
struct iax2_peer *peer; struct iax2_peer *peer;
int processed = 0; int processed = 0;
int totalcalls = 0; int totalcalls = 0;
#ifdef ZT_TIMERACK
int x = 1; int x = 1;
#endif
if (iaxtrunkdebug) if (iaxtrunkdebug)
ast_verbose("Beginning trunk processing\n"); ast_verbose("Beginning trunk processing\n");
if (events & AST_IO_PRI) { if (events & AST_IO_PRI) {
@ -5116,7 +5118,9 @@ static int set_config(char *config_file, struct sockaddr_in* sin){
int format; int format;
struct iax2_user *user; struct iax2_user *user;
struct iax2_peer *peer; struct iax2_peer *peer;
#if 0
static unsigned short int last_port=0; static unsigned short int last_port=0;
#endif
cfg = ast_load(config_file); cfg = ast_load(config_file);

@ -413,7 +413,7 @@ static int mgcp_postrequest(struct mgcp_subchannel *sub, unsigned char *data, in
time(&t); time(&t);
if (sub->messagepending && (sub->lastouttime + 20 < t)) { if (sub->messagepending && (sub->lastouttime + 20 < t)) {
ast_log(LOG_NOTICE, "Timeout waiting for response to message:%d, lastouttime: %ld, now: %ld. Dumping pending queue\n", ast_log(LOG_NOTICE, "Timeout waiting for response to message:%d, lastouttime: %ld, now: %ld. Dumping pending queue\n",
sub->msgs ? sub->msgs->seqno : -1, sub->lastouttime, t); sub->msgs ? sub->msgs->seqno : -1, (long) sub->lastouttime, (long) t);
dump_queue(sub->parent); dump_queue(sub->parent);
} }
msg->seqno = seqno; msg->seqno = seqno;
@ -2546,7 +2546,7 @@ static void *do_monitor(void *data)
static int restart_monitor(void) static int restart_monitor(void)
{ {
/* If we're supposed to be stopped -- stay stopped */ /* If we're supposed to be stopped -- stay stopped */
if (monitor_thread == -2) if (monitor_thread == (pthread_t) -2)
return 0; return 0;
if (ast_mutex_lock(&monlock)) { if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n"); ast_log(LOG_WARNING, "Unable to lock monitor\n");

@ -28,6 +28,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -82,7 +83,7 @@ static ast_mutex_t monlock = AST_MUTEX_INITIALIZER;
/* This is the thread for the monitor which checks for input on the channels /* This is the thread for the monitor which checks for input on the channels
which are not currently in use. */ which are not currently in use. */
static pthread_t monitor_thread = -1; static pthread_t monitor_thread = (pthread_t) -1;
static int restart_monitor(void); static int restart_monitor(void);
@ -644,7 +645,7 @@ static void *do_monitor(void *data)
static int restart_monitor() static int restart_monitor()
{ {
/* If we're supposed to be stopped -- stay stopped */ /* If we're supposed to be stopped -- stay stopped */
if (monitor_thread == -2) if (monitor_thread == (pthread_t) -2)
return 0; return 0;
if (ast_mutex_lock(&monlock)) { if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n"); ast_log(LOG_WARNING, "Unable to lock monitor\n");
@ -655,7 +656,7 @@ static int restart_monitor()
ast_log(LOG_WARNING, "Cannot kill myself\n"); ast_log(LOG_WARNING, "Cannot kill myself\n");
return -1; return -1;
} }
if (monitor_thread != -1) { if (monitor_thread != (pthread_t) -1) {
pthread_cancel(monitor_thread); pthread_cancel(monitor_thread);
/* Nudge it a little, as it's probably stuck in select */ /* Nudge it a little, as it's probably stuck in select */
pthread_kill(monitor_thread, SIGURG); pthread_kill(monitor_thread, SIGURG);
@ -949,11 +950,11 @@ int unload_module()
return -1; return -1;
} }
if (!ast_mutex_lock(&monlock)) { if (!ast_mutex_lock(&monlock)) {
if (monitor_thread > -1) { if (monitor_thread != (pthread_t) -1 && monitor_thread != (pthread_t) -2) {
pthread_cancel(monitor_thread); pthread_cancel(monitor_thread);
pthread_join(monitor_thread, NULL); pthread_join(monitor_thread, NULL);
} }
monitor_thread = -2; monitor_thread = (pthread_t) -2;
ast_mutex_unlock(&monlock); ast_mutex_unlock(&monlock);
} else { } else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n"); ast_log(LOG_WARNING, "Unable to lock the monitor\n");

@ -5287,7 +5287,7 @@ restartsearch:
static int restart_monitor(void) static int restart_monitor(void)
{ {
/* If we're supposed to be stopped -- stay stopped */ /* If we're supposed to be stopped -- stay stopped */
if (monitor_thread == -2) if (monitor_thread == (pthread_t) -2)
return 0; return 0;
if (ast_mutex_lock(&monlock)) { if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n"); ast_log(LOG_WARNING, "Unable to lock monitor\n");
@ -6140,7 +6140,7 @@ int unload_module()
pthread_kill(monitor_thread, SIGURG); pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL); pthread_join(monitor_thread, NULL);
} }
monitor_thread = -2; monitor_thread = (pthread_t) -2;
ast_mutex_unlock(&monlock); ast_mutex_unlock(&monlock);
} else { } else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n"); ast_log(LOG_WARNING, "Unable to lock the monitor\n");

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -18,6 +18,7 @@
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <asterisk/image.h> #include <asterisk/image.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/module.h> #include <asterisk/module.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>

@ -17,6 +17,7 @@
#include <asterisk/frame.h> #include <asterisk/frame.h>
#include <asterisk/sched.h> #include <asterisk/sched.h>
#include <asterisk/chanvars.h> #include <asterisk/chanvars.h>
#include <unistd.h>
#include <setjmp.h> #include <setjmp.h>
#include <pthread.h> #include <pthread.h>
@ -771,7 +772,7 @@ static inline int ast_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds,
#define CHECK_BLOCKING(c) { \ #define CHECK_BLOCKING(c) { \
if ((c)->blocking) {\ if ((c)->blocking) {\
ast_log(LOG_WARNING, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", pthread_self(), (c)->name, (c)->blocker, (c)->blockproc); \ ast_log(LOG_WARNING, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), (c)->name, (long) (c)->blocker, (c)->blockproc); \
CRASH; \ CRASH; \
} else { \ } else { \
(c)->blocker = pthread_self(); \ (c)->blocker = pthread_self(); \

@ -13,7 +13,9 @@
#ifndef _ASTERISK_SRV_H #ifndef _ASTERISK_SRV_H
#define _ASTERISK_SRV_H #define _ASTERISK_SRV_H
#include <asterisk/channel.h>
struct ast_channel;
/* Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup */ /* Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup */
extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service); extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service);

@ -170,7 +170,9 @@ int ast_load_resource(char *resource_name)
int res; int res;
struct module *m; struct module *m;
int flags=RTLD_NOW; int flags=RTLD_NOW;
#ifdef RTLD_GLOBAL
char *val; char *val;
#endif
char *key; char *key;
int o; int o;
struct ast_config *cfg; struct ast_config *cfg;

@ -250,7 +250,7 @@ extern void ast_log(int level, const char *file, int line, const char *function,
} else } else
/** Cannot use ast_log() from locked section of ast_log()! /** Cannot use ast_log() from locked section of ast_log()!
ast_log(LOG_WARNING, "Unable to retrieve local time?\n"); **/ ast_log(LOG_WARNING, "Unable to retrieve local time?\n"); **/
fprintf(stderr, "ast_log: Unable to retrieve local time for %ld?\n", t); fprintf(stderr, "ast_log: Unable to retrieve local time for %ld?\n", (long)t);
} else { } else {
if (logfiles) { if (logfiles) {
f = logfiles; f = logfiles;
@ -260,12 +260,12 @@ extern void ast_log(int level, const char *file, int line, const char *function,
time(&t); time(&t);
localtime_r(&t,&tm); localtime_r(&t,&tm);
strftime(date, sizeof(date), "%b %e %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); fprintf(f->f, "%s %s[%ld]: File %s, Line %d (%s): ", date, levels[level], (long)pthread_self(), file, line, function);
} else { } else {
sprintf(linestr, "%d", line); sprintf(linestr, "%d", line);
fprintf(f->f, "%s[%ld]: File %s, Line %s (%s): ", fprintf(f->f, "%s[%ld]: File %s, Line %s (%s): ",
term_color(tmp, levels[level], colors[level], 0, sizeof(tmp)), term_color(tmp, levels[level], colors[level], 0, sizeof(tmp)),
pthread_self(), (long)pthread_self(),
term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)), term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)), term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4))); term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
@ -278,7 +278,7 @@ extern void ast_log(int level, const char *file, int line, const char *function,
f = f->next; f = f->next;
} }
} else { } else {
fprintf(stdout, "%s[%ld]: File %s, Line %d (%s): ", levels[level], pthread_self(), file, line, function); fprintf(stdout, "%s[%ld]: File %s, Line %d (%s): ", levels[level], (long)pthread_self(), file, line, function);
va_start(ap, fmt); va_start(ap, fmt);
vfprintf(stdout, fmt, ap); vfprintf(stdout, fmt, ap);
va_end(ap); va_end(ap);

@ -726,7 +726,7 @@ static void *accept_thread(void *ignore)
for (;;) { for (;;) {
sinlen = sizeof(sin); sinlen = sizeof(sin);
as = accept(asock, &sin, &sinlen); as = accept(asock, (struct sockaddr *)&sin, &sinlen);
if (as < 0) { if (as < 0) {
ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno)); ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
continue; continue;
@ -921,7 +921,7 @@ int init_manager(void)
return -1; return -1;
} }
setsockopt(asock, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x)); setsockopt(asock, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x));
if (bind(asock, &ba, sizeof(ba))) { if (bind(asock, (struct sockaddr *)&ba, sizeof(ba))) {
ast_log(LOG_WARNING, "Unable to bind socket: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unable to bind socket: %s\n", strerror(errno));
close(asock); close(asock);
asock = -1; asock = -1;

@ -32,8 +32,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <signal.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/signal.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <glib.h> #include <glib.h>

@ -243,7 +243,7 @@ static int scan_service(char *fn, time_t now, time_t atime)
if (o->retries <= o->maxretries + 1) { if (o->retries <= o->maxretries + 1) {
/* Add a retry line at the end */ /* Add a retry line at the end */
fseek(f, 0L, SEEK_END); fseek(f, 0L, SEEK_END);
fprintf(f, "Retry: %d (%ld)\n", o->retries, now); fprintf(f, "Retry: %d (%ld)\n", o->retries, (long) now);
fclose(f); fclose(f);
now += o->retrytime; now += o->retrytime;
launch_service(o); launch_service(o);

@ -27,6 +27,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
@ -477,7 +478,9 @@ static struct ast_generator mohgen =
static int moh_register(char *classname, char *mode, char *param, char *miscargs) static int moh_register(char *classname, char *mode, char *param, char *miscargs)
{ {
struct mohclass *moh; struct mohclass *moh;
#ifdef ZAPATA_MOH
int x; int x;
#endif
ast_mutex_lock(&moh_lock); ast_mutex_lock(&moh_lock);
moh = get_mohbyname(classname); moh = get_mohbyname(classname);
ast_mutex_unlock(&moh_lock); ast_mutex_unlock(&moh_lock);

@ -723,8 +723,8 @@ struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io,
rtp->us.sin_port = htons(x); rtp->us.sin_port = htons(x);
if (rtp->rtcp) if (rtp->rtcp)
rtp->rtcp->us.sin_port = htons(x + 1); rtp->rtcp->us.sin_port = htons(x + 1);
if (!bind(rtp->s, &rtp->us, sizeof(rtp->us)) && if (!bind(rtp->s, (struct sockaddr *)&rtp->us, sizeof(rtp->us)) &&
(!rtp->rtcp || !bind(rtp->rtcp->s, &rtp->rtcp->us, sizeof(rtp->rtcp->us)))) (!rtp->rtcp || !bind(rtp->rtcp->s, (struct sockaddr *)&rtp->rtcp->us, sizeof(rtp->rtcp->us))))
break; break;
if (errno != EADDRINUSE) { if (errno != EADDRINUSE) {
ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno));
@ -873,7 +873,7 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0)); rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
for (x=0;x<4;x++) { for (x=0;x<4;x++) {
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) { if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, hdrlen + 4, 0, &rtp->them, sizeof(rtp->them)); res = sendto(rtp->s, (void *)rtpheader, hdrlen + 4, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
if (res <0) if (res <0)
ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno)); ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
#if 0 #if 0
@ -960,7 +960,7 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
rtpheader[1] = htonl(rtp->lastts); rtpheader[1] = htonl(rtp->lastts);
rtpheader[2] = htonl(rtp->ssrc); rtpheader[2] = htonl(rtp->ssrc);
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) { if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, &rtp->them, sizeof(rtp->them)); res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
if (res <0) if (res <0)
ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno)); ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
#if 0 #if 0

@ -309,8 +309,8 @@ void ast_sched_dump(struct sched_context *con)
q->id, q->id,
q->callback, q->callback,
q->data, q->data,
s, (long)s,
ms); (long)ms);
q=q->next; q=q->next;
} }
ast_log(LOG_DEBUG, "=================================================\n"); ast_log(LOG_DEBUG, "=================================================\n");

Loading…
Cancel
Save