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 <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;

@ -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);

@ -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;
}

@ -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);

@ -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 */

@ -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)

@ -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);
}

@ -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 */

@ -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;

@ -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) {

@ -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;

@ -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);

@ -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");

@ -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");

@ -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");

@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

@ -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(); \

@ -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);

@ -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;

@ -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);

@ -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;

@ -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>

@ -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);

@ -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);

@ -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

@ -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");

Loading…
Cancel
Save