aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-12-14 23:36:30 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-12-14 23:36:30 +0000
commit70cedacdde512d2ed5984eec242c55f3239b73fc (patch)
tree48694f38698e4ead3840305333816193c7fcd8a0
parentc60f8a2b8e1551244e674baff85cb1a4f2d5fd5b (diff)
Merge slimey's Solaris compatibility (with small mods) (bug #2740)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4446 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xCREDITS2
-rwxr-xr-xMakefile34
-rwxr-xr-xacl.c5
-rwxr-xr-xaesopt.h2
-rwxr-xr-xagi/Makefile9
-rwxr-xr-xagi/eagi-sphinx-test.c3
-rwxr-xr-xagi/eagi-test.c3
-rwxr-xr-xapps/Makefile2
-rwxr-xr-xapps/app_nbscat.c4
-rwxr-xr-xapps/app_qcall.c17
-rwxr-xr-xapps/app_sms.c4
-rwxr-xr-xast_expr.y8
-rwxr-xr-xasterisk.c33
-rwxr-xr-xchannels/Makefile10
-rwxr-xr-xchannels/chan_mgcp.c4
-rwxr-xr-xchannels/chan_modem.c13
-rwxr-xr-xchannels/chan_zap.c2
-rwxr-xr-xchannels/iax2-parser.c56
-rwxr-xr-xcli.c5
-rwxr-xr-xcodecs/Makefile4
-rwxr-xr-xcodecs/gsm/Makefile2
-rwxr-xr-xcodecs/lpc10/Makefile2
-rwxr-xr-xdb1-ast/Makefile5
-rwxr-xr-xdb1-ast/include/db.h14
-rwxr-xr-xeditline/Makefile.in6
-rwxr-xr-xeditline/np/vis.c4
-rwxr-xr-xeditline/sys.h2
-rwxr-xr-xformats/format_g726.c4
-rwxr-xr-xformats/format_g729.c4
-rwxr-xr-xformats/format_gsm.c4
-rwxr-xr-xformats/format_h263.c4
-rwxr-xr-xformats/format_ilbc.c4
-rwxr-xr-xformats/format_jpeg.c4
-rwxr-xr-xformats/format_pcm.c4
-rwxr-xr-xformats/format_pcm_alaw.c4
-rwxr-xr-xformats/format_sln.c4
-rwxr-xr-xformats/format_vox.c4
-rwxr-xr-xformats/format_wav.c4
-rwxr-xr-xformats/format_wav_gsm.c4
-rwxr-xr-xinclude/asterisk/channel.h13
-rwxr-xr-xinclude/asterisk/frame.h4
-rwxr-xr-xinclude/asterisk/lock.h4
-rwxr-xr-xinclude/solaris-compat/compat.h34
-rwxr-xr-xinclude/solaris-compat/sys/cdefs.h10
-rwxr-xr-xinclude/solaris-compat/sys/queue.h540
-rwxr-xr-xlogger.c44
-rwxr-xr-xmd5.c3
-rwxr-xr-xmkdep2
-rwxr-xr-xmkpkgconfig2
-rwxr-xr-xpbx/pbx_dundi.c8
-rwxr-xr-xrtp.c28
-rwxr-xr-xsay.c4
-rwxr-xr-xstdtime/localtime.c10
-rwxr-xr-xstrcompat.c144
-rwxr-xr-xutils.c7
55 files changed, 1098 insertions, 62 deletions
diff --git a/CREDITS b/CREDITS
index 72cd9cfaf..1d47d81a7 100755
--- a/CREDITS
+++ b/CREDITS
@@ -64,6 +64,8 @@ Josh Roberson - chan_zap reload support, Advanced Voicemail Features, other misc
William Waites - syslog support, SIP NAT traversal for SIP-UA. ww@styx.org
Rich Murphey - Porting to FreeBSD, NetBSD, OpenBSD, and Darwin.
rich@whiteoaklabs.com http://whiteoaklabs.com
+Simon Lockhart - Porting to Solaris (based on work of Logan ???)
+ simon@slimey.org
=== OTHER CONTRIBUTIONS ===
John Todd - Monkey sounds and associated teletorture prompt
diff --git a/Makefile b/Makefile
index fe1b8083e..bc3dc1a56 100755
--- a/Makefile
+++ b/Makefile
@@ -55,6 +55,12 @@ endif
PWD=$(shell pwd)
+GREP=grep
+ifeq (${OSARCH},SunOS)
+GREP=/usr/xpg4/bin/grep
+M4=/usr/local/bin/m4
+endif
+
######### More GSM codec optimization
######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
######### which support MMX instructions. This should be newer pentiums,
@@ -136,7 +142,7 @@ ifneq ($(PROC),ultrasparc)
CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
endif
-CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
+CFLAGS+=$(shell if uname -m | $(GREP) -q ppc; then echo "-fsigned-char"; fi)
CFLAGS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "-DOSP_SUPPORT -I/usr/include/osp" ; fi)
ifeq (${OSARCH},FreeBSD)
@@ -155,6 +161,10 @@ endif
ifeq (${OSARCH},OpenBSD)
CFLAGS+=-pthread
endif
+ifeq (${OSARCH},SunOS)
+CFLAGS+=-Wcast-align -DSOLARIS
+INCLUDE+=-Iinclude/solaris-compat -I/usr/local/ssl/include
+endif
#Uncomment this to use the older DSP routines
#CFLAGS+=-DOLD_DSP_ROUTINES
@@ -207,6 +217,9 @@ endif
ifeq (${OSARCH},OpenBSD)
LIBS=-lcrypto -lpthread -lm -lncurses
endif
+ifeq (${OSARCH},SunOS)
+LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/usr/local/ssl/lib
+endif
LIBS+=-lssl
OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
translate.o file.o say.o pbx.o cli.o md5.o term.o \
@@ -223,6 +236,11 @@ else
ASTLINK=-Wl,-E
SOLINK=-shared -Xlinker -x
endif
+ifeq (${OSARCH},SunOS)
+OBJS+=strcompat.o
+ASTLINK=
+SOLINK=-shared -fpic -L/usr/local/ssl/lib
+endif
CC=gcc
INSTALL=install
@@ -260,7 +278,7 @@ endif
.PHONY: _version
_version:
- if [ -d CVS ] && ! [ -f .version ]; then echo $(ASTERISKVERSION) > .version; fi
+ if [ -d CVS ] && [ ! -f .version ]; then echo $(ASTERISKVERSION) > .version; fi
.version: _version
@@ -311,7 +329,7 @@ clean:
rm -f *.o *.so asterisk .depend
rm -f build.h
rm -f ast_expr.c
- @if [ -e editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
+ @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
@if [ -d mpg123-0.59r ]; then make -C mpg123-0.59r clean; fi
$(MAKE) -C db1-ast clean
$(MAKE) -C stdtime clean
@@ -320,7 +338,7 @@ datafiles: all
sh mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
for x in sounds/digits/*.gsm; do \
- if grep -q "^%`basename $$x`%" sounds.txt; then \
+ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
else \
echo "No description for $$x"; \
@@ -329,7 +347,7 @@ datafiles: all
done
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
for x in sounds/letters/*.gsm; do \
- if grep -q "^%`basename $$x`%" sounds.txt; then \
+ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
else \
echo "No description for $$x"; \
@@ -338,7 +356,7 @@ datafiles: all
done
mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
for x in sounds/phonetic/*.gsm; do \
- if grep -q "^%`basename $$x`%" sounds.txt; then \
+ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
else \
echo "No description for $$x"; \
@@ -346,7 +364,7 @@ datafiles: all
fi; \
done
for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-*; do \
- if grep -q "^%`basename $$x`%" sounds.txt; then \
+ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
else \
echo "No description for $$x"; \
@@ -476,7 +494,7 @@ samples: all datafiles adsi
echo "Skipping asterisk.conf creation"; \
fi
for x in sounds/demo-*; do \
- if grep -q "^%`basename $$x`%" sounds.txt; then \
+ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
else \
echo "No description for $$x"; \
diff --git a/acl.c b/acl.c
index c7eb34270..9169659a9 100755
--- a/acl.c
+++ b/acl.c
@@ -38,6 +38,11 @@
AST_MUTEX_DEFINE_STATIC(routeseq_lock);
#endif
+#if defined (SOLARIS)
+#include <sys/sockio.h>
+#endif
+
+
struct ast_ha {
/* Host access rule */
diff --git a/aesopt.h b/aesopt.h
index 94e3e47f1..f476de09e 100755
--- a/aesopt.h
+++ b/aesopt.h
@@ -156,6 +156,8 @@
# include <sys/endian.h>
#elif defined( BSD ) && ( BSD >= 199103 ) || defined(__APPLE__)
# include <machine/endian.h>
+#elif defined ( SOLARIS )
+# include <solaris-compat/compat.h>
#elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
# include <endian.h>
#if !defined(__APPLE__)
diff --git a/agi/Makefile b/agi/Makefile
index 2f87df5f8..0d8a35922 100755
--- a/agi/Makefile
+++ b/agi/Makefile
@@ -15,6 +15,11 @@ AGIS=agi-test.agi eagi-test eagi-sphinx-test
CFLAGS+=
+LIBS=
+ifeq ($(OSARCH),SunOS)
+LIBS=-lsocket -lnsl ../strcompat.o
+endif
+
all: depend $(AGIS)
install: all
@@ -22,10 +27,10 @@ install: all
for x in $(AGIS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(AGI_DIR) ; done
eagi-test: eagi-test.o
- $(CC) $(CFLAGS) -o eagi-test eagi-test.o
+ $(CC) $(CFLAGS) -o eagi-test eagi-test.o $(LIBS)
eagi-sphinx-test: eagi-sphinx-test.o
- $(CC) $(CFLAGS) -o eagi-sphinx-test eagi-sphinx-test.o
+ $(CC) $(CFLAGS) -o eagi-sphinx-test eagi-sphinx-test.o $(LIBS)
clean:
rm -f *.so *.o look .depend eagi-test eagi-sphinx-test
diff --git a/agi/eagi-sphinx-test.c b/agi/eagi-sphinx-test.c
index 3015b730b..72bd93fd4 100755
--- a/agi/eagi-sphinx-test.c
+++ b/agi/eagi-sphinx-test.c
@@ -17,6 +17,9 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#ifdef SOLARIS
+#include <solaris-compat/compat.h>
+#endif
#define AUDIO_FILENO (STDERR_FILENO + 1)
diff --git a/agi/eagi-test.c b/agi/eagi-test.c
index aa498cb88..360fd4222 100755
--- a/agi/eagi-test.c
+++ b/agi/eagi-test.c
@@ -11,6 +11,9 @@
#include <errno.h>
#include <string.h>
#include <sys/select.h>
+#ifdef SOLARIS
+#include <solaris-compat/compat.h>
+#endif
#define AUDIO_FILENO (STDERR_FILENO + 1)
diff --git a/apps/Makefile b/apps/Makefile
index 08e24de11..48dfdedd7 100755
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -33,8 +33,10 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
app_dumpchan.so app_waitforsilence.so
ifneq (${OSARCH},Darwin)
+ifneq (${OSARCH},SunOS)
APPS+=app_intercom.so
endif
+endif
#
# Obsolete things...
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index 75951de51..f8b4b37b9 100755
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -31,6 +31,10 @@
#define LOCAL_NBSCAT "/usr/local/bin/nbscat8k"
#define NBSCAT "/usr/bin/nbscat8k"
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+
static char *tdesc = "Silly NBS Stream Application";
static char *app = "NBScat";
diff --git a/apps/app_qcall.c b/apps/app_qcall.c
index f5721e167..204e491a0 100755
--- a/apps/app_qcall.c
+++ b/apps/app_qcall.c
@@ -95,6 +95,23 @@ LOCAL_USER_DECL;
#define OURCLID "2564286275" /* The callerid to be displayed when calling */
#endif
+#ifdef SOLARIS
+int flock(int fd, int type)
+{
+ struct flock lock;
+
+ lock.l_type = type;
+ lock.l_whence = SEEK_SET;
+ lock.l_start = 0;
+ lock.l_len = 0;
+
+ return fcntl(f, F_SETLK, &lock);
+}
+
+#define LOCK_EX F_WRLCK
+#define LOCK_UN F_UNLCK
+#endif
+
static void *qcall_do(void *arg);
static void *qcall(void *ignore)
diff --git a/apps/app_sms.c b/apps/app_sms.c
index faba221d6..42412ddf5 100755
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1077,6 +1077,10 @@ sms_handleincoming (sms_t * h)
return 0; /* no error */
}
+#ifdef SOLARIS
+#define NAME_MAX 1024
+#endif
+
static void
sms_nextoutgoing (sms_t * h)
{ /* find and fill in next message, or send a REL if none waiting */
diff --git a/ast_expr.y b/ast_expr.y
index df08f6829..e90931f87 100755
--- a/ast_expr.y
+++ b/ast_expr.y
@@ -13,7 +13,11 @@
#include <string.h>
#include <locale.h>
#include <ctype.h>
+#ifndef SOLARIS
#include <err.h>
+#else
+typedef uint64_t quad_t;
+#endif
#include <errno.h>
#include <regex.h>
#include <limits.h>
@@ -39,6 +43,10 @@
/* #define ast_log fprintf
#define LOG_WARNING stderr */
+
+#ifdef SOLARIS
+#define __P(p) p
+#endif
enum valtype {
integer, numeric_string, string
diff --git a/asterisk.c b/asterisk.c
index 4dcf27a81..204ef160a 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -53,10 +53,15 @@
#include <grp.h>
#include <pwd.h>
-#if defined(__FreeBSD__) || defined( __NetBSD__ )
+#if defined(__FreeBSD__) || defined( __NetBSD__ ) || defined(SOLARIS)
#include <netdb.h>
#endif
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#define PF_LOCAL PF_UNIX
+#endif
+
#define AST_MAX_CONNECTS 128
#define NUM_MSGS 64
@@ -315,7 +320,7 @@ static void *netconsole(void *vconsole)
static void *listener(void *unused)
{
- struct sockaddr_un sun;
+ struct sockaddr_un sunaddr;
int s;
int len;
int x;
@@ -335,8 +340,8 @@ static void *listener(void *unused)
ast_log(LOG_WARNING, "poll returned error: %s\n", strerror(errno));
continue;
}
- len = sizeof(sun);
- s = accept(ast_socket, (struct sockaddr *)&sun, &len);
+ len = sizeof(sunaddr);
+ s = accept(ast_socket, (struct sockaddr *)&sunaddr, &len);
if (s < 0) {
if (errno != EINTR)
ast_log(LOG_WARNING, "Accept returned %d: %s\n", s, strerror(errno));
@@ -377,7 +382,7 @@ static void *listener(void *unused)
static int ast_makesocket(void)
{
- struct sockaddr_un sun;
+ struct sockaddr_un sunaddr;
int res;
int x;
for (x=0;x<AST_MAX_CONNECTS;x++)
@@ -388,10 +393,10 @@ static int ast_makesocket(void)
ast_log(LOG_WARNING, "Unable to create control socket: %s\n", strerror(errno));
return -1;
}
- memset(&sun, 0, sizeof(sun));
- sun.sun_family = AF_LOCAL;
- strncpy(sun.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sun.sun_path)-1);
- res = bind(ast_socket, (struct sockaddr *)&sun, sizeof(sun));
+ memset(&sunaddr, 0, sizeof(sunaddr));
+ sunaddr.sun_family = AF_LOCAL;
+ strncpy(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path)-1);
+ res = bind(ast_socket, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
if (res) {
ast_log(LOG_WARNING, "Unable to bind socket to %s: %s\n", (char *)ast_config_AST_SOCKET, strerror(errno));
close(ast_socket);
@@ -412,17 +417,17 @@ static int ast_makesocket(void)
static int ast_tryconnect(void)
{
- struct sockaddr_un sun;
+ struct sockaddr_un sunaddr;
int res;
ast_consock = socket(PF_LOCAL, SOCK_STREAM, 0);
if (ast_consock < 0) {
ast_log(LOG_WARNING, "Unable to create socket: %s\n", strerror(errno));
return 0;
}
- memset(&sun, 0, sizeof(sun));
- sun.sun_family = AF_LOCAL;
- strncpy(sun.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sun.sun_path)-1);
- res = connect(ast_consock, (struct sockaddr *)&sun, sizeof(sun));
+ memset(&sunaddr, 0, sizeof(sunaddr));
+ sunaddr.sun_family = AF_LOCAL;
+ strncpy(sunaddr.sun_path, (char *)ast_config_AST_SOCKET, sizeof(sunaddr.sun_path)-1);
+ res = connect(ast_consock, (struct sockaddr *)&sunaddr, sizeof(sunaddr));
if (res) {
close(ast_consock);
ast_consock = -1;
diff --git a/channels/Makefile b/channels/Makefile
index 9810cec95..5769fc073 100755
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -19,7 +19,7 @@ PROC=$(shell uname -m)
CHANNEL_LIBS=chan_modem.so chan_sip.so \
chan_modem_aopen.so \
- chan_modem_bestdata.so chan_modem_i4l.so \
+ chan_modem_bestdata.so \
chan_agent.so chan_mgcp.so chan_iax2.so \
chan_local.so chan_skinny.so chan_features.so
@@ -52,7 +52,13 @@ H323LIB=-lh323_NetBSD_x86_r
SOLINK+=-L/usr/local/lib
endif
ifneq (${OSARCH},Darwin)
-CHANNEL_LIBS+=chan_oss.so
+ifneq (${OSARCH},SunOS)
+CHANNEL_LIBS+=chan_oss.so chan_modem_i4l.so
+endif
+endif
+
+ifeq (${OSARCH},SunOS)
+SOLINK+=-lrt
endif
CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 72851dd3d..98070483b 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -105,6 +105,10 @@
#define MAX_EXPIREY 3600
#define CANREINVITE 1
+#ifndef INADDR_NONE
+#define INADDR_NONE (in_addr_t)(-1)
+#endif
+
static char *desc = "Media Gateway Control Protocol (MGCP)";
static char *type = "MGCP";
static char *tdesc = "Media Gateway Control Protocol (MGCP)";
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index 41d95540b..9a1e2074d 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -709,8 +709,19 @@ static void stty(struct ast_modem_pvt *p)
ast_log(LOG_WARNING, "Unable to get serial parameters on %s: %s\n", p->dev, strerror(errno));
return;
}
+#ifndef SOLARIS
cfmakeraw(&mode);
- cfsetspeed(&mode, B115200);
+#else
+ mode.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
+ |INLCR|IGNCR|ICRNL|IXON);
+ mode.c_oflag &= ~OPOST;
+ mode.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ mode.c_cflag &= ~(CSIZE|PARENB);
+ mode.c_cflag |= CS8;
+#endif
+
+ cfsetispeed(&mode, B115200);
+ cfsetospeed(&mode, B115200);
if (tcsetattr(p->fd, TCSANOW, &mode))
ast_log(LOG_WARNING, "Unable to set serial parameters on %s: %s\n", p->dev, strerror(errno));
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 25b99a315..7b3216b58 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -42,7 +42,9 @@
#include <sys/signal.h>
#include <errno.h>
#include <stdlib.h>
+#ifndef SOLARIS
#include <stdint.h>
+#endif
#include <unistd.h>
#include <sys/ioctl.h>
#ifdef __linux__
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index b66de4124..90d482255 100755
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -30,6 +30,22 @@ static int frames = 0;
static int iframes = 0;
static int oframes = 0;
+#ifdef SOLARIS
+static unsigned int get_uint32(unsigned char *p)
+{
+ return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+}
+
+static unsigned short get_uint16(unsigned char *p)
+{
+ return (p[0] << 8) | p[1] ;
+}
+
+#else
+#define get_uint32(p) (*((unsigned int *)(p)))
+#define get_uint16(p) (*((unsigned short *)(p)))
+#endif
+
static void internaloutput(const char *str)
{
fputs(str, stdout);
@@ -67,7 +83,7 @@ static void dump_string(char *output, int maxlen, void *value, int len)
static void dump_int(char *output, int maxlen, void *value, int len)
{
if (len == (int)sizeof(unsigned int))
- snprintf(output, maxlen, "%lu", (unsigned long)ntohl(*((unsigned int *)value)));
+ snprintf(output, maxlen, "%lu", (unsigned long)ntohl(get_uint32(value)));
else
snprintf(output, maxlen, "Invalid INT");
}
@@ -75,7 +91,7 @@ static void dump_int(char *output, int maxlen, void *value, int len)
static void dump_short(char *output, int maxlen, void *value, int len)
{
if (len == (int)sizeof(unsigned short))
- snprintf(output, maxlen, "%d", ntohs(*((unsigned short *)value)));
+ snprintf(output, maxlen, "%d", ntohs(get_uint16(value)));
else
snprintf(output, maxlen, "Invalid SHORT");
}
@@ -105,8 +121,8 @@ static void dump_prov_flags(char *output, int maxlen, void *value, int len)
{
char buf[256] = "";
if (len == (int)sizeof(unsigned int))
- snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(*((unsigned int *)value)),
- iax_provflags2str(buf, sizeof(buf), ntohl(*((unsigned int *)value))));
+ snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(get_uint32(value)),
+ iax_provflags2str(buf, sizeof(buf), ntohl(get_uint32(value))));
else
snprintf(output, maxlen, "Invalid INT");
}
@@ -550,14 +566,14 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->capability = ntohl(*((unsigned int *)(data + 2)));
+ ies->capability = ntohl(get_uint32(data + 2));
break;
case IAX_IE_FORMAT:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->format = ntohl(*((unsigned int *)(data + 2)));
+ ies->format = ntohl(get_uint32(data + 2));
break;
case IAX_IE_LANGUAGE:
ies->language = data + 2;
@@ -567,21 +583,21 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->version = ntohs(*((unsigned short *)(data + 2)));
+ ies->version = ntohs(get_uint16(data + 2));
break;
case IAX_IE_ADSICPE:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->adsicpe = ntohs(*((unsigned short *)(data + 2)));
+ ies->adsicpe = ntohs(get_uint16(data + 2));
break;
case IAX_IE_SAMPLINGRATE:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->samprate = ntohs(*((unsigned short *)(data + 2)));
+ ies->samprate = ntohs(get_uint16(data + 2));
break;
case IAX_IE_DNID:
ies->dnid = data + 2;
@@ -594,7 +610,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->authmethods = ntohs(*((unsigned short *)(data + 2)));
+ ies->authmethods = ntohs(get_uint16(data + 2));
break;
case IAX_IE_CHALLENGE:
ies->challenge = data + 2;
@@ -613,21 +629,21 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting refresh to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->refresh = ntohs(*((unsigned short *)(data + 2)));
+ ies->refresh = ntohs(get_uint16(data + 2));
break;
case IAX_IE_DPSTATUS:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting dpstatus to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->dpstatus = ntohs(*((unsigned short *)(data + 2)));
+ ies->dpstatus = ntohs(get_uint16(data + 2));
break;
case IAX_IE_CALLNO:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting callno to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->callno = ntohs(*((unsigned short *)(data + 2)));
+ ies->callno = ntohs(get_uint16(data + 2));
break;
case IAX_IE_CAUSE:
ies->cause = data + 2;
@@ -645,7 +661,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->msgcount = ntohs(*((unsigned short *)(data + 2)));
+ ies->msgcount = ntohs(get_uint16(data + 2));
break;
case IAX_IE_AUTOANSWER:
ies->autoanswer = 1;
@@ -658,21 +674,21 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->transferid = ntohl(*((unsigned int *)(data + 2)));
+ ies->transferid = ntohl(get_uint32(data + 2));
break;
case IAX_IE_DATETIME:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->datetime = ntohl(*((unsigned int *)(data + 2)));
+ ies->datetime = ntohl(get_uint32(data + 2));
break;
case IAX_IE_FIRMWAREVER:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->firmwarever = ntohs(*((unsigned short *)(data + 2)));
+ ies->firmwarever = ntohs(get_uint16(data + 2));
break;
case IAX_IE_DEVICETYPE:
ies->devicetype = data + 2;
@@ -685,7 +701,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->fwdesc = ntohl(*((unsigned int *)(data + 2)));
+ ies->fwdesc = ntohl(get_uint32(data + 2));
break;
case IAX_IE_FWBLOCKDATA:
ies->fwdata = data + 2;
@@ -697,7 +713,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
errorf(tmp);
} else {
ies->provverpres = 1;
- ies->provver = ntohl(*((unsigned int *)(data + 2)));
+ ies->provver = ntohl(get_uint32(data + 2));
}
break;
case IAX_IE_CALLINGPRES:
@@ -721,7 +737,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->calling_tns = ntohs(*((unsigned short *)(data + 2)));
+ ies->calling_tns = ntohs(get_uint16(data + 2));
break;
default:
snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
diff --git a/cli.c b/cli.c
index 28d40cad0..8a99c6e4b 100755
--- a/cli.c
+++ b/cli.c
@@ -47,7 +47,12 @@ void ast_cli(int fd, char *fmt, ...)
va_list ap;
va_start(ap, fmt);
+#ifdef SOLARIS
+ stuff = (char *)malloc(10240);
+ vsnprintf(stuff, 10240, fmt, ap);
+#else
res = vasprintf(&stuff, fmt, ap);
+#endif
va_end(ap);
if (res == -1) {
ast_log(LOG_ERROR, "Out of memory\n");
diff --git a/codecs/Makefile b/codecs/Makefile
index 82d8f458e..07dc35343 100755
--- a/codecs/Makefile
+++ b/codecs/Makefile
@@ -41,8 +41,8 @@ all: depend $(CODECS)
clean:
rm -f *.so *.o .depend
- ! [ -d g723.1 ] || $(MAKE) -C g723.1 clean
- ! [ -d g723.1b ] || $(MAKE) -C g723.1b clean
+ [ ! -d g723.1 ] || $(MAKE) -C g723.1 clean
+ [ ! -d g723.1b ] || $(MAKE) -C g723.1b clean
$(MAKE) -C gsm clean
$(MAKE) -C lpc10 clean
$(MAKE) -C ilbc clean
diff --git a/codecs/gsm/Makefile b/codecs/gsm/Makefile
index 86f25f11a..6b34233b2 100755
--- a/codecs/gsm/Makefile
+++ b/codecs/gsm/Makefile
@@ -38,6 +38,7 @@ WAV49 = -DWAV49
######### probably require gcc.
ifneq (${OSARCH},Darwin)
+ifneq (${OSARCH},SunOS)
ifneq (${PROC},x86_64)
ifneq (${PROC},ultrasparc)
ifneq ($(shell uname -m),ppc)
@@ -48,6 +49,7 @@ endif
endif
endif
endif
+endif
#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
#This works for even old (2.96) versions of gcc and provides a small boost either way.
diff --git a/codecs/lpc10/Makefile b/codecs/lpc10/Makefile
index 23d6886e8..0a2e03008 100755
--- a/codecs/lpc10/Makefile
+++ b/codecs/lpc10/Makefile
@@ -39,6 +39,7 @@ ifneq ($(PROC),alpha)
ifeq ($(PROC),ultrasparc)
CFLAGS+= -mtune=$(PROC) -mcpu=v8 -O3 -fomit-frame-pointer
else
+ifneq ($(OSARCH),SunOS)
CFLAGS+= -march=$(PROC)
endif
endif
@@ -46,6 +47,7 @@ endif
endif
endif
endif
+endif
LIB = $(LIB_TARGET_DIR)/liblpc10.a
diff --git a/db1-ast/Makefile b/db1-ast/Makefile
index f8192f795..0aa9fdb02 100755
--- a/db1-ast/Makefile
+++ b/db1-ast/Makefile
@@ -48,6 +48,11 @@ clean:
OORG= -O2
CL= $(CC) -Wall -c -D__DBINTERFACE_PRIVATE $(OORG) -I. -Iinclude
+OSTYPE=$(shell uname -s)
+ifeq ($(OSTYPE),SunOS)
+CL+=-I../include -I../include/solaris-compat -DSOLARIS
+endif
+
db_dump185.o: db_dump185.c
$(CL) -o $@ $<
%.o: hash/%.c
diff --git a/db1-ast/include/db.h b/db1-ast/include/db.h
index d1258d2a6..a58724bdd 100755
--- a/db1-ast/include/db.h
+++ b/db1-ast/include/db.h
@@ -45,6 +45,10 @@
#include <compat.h>
#endif
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#endif
+
#define RET_ERROR -1 /* Return values. */
#define RET_SUCCESS 0
#define RET_SPECIAL 1
@@ -53,10 +57,10 @@
#define __BIT_TYPES_DEFINED__
#if (!defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__))
typedef __signed char int8_t;
-typedef unsigned char u_int8_t;
typedef short int16_t;
-typedef unsigned short u_int16_t;
typedef int int32_t;
+typedef unsigned char u_int8_t;
+typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
#ifdef WE_DONT_NEED_QUADS
typedef long long int64_t;
@@ -65,6 +69,12 @@ typedef unsigned long long u_int64_t;
#endif /* __FreeBSD__ */
#endif
+#ifdef SOLARIS
+#define __P(p) p
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */
typedef u_int32_t pgno_t;
#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */
diff --git a/editline/Makefile.in b/editline/Makefile.in
index a18efd780..67ae6ad40 100755
--- a/editline/Makefile.in
+++ b/editline/Makefile.in
@@ -2,6 +2,8 @@
# Generic Makefile for libedit.
#
+OSTYPE=$(shell uname -s)
+
SHELL = /bin/sh
CC = @CC@
@@ -18,6 +20,10 @@ LIBS = @LIBS@
INSTALL = @INSTALL@
PREFIX = @prefix@
+ifeq ($(OSTYPE),SunOS)
+CFLAGS+=-DSOLARIS -I../include/solaris-compat
+endif
+
# .c files.
ACSRCS = @ACSRCS@
BCSRCS = @BCSRCS@
diff --git a/editline/np/vis.c b/editline/np/vis.c
index 259f03bd6..97406cdf8 100755
--- a/editline/np/vis.c
+++ b/editline/np/vis.c
@@ -67,6 +67,10 @@ __weak_alias(vis,_vis)
#define BELL '\007'
#endif
+#ifdef SOLARIS
+typedef unsigned int u_int32_t;
+#endif
+
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
diff --git a/editline/sys.h b/editline/sys.h
index 9970f18f8..a306d1df7 100755
--- a/editline/sys.h
+++ b/editline/sys.h
@@ -96,10 +96,12 @@ typedef void (*sig_t)(int);
/*
* Broken hdrs.
*/
+#ifndef SOLARIS
extern int tgetent(const char *bp, char *name);
extern int tgetflag(const char *id);
extern int tgetnum(const char *id);
extern char *tgetstr(const char *id, char **area);
+#endif
extern char *tgoto(const char *cap, int col, int row);
extern int tputs(const char *str, int affcnt, int (*putc)(int));
extern char *getenv(const char *);
diff --git a/formats/format_g726.c b/formats/format_g726.c
index 172b4cd41..16c45b765 100755
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -27,8 +27,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#define RATE_40 0
#define RATE_32 1
diff --git a/formats/format_g729.c b/formats/format_g729.c
index be41781dd..7c268996b 100755
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
/* Some Ideas for this code came from makeg729e.c by Jeffrey Chilton */
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index a51ee0262..cb1a7ab0d 100755
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#include "msgsm.h"
/* Some Ideas for this code came from makegsme.c by Jeffrey Chilton */
diff --git a/formats/format_h263.c b/formats/format_h263.c
index d2e2e76e5..17805b231 100755
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
/* Some Ideas for this code came from makeh263e.c by Jeffrey Chilton */
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index 5b47ddc67..f92018cf2 100755
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -30,8 +30,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
/* Some Ideas for this code came from makeg729e.c by Jeffrey Chilton */
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 56c5ef8d8..b08403009 100755
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -30,8 +30,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
static char *desc = "JPEG (Joint Picture Experts Group) Image Format";
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 3e037ca95..6d0127177 100755
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#define BUF_SIZE 160 /* 160 samples */
diff --git a/formats/format_pcm_alaw.c b/formats/format_pcm_alaw.c
index d828aedcc..866cd2360 100755
--- a/formats/format_pcm_alaw.c
+++ b/formats/format_pcm_alaw.c
@@ -30,8 +30,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#define BUF_SIZE 160 /* 160 samples */
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 0a52c10f0..639905e01 100755
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -26,8 +26,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#define BUF_SIZE 320 /* 320 samples */
diff --git a/formats/format_vox.c b/formats/format_vox.c
index 78afc6598..7601994fd 100755
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#define BUF_SIZE 80 /* 160 samples */
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 375553913..be6053447 100755
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
/* Some Ideas for this code came from makewave.c by Jeffrey Chilton */
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index c46c819dd..a34ae929d 100755
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -28,8 +28,12 @@
#ifdef __linux__
#include <endian.h>
#else
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#else
#include <machine/endian.h>
#endif
+#endif
#include "msgsm.h"
/* Some Ideas for this code came from makewave.c by Jeffrey Chilton */
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 7c129f73c..28c566364 100755
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -829,6 +829,19 @@ static inline int ast_fdisset(struct pollfd *pfds, int fd, int max, int *start)
return 0;
}
+#ifdef SOLARIS
+static inline void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
+{
+ tvdiff->tv_sec = tvend->tv_sec - tvstart->tv_sec;
+ tvdiff->tv_usec = tvend->tv_usec - tvstart->tv_usec;
+ if (tvdiff->tv_usec < 0) {
+ tvdiff->tv_sec --;
+ tvdiff->tv_usec += 1000000;
+ }
+
+}
+#endif
+
//! Waits for activity on a group of channels
/*!
* \param nfds the maximum number of file descriptors in the sets
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 784bea39c..1d59fee13 100755
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -22,6 +22,10 @@ extern "C" {
#include <sys/types.h>
#include <sys/time.h>
+
+#ifdef SOLARIS
+#include "solaris-compat/compat.h"
+#endif
/*
* Autodetect system endianess
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index f2066de38..81a31affa 100755
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -48,6 +48,10 @@
#define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE
#endif /* PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */
+#ifdef SOLARIS
+#define AST_MUTEX_INIT_W_CONSTRUCTORS
+#endif
+
#ifdef DEBUG_THREADS
#ifdef THREAD_CRASH
diff --git a/include/solaris-compat/compat.h b/include/solaris-compat/compat.h
new file mode 100755
index 000000000..6b304b2ba
--- /dev/null
+++ b/include/solaris-compat/compat.h
@@ -0,0 +1,34 @@
+#ifndef _SOLARIS_COMPAT_H
+#define _SOLARIS_COMPAT_H
+
+#define __BEGIN_DECLS
+#define __END_DECLS
+
+#ifndef __P
+#define __P(p) p
+#endif
+
+#define LITTLE_ENDIAN 1234
+#define BIG_ENDIAN 4321
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+
+#ifdef __sparc__
+#define BYTE_ORDER BIG_ENDIAN
+#define __BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#define ____BYTE_ORDER BIG_ENDIAN
+#endif
+
+#ifndef __BIT_TYPES_DEFINED__
+#define __BIT_TYPES_DEFINED__
+typedef unsigned char u_int8_t;
+typedef unsigned short u_int16_t;
+typedef unsigned int u_int32_t;
+#endif
+
+int setenv(const char *name, const char *value, int overwrite);
+
+#endif
diff --git a/include/solaris-compat/sys/cdefs.h b/include/solaris-compat/sys/cdefs.h
new file mode 100755
index 000000000..40f76af87
--- /dev/null
+++ b/include/solaris-compat/sys/cdefs.h
@@ -0,0 +1,10 @@
+#ifndef __SYS_CDEFS_H_
+#define __SYS_CDEFS_H_
+
+#define __BEGIN_DECLS
+#define __END_DECLS
+
+#define __P(p) p
+
+
+#endif
diff --git a/include/solaris-compat/sys/queue.h b/include/solaris-compat/sys/queue.h
new file mode 100755
index 000000000..ac273dfe3
--- /dev/null
+++ b/include/solaris-compat/sys/queue.h
@@ -0,0 +1,540 @@
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ * $FreeBSD: src/sys/sys/queue.h,v 1.24.2.4 2000/05/05 01:41:41 archie Exp $
+ */
+
+#ifndef _SYS_QUEUE_H_
+#define _SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * singly-linked tail queues, lists, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The elements
+ * are singly linked for minimum space and pointer manipulation overhead at
+ * the expense of O(n) removal for arbitrary elements. New elements can be
+ * added to the list after an existing element or at the head of the list.
+ * Elements being removed from the head of the list should use the explicit
+ * macro for this purpose for optimum efficiency. A singly-linked list may
+ * only be traversed in the forward direction. Singly-linked lists are ideal
+ * for applications with large datasets and few or no removals or for
+ * implementing a LIFO queue.
+ *
+ * A singly-linked tail queue is headed by a pair of pointers, one to the
+ * head of the list and the other to the tail of the list. The elements are
+ * singly linked for minimum space and pointer manipulation overhead at the
+ * expense of O(n) removal for arbitrary elements. New elements can be added
+ * to the list after an existing element, at the head of the list, or at the
+ * end of the list. Elements being removed from the head of the tail queue
+ * should use the explicit macro for this purpose for optimum efficiency.
+ * A singly-linked tail queue may only be traversed in the forward direction.
+ * Singly-linked tail queues are ideal for applications with large datasets
+ * and few or no removals or for implementing a FIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ *
+ *
+ * SLIST LIST STAILQ TAILQ CIRCLEQ
+ * _HEAD + + + + +
+ * _ENTRY + + + + +
+ * _INIT + + + + +
+ * _EMPTY + + + + +
+ * _FIRST + + + + +
+ * _NEXT + + + + +
+ * _PREV - - - + +
+ * _LAST - - + + +
+ * _FOREACH + + + + +
+ * _FOREACH_REVERSE - - - + +
+ * _INSERT_HEAD + + + + +
+ * _INSERT_BEFORE - + - + +
+ * _INSERT_AFTER + + + + +
+ * _INSERT_TAIL - - + + +
+ * _REMOVE_HEAD + - + - -
+ * _REMOVE + + + + +
+ *
+ */
+
+/*
+ * Singly-linked List definitions.
+ */
+#define SLIST_HEAD(name, type) \
+struct name { \
+ struct type *slh_first; /* first element */ \
+}
+
+#define SLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define SLIST_ENTRY(type) \
+struct { \
+ struct type *sle_next; /* next element */ \
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
+
+#define SLIST_FIRST(head) ((head)->slh_first)
+
+#define SLIST_FOREACH(var, head, field) \
+ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+#define SLIST_INIT(head) { \
+ (head)->slh_first = NULL; \
+}
+
+#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \
+ (slistelm)->field.sle_next = (elm); \
+} while (0)
+
+#define SLIST_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.sle_next = (head)->slh_first; \
+ (head)->slh_first = (elm); \
+} while (0)
+
+#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
+
+#define SLIST_REMOVE_HEAD(head, field) do { \
+ (head)->slh_first = (head)->slh_first->field.sle_next; \
+} while (0)
+
+#define SLIST_REMOVE(head, elm, type, field) do { \
+ if ((head)->slh_first == (elm)) { \
+ SLIST_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = (head)->slh_first; \
+ while( curelm->field.sle_next != (elm) ) \
+ curelm = curelm->field.sle_next; \
+ curelm->field.sle_next = \
+ curelm->field.sle_next->field.sle_next; \
+ } \
+} while (0)
+
+/*
+ * Singly-linked Tail queue definitions.
+ */
+#define STAILQ_HEAD(name, type) \
+struct name { \
+ struct type *stqh_first;/* first element */ \
+ struct type **stqh_last;/* addr of last next element */ \
+}
+
+#define STAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).stqh_first }
+
+#define STAILQ_ENTRY(type) \
+struct { \
+ struct type *stqe_next; /* next element */ \
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
+
+#define STAILQ_INIT(head) do { \
+ (head)->stqh_first = NULL; \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (0)
+
+#define STAILQ_FIRST(head) ((head)->stqh_first)
+#define STAILQ_LAST(head) (*(head)->stqh_last)
+
+#define STAILQ_FOREACH(var, head, field) \
+ for((var) = (head)->stqh_first; (var); (var) = (var)->field.stqe_next)
+
+#define STAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (head)->stqh_first = (elm); \
+} while (0)
+
+#define STAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.stqe_next = NULL; \
+ *(head)->stqh_last = (elm); \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+} while (0)
+
+#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
+ if (((elm)->field.stqe_next = (tqelm)->field.stqe_next) == NULL)\
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (tqelm)->field.stqe_next = (elm); \
+} while (0)
+
+#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
+
+#define STAILQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->stqh_first = \
+ (head)->stqh_first->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (0)
+
+#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \
+ if (((head)->stqh_first = (elm)->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (0)
+
+#define STAILQ_REMOVE(head, elm, type, field) do { \
+ if ((head)->stqh_first == (elm)) { \
+ STAILQ_REMOVE_HEAD(head, field); \
+ } \
+ else { \
+ struct type *curelm = (head)->stqh_first; \
+ while( curelm->field.stqe_next != (elm) ) \
+ curelm = curelm->field.stqe_next; \
+ if((curelm->field.stqe_next = \
+ curelm->field.stqe_next->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(curelm)->field.stqe_next; \
+ } \
+} while (0)
+
+/*
+ * List definitions.
+ */
+#define LIST_HEAD(name, type) \
+struct name { \
+ struct type *lh_first; /* first element */ \
+}
+
+#define LIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
+
+/*
+ * List functions.
+ */
+
+#define LIST_EMPTY(head) ((head)->lh_first == NULL)
+
+#define LIST_FIRST(head) ((head)->lh_first)
+
+#define LIST_FOREACH(var, head, field) \
+ for((var) = (head)->lh_first; (var); (var) = (var)->field.le_next)
+
+#define LIST_INIT(head) do { \
+ (head)->lh_first = NULL; \
+} while (0)
+
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ (listelm)->field.le_next->field.le_prev = \
+ &(elm)->field.le_next; \
+ (listelm)->field.le_next = (elm); \
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
+} while (0)
+
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
+ (elm)->field.le_next = (listelm); \
+ *(listelm)->field.le_prev = (elm); \
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
+} while (0)
+
+#define LIST_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+ (head)->lh_first = (elm); \
+ (elm)->field.le_prev = &(head)->lh_first; \
+} while (0)
+
+#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+
+#define LIST_REMOVE(elm, field) do { \
+ if ((elm)->field.le_next != NULL) \
+ (elm)->field.le_next->field.le_prev = \
+ (elm)->field.le_prev; \
+ *(elm)->field.le_prev = (elm)->field.le_next; \
+} while (0)
+
+/*
+ * Tail queue definitions.
+ */
+#define TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+}
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+}
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+
+#define TAILQ_FOREACH(var, head, field) \
+ for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
+
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = TAILQ_LAST((head), headname); \
+ (var); \
+ (var) = TAILQ_PREV((var), headname, field))
+
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+#define TAILQ_INIT(head) do { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ (elm)->field.tqe_next->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (listelm)->field.tqe_next = (elm); \
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (0)
+
+/*
+ * Circular queue definitions.
+ */
+#define CIRCLEQ_HEAD(name, type) \
+struct name { \
+ struct type *cqh_first; /* first element */ \
+ struct type *cqh_last; /* last element */ \
+}
+
+#define CIRCLEQ_ENTRY(type) \
+struct { \
+ struct type *cqe_next; /* next element */ \
+ struct type *cqe_prev; /* previous element */ \
+}
+
+/*
+ * Circular queue functions.
+ */
+#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
+
+#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
+
+#define CIRCLEQ_FOREACH(var, head, field) \
+ for((var) = (head)->cqh_first; \
+ (var) != (void *)(head); \
+ (var) = (var)->field.cqe_next)
+
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
+ for((var) = (head)->cqh_last; \
+ (var) != (void *)(head); \
+ (var) = (var)->field.cqe_prev)
+
+#define CIRCLEQ_INIT(head) do { \
+ (head)->cqh_first = (void *)(head); \
+ (head)->cqh_last = (void *)(head); \
+} while (0)
+
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm)->field.cqe_next; \
+ (elm)->field.cqe_prev = (listelm); \
+ if ((listelm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (listelm)->field.cqe_next->field.cqe_prev = (elm); \
+ (listelm)->field.cqe_next = (elm); \
+} while (0)
+
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm); \
+ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
+ if ((listelm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (listelm)->field.cqe_prev->field.cqe_next = (elm); \
+ (listelm)->field.cqe_prev = (elm); \
+} while (0)
+
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.cqe_next = (head)->cqh_first; \
+ (elm)->field.cqe_prev = (void *)(head); \
+ if ((head)->cqh_last == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (head)->cqh_first->field.cqe_prev = (elm); \
+ (head)->cqh_first = (elm); \
+} while (0)
+
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.cqe_next = (void *)(head); \
+ (elm)->field.cqe_prev = (head)->cqh_last; \
+ if ((head)->cqh_first == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (head)->cqh_last->field.cqe_next = (elm); \
+ (head)->cqh_last = (elm); \
+} while (0)
+
+#define CIRCLEQ_LAST(head) ((head)->cqh_last)
+
+#define CIRCLEQ_NEXT(elm,field) ((elm)->field.cqe_next)
+
+#define CIRCLEQ_PREV(elm,field) ((elm)->field.cqe_prev)
+
+#define CIRCLEQ_REMOVE(head, elm, field) do { \
+ if ((elm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm)->field.cqe_prev; \
+ else \
+ (elm)->field.cqe_next->field.cqe_prev = \
+ (elm)->field.cqe_prev; \
+ if ((elm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm)->field.cqe_next; \
+ else \
+ (elm)->field.cqe_prev->field.cqe_next = \
+ (elm)->field.cqe_next; \
+} while (0)
+
+#ifdef KERNEL
+
+/*
+ * XXX insque() and remque() are an old way of handling certain queues.
+ * They bogusly assumes that all queue heads look alike.
+ */
+
+struct quehead {
+ struct quehead *qh_link;
+ struct quehead *qh_rlink;
+};
+
+#ifdef __GNUC__
+
+static __inline void
+insque(void *a, void *b)
+{
+ struct quehead *element = a, *head = b;
+
+ element->qh_link = head->qh_link;
+ element->qh_rlink = head;
+ head->qh_link = element;
+ element->qh_link->qh_rlink = element;
+}
+
+static __inline void
+remque(void *a)
+{
+ struct quehead *element = a;
+
+ element->qh_link->qh_rlink = element->qh_rlink;
+ element->qh_rlink->qh_link = element->qh_link;
+ element->qh_rlink = 0;
+}
+
+#else /* !__GNUC__ */
+
+void insque __P((void *a, void *b));
+void remque __P((void *a));
+
+#endif /* __GNUC__ */
+
+#endif /* KERNEL */
+
+#endif /* !_SYS_QUEUE_H_ */
+
diff --git a/logger.c b/logger.c
index e9e75b831..5fb0348af 100755
--- a/logger.c
+++ b/logger.c
@@ -136,7 +136,9 @@ static struct logchannel *make_logchannel(char *channel, char *components, int l
{
struct logchannel *chan;
char *facility;
+#ifndef SOLARIS
CODE *cptr;
+#endif
if (ast_strlen_zero(channel))
return NULL;
@@ -155,6 +157,8 @@ static struct logchannel *make_logchannel(char *channel, char *components, int l
if(!facility++ || !facility) {
facility = "local0";
}
+
+#ifndef SOLARIS
/*
* Walk through the list of facilitynames (defined in sys/syslog.h)
* to see if we can find the one we have been given
@@ -168,6 +172,46 @@ static struct logchannel *make_logchannel(char *channel, char *components, int l
}
cptr++;
}
+#else
+ chan->facility = -1;
+ if (!strcasecmp(facility, "kern"))
+ chan->facility = LOG_KERN;
+ else if (!strcasecmp(facility, "USER"))
+ chan->facility = LOG_USER;
+ else if (!strcasecmp(facility, "MAIL"))
+ chan->facility = LOG_MAIL;
+ else if (!strcasecmp(facility, "DAEMON"))
+ chan->facility = LOG_DAEMON;
+ else if (!strcasecmp(facility, "AUTH"))
+ chan->facility = LOG_AUTH;
+ else if (!strcasecmp(facility, "SYSLOG"))
+ chan->facility = LOG_SYSLOG;
+ else if (!strcasecmp(facility, "LPR"))
+ chan->facility = LOG_LPR;
+ else if (!strcasecmp(facility, "NEWS"))
+ chan->facility = LOG_NEWS;
+ else if (!strcasecmp(facility, "UUCP"))
+ chan->facility = LOG_UUCP;
+ else if (!strcasecmp(facility, "CRON"))
+ chan->facility = LOG_CRON;
+ else if (!strcasecmp(facility, "LOCAL0"))
+ chan->facility = LOG_LOCAL0;
+ else if (!strcasecmp(facility, "LOCAL1"))
+ chan->facility = LOG_LOCAL1;
+ else if (!strcasecmp(facility, "LOCAL2"))
+ chan->facility = LOG_LOCAL2;
+ else if (!strcasecmp(facility, "LOCAL3"))
+ chan->facility = LOG_LOCAL3;
+ else if (!strcasecmp(facility, "LOCAL4"))
+ chan->facility = LOG_LOCAL4;
+ else if (!strcasecmp(facility, "LOCAL5"))
+ chan->facility = LOG_LOCAL5;
+ else if (!strcasecmp(facility, "LOCAL6"))
+ chan->facility = LOG_LOCAL6;
+ else if (!strcasecmp(facility, "LOCAL7"))
+ chan->facility = LOG_LOCAL7;
+#endif
+
if (0 > chan->facility) {
fprintf(stderr, "Logger Warning: bad syslog facility in logger.conf\n");
free(chan);
diff --git a/md5.c b/md5.c
index 17a00c6fc..d39e0fe1a 100755
--- a/md5.c
+++ b/md5.c
@@ -8,6 +8,9 @@
# include <sys/endian.h>
#elif defined( BSD ) && ( BSD >= 199103 ) || defined(__APPLE__)
# include <machine/endian.h>
+#elif defined( __sparc__ ) && defined( SOLARIS )
+# define BIG_ENDIAN 4321
+# define BYTE_ORDER BIG_ENDIAN
#else
# include <endian.h>
#endif
diff --git a/mkdep b/mkdep
index 94e6e482a..3f30b51ac 100755
--- a/mkdep
+++ b/mkdep
@@ -1,4 +1,4 @@
-#!/bin/sh -
+#!/bin/bash -
#
# $OpenBSD: mkdep.gcc.sh,v 1.8 1998/09/02 06:40:07 deraadt Exp $
# $NetBSD: mkdep.gcc.sh,v 1.9 1994/12/23 07:34:59 jtc Exp $
diff --git a/mkpkgconfig b/mkpkgconfig
index a4f143bed..3b097a9fe 100755
--- a/mkpkgconfig
+++ b/mkpkgconfig
@@ -2,7 +2,7 @@
PPATH=$1
## Make sure we were called from Makefile
-if [ "x$ASTERISKVERSIONNUM" == "x" ]; then
+if [ "x$ASTERISKVERSIONNUM" = "x" ]; then
echo " ** Do not call this script directly"
exit
fi
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 0bc2c7996..b68a1050a 100755
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -39,7 +39,7 @@
#include <sys/socket.h>
#include <string.h>
#include <errno.h>
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(SOLARIS)
#include <sys/types.h>
#include <netinet/in_systm.h>
#endif
@@ -406,7 +406,7 @@ static void reset_global_eid(void)
close(s);
}
#else
-#if defined(ifa_broadaddr)
+#if defined(ifa_broadaddr) && !defined(SOLARIS)
char eid_str[20];
struct ifaddrs *ifap;
@@ -4518,14 +4518,14 @@ static int set_config(char *config_file, struct sockaddr_in* sin)
tos = IPTOS_THROUGHPUT;
else if (!strcasecmp(v->value, "reliability"))
tos = IPTOS_RELIABILITY;
-#if !defined(__NetBSD__)
+#if !defined(__NetBSD__) && !defined(SOLARIS)
else if (!strcasecmp(v->value, "mincost"))
tos = IPTOS_MINCOST;
#endif
else if (!strcasecmp(v->value, "none"))
tos = 0;
else
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) && !defined(SOLARIS)
ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
#else
ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', or 'none'\n", v->lineno);
diff --git a/rtp.c b/rtp.c
index 55d79ca30..92dea1dca 100755
--- a/rtp.c
+++ b/rtp.c
@@ -1084,9 +1084,23 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
return 0;
}
+#ifdef SOLARIS
+static void put_uint32(unsigned char *buf, int i)
+{
+ unsigned char *c = (unsigned char *)&i;
+
+ buf[0] = (i>>24) & 0xff;
+ buf[1] = (i>>16) & 0xff;
+ buf[2] = (i>>8) & 0xff;
+ buf[3] = i & 0xff;
+}
+#else
+#define put_uint32(p,v) ((*((unsigned int *)(p))) = (v))
+#endif
+
static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec)
{
- unsigned int *rtpheader;
+ unsigned char *rtpheader;
char iabuf[INET_ADDRSTRLEN];
int hdrlen = 12;
int res;
@@ -1165,10 +1179,14 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
}
}
/* Get a pointer to the header */
- rtpheader = (unsigned int *)(f->data - hdrlen);
- rtpheader[0] = htonl((2 << 30) | (codec << 16) | (rtp->seqno++) | (mark << 23));
- rtpheader[1] = htonl(rtp->lastts);
- rtpheader[2] = htonl(rtp->ssrc);
+ rtpheader = (unsigned char *)(f->data - hdrlen);
+
+ put_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (rtp->seqno) | (mark << 23)));
+ put_uint32(rtpheader + 4, htonl(rtp->lastts));
+ put_uint32(rtpheader + 8, htonl(rtp->ssrc));
+
+ rtp->seqno++;
+
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
if (res <0)
diff --git a/say.c b/say.c
index e3b3106dd..d8533e953 100755
--- a/say.c
+++ b/say.c
@@ -28,6 +28,10 @@
#include "asterisk.h"
#include <stdio.h>
+#ifdef SOLARIS
+#include <iso/limits_iso.h>
+#endif
+
/* Forward declaration */
static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang);
diff --git a/stdtime/localtime.c b/stdtime/localtime.c
index 1f6309e3f..2f9d412fd 100755
--- a/stdtime/localtime.c
+++ b/stdtime/localtime.c
@@ -113,6 +113,12 @@ struct lsinfo { /* leap second information */
#define MY_TZNAME_MAX 255
#endif /* !defined TZNAME_MAX */
+#ifdef SOLARIS
+#undef TM_ZONE
+#undef TM_GMTOFF
+#endif
+
+
struct state {
char name[TZ_STRLEN_MAX + 1];
int leapcnt;
@@ -1208,7 +1214,11 @@ const time_t * const timep;
char *buf;
{
struct tm tm;
+#ifdef SOLARIS
+ return asctime_r(localtime_r(timep, &tm), buf, 256);
+#else
return asctime_r(localtime_r(timep, &tm), buf);
+#endif
}
/*
diff --git a/strcompat.c b/strcompat.c
new file mode 100755
index 000000000..289116476
--- /dev/null
+++ b/strcompat.c
@@ -0,0 +1,144 @@
+/* Compatibility functions for strsep and strtoq missing on Solaris */
+
+#include <sys/types.h>
+#include <stdio.h>
+
+char* strsep(char** str, const char* delims)
+{
+ char* token;
+
+ if (*str==NULL) {
+ /* No more tokens */
+ return NULL;
+ }
+
+ token=*str;
+ while (**str!='\0') {
+ if (strchr(delims,**str)!=NULL) {
+ **str='\0';
+ (*str)++;
+ return token;
+ }
+ (*str)++;
+ }
+ /* There is no other token */
+ *str=NULL;
+ return token;
+}
+
+
+#define LONG_MIN (-9223372036854775807L-1L)
+ /* min value of a "long int" */
+#define LONG_MAX 9223372036854775807L
+ /* max value of a "long int" */
+
+/*
+ * Convert a string to a quad integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+uint64_t
+strtoq(const char *nptr, char **endptr, int base)
+{
+ const char *s;
+ uint64_t acc;
+ unsigned char c;
+ uint64_t qbase, cutoff;
+ int neg, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ s = nptr;
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else {
+ neg = 0;
+ if (c == '+')
+ c = *s++;
+ }
+ if ((base == 0 || base == 16) &&
+ c == '\0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '\0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for quads is
+ * [-9223372036854775808..9223372036854775807] and the input base
+ * is 10, cutoff will be set to 922337203685477580 and cutlim to
+ * either 7 (neg==0) or 8 (neg==1), meaning that if we have
+ * accumulated a value > 922337203685477580, or equal but the
+ * next digit is > 7 (or 8), the number is too big, and we will
+ * return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ qbase = (unsigned)base;
+ cutoff = neg ? (uint64_t)-(LONG_MIN + LONG_MAX) + LONG_MAX : LONG_MAX;
+ cutlim = cutoff % qbase;
+ cutoff /= qbase;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
+ if (isdigit(c))
+ c -= '\0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= qbase;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_MIN : LONG_MAX;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *((const char **)endptr) = any ? s - 1 : nptr;
+ return (acc);
+}
+
+int setenv(const char *name, const char *value, int overwrite)
+{
+ unsigned char *buf;
+ int buflen, ret;
+
+ buflen = strlen(name) + strlen(value) + 2;
+ if ((buf = malloc(buflen)) == NULL)
+ return -1;
+
+ if (!overwrite && getenv(name))
+ return 0;
+
+ snprintf(buf, buflen, "%s=%s", name, value);
+ ret = putenv(buf);
+
+ free(buf);
+
+ return ret;
+}
diff --git a/utils.c b/utils.c
index 49fe1f3fe..c296275c1 100755
--- a/utils.c
+++ b/utils.c
@@ -168,10 +168,17 @@ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp)
}
if (!s || !*s)
return NULL;
+#ifdef SOLARIS
+ result = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &herrno);
+
+ if (!result || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0])
+ return NULL;
+#else
res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &herrno);
if (res || !result || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0])
return NULL;
+#endif
return &hp->hp;
}