[asterisk-commits] tilghman: branch 1.8 r289104 - in /branches/1.8: ./ apps/ include/asterisk/ m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 28 13:18:48 CDT 2010


Author: tilghman
Date: Tue Sep 28 13:18:43 2010
New Revision: 289104

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=289104
Log:
Solaris compatibility fixes

Review: https://reviewboard.asterisk.org/r/942/

Modified:
    branches/1.8/Makefile
    branches/1.8/apps/app_voicemail.c
    branches/1.8/configure
    branches/1.8/configure.ac
    branches/1.8/include/asterisk/autoconfig.h.in
    branches/1.8/include/asterisk/compat.h
    branches/1.8/main/strcompat.c
    branches/1.8/makeopts.in
    branches/1.8/tests/test_time.c
    branches/1.8/tests/test_utils.c

Modified: branches/1.8/Makefile
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/Makefile?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/Makefile (original)
+++ branches/1.8/Makefile Tue Sep 28 13:18:43 2010
@@ -123,46 +123,6 @@
 
 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
 DEBUG=-g3
-
-# Define standard directories for various platforms
-# These apply if they are not redefined in asterisk.conf 
-ifeq ($(OSARCH),SunOS)
-  ASTETCDIR=/var/etc/asterisk
-  ASTLIBDIR=/opt/asterisk/lib
-  ASTVARLIBDIR=/var/opt/asterisk
-  ASTDBDIR=$(ASTVARLIBDIR)
-  ASTKEYDIR=$(ASTVARLIBDIR)
-  ASTSPOOLDIR=/var/spool/asterisk
-  ASTLOGDIR=/var/log/asterisk
-  ASTHEADERDIR=/opt/asterisk/include
-  ASTSBINDIR=/opt/asterisk/sbin
-  ASTVARRUNDIR=/var/run/asterisk
-  ASTMANDIR=/opt/asterisk/man
-else
-  ASTETCDIR=$(sysconfdir)/asterisk
-  ASTLIBDIR=$(libdir)/asterisk
-  ASTHEADERDIR=$(includedir)/asterisk
-  ASTSBINDIR=$(sbindir)
-  ASTSPOOLDIR=$(localstatedir)/spool/asterisk
-  ASTLOGDIR=$(localstatedir)/log/asterisk
-  ASTVARRUNDIR=$(localstatedir)/run/asterisk
-  ASTMANDIR=$(mandir)
-ifneq ($(findstring BSD,$(OSARCH)),)
-  ASTVARLIBDIR=$(prefix)/share/asterisk
-  ASTVARRUNDIR=$(localstatedir)/run/asterisk
-  ASTDBDIR=$(localstatedir)/db/asterisk
-else
-  ASTVARLIBDIR=$(localstatedir)/lib/asterisk
-  ASTDBDIR=$(ASTVARLIBDIR)
-endif
-ifneq ($(findstring darwin,$(OSARCH)),)
-  ASTVARRUNDIR=/Library/Application Support/Asterisk/Run
-endif
-  ASTKEYDIR=$(ASTVARLIBDIR)
-endif
-ifeq ($(ASTDATADIR),)
-  ASTDATADIR:=$(ASTVARLIBDIR)
-endif
 
 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
 # when starting Asterisk

Modified: branches/1.8/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_voicemail.c?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/apps/app_voicemail.c (original)
+++ branches/1.8/apps/app_voicemail.c Tue Sep 28 13:18:43 2010
@@ -12432,7 +12432,7 @@
 	char testcontext[] = "test";
 	char testmailbox[] = "00000000";
 	char from[] = "test at example.net", cidnum[] = "1234", cidname[] = "Mark Spencer", format[] = "gsm";
-	char attach[] = "/var/lib/asterisk/sounds/en/tt-weasels", attach2[] = "/var/lib/asterisk/sounds/en/tt-somethingwrong";
+	char attach[256], attach2[256];
 	char buf[256] = ""; /* No line should actually be longer than 80 */
 	struct ast_channel *chan = NULL;
 	struct ast_vm_user *vmu, vmus = {
@@ -12469,6 +12469,9 @@
 	case TEST_EXECUTE:
 		break;
 	}
+
+	snprintf(attach, sizeof(attach), "%s/sounds/en/tt-weasels", ast_config_AST_VAR_DIR);
+	snprintf(attach2, sizeof(attach2), "%s/sounds/en/tt-somethingwrong", ast_config_AST_VAR_DIR);
 
 	if (!(vmu = find_user(&vmus, testcontext, testmailbox)) &&
 		!(vmu = find_or_create(testcontext, testmailbox))) {

Modified: branches/1.8/configure.ac
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/configure.ac?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/configure.ac (original)
+++ branches/1.8/configure.ac Tue Sep 28 13:18:43 2010
@@ -37,7 +37,35 @@
 # specify output header file
 AC_CONFIG_HEADER(include/asterisk/autoconfig.h)
 
-AC_USE_SYSTEM_EXTENSIONS	# note- does not work on FreeBSD
+AC_USE_SYSTEM_EXTENSIONS	dnl note- does not work on FreeBSD
+
+# System default paths
+AC_SUBST([astsbindir],        ['${sbindir}'])dnl
+AC_SUBST([astetcdir],         ['${sysconfdir}/asterisk'])dnl
+AC_SUBST([astheaderdir],      ['${includedir}/asterisk'])dnl
+AC_SUBST([astlibdir],         ['${libdir}/asterisk'])dnl
+AC_SUBST([astmandir],         ['${mandir}'])dnl
+AC_SUBST([astvarlibdir],      ['${localstatedir}/lib/asterisk'])dnl
+AC_SUBST([astdatadir],        ['${astvarlibdir}'])dnl
+AC_SUBST([astdbdir],          ['${astvarlibdir}'])dnl
+AC_SUBST([astkeydir],         ['${astvarlibdir}'])dnl
+AC_SUBST([astspooldir],       ['${localstatedir}/spool/asterisk'])dnl
+AC_SUBST([astlogdir],         ['${localstatedir}/log/asterisk'])dnl
+AC_SUBST([astvarrundir],      ['${localstatedir}/run/asterisk'])dnl
+
+case "${host_os}" in
+     *bsd*)
+     if test ${prefix} = 'NONE'; then
+        astvarlibdir='${prefix}/share/asterisk'
+        astdbdir='${localstatedir}/db/asterisk'
+     fi
+     ;;
+     darwin*)
+     if test ${prefix} = 'NONE'; then
+        astvarrundir='/Library/Application Support/Asterisk/Run'
+     fi
+     ;;
+esac
 
 case "${host_os}" in
      freebsd*)
@@ -49,10 +77,10 @@
      AC_PREFIX_DEFAULT([/usr/local])
      if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then
         if test ${sysconfdir} = '${prefix}/etc'; then
-           sysconfdir=/etc
+           astetcdir=/etc/asterisk
         fi
         if test ${mandir} = '${prefix}/man'; then
-           mandir=/usr/share/man
+           astmandir=/usr/share/man
         fi
      fi
      CPPFLAGS=-I/usr/local/include
@@ -61,6 +89,19 @@
      darwin*)
      AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.])
      AC_DEFINE([_DARWIN_UNLIMITED_SELECT], 1, [Define to 1 if running on Darwin.])
+     ;;
+     solaris*)
+     if test ${prefix} = 'NONE'; then
+        astetcdir=/var/etc/asterisk
+        astsbindir=/opt/asterisk/sbin
+        astlibdir=/opt/asterisk/lib
+        astheaderdir=/opt/asterisk/include
+        astmandir=/opt/asterisk/man
+        astvarlibdir=/var/opt/asterisk
+        astspooldir=/var/spool/asterisk
+        astlogdir=/var/log/asterisk
+        astvarrundir=/var/run/asterisk
+     fi
      ;;
      *)
      AC_PREFIX_DEFAULT([/usr])
@@ -464,7 +505,7 @@
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii memchr memmove memset mkdir munmap ntohll newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
+AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob htonll ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap ntohll newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv utime vasprintf getpeereid sysctl swapctl])
 
 # NOTE: we use AC_CHECK_LIB to get -lm into the arguments for later checks,
 # so that AC_CHECK_FUNCS can detect functions in that library.

Modified: branches/1.8/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/autoconfig.h.in?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/include/asterisk/autoconfig.h.in (original)
+++ branches/1.8/include/asterisk/autoconfig.h.in Tue Sep 28 13:18:43 2010
@@ -439,6 +439,9 @@
 
 /* Define to 1 if you have the `mkdir' function. */
 #undef HAVE_MKDIR
+
+/* Define to 1 if you have the `mkdtemp' function. */
+#undef HAVE_MKDTEMP
 
 /* Define to 1 if you have a working `mmap' system call. */
 #undef HAVE_MMAP

Modified: branches/1.8/include/asterisk/compat.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/compat.h?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/include/asterisk/compat.h (original)
+++ branches/1.8/include/asterisk/compat.h Tue Sep 28 13:18:43 2010
@@ -97,6 +97,10 @@
 uint64_t htonll(uint64_t host64);
 #endif
 
+#ifndef HAVE_MKDTEMP
+char *mkdtemp(char *template_s);
+#endif
+
 #ifndef HAVE_NTOHLL
 uint64_t ntohll(uint64_t net64);
 #endif

Modified: branches/1.8/main/strcompat.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/strcompat.c?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/main/strcompat.c (original)
+++ branches/1.8/main/strcompat.c Tue Sep 28 13:18:43 2010
@@ -28,6 +28,8 @@
 #include <dirent.h>         /* for opendir(3) */
 #include <unistd.h>         /* for fcntl(2) */
 #include <fcntl.h>          /* for fcntl(2) */
+
+#include "asterisk/utils.h"
 
 #ifndef HAVE_STRSEP
 char *strsep(char **str, const char *delims)
@@ -478,3 +480,91 @@
 }
 #endif
 
+#ifndef HAVE_MKDTEMP
+/*	$OpenBSD: mktemp.c,v 1.30 2010/03/21 23:09:30 schwarze Exp $ */
+/*
+ * Copyright (c) 1996-1998, 2008 Theo de Raadt
+ * Copyright (c) 1997, 2008-2009 Todd C. Miller
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define MKTEMP_NAME	0
+#define MKTEMP_FILE	1
+#define MKTEMP_DIR	2
+
+#define TEMPCHARS	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."
+#define NUM_CHARS	(sizeof(TEMPCHARS) - 1)
+
+static int mktemp_internal(char *path, int slen, int mode)
+{
+	char *start, *cp, *ep;
+	const char *tempchars = TEMPCHARS;
+	unsigned int r, tries;
+	struct stat sb;
+	size_t len;
+	int fd;
+
+	len = strlen(path);
+	if (len == 0 || slen >= len) {
+		errno = EINVAL;
+		return(-1);
+	}
+	ep = path + len - slen;
+
+	tries = 1;
+	for (start = ep; start > path && start[-1] == 'X'; start--) {
+		if (tries < INT_MAX / NUM_CHARS) {
+			tries *= NUM_CHARS;
+		}
+	}
+	tries *= 2;
+
+	do {
+		for (cp = start; cp != ep; cp++) {
+			r = ast_random() % NUM_CHARS;
+			*cp = tempchars[r];
+		}
+
+		switch (mode) {
+		case MKTEMP_NAME:
+			if (lstat(path, &sb) != 0) {
+				return (errno == ENOENT ? 0 : -1);
+			}
+			break;
+		case MKTEMP_FILE:
+			fd = open(path, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
+			if (fd != -1 || errno != EEXIST) {
+				return (fd);
+			}
+			break;
+		case MKTEMP_DIR:
+			if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) {
+				return (0);
+			}
+			if (errno != EEXIST) {
+				return (-1);
+			}
+			break;
+		}
+	} while (--tries);
+
+	errno = EEXIST;
+	return(-1);
+}
+
+char *mkdtemp(char *path)
+{
+	return mktemp_internal(path, 0, MKTEMP_DIR) ? NULL : path;
+}
+#endif

Modified: branches/1.8/makeopts.in
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/makeopts.in?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/makeopts.in (original)
+++ branches/1.8/makeopts.in Tue Sep 28 13:18:43 2010
@@ -77,6 +77,20 @@
 sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
 
+ASTSBINDIR = @astsbindir@
+ASTETCDIR = @astetcdir@
+ASTHEADERDIR = @astheaderdir@
+ASTLIBDIR = @astlibdir@
+ASTMANDIR = @astmandir@
+astvarlibdir = @astvarlibdir@
+ASTVARLIBDIR = @astvarlibdir@
+ASTDATADIR = @astdatadir@
+ASTDBDIR = @astdbdir@
+ASTKEYDIR = @astkeydir@
+ASTSPOOLDIR = @astspooldir@
+ASTLOGDIR = @astlogdir@
+ASTVARRUNDIR = @astvarrundir@
+
 AST_DEVMODE=@AST_DEVMODE@
 NOISY_BUILD=@NOISY_BUILD@
 

Modified: branches/1.8/tests/test_time.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/tests/test_time.c?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/tests/test_time.c (original)
+++ branches/1.8/tests/test_time.c Tue Sep 28 13:18:43 2010
@@ -82,6 +82,7 @@
 				ast_log(LOG_WARNING, "system(%s) returned non-zero: %d\n", syscmd, system_res);
 			}
 			ast_localtime_wakeup_monitor();
+			sched_yield();
 			ast_localtime(&tv, &atm[i], tzfile);
 			if (i != 0) {
 				if (atm[i].tm_hour == atm[i - 1].tm_hour) {

Modified: branches/1.8/tests/test_utils.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/tests/test_utils.c?view=diff&rev=289104&r1=289103&r2=289104
==============================================================================
--- branches/1.8/tests/test_utils.c (original)
+++ branches/1.8/tests/test_utils.c Tue Sep 28 13:18:43 2010
@@ -253,6 +253,7 @@
 		break;
 	}
 
+#if 0 /* Not defined on Solaris */
 	ast_test_status_update(test,
 			       "address of __stub__ast_crypto_loaded is %p\n",
 			       __stub__ast_crypto_loaded);
@@ -264,6 +265,7 @@
 	ast_test_status_update(test,
 			       "pointer to ast_crypto_loaded is %p\n",
 			       ast_crypto_loaded);
+#endif
 
 	return ast_crypto_loaded() ? AST_TEST_PASS : AST_TEST_FAIL;
 }
@@ -308,6 +310,7 @@
 		break;
 	}
 
+#if 0
 	ast_test_status_update(test,
 			       "address of __stub__ast_agi_register is %p\n",
 			       __stub__ast_agi_register);
@@ -319,6 +322,7 @@
 	ast_test_status_update(test,
 			       "pointer to ast_agi_register is %p\n",
 			       ast_agi_register);
+#endif
 
 	if (ast_agi_register(ast_module_info->self, &noop_command) == AST_OPTIONAL_API_UNAVAILABLE) {
 		return AST_TEST_FAIL;




More information about the asterisk-commits mailing list