BSD portability enhancements (bug #234)
authorMark Spencer <markster@digium.com>
Mon, 8 Sep 2003 16:48:07 +0000 (16:48 +0000)
committerMark Spencer <markster@digium.com>
Mon, 8 Sep 2003 16:48:07 +0000 (16:48 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1486 65c4cc65-6c06-0410-ace0-fbb531ad65f3

35 files changed:
agi/eagi-sphinx-test.c
apps/app_agi.c
apps/app_mp3.c
apps/app_queue.c
apps/app_voicemail.c
apps/app_voicemail2.c
asterisk.c
autoservice.c
cdr/cdr_mysql.c
channel.c
channels/chan_agent.c
channels/chan_iax2.c
channels/chan_mgcp.c
channels/chan_modem.c
channels/chan_sip.c
formats/format_g729.c
formats/format_gsm.c
formats/format_h263.c
formats/format_jpeg.c
formats/format_mp3.c
formats/format_pcm.c
formats/format_pcm_alaw.c
formats/format_vox.c
formats/format_wav.c
formats/format_wav_gsm.c
include/asterisk/channel.h
include/asterisk/srv.h
loader.c
logger.c
manager.c
pbx/pbx_gtkconsole.c
pbx/pbx_spool.c
res/res_musiconhold.c
rtp.c
sched.c

index ed02394..3015b73 100755 (executable)
@@ -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;
index 6399c02..294b56b 100755 (executable)
@@ -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);
index 52f1225..c8196a7 100755 (executable)
@@ -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;
 }
index af349a0..68d883c 100755 (executable)
@@ -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);
index 8ee076a..8c2a23f 100755 (executable)
@@ -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 */
index 7fb3b43..e5f1db7 100755 (executable)
@@ -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)
index 498a056..88c5f01 100755 (executable)
@@ -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);
 }
 
index fc81c48..7e5699b 100755 (executable)
@@ -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 */
index b5cc8e5..adf03e2 100755 (executable)
@@ -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;
index 9081943..2ecde4f 100755 (executable)
--- 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) {
index d293f9c..7421f5d 100755 (executable)
@@ -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;
index 71c5056..7695779 100755 (executable)
@@ -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);
        
index 1e40d5a..5871d04 100755 (executable)
@@ -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");
index de8237f..1da77d3 100755 (executable)
@@ -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");
index b2f22ad..34a4abe 100755 (executable)
@@ -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");
index 23a3c5a..f4ba3db 100755 (executable)
@@ -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>
index ad39c0a..e154f64 100755 (executable)
@@ -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>
index 6e0f8ed..671a5f9 100755 (executable)
@@ -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>
index 7e646f8..db7c209 100755 (executable)
@@ -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>
index 832110e..2a45245 100755 (executable)
@@ -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>
index 038de17..a175f40 100755 (executable)
@@ -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>
index 54d79bb..d7d375e 100755 (executable)
@@ -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>
index 9ea35ff..851f1fb 100755 (executable)
@@ -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>
index 2a549b7..7cc5c6f 100755 (executable)
@@ -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>
index 55a607d..fc8364c 100755 (executable)
@@ -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>
index cb56d8a..815f882 100755 (executable)
@@ -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(); \
index df8a411..1c3711d 100755 (executable)
@@ -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);
 
index de5674c..5e7efce 100755 (executable)
--- 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;
index 30d37b1..36c76e6 100755 (executable)
--- 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);
index 42b4350..74b73ac 100755 (executable)
--- 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;
index e6388bb..86755d2 100755 (executable)
@@ -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>
index 3c25695..d51c17e 100755 (executable)
@@ -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);
index 487d6a2..3dc78fb 100755 (executable)
@@ -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 0c0c1c3..bd29e04 100755 (executable)
--- 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 6744a7f..f8fdbca 100755 (executable)
--- 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");