[asterisk-commits] pcadach: branch pcadach/chan_h323-live r43038 - in /team/pcadach/chan_h323-li...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Sep 16 13:20:07 MST 2006


Author: pcadach
Date: Sat Sep 16 15:20:07 2006
New Revision: 43038

URL: http://svn.digium.com/view/asterisk?rev=43038&view=rev
Log:
Merged revisions 42982,43008,43024 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r42982 | qwell | 2006-09-15 23:16:00 +0600 (Птн, 15 Сен 2006) | 3 lines

Many Solaris fixes - this moves some of the stuff from utils.c to strcompat.c
Every OS uses strcompat now - this was done on purpose.

................
r43008 | tilghman | 2006-09-16 11:43:54 +0600 (Сбт, 16 Сен 2006) | 10 lines

Merged revisions 43003 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r43003 | tilghman | 2006-09-15 23:44:02 -0500 (Fri, 15 Sep 2006) | 2 lines

When the marked user enters the conference, we should no longer timeout

........

................
r43024 | tilghman | 2006-09-16 14:10:55 +0600 (Сбт, 16 Сен 2006) | 10 lines

Merged revisions 43019 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r43019 | tilghman | 2006-09-16 02:57:04 -0500 (Sat, 16 Sep 2006) | 2 lines

When a realtime peer expires, reset the ipaddress in the realtime database back to 0 (Issue 6656)

........

................

Modified:
    team/pcadach/chan_h323-live/   (props changed)
    team/pcadach/chan_h323-live/agi/Makefile
    team/pcadach/chan_h323-live/apps/app_meetme.c
    team/pcadach/chan_h323-live/channels/chan_iax2.c
    team/pcadach/chan_h323-live/configure
    team/pcadach/chan_h323-live/configure.ac
    team/pcadach/chan_h323-live/include/asterisk/autoconfig.h.in
    team/pcadach/chan_h323-live/include/asterisk/compat.h
    team/pcadach/chan_h323-live/include/asterisk/strings.h
    team/pcadach/chan_h323-live/include/asterisk/utils.h
    team/pcadach/chan_h323-live/main/Makefile
    team/pcadach/chan_h323-live/main/strcompat.c
    team/pcadach/chan_h323-live/main/utils.c
    team/pcadach/chan_h323-live/utils/Makefile

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/pcadach/chan_h323-live/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Sep 16 15:20:07 2006
@@ -1,1 +1,1 @@
-/trunk:1-42978
+/trunk:1-43037

Modified: team/pcadach/chan_h323-live/agi/Makefile
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/agi/Makefile?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/agi/Makefile (original)
+++ team/pcadach/chan_h323-live/agi/Makefile Sat Sep 16 15:20:07 2006
@@ -16,16 +16,18 @@
 AGIS=agi-test.agi eagi-test eagi-sphinx-test jukebox.agi
 
 ifeq ($(OSARCH),SunOS)
-  LIBS+=-lsocket -lnsl ../main/strcompat.o
+  LIBS+=-lsocket -lnsl
 endif
 
 include $(ASTTOPDIR)/Makefile.rules
 
 all: $(AGIS)
 
-eagi-test: eagi-test.o
+eagi-test: eagi-test.o strcompat.o
 
 eagi-sphinx-test: eagi-sphinx-test.o
+
+$(eval $(call ast_make_o_c,strcompat.o,../main/strcompat.c))
 
 install: all
 	mkdir -p $(DESTDIR)$(AGI_DIR)

Modified: team/pcadach/chan_h323-live/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/apps/app_meetme.c?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/apps/app_meetme.c (original)
+++ team/pcadach/chan_h323-live/apps/app_meetme.c Sat Sep 16 15:20:07 2006
@@ -1432,6 +1432,8 @@
 						}
 					}
 				} else if(currentmarked >= 1 && lastmarked == 0) {
+					/* Marked user entered, so cancel timeout */
+					timeout = 0;
 					if (confflags & CONFFLAG_MONITOR)
 						ztc.confmode = ZT_CONF_CONFMON | ZT_CONF_LISTENER;
 					else if (confflags & CONFFLAG_TALKER)

Modified: team/pcadach/chan_h323-live/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_iax2.c?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_iax2.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_iax2.c Sat Sep 16 15:20:07 2006
@@ -800,6 +800,7 @@
 static struct ast_frame *iax2_read(struct ast_channel *c);
 static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly);
 static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly);
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, time_t regtime);
 static void destroy_user(struct iax2_user *user);
 static void prune_peers(void);
 
@@ -2496,6 +2497,7 @@
 		time(&nowtime);
 		if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
 			memset(&peer->addr, 0, sizeof(peer->addr));
+			realtime_update_peer(peer->name, &peer->addr, 0);
 			if (option_debug)
 				ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
 						peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);

Modified: team/pcadach/chan_h323-live/configure
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/configure?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/configure (original)
+++ team/pcadach/chan_h323-live/configure Sat Sep 16 15:20:07 2006
@@ -13477,7 +13477,8 @@
 
 
 
-for ac_func in atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol unsetenv utime strtoq strcasestr asprintf vasprintf
+
+for ac_func in asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_func" >&5

Modified: team/pcadach/chan_h323-live/configure.ac
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/configure.ac?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/configure.ac (original)
+++ team/pcadach/chan_h323-live/configure.ac Sat Sep 16 15:20:07 2006
@@ -240,7 +240,7 @@
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol unsetenv utime strtoq strcasestr asprintf vasprintf])
+AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
 
 AC_MSG_CHECKING(for compiler atomic operations)
 AC_LINK_IFELSE(

Modified: team/pcadach/chan_h323-live/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/include/asterisk/autoconfig.h.in?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/include/asterisk/autoconfig.h.in (original)
+++ team/pcadach/chan_h323-live/include/asterisk/autoconfig.h.in Sat Sep 16 15:20:07 2006
@@ -113,6 +113,9 @@
 
 /* Define to 1 if you have the `gethostname' function. */
 #undef HAVE_GETHOSTNAME
+
+/* Define to 1 if you have the `getloadavg' function. */
+#undef HAVE_GETLOADAVG
 
 /* Define to 1 if you have the `getpagesize' function. */
 #undef HAVE_GETPAGESIZE

Modified: team/pcadach/chan_h323-live/include/asterisk/compat.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/include/asterisk/compat.h?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/include/asterisk/compat.h (original)
+++ team/pcadach/chan_h323-live/include/asterisk/compat.h Sat Sep 16 15:20:07 2006
@@ -18,17 +18,46 @@
 
 #include <inttypes.h>
 #include <sys/types.h>
+#include <stdarg.h>
 
-#ifndef HAVE_STRSEP
-char* strsep(char** str, const char* delims);
+#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+int asprintf(char **str, const char *fmt, ...);
+#endif
+
+#ifndef HAVE_GETLOADAVG
+int getloadavg(double *list, int nelem);
 #endif
 
 #ifndef HAVE_SETENV
 int setenv(const char *name, const char *value, int overwrite);
 #endif
 
+#ifndef HAVE_STRCASESTR
+char *strcasestr(const char *, const char *);
+#endif
+
+#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
+char *strndup(const char *, size_t);
+#endif
+
+#ifndef HAVE_STRNLEN
+size_t strnlen(const char *, size_t);
+#endif
+
+#ifndef HAVE_STRSEP
+char* strsep(char** str, const char* delims);
+#endif
+
+#ifndef HAVE_STRTOQ
+uint64_t strtoq(const char *nptr, char **endptr, int base);
+#endif
+
 #ifndef HAVE_UNSETENV
 int unsetenv(const char *name);
+#endif
+
+#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+int vasprintf(char **strp, const char *fmt, va_list ap);
 #endif
 
 #ifdef SOLARIS

Modified: team/pcadach/chan_h323-live/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/include/asterisk/strings.h?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/include/asterisk/strings.h (original)
+++ team/pcadach/chan_h323-live/include/asterisk/strings.h Sat Sep 16 15:20:07 2006
@@ -256,28 +256,4 @@
 		(ra)->ptr; \
 	})
 
-#ifndef HAVE_STRCASESTR
-char *strcasestr(const char *, const char *);
-#endif
-
-#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
-char *strndup(const char *, size_t);
-#endif
-
-#ifndef HAVE_STRNLEN
-size_t strnlen(const char *, size_t);
-#endif
-
-#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
-int vasprintf(char **strp, const char *fmt, va_list ap);
-#endif
-
-#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) 
-int asprintf(char **str, const char *fmt, ...);
-#endif
-
-#ifndef HAVE_STRTOQ
-uint64_t strtoq(const char *nptr, char **endptr, int base);
-#endif
-
 #endif /* _ASTERISK_STRINGS_H */

Modified: team/pcadach/chan_h323-live/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/include/asterisk/utils.h?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/include/asterisk/utils.h (original)
+++ team/pcadach/chan_h323-live/include/asterisk/utils.h Sat Sep 16 15:20:07 2006
@@ -264,10 +264,6 @@
 */
 char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
 
-#ifndef HAVE_GETLOADAVG
-int getloadavg(double *list, int nelem);
-#endif
-
 #ifdef linux
 #define ast_random random
 #else

Modified: team/pcadach/chan_h323-live/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/main/Makefile?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/main/Makefile (original)
+++ team/pcadach/chan_h323-live/main/Makefile Sat Sep 16 15:20:07 2006
@@ -25,7 +25,8 @@
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
-	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o
+	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
+	strcompat.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static
@@ -89,7 +90,6 @@
 
 ifeq ($(OSARCH),SunOS)
   AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/opt/ssl/lib -L/usr/local/ssl/lib
-  OBJS+=strcompat.o
   ASTLINK=
 endif
 

Modified: team/pcadach/chan_h323-live/main/strcompat.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/main/strcompat.c?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/main/strcompat.c (original)
+++ team/pcadach/chan_h323-live/main/strcompat.c Sat Sep 16 15:20:07 2006
@@ -22,7 +22,11 @@
 #include "asterisk.h"
 
 #include <sys/types.h>
+#include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <alloca.h>
+#include <string.h>
 
 #ifndef HAVE_STRSEP
 char *strsep(char **str, const char *delims)
@@ -75,3 +79,262 @@
 	return setenv(name, "", 0);
 }
 #endif
+
+#ifndef HAVE_STRCASESTR
+static char *upper(const char *orig, char *buf, int bufsize)
+{
+	int i = 0;
+
+	while (i < (bufsize - 1) && orig[i]) {
+		buf[i] = toupper(orig[i]);
+		i++;
+	}
+
+	buf[i] = '\0';
+
+	return buf;
+}
+
+char *strcasestr(const char *haystack, const char *needle)
+{
+	char *u1, *u2;
+	int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1;
+
+	u1 = alloca(u1len);
+	u2 = alloca(u2len);
+	if (u1 && u2) {
+		char *offset;
+		if (u2len > u1len) {
+			/* Needle bigger than haystack */
+			return NULL;
+		}
+		offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len));
+		if (offset) {
+			/* Return the offset into the original string */
+			return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1)));
+		} else {
+			return NULL;
+		}
+	} else {
+		return NULL;
+	}
+}
+#endif /* !HAVE_STRCASESTR */
+
+#ifndef HAVE_STRNLEN
+size_t strnlen(const char *s, size_t n)
+{
+	size_t len;
+
+	for (len = 0; len < n; len++)
+		if (s[len] == '\0')
+			break;
+
+	return len;
+}
+#endif /* !HAVE_STRNLEN */
+
+#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
+char *strndup(const char *s, size_t n)
+{
+	size_t len = strnlen(s, n);
+	char *new = malloc(len + 1);
+
+	if (!new)
+		return NULL;
+
+	new[len] = '\0';
+	return memcpy(new, s, len);
+}
+#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */
+
+#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+int vasprintf(char **strp, const char *fmt, va_list ap)
+{
+	int size;
+	va_list ap2;
+	char s;
+
+	*strp = NULL;
+	va_copy(ap2, ap);
+	size = vsnprintf(&s, 1, fmt, ap2);
+	va_end(ap2);
+	*strp = malloc(size + 1);
+	if (!*strp)
+		return -1;
+	vsnprintf(*strp, size + 1, fmt, ap);
+
+	return size;
+}
+#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+
+/*
+ * Based on Code from bsd-asprintf from OpenSSH
+ * Copyright (c) 2004 Darren Tucker.
+ *
+ * Based originally on asprintf.c from OpenBSD:
+ * Copyright (c) 1997 Todd C. Miller <Todd.Miller at courtesan.com>
+ *
+ * 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.
+ */
+#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) 
+int asprintf(char **str, const char *fmt, ...)
+{
+        va_list ap;
+        int ret;
+
+        *str = NULL;
+        va_start(ap, fmt);
+        ret = vasprintf(str, fmt, ap);
+        va_end(ap);
+
+        return ret;
+}
+#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+
+#ifndef HAVE_STRTOQ
+#ifndef LONG_MIN
+#define LONG_MIN        (-9223372036854775807L-1L)
+	                                 /* min value of a "long int" */
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX        9223372036854775807L
+	                                 /* max value of a "long int" */
+#endif
+
+/*! \brief
+ * Convert a string to a quad integer.
+ *
+ * \note 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;
+}
+#endif /* !HAVE_STRTOQ */
+
+#ifndef HAVE_GETLOADAVG
+#ifdef linux
+/*! \brief Alternative method of getting load avg on Linux only */
+int getloadavg(double *list, int nelem)
+{
+	FILE *LOADAVG;
+	double avg[3] = { 0.0, 0.0, 0.0 };
+	int i, res = -1;
+
+	if ((LOADAVG = fopen("/proc/loadavg", "r"))) {
+		fscanf(LOADAVG, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]);
+		res = 0;
+		fclose(LOADAVG);
+	}
+
+	for (i = 0; (i < nelem) && (i < 3); i++) {
+		list[i] = avg[i];
+	}
+
+	return res;
+}
+#else /* !linux */
+/*! \brief Return something that won't cancel the call, but still return -1, in case
+ * we correct the implementation to check return value */
+int getloadavg(double *list, int nelem)
+{
+	int i;
+
+	for (i = 0; i < nelem; i++) {
+		list[i] = 0.1;
+	}
+	return -1;
+}
+#endif /* linux */
+#endif /* !HAVE_GETLOADAVG */

Modified: team/pcadach/chan_h323-live/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/main/utils.c?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/main/utils.c (original)
+++ team/pcadach/chan_h323-live/main/utils.c Sat Sep 16 15:20:07 2006
@@ -750,266 +750,6 @@
 }
 #undef ONE_MILLION
 
-#ifndef HAVE_STRCASESTR
-static char *upper(const char *orig, char *buf, int bufsize)
-{
-	int i = 0;
-
-	while (i < (bufsize - 1) && orig[i]) {
-		buf[i] = toupper(orig[i]);
-		i++;
-	}
-
-	buf[i] = '\0';
-
-	return buf;
-}
-
-char *strcasestr(const char *haystack, const char *needle)
-{
-	char *u1, *u2;
-	int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1;
-
-	u1 = alloca(u1len);
-	u2 = alloca(u2len);
-	if (u1 && u2) {
-		char *offset;
-		if (u2len > u1len) {
-			/* Needle bigger than haystack */
-			return NULL;
-		}
-		offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len));
-		if (offset) {
-			/* Return the offset into the original string */
-			return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1)));
-		} else {
-			return NULL;
-		}
-	} else {
-		ast_log(LOG_ERROR, "Out of memory\n");
-		return NULL;
-	}
-}
-#endif /* !HAVE_STRCASESTR */
-
-#ifndef HAVE_STRNLEN
-size_t strnlen(const char *s, size_t n)
-{
-	size_t len;
-
-	for (len = 0; len < n; len++)
-		if (s[len] == '\0')
-			break;
-
-	return len;
-}
-#endif /* !HAVE_STRNLEN */
-
-#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
-char *strndup(const char *s, size_t n)
-{
-	size_t len = strnlen(s, n);
-	char *new = ast_malloc(len + 1);
-
-	if (!new)
-		return NULL;
-
-	new[len] = '\0';
-	return memcpy(new, s, len);
-}
-#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */
-
-#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
-int vasprintf(char **strp, const char *fmt, va_list ap)
-{
-	int size;
-	va_list ap2;
-	char s;
-
-	*strp = NULL;
-	va_copy(ap2, ap);
-	size = vsnprintf(&s, 1, fmt, ap2);
-	va_end(ap2);
-	*strp = ast_malloc(size + 1);
-	if (!*strp)
-		return -1;
-	vsnprintf(*strp, size + 1, fmt, ap);
-
-	return size;
-}
-#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
-
-/*
- * Based on Code from bsd-asprintf from OpenSSH
- * Copyright (c) 2004 Darren Tucker.
- *
- * Based originally on asprintf.c from OpenBSD:
- * Copyright (c) 1997 Todd C. Miller <Todd.Miller at courtesan.com>
- *
- * 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.
- */
-#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) 
-int asprintf(char **str, const char *fmt, ...)
-{
-        va_list ap;
-        int ret;
-
-        *str = NULL;
-        va_start(ap, fmt);
-        ret = vasprintf(str, fmt, ap);
-        va_end(ap);
-
-        return ret;
-}
-#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
-
-#ifndef HAVE_STRTOQ
-#ifndef LONG_MIN
-#define LONG_MIN        (-9223372036854775807L-1L)
-	                                 /* min value of a "long int" */
-#endif
-#ifndef LONG_MAX
-#define LONG_MAX        9223372036854775807L
-	                                 /* max value of a "long int" */
-#endif
-
-/*! \brief
- * Convert a string to a quad integer.
- *
- * \note 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;
-}
-#endif /* !HAVE_STRTOQ */
-
-#ifndef HAVE_GETLOADAVG
-#ifdef linux
-/*! \brief Alternative method of getting load avg on Linux only */
-int getloadavg(double *list, int nelem)
-{
-	FILE *LOADAVG;
-	double avg[3] = { 0.0, 0.0, 0.0 };
-	int i, res = -1;
-
-	if ((LOADAVG = fopen("/proc/loadavg", "r"))) {
-		fscanf(LOADAVG, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]);
-		res = 0;
-		fclose(LOADAVG);
-	}
-
-	for (i = 0; (i < nelem) && (i < 3); i++) {
-		list[i] = avg[i];
-	}
-
-	return res;
-}
-#else /* !linux */
-/*! \brief Return something that won't cancel the call, but still return -1, in case
- * we correct the implementation to check return value */
-int getloadavg(double *list, int nelem)
-{
-	int i;
-
-	for (i = 0; i < nelem; i++) {
-		list[i] = 0.1;
-	}
-	return -1;
-}
-#endif /* linux */
-#endif /* !defined(_BSD_SOURCE) */
-
 /*! \brief glibc puts a lock inside random(3), so that the results are thread-safe.
  * BSD libc (and others) do not. */
 #ifndef linux

Modified: team/pcadach/chan_h323-live/utils/Makefile
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/utils/Makefile?rev=43038&r1=43037&r2=43038&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/utils/Makefile (original)
+++ team/pcadach/chan_h323-live/utils/Makefile Sat Sep 16 15:20:07 2006
@@ -16,7 +16,7 @@
 UTILS:=astman smsq stereorize streamplayer aelparse muted
 
 ifeq (${OSARCH},SunOS)
-  LIBS+=../main/strcompat.o -lsocket -lnsl
+  LIBS+=-lsocket -lnsl
 endif
 
 ifeq ($(POPT_LIB),)
@@ -57,6 +57,8 @@
 $(eval $(call ast_make_final,stereorize,stereorize.o frame.o))
 stereorize: LIBS+=-lm
 
+$(eval $(call ast_make_o_c,strcompat.o,../main/strcompat.c))
+
 ../main/ast_expr2.c:
 	@echo "   [BISON] ../main/ast_expr2.y -> $@"
 	@bison -o $@ -d --name-prefix=ast_yy ../main/ast_expr2.y
@@ -81,7 +83,7 @@
 $(eval $(call ast_make_o_c,pbx_ael.o,../pbx/pbx_ael.c))
 pbx_ael.o: CFLAGS+=-DSTANDALONE_AEL
 
-$(eval $(call ast_make_final,aelparse,aelflex.o aelbison.o pbx_ael.o ael_main.o ast_expr2f.o ast_expr2.o))
+$(eval $(call ast_make_final,aelparse,aelflex.o aelbison.o pbx_ael.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o))
 
 $(eval $(call ast_make_o_c,ael_main.o,ael_main.c ../include/asterisk/ael_structs.h))
 
@@ -92,7 +94,7 @@
 	rm ast_expr2.o ast_expr2f.o 
 	./testexpr2s expr2.testinput
 
-smsq: smsq.o
+smsq: smsq.o strcompat.o
 smsq: LIBS+=$(POPT_LIB)
 
 streamplayer: streamplayer.o



More information about the asterisk-commits mailing list