aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-08 16:48:07 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-08 16:48:07 +0000
commit2be6d9d7c174007ac0018fed802364d2115f0283 (patch)
tree32674bc8c5dc21153e7c8a4548f6641aef0566bf
parentee8cba2208114438d40442616149adf12cc422c2 (diff)
BSD portability enhancements (bug #234)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1486 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xagi/eagi-sphinx-test.c4
-rwxr-xr-xapps/app_agi.c4
-rwxr-xr-xapps/app_mp3.c4
-rwxr-xr-xapps/app_queue.c2
-rwxr-xr-xapps/app_voicemail.c4
-rwxr-xr-xapps/app_voicemail2.c23
-rwxr-xr-xasterisk.c4
-rwxr-xr-xautoservice.c8
-rwxr-xr-xcdr/cdr_mysql.c23
-rwxr-xr-xchannel.c4
-rwxr-xr-xchannels/chan_agent.c2
-rwxr-xr-xchannels/chan_iax2.c4
-rwxr-xr-xchannels/chan_mgcp.c4
-rwxr-xr-xchannels/chan_modem.c11
-rwxr-xr-xchannels/chan_sip.c4
-rwxr-xr-xformats/format_g729.c1
-rwxr-xr-xformats/format_gsm.c1
-rwxr-xr-xformats/format_h263.c1
-rwxr-xr-xformats/format_jpeg.c1
-rwxr-xr-xformats/format_mp3.c1
-rwxr-xr-xformats/format_pcm.c1
-rwxr-xr-xformats/format_pcm_alaw.c1
-rwxr-xr-xformats/format_vox.c1
-rwxr-xr-xformats/format_wav.c1
-rwxr-xr-xformats/format_wav_gsm.c1
-rwxr-xr-xinclude/asterisk/channel.h3
-rwxr-xr-xinclude/asterisk/srv.h4
-rwxr-xr-xloader.c2
-rwxr-xr-xlogger.c8
-rwxr-xr-xmanager.c4
-rwxr-xr-xpbx/pbx_gtkconsole.c2
-rwxr-xr-xpbx/pbx_spool.c2
-rwxr-xr-xres/res_musiconhold.c3
-rwxr-xr-xrtp.c8
-rwxr-xr-xsched.c4
35 files changed, 93 insertions, 62 deletions
diff --git a/agi/eagi-sphinx-test.c b/agi/eagi-sphinx-test.c
index ed0239435..3015b730b 100755
--- a/agi/eagi-sphinx-test.c
+++ b/agi/eagi-sphinx-test.c
@@ -13,9 +13,9 @@
#include <string.h>
#include <sys/select.h>
#include <fcntl.h>
-#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <netdb.h>
#define AUDIO_FILENO (STDERR_FILENO + 1)
@@ -44,7 +44,7 @@ static int connect_sphinx(void)
sin.sin_family = AF_INET;
sin.sin_port = htons(SPHINX_PORT);
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));
close(sphinx_sock);
sphinx_sock = -1;
diff --git a/apps/app_agi.c b/apps/app_agi.c
index 6399c0249..294b56bd3 100755
--- a/apps/app_agi.c
+++ b/apps/app_agi.c
@@ -23,7 +23,7 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/signal.h>
+#include <signal.h>
#include <sys/time.h>
#include <stdio.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++)
close(x);
/* Execute script */
- execl(script, script, args, NULL);
+ execl(script, script, args, (char *)NULL);
/* Can't use ast_log since FD's are closed */
fprintf(stderr, "Failed to execute '%s': %s\n", script, strerror(errno));
exit(1);
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 52f1225c6..c8196a75f 100755
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -61,9 +61,9 @@ static int mp3play(char *filename, int fd)
}
/* Execute mpg123, but buffer if it's a net connection */
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
- 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");
return -1;
}
diff --git a/apps/app_queue.c b/apps/app_queue.c
index af349a0d7..68d883c10 100755
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1372,7 +1372,7 @@ static int queues_show(int fd, int argc, char **argv)
strcat(max, " (dynamic)");
if (mem->calls) {
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
strcpy(calls, " has taken no calls yet");
ast_cli(fd, " %s/%s%s%s\n", mem->tech, mem->loc, max, calls);
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 8ee076acd..8c2a23f9d 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -643,7 +643,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
chan->priority,
chan->name,
chan->callerid ? chan->callerid : "Unknown",
- date, time(NULL));
+ date, (long) time(NULL));
fclose(txt);
} else
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");
if (txt) {
time(&end);
- fprintf(txt, "duration=%ld\n", end-start);
+ fprintf(txt, "duration=%ld\n", (long)(end-start));
fclose(txt);
}
/* Send e-mail if applicable */
diff --git a/apps/app_voicemail2.c b/apps/app_voicemail2.c
index 7fb3b4388..e5f1db755 100755
--- a/apps/app_voicemail2.c
+++ b/apps/app_voicemail2.c
@@ -1095,7 +1095,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
chan->priority,
chan->name,
chan->callerid ? chan->callerid : "Unknown",
- date, time(NULL));
+ date, (long)time(NULL));
fclose(txt);
} else
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");
if (txt) {
time(&end);
- fprintf(txt, "duration=%ld\n", end-start);
+ fprintf(txt, "duration=%ld\n", (long)(end-start));
fclose(txt);
}
stringp = fmt;
@@ -2100,10 +2100,11 @@ static int play_datetime_format(struct ast_channel *chan, time_t time, struct vm
{
struct timeval now;
struct tm tmnow;
- time_t beg_today;
+ time_t beg_today, tnow;
gettimeofday(&now,NULL);
- localtime_r(&now.tv_sec,&tmnow);
+ tnow = now.tv_sec;
+ localtime_r(&tnow,&tmnow);
tmnow.tm_hour = 0;
tmnow.tm_min = 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 tm tmnow;
- time_t beg_today;
+ time_t beg_today, tnow;
gettimeofday(&now,NULL);
- localtime_r(&now.tv_sec,&tmnow);
+ tnow = now.tv_sec;
+ localtime_r(&tnow,&tmnow);
tmnow.tm_hour = 0;
tmnow.tm_min = 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];
struct vm_zone *the_zone = NULL;
struct ast_config *msg_cfg;
- time_t t;
+ time_t t, tnow;
struct timeval tv_now;
struct tm time_now, time_then;
+ long tin;
make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
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")))
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);
return 0;
}
+ t = tin;
ast_destroy(msg_cfg);
/* 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 */
localtime_r(&t, &time_now);
gettimeofday(&tv_now,NULL);
- localtime_r(&tv_now.tv_sec,&time_then);
+ tnow = tv_now.tv_sec;
+ localtime_r(&tnow,&time_then);
/* Day difference */
if (time_now.tm_year == time_then.tm_year)
diff --git a/asterisk.c b/asterisk.c
index 498a0562d..88c5f01ce 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -505,7 +505,7 @@ static void __quit_handler(int num)
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)
{
@@ -538,7 +538,7 @@ static void console_verboser(const char *s, int pos, int replace, int complete)
fflush(stdout);
if (complete)
/* Wake up a select()ing console */
- if (consolethread > -1)
+ if (consolethread != (pthread_t) -1)
pthread_kill(consolethread, SIGURG);
}
diff --git a/autoservice.c b/autoservice.c
index fc81c483b..7e5699b97 100755
--- a/autoservice.c
+++ b/autoservice.c
@@ -44,7 +44,7 @@ struct asent {
};
static struct asent *aslist = NULL;
-static pthread_t asthread = -1;
+static pthread_t asthread = (pthread_t) -1;
static void *autoservice_run(void *ign)
{
@@ -80,7 +80,7 @@ static void *autoservice_run(void *ign)
ast_frfree(f);
}
}
- asthread = -1;
+ asthread = (pthread_t) -1;
return NULL;
}
@@ -90,7 +90,7 @@ int ast_autoservice_start(struct ast_channel *chan)
struct asent *as;
int needstart;
ast_mutex_lock(&autolock);
- needstart = (asthread == -1) ? 1 : 0 /* aslist ? 0 : 1 */;
+ needstart = (asthread == (pthread_t) -1) ? 1 : 0 /* aslist ? 0 : 1 */;
as = aslist;
while(as) {
if (as->chan == chan)
@@ -142,7 +142,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
if (!chan->_softhangup)
res = 0;
}
- if (asthread != -1)
+ if (asthread != (pthread_t) -1)
pthread_kill(asthread, SIGURG);
ast_mutex_unlock(&autolock);
/* Wait for it to un-block */
diff --git a/cdr/cdr_mysql.c b/cdr/cdr_mysql.c
index b5cc8e51a..adf03e261 100755
--- a/cdr/cdr_mysql.c
+++ b/cdr/cdr_mysql.c
@@ -86,23 +86,26 @@ static int mysql_log(struct ast_cdr *cdr)
}
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 */
- 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));
- 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));
- 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));
- 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));
- 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));
- 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));
#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));
#endif
@@ -141,7 +144,7 @@ char *description(void)
return desc;
}
-int my_unload_module(void)
+static int my_unload_module(void)
{
if (connected) {
mysql_close(&mysql);
@@ -177,7 +180,7 @@ int my_unload_module(void)
return 0;
}
-int my_load_module(void)
+static int my_load_module(void)
{
int res;
struct ast_config *cfg;
diff --git a/channel.c b/channel.c
index 908194392..2ecde4fee 100755
--- a/channel.c
+++ b/channel.c
@@ -318,7 +318,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
tmp->data = NULL;
tmp->fin = 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;
ast_mutex_init(&tmp->lock);
AST_LIST_HEAD_INIT(headp);
@@ -653,7 +653,7 @@ int ast_hangup(struct ast_channel *chan)
if (chan->blocking) {
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",
- pthread_self(), chan->name, chan->blocker, chan->blockproc);
+ (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
CRASH;
}
if (!chan->zombie) {
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index d293f9cc1..7421f5d53 100755
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -194,7 +194,7 @@ static struct agent_pvt *add_agent(char *agent, int pending)
strncpy(p->agent, tmp, sizeof(p->agent) -1);
ast_mutex_init( &p->lock );
ast_mutex_init( &p->app_lock );
- p->owning_app = -1;
+ p->owning_app = (pthread_t) -1;
p->app_sleep_cond = 1;
p->group = group;
p->pending = pending;
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 71c5056bd..76957798d 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -3576,7 +3576,9 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
struct iax2_peer *peer;
int processed = 0;
int totalcalls = 0;
+#ifdef ZT_TIMERACK
int x = 1;
+#endif
if (iaxtrunkdebug)
ast_verbose("Beginning trunk processing\n");
if (events & AST_IO_PRI) {
@@ -5116,7 +5118,9 @@ static int set_config(char *config_file, struct sockaddr_in* sin){
int format;
struct iax2_user *user;
struct iax2_peer *peer;
+#if 0
static unsigned short int last_port=0;
+#endif
cfg = ast_load(config_file);
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 1e40d5a73..5871d0449 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -413,7 +413,7 @@ static int mgcp_postrequest(struct mgcp_subchannel *sub, unsigned char *data, in
time(&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",
- sub->msgs ? sub->msgs->seqno : -1, sub->lastouttime, t);
+ sub->msgs ? sub->msgs->seqno : -1, (long) sub->lastouttime, (long) t);
dump_queue(sub->parent);
}
msg->seqno = seqno;
@@ -2546,7 +2546,7 @@ static void *do_monitor(void *data)
static int restart_monitor(void)
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == -2)
+ if (monitor_thread == (pthread_t) -2)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index de8237ff8..1da77d321 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.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
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);
@@ -644,7 +645,7 @@ static void *do_monitor(void *data)
static int restart_monitor()
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == -2)
+ if (monitor_thread == (pthread_t) -2)
return 0;
if (ast_mutex_lock(&monlock)) {
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");
return -1;
}
- if (monitor_thread != -1) {
+ if (monitor_thread != (pthread_t) -1) {
pthread_cancel(monitor_thread);
/* Nudge it a little, as it's probably stuck in select */
pthread_kill(monitor_thread, SIGURG);
@@ -949,11 +950,11 @@ int unload_module()
return -1;
}
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_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = (pthread_t) -2;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index b2f22ad5e..34a4abef8 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -5287,7 +5287,7 @@ restartsearch:
static int restart_monitor(void)
{
/* If we're supposed to be stopped -- stay stopped */
- if (monitor_thread == -2)
+ if (monitor_thread == (pthread_t) -2)
return 0;
if (ast_mutex_lock(&monlock)) {
ast_log(LOG_WARNING, "Unable to lock monitor\n");
@@ -6140,7 +6140,7 @@ int unload_module()
pthread_kill(monitor_thread, SIGURG);
pthread_join(monitor_thread, NULL);
}
- monitor_thread = -2;
+ monitor_thread = (pthread_t) -2;
ast_mutex_unlock(&monlock);
} else {
ast_log(LOG_WARNING, "Unable to lock the monitor\n");
diff --git a/formats/format_g729.c b/formats/format_g729.c
index 23a3c5a6d..f4ba3db66 100755
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index ad39c0a0f..e154f64eb 100755
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_h263.c b/formats/format_h263.c
index 6e0f8edad..671a5f954 100755
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 7e646f894..db7c2096e 100755
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -18,6 +18,7 @@
#include <asterisk/sched.h>
#include <asterisk/module.h>
#include <asterisk/image.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_mp3.c b/formats/format_mp3.c
index 832110e67..2a45245d3 100755
--- a/formats/format_mp3.c
+++ b/formats/format_mp3.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 038de171d..a175f40ae 100755
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_pcm_alaw.c b/formats/format_pcm_alaw.c
index 54d79bb29..d7d375edb 100755
--- a/formats/format_pcm_alaw.c
+++ b/formats/format_pcm_alaw.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_vox.c b/formats/format_vox.c
index 9ea35ffd5..851f1fb81 100755
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 2a549b710..7cc5c6ff4 100755
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index 55a607d2f..fc8364cd1 100755
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -17,6 +17,7 @@
#include <asterisk/logger.h>
#include <asterisk/sched.h>
#include <asterisk/module.h>
+#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index cb56d8a7a..815f882f4 100755
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -17,6 +17,7 @@
#include <asterisk/frame.h>
#include <asterisk/sched.h>
#include <asterisk/chanvars.h>
+#include <unistd.h>
#include <setjmp.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) { \
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; \
} else { \
(c)->blocker = pthread_self(); \
diff --git a/include/asterisk/srv.h b/include/asterisk/srv.h
index df8a411c5..1c3711dae 100755
--- a/include/asterisk/srv.h
+++ b/include/asterisk/srv.h
@@ -13,7 +13,9 @@
#ifndef _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 */
extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service);
diff --git a/loader.c b/loader.c
index de5674c12..5e7efce5f 100755
--- a/loader.c
+++ b/loader.c
@@ -170,7 +170,9 @@ int ast_load_resource(char *resource_name)
int res;
struct module *m;
int flags=RTLD_NOW;
+#ifdef RTLD_GLOBAL
char *val;
+#endif
char *key;
int o;
struct ast_config *cfg;
diff --git a/logger.c b/logger.c
index 30d37b11f..36c76e6c5 100755
--- a/logger.c
+++ b/logger.c
@@ -250,7 +250,7 @@ extern void ast_log(int level, const char *file, int line, const char *function,
} else
/** Cannot use ast_log() from locked section of ast_log()!
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 {
if (logfiles) {
f = logfiles;
@@ -260,12 +260,12 @@ extern void ast_log(int level, const char *file, int line, const char *function,
time(&t);
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);
+ fprintf(f->f, "%s %s[%ld]: File %s, Line %d (%s): ", date, levels[level], (long)pthread_self(), file, line, function);
} else {
sprintf(linestr, "%d", line);
fprintf(f->f, "%s[%ld]: File %s, Line %s (%s): ",
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(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
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;
}
} 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);
vfprintf(stdout, fmt, ap);
va_end(ap);
diff --git a/manager.c b/manager.c
index 42b4350c7..74b73ac37 100755
--- a/manager.c
+++ b/manager.c
@@ -726,7 +726,7 @@ static void *accept_thread(void *ignore)
for (;;) {
sinlen = sizeof(sin);
- as = accept(asock, &sin, &sinlen);
+ as = accept(asock, (struct sockaddr *)&sin, &sinlen);
if (as < 0) {
ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
continue;
@@ -921,7 +921,7 @@ int init_manager(void)
return -1;
}
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));
close(asock);
asock = -1;
diff --git a/pbx/pbx_gtkconsole.c b/pbx/pbx_gtkconsole.c
index e6388bbbf..86755d245 100755
--- a/pbx/pbx_gtkconsole.c
+++ b/pbx/pbx_gtkconsole.c
@@ -32,8 +32,8 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
+#include <signal.h>
#include <sys/time.h>
-#include <sys/signal.h>
#include <gtk/gtk.h>
#include <glib.h>
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 3c256956f..d51c17e9c 100755
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -243,7 +243,7 @@ static int scan_service(char *fn, time_t now, time_t atime)
if (o->retries <= o->maxretries + 1) {
/* Add a retry line at the 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);
now += o->retrytime;
launch_service(o);
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 487d6a252..3dc78fba0 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include <unistd.h>
#include <string.h>
+#include <signal.h>
#include <stdlib.h>
#include <stdio.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)
{
struct mohclass *moh;
+#ifdef ZAPATA_MOH
int x;
+#endif
ast_mutex_lock(&moh_lock);
moh = get_mohbyname(classname);
ast_mutex_unlock(&moh_lock);
diff --git a/rtp.c b/rtp.c
index 0c0c1c33a..bd29e044b 100755
--- a/rtp.c
+++ b/rtp.c
@@ -723,8 +723,8 @@ struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io,
rtp->us.sin_port = htons(x);
if (rtp->rtcp)
rtp->rtcp->us.sin_port = htons(x + 1);
- if (!bind(rtp->s, &rtp->us, sizeof(rtp->us)) &&
- (!rtp->rtcp || !bind(rtp->rtcp->s, &rtp->rtcp->us, sizeof(rtp->rtcp->us))))
+ if (!bind(rtp->s, (struct sockaddr *)&rtp->us, sizeof(rtp->us)) &&
+ (!rtp->rtcp || !bind(rtp->rtcp->s, (struct sockaddr *)&rtp->rtcp->us, sizeof(rtp->rtcp->us))))
break;
if (errno != EADDRINUSE) {
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));
for (x=0;x<4;x++) {
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)
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
@@ -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[2] = htonl(rtp->ssrc);
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)
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
diff --git a/sched.c b/sched.c
index 6744a7f99..f8fdbca30 100755
--- a/sched.c
+++ b/sched.c
@@ -309,8 +309,8 @@ void ast_sched_dump(struct sched_context *con)
q->id,
q->callback,
q->data,
- s,
- ms);
+ (long)s,
+ (long)ms);
q=q->next;
}
ast_log(LOG_DEBUG, "=================================================\n");