[asterisk-commits] rizzo: branch rizzo/astobj2 r45804 - in /team/rizzo/astobj2: channels/ codecs...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Oct 20 15:00:33 MST 2006


Author: rizzo
Date: Fri Oct 20 17:00:33 2006
New Revision: 45804

URL: http://svn.digium.com/view/asterisk?rev=45804&view=rev
Log:
FreeBSD 4 compatibility fixes.
Part of it (chan_zap.c and codecs/codec_zap.c) is to adapt
to older versions of zaptel (which is all is supported there),
and the rest (mostly changes to compiler.h, plus a path
to ast_expr2f.c and removal of %z formats) is to adapt to gcc 2.95.
These changes are fully compatible with newer compilers as well.


Modified:
    team/rizzo/astobj2/channels/chan_iax2.c
    team/rizzo/astobj2/channels/chan_zap.c
    team/rizzo/astobj2/codecs/codec_zap.c
    team/rizzo/astobj2/include/asterisk/compiler.h
    team/rizzo/astobj2/main/ast_expr2f.c
    team/rizzo/astobj2/main/rtp.c

Modified: team/rizzo/astobj2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_iax2.c?rev=45804&r1=45803&r2=45804&view=diff
==============================================================================
--- team/rizzo/astobj2/channels/chan_iax2.c (original)
+++ team/rizzo/astobj2/channels/chan_iax2.c Fri Oct 20 17:00:33 2006
@@ -6243,7 +6243,7 @@
 	memcpy(&sin, &thread->iosin, sizeof(sin));
 
 	if (res < sizeof(*mh)) {
-		ast_log(LOG_WARNING, "midget packet received (%d of %zd min)\n", res, sizeof(*mh));
+		ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, (int)sizeof(*mh));
 		return 1;
 	}
 	if ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000)) {
@@ -6267,8 +6267,8 @@
 		switch(meta->metacmd) {
 		case IAX_META_TRUNK:
 			if (res < (sizeof(*meta) + sizeof(*mth))) {
-				ast_log(LOG_WARNING, "midget meta trunk packet received (%d of %zd min)\n", res,
-					sizeof(*meta) + sizeof(*mth));
+				ast_log(LOG_WARNING, "midget meta trunk packet received (%d of %d min)\n", res,
+					(int)(sizeof(*meta) + sizeof(*mth)));
 				return 1;
 			}
 			mth = (struct ast_iax2_meta_trunk_hdr *)(meta->data);
@@ -6519,7 +6519,7 @@
 		}
 		/* A full frame */
 		if (res < sizeof(*fh)) {
-			ast_log(LOG_WARNING, "midget packet received (%d of %zd min)\n", res, sizeof(*fh));
+			ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, (int)sizeof(*fh));
 			ast_mutex_unlock(&iaxsl[fr->callno]);
 			return 1;
 		}

Modified: team/rizzo/astobj2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_zap.c?rev=45804&r1=45803&r2=45804&view=diff
==============================================================================
--- team/rizzo/astobj2/channels/chan_zap.c (original)
+++ team/rizzo/astobj2/channels/chan_zap.c Fri Oct 20 17:00:33 2006
@@ -65,8 +65,41 @@
 #include <sys/ioctl.h>
 #include <math.h>
 #include <ctype.h>
+#if defined(HAVE_ZAPTEL_VERSION) && HAVE_ZAPTEL_VERSION < 100
+#include <zaptel.h>
+#include <tonezone.h>
+#ifndef	ZT_TONE_DTMF_BASE
+#define ZT_TONE_DTMF_BASE       64
+  	 
+  	 /*
+  	  * These must be in the same order as the dtmf_tones array in tones.h
+  	  */
+  	 enum {
+  	         ZT_TONE_DTMF_0 = ZT_TONE_DTMF_BASE,
+  	         ZT_TONE_DTMF_1,
+  	         ZT_TONE_DTMF_2,
+  	         ZT_TONE_DTMF_3,
+  	         ZT_TONE_DTMF_4,
+  	         ZT_TONE_DTMF_5,
+  	         ZT_TONE_DTMF_6,
+  	         ZT_TONE_DTMF_7,
+  	         ZT_TONE_DTMF_8,
+  	         ZT_TONE_DTMF_9,
+  	         ZT_TONE_DTMF_s,
+  	         ZT_TONE_DTMF_p,
+  	         ZT_TONE_DTMF_A,
+  	         ZT_TONE_DTMF_B,
+  	         ZT_TONE_DTMF_C,
+  	         ZT_TONE_DTMF_D
+  	 };
+  	 
+#define ZT_TONE_DTMF_MAX ZT_TONE_DTMF_D
+#endif
+
+#else
 #include <zaptel/zaptel.h>
 #include <zaptel/tonezone.h>
+#endif
 
 #ifdef HAVE_PRI
 #include <libpri.h>
@@ -1168,10 +1201,11 @@
 		int res;
 		ZT_DIAL_OPERATION zo = {
 			.op = ZT_DIAL_OP_APPEND,
-			.dialstr[0] = 'T',
-			.dialstr[1] = digit,
-			.dialstr[2] = 0,
 		};
+
+		zo.dialstr[0] = 'T';
+		zo.dialstr[1] = digit;
+		zo.dialstr[2] = 0;
 		if ((res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_DIAL, &zo)))
 			ast_log(LOG_WARNING, "Couldn't dial digit %c\n", digit);
 		else

Modified: team/rizzo/astobj2/codecs/codec_zap.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/codecs/codec_zap.c?rev=45804&r1=45803&r2=45804&view=diff
==============================================================================
--- team/rizzo/astobj2/codecs/codec_zap.c (original)
+++ team/rizzo/astobj2/codecs/codec_zap.c Fri Oct 20 17:00:33 2006
@@ -56,6 +56,12 @@
 #include "asterisk/linkedlists.h"
 
 #define BUFFER_SAMPLES	8000
+
+#if defined(HAVE_ZAPTEL_VERSION) && HAVE_ZAPTEL_VERSION < 100
+static int reload(void) { return 0; }
+static int unload_module(void) { return 0; }
+static int load_module(void) { return -1; }
+#else
 
 static unsigned int global_useplc = 0;
 
@@ -413,6 +419,7 @@
 
 	return 0;
 }
+#endif /* full module */
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generic Zaptel Transcoder Codec Translator",
 		.load = load_module,

Modified: team/rizzo/astobj2/include/asterisk/compiler.h
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/include/asterisk/compiler.h?rev=45804&r1=45803&r2=45804&view=diff
==============================================================================
--- team/rizzo/astobj2/include/asterisk/compiler.h (original)
+++ team/rizzo/astobj2/include/asterisk/compiler.h Fri Oct 20 17:00:33 2006
@@ -53,4 +53,14 @@
 #define attribute_malloc
 #endif
 
+/* help old compilers  */
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#define __builtin_expect(exp, c) (exp)
+#undef force_inline
+#define force_inline inline
+#undef attribute_malloc
+#define attribute_malloc
+#undef attribute_pure
+#define attribute_pure
+#endif
 #endif /* _ASTERISK_COMPILER_H */

Modified: team/rizzo/astobj2/main/ast_expr2f.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/main/ast_expr2f.c?rev=45804&r1=45803&r2=45804&view=diff
==============================================================================
--- team/rizzo/astobj2/main/ast_expr2f.c (original)
+++ team/rizzo/astobj2/main/ast_expr2f.c Fri Oct 20 17:00:33 2006
@@ -1391,7 +1391,8 @@
 	} u;
 } ;
 
-#include "ast_expr2.h" /* the o/p of the bison on ast_expr2.y */
+/* this is compiled from main/ and from utils/ so we need a good path */
+#include "../main/ast_expr2.h" /* the o/p of the bison on ast_expr2.y */
 
 #define SET_COLUMNS	do {		\
 	yylloc_param->first_column = (int)(yyg->yytext_r - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); \

Modified: team/rizzo/astobj2/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/main/rtp.c?rev=45804&r1=45803&r2=45804&view=diff
==============================================================================
--- team/rizzo/astobj2/main/rtp.c (original)
+++ team/rizzo/astobj2/main/rtp.c Fri Oct 20 17:00:33 2006
@@ -421,14 +421,14 @@
 	
 	if (len < sizeof(struct stun_header)) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Runt STUN packet (only %zd, wanting at least %zd)\n", len, sizeof(struct stun_header));
+			ast_log(LOG_DEBUG, "Runt STUN packet (only %d, wanting at least %d)\n", (int) len, sizeof(struct stun_header));
 		return -1;
 	}
 	if (stundebug)
 		ast_verbose("STUN Packet, msg %s (%04x), length: %d\n", stun_msg2str(ntohs(hdr->msgtype)), ntohs(hdr->msgtype), ntohs(hdr->msglen));
 	if (ntohs(hdr->msglen) > len - sizeof(struct stun_header)) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Scrambled STUN packet length (got %d, expecting %zd)\n", ntohs(hdr->msglen), len - sizeof(struct stun_header));
+			ast_log(LOG_DEBUG, "Scrambled STUN packet length (got %d, expecting %d)\n", ntohs(hdr->msglen), (int)(len - sizeof(struct stun_header)));
 	} else
 		len = ntohs(hdr->msglen);
 	data += sizeof(struct stun_header);
@@ -436,13 +436,13 @@
 	while(len) {
 		if (len < sizeof(struct stun_attr)) {
 			if (option_debug)
-				ast_log(LOG_DEBUG, "Runt Attribute (got %zd, expecting %zd)\n", len, sizeof(struct stun_attr));
+				ast_log(LOG_DEBUG, "Runt Attribute (got %d, expecting %d)\n", (int)len, sizeof(struct stun_attr));
 			break;
 		}
 		attr = (struct stun_attr *)data;
 		if (ntohs(attr->len) > len) {
 			if (option_debug)
-				ast_log(LOG_DEBUG, "Inconsistent Attribute (length %d exceeds remaining msg len %zd)\n", ntohs(attr->len), len);
+				ast_log(LOG_DEBUG, "Inconsistent Attribute (length %d exceeds remaining msg len %d)\n", ntohs(attr->len), (int)len);
 			break;
 		}
 		if (stun_process_attr(&st, attr)) {



More information about the asterisk-commits mailing list