[svn-commits] oej: branch oej/codename-pineapple r47760 - in /team/oej/codename-pineapple: ...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Nov 16 13:24:40 MST 2006


Author: oej
Date: Thu Nov 16 14:24:39 2006
New Revision: 47760

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47760
Log:
Update. Dear old automerge, who killed you?

Modified:
    team/oej/codename-pineapple/   (props changed)
    team/oej/codename-pineapple/apps/app_meetme.c
    team/oej/codename-pineapple/channels/chan_local.c
    team/oej/codename-pineapple/channels/chan_sip.c
    team/oej/codename-pineapple/configs/sip.conf.sample
    team/oej/codename-pineapple/configure
    team/oej/codename-pineapple/configure.ac
    team/oej/codename-pineapple/main/cli.c

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Nov 16 14:24:39 2006
@@ -1,1 +1,1 @@
-/trunk:1-47719
+/trunk:1-47759

Modified: team/oej/codename-pineapple/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/apps/app_meetme.c?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/apps/app_meetme.c (original)
+++ team/oej/codename-pineapple/apps/app_meetme.c Thu Nov 16 14:24:39 2006
@@ -2953,6 +2953,10 @@
 
 	/* Find conference */
 	sla = sla2 = ASTOBJ_CONTAINER_FIND(&slas, data);
+
+	if (!sla2)
+		return AST_DEVICE_INVALID;
+
 	ASTOBJ_UNREF(sla2, sla_destroy);
 
 	if (option_debug)

Modified: team/oej/codename-pineapple/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_local.c?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/channels/chan_local.c (original)
+++ team/oej/codename-pineapple/channels/chan_local.c Thu Nov 16 14:24:39 2006
@@ -202,6 +202,9 @@
 	struct local_pvt *p = ast->tech_pvt;
 	int isoutbound;
 	int res = -1;
+
+	if (!p)
+		return -1;
 
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
@@ -276,6 +279,9 @@
 	int res = -1;
 	int isoutbound;
 
+	if (!p)
+		return -1;
+
 	/* Just queue for delivery to the other side */
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
@@ -320,6 +326,9 @@
 	int res = 0;
 	struct ast_frame f = { AST_FRAME_CONTROL, };
 	int isoutbound;
+
+	if (!p)
+		return -1;
 
 	/* If this is an MOH hold or unhold, do it on the Local channel versus real channel */
 	if (condition == AST_CONTROL_HOLD) {
@@ -347,6 +356,9 @@
 	struct ast_frame f = { AST_FRAME_DTMF_BEGIN, };
 	int isoutbound;
 
+	if (!p)
+		return -1;
+
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
 	f.subclass = digit;
@@ -363,6 +375,9 @@
 	struct ast_frame f = { AST_FRAME_DTMF_END, };
 	int isoutbound;
 
+	if (!p)
+		return -1;
+
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
 	f.subclass = digit;
@@ -378,6 +393,9 @@
 	int res = -1;
 	struct ast_frame f = { AST_FRAME_TEXT, };
 	int isoutbound;
+
+	if (!p)
+		return -1;
 
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
@@ -395,6 +413,9 @@
 	struct ast_frame f = { AST_FRAME_HTML, };
 	int isoutbound;
 
+	if (!p)
+		return -1;
+	
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
 	f.subclass = subclass;
@@ -413,6 +434,9 @@
 	int res;
 	struct ast_var_t *varptr = NULL, *new;
 	size_t len, namelen;
+
+	if (!p)
+		return -1;
 	
 	ast_mutex_lock(&p->lock);
 
@@ -453,6 +477,9 @@
 	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
 	struct ast_channel *ochan = NULL;
 	int glaredetect = 0;
+
+	if (!p)
+		return -1;
 
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);

Modified: team/oej/codename-pineapple/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip.c?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip.c Thu Nov 16 14:24:39 2006
@@ -238,6 +238,21 @@
 	AST_FAILURE = -1,
 };
 
+/*! \brief States for the INVITE transaction, not the dialog 
+	\note this is for the INVITE that sets up the dialog
+*/
+enum invitestates {
+	INV_NONE = 0,	/*!< No state at all, maybe not an INVITE dialog */
+	INV_CALLING,	/*!< Invite sent, no answer */
+	INV_PROCEEDING,	/*!< We got 1xx message */
+	INV_EARLY_MEDIA, /*!< We got 18x message with to-tag back */
+	INV_COMPLETED,	/*!< Got final response with error. Wait for ACK, then CONFIRMED */
+	INV_CONFIRMED,	/*!< Confirmed response - we've got an ack (Incoming calls only) */
+	INV_TERMINATED,	/*!< Transaction done - either successful (AST_STATE_UP) or failed, but done 
+				The only way out of this is a BYE from one side */
+	INV_CANCELLED	/*!< Transaction cancelled by client or server in non-terminated state */
+};
+
 /* Do _NOT_ make any changes to this enum, or the array following it;
    if you think you are doing the right thing, you are probably
    not doing the right thing. If you think there are changes
@@ -515,6 +530,7 @@
 static int global_limitonpeers;		/*!< Match call limit on peers only */
 static int global_rtautoclear;
 static int global_notifyringing;	/*!< Send notifications on ringing */
+static int global_notifyhold;		/*!< Send notifications on hold */
 static int global_alwaysauthreject;	/*!< Send 401 Unauthorized for all failing requests */
 static int global_srvlookup;			/*!< SRV Lookup on or off. Default is off, RFC behavior is on */
 static int pedanticsipchecking;		/*!< Extra checking ?  Default off */
@@ -699,7 +715,7 @@
 #define SIP_REALTIME		(1 << 11)	/*!< Flag for realtime users */
 #define SIP_USECLIENTCODE	(1 << 12)	/*!< Trust X-ClientCode info message */
 #define SIP_OUTGOING		(1 << 13)	/*!< Direction of the last transaction in this dialog */
-#define SIP_CAN_BYE		(1 << 14)	/*!< Can we send BYE on this dialog? */
+#define SIP_FREE_BIT		(1 << 14)	/*!< ---- */
 #define SIP_DEFER_BYE_ON_TRANSFER	(1 << 15)	/*!< Do not hangup at first ast_hangup */
 #define SIP_DTMF		(3 << 16)	/*!< DTMF Support: four settings, uses two bits */
 #define SIP_DTMF_RFC2833	(0 << 16)	/*!< DTMF Support: RTP DTMF - "rfc2833" */
@@ -870,6 +886,7 @@
 /*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe  */
 struct sip_pvt {
 	ast_mutex_t pvt_lock;			/*!< Dialog private lock */
+	enum invitestates invitestate;		/*!< Track state of SIP_INVITEs */
 	int method;				/*!< SIP method that opened this dialog */
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(callid);	/*!< Global CallID */
@@ -2915,6 +2932,7 @@
 		if (option_debug > 1)
 			ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
 		transmit_invite(p, SIP_INVITE, 1, 2);
+		p->invitestate = INV_CALLING;
 		
 		/* Initialize auto-congest time */
 		p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, p);
@@ -3417,12 +3435,13 @@
 				__sip_pretend_ack(p);
 
 				/* if we can't send right now, mark it pending */
-				if (!ast_test_flag(&p->flags[0], SIP_CAN_BYE)) {
+				if (p->invitestate == INV_CALLING) {
+					/* We can't send anything in CALLING state */
 					ast_set_flag(&p->flags[0], SIP_PENDINGBYE);
 					/* Do we need a timer here if we don't hear from them at all? */
 				} else {
 					/* Send a new request: CANCEL */
-					transmit_request_with_auth(p, SIP_CANCEL, p->ocseq, XMIT_RELIABLE, FALSE);
+					transmit_request(p, SIP_CANCEL, p->ocseq, XMIT_RELIABLE, FALSE);
 					/* Actually don't destroy us yet, wait for the 487 on our original 
 					   INVITE, but do set an autodestruct just in case we never get it. */
 					needdestroy = 0;
@@ -5256,7 +5275,8 @@
 					"Uniqueid: %s\r\n",
 					p->owner->name, 
 					p->owner->uniqueid);
-			sip_peer_hold(p, 0);
+			if (global_notifyhold)
+				sip_peer_hold(p, FALSE);
 		} 
 		ast_clear_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD);	/* Clear both flags */
 	} else if (!sin.sin_addr.s_addr || sendonly ) {
@@ -5274,7 +5294,8 @@
 			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR);
 		else if (sendonly == 2)	/* Inactive stream */
 			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_INACTIVE);
-		sip_peer_hold(p, 1);
+		if (global_notifyhold)
+			sip_peer_hold(p, TRUE);
 	}
 	
 	return 0;
@@ -7466,6 +7487,9 @@
 static int transmit_request(struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch)
 {
 	struct sip_request resp;
+
+	if (sipmethod == SIP_ACK)
+		p->invitestate = INV_CONFIRMED;
 
 	reqprep(&resp, p, sipmethod, seqno, newbranch);
 	add_header_contentLength(&resp, 0);
@@ -10411,6 +10435,7 @@
 	ast_cli(fd, "  Outbound reg. timeout:  %d secs\n", global_reg_timeout);
 	ast_cli(fd, "  Outbound reg. attempts: %d\n", global_regattempts_max);
 	ast_cli(fd, "  Notify ringing state:   %s\n", global_notifyringing ? "Yes" : "No");
+	ast_cli(fd, "  Notify hold state:      %s\n", global_notifyhold ? "Yes" : "No");
 	ast_cli(fd, "  SIP Transfer mode:      %s\n", transfermode2str(global_allowtransfer));
 	ast_cli(fd, "  Max Call Bitrate:       %d kbps\r\n", default_maxcallbitrate);
 	ast_cli(fd, "  Auto-Framing:           %s \r\n", global_autoframing ? "Yes" : "No");
@@ -11646,12 +11671,12 @@
 {
 	if (ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
 		/* if we can't BYE, then this is really a pending CANCEL */
-		if (!ast_test_flag(&p->flags[0], SIP_CAN_BYE))
-			transmit_request_with_auth(p, SIP_CANCEL, p->ocseq, 1, 0);
+		if (p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA)
+			transmit_request(p, SIP_CANCEL, p->ocseq, XMIT_RELIABLE, FALSE);
 			/* Actually don't destroy us yet, wait for the 487 on our original 
 			   INVITE, but do set an autodestruct just in case we never get it. */
 		else 
-			transmit_request_with_auth(p, SIP_BYE, 0, 1, 1);
+			transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, TRUE);
 		ast_clear_flag(&p->flags[0], SIP_PENDINGBYE);	
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 	} else if (ast_test_flag(&p->flags[0], SIP_NEEDREINVITE)) {
@@ -11697,6 +11722,15 @@
 	if (resp > 100 && resp < 200 && resp != 180 && resp != 183)
 		resp = 183;
 
+ 	/* Any response between 100 and 199 is PROCEEDING */
+ 	if (resp >= 100 && resp < 200 && p->invitestate == INV_CALLING)
+ 		p->invitestate = INV_PROCEEDING;
+ 
+ 	/* Final response, not 200 ? */
+ 	if (resp >= 300 && (p->invitestate == INV_CALLING || p->invitestate == INV_PROCEEDING || p->invitestate == INV_EARLY_MEDIA ))
+ 		p->invitestate = INV_COMPLETED;
+ 		
+
 	switch (resp) {
 	case 100:	/* Trying */
 		if (!ast_test_flag(req, SIP_PKT_IGNORE))
@@ -11714,13 +11748,13 @@
 			}
 		}
 		if (find_sdp(req)) {
+			p->invitestate = INV_EARLY_MEDIA;
 			res = process_sdp(p, req);
 			if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
 				/* Queue a progress frame only if we have SDP in 180 */
 				ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
 			}
 		}
-		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
 
@@ -11729,13 +11763,13 @@
 			sip_cancel_destroy(p);
 		/* Ignore 183 Session progress without SDP */
 		if (find_sdp(req)) {
+			p->invitestate = INV_EARLY_MEDIA;
 			res = process_sdp(p, req);
 			if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
 				/* Queue a progress frame */
 				ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
 			}
 		}
-		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
 
@@ -11833,8 +11867,8 @@
 				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
 		}
 		/* If I understand this right, the branch is different for a non-200 ACK only */
+		p->invitestate = INV_TERMINATED;
 		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, TRUE);
-		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
 
@@ -13441,6 +13475,7 @@
 			if (option_debug > 1)
 				ast_log(LOG_DEBUG, "%s: New call is still down.... Trying... \n", c->name);
 			transmit_response(p, "100 Trying", req);
+			p->invitestate = INV_PROCEEDING;
 			ast_setstate(c, AST_STATE_RING);
 			if (strcmp(p->exten, ast_pickup_ext())) {	/* Call to extension -start pbx on this call */
 				enum ast_pbx_result res;
@@ -13450,6 +13485,7 @@
 				switch(res) {
 				case AST_PBX_FAILED:
 					ast_log(LOG_WARNING, "Failed to start PBX :(\n");
+					p->invitestate = INV_COMPLETED;
 					if (ast_test_flag(req, SIP_PKT_IGNORE))
 						transmit_response(p, "503 Unavailable", req);
 					else
@@ -13457,6 +13493,7 @@
 					break;
 				case AST_PBX_CALL_LIMIT:
 					ast_log(LOG_WARNING, "Failed to start PBX (call limit reached) \n");
+					p->invitestate = INV_COMPLETED;
 					if (ast_test_flag(req, SIP_PKT_IGNORE))
 						transmit_response(p, "480 Temporarily Unavailable", req);
 					else
@@ -13493,6 +13530,7 @@
 					ast_setstate(c, AST_STATE_DOWN);
 					c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
 				}
+				p->invitestate = INV_COMPLETED;
 				ast_hangup(c);
 				sip_pvt_lock(p);
 				c = NULL;
@@ -13500,9 +13538,11 @@
 			break;
 		case AST_STATE_RING:
 			transmit_response(p, "100 Trying", req);
+			p->invitestate = INV_PROCEEDING;
 			break;
 		case AST_STATE_RINGING:
 			transmit_response(p, "180 Ringing", req);
+			p->invitestate = INV_PROCEEDING;
 			break;
 		case AST_STATE_UP:
 			if (option_debug > 1)
@@ -13588,6 +13628,7 @@
 					transmit_response_with_sdp(p, "200 OK", req, XMIT_CRITICAL);
 
 			}
+			p->invitestate = INV_TERMINATED;
 			break;
 		default:
 			ast_log(LOG_WARNING, "Don't know how to handle INVITE in state %d\n", c->_state);
@@ -13608,6 +13649,7 @@
 				transmit_response(p, msg, req);
 			else
 				transmit_response_reliable(p, msg, req);
+			p->invitestate = INV_COMPLETED;
 			sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		}
 	}
@@ -14063,6 +14105,7 @@
 		
 	check_via(p, req);
 	ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
+	p->invitestate = INV_CANCELLED;
 	
 	if (p->owner && p->owner->_state == AST_STATE_UP) {
 		/* This call is up, cancel is ignored, we need a bye */
@@ -14095,8 +14138,10 @@
 	struct ast_channel *bridged_to;
 	
 	/* If we have an INCOMING invite that we haven't answered, terminate that transaction */
-	if (p->pendinginvite && !ast_test_flag(&p->flags[0], SIP_OUTGOING) && !ast_test_flag(req, SIP_PKT_IGNORE) && !p->owner)
+	if (p->pendinginvite && !ast_test_flag(&p->flags[0], SIP_OUTGOING) && !ast_test_flag(req, SIP_PKT_IGNORE) && !p->owner) 
 		transmit_response_reliable(p, "487 Request Terminated", &p->initreq);
+
+	p->invitestate = INV_TERMINATED;
 
 	copy_request(&p->initreq, req);
 	if (sipdebug && option_debug)
@@ -14667,6 +14712,7 @@
 	case SIP_ACK:
 		/* Make sure we don't ignore this */
 		if (seqno == p->pendinginvite) {
+			p->invitestate = INV_CONFIRMED;
 			p->pendinginvite = 0;
 			__sip_ack(p, seqno, FLAG_RESPONSE, 0);
 			if (find_sdp(req)) {
@@ -16090,6 +16136,7 @@
 	expiry = DEFAULT_EXPIRY;
 	global_notifyringing = DEFAULT_NOTIFYRINGING;
 	global_limitonpeers = FALSE;		/*!< Match call limit on peers only */
+	global_notifyhold = FALSE;		/*!< Keep track of hold status for a peer */
 	global_alwaysauthreject = 0;
 	global_allowsubscribe = FALSE;
 	ast_copy_string(global_useragent, DEFAULT_USERAGENT, sizeof(global_useragent));
@@ -16216,6 +16263,8 @@
 			global_notifyringing = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "limitpeersonly")) {
 			global_limitonpeers = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "notifyhold")) {
+			global_notifyhold = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "alwaysauthreject")) {
 			global_alwaysauthreject = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "mohinterpret") 

Modified: team/oej/codename-pineapple/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/configs/sip.conf.sample?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/configs/sip.conf.sample (original)
+++ team/oej/codename-pineapple/configs/sip.conf.sample Thu Nov 16 14:24:39 2006
@@ -175,7 +175,10 @@
 ;subscribecontext = default	; Set a specific context for SUBSCRIBE requests
 				; Useful to limit subscriptions to local extensions
 				; Settable per peer/user also
-;notifyringing = yes		; Notify subscriptions on RINGING state
+;notifyringing = yes		; Notify subscriptions on RINGING state (default: no)
+;notifyhold = yes		; Notify subscriptions on HOLD state (default: no)
+				; Turning on notifyringing and notifyhold will add a lot
+				; more database transactions if you are using realtime.
 
 ;----------------------------------------- T.38 FAX PASSTHROUGH SUPPORT -----------------------
 ;
@@ -266,6 +269,12 @@
 				; route = Assume NAT, don't send rport 
 				; (work around more UNIDEN bugs)
 
+;----------------------------------- MEDIA HANDLING --------------------------------
+; By default, Asterisk tries to re-invite the audio to an optimal path. If there's
+; no reason for Asterisk to stay in the media path, the media will be redirected.
+; This does not really work with in the case where Asterisk is outside and have
+; clients on the inside of a NAT. In that case, you want to set canreinvite=nonat
+;
 ;canreinvite=yes		; Asterisk by default tries to redirect the
 				; RTP media stream (audio) to go directly from
 				; the caller to the callee.  Some devices do not

Modified: team/oej/codename-pineapple/configure
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/configure?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/configure (original)
+++ team/oej/codename-pineapple/configure Thu Nov 16 14:24:39 2006
@@ -32972,6 +32972,98 @@
 fi
 
 
+if test "${USE_ZAPTEL}" != "no"; then
+   if test "${PBX_ZAPTEL}" != "1"; then
+      { echo "$as_me:$LINENO: checking for ZT_DIAL_OP_CANCEL in zaptel.h" >&5
+echo $ECHO_N "checking for ZT_DIAL_OP_CANCEL in zaptel.h... $ECHO_C" >&6; }
+      saved_cppflags="${CPPFLAGS}"
+      if test "x${ZAPTEL_DIR}" != "x"; then
+	 CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
+      fi
+      cat >conftest.$ac_ext <<_ACEOF
+
+	/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <zaptel.h>
+int
+main ()
+{
+int foo = ZT_DIAL_OP_CANCEL;
+  ;
+  return 0;
+}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  	{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+		ac_cv_zaptel_h="yes"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+		{ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+		ac_cv_zaptel_h="no"
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+      CPPFLAGS="${saved_cppflags}"
+      if test "${ac_cv_zaptel_h}" = "yes"; then
+         { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+	 { echo "$as_me:$LINENO: *** The Zaptel installation on this system is too old" >&5
+echo "$as_me: *** The Zaptel installation on this system is too old" >&6;}
+	 { echo "$as_me:$LINENO: *** to be useable with this version of Asterisk." >&5
+echo "$as_me: *** to be useable with this version of Asterisk." >&6;}
+	 { echo "$as_me:$LINENO: *** Either upgrade your Zaptel installation" >&5
+echo "$as_me: *** Either upgrade your Zaptel installation" >&or run configure;}
+	 { echo "$as_me:$LINENO: *** including --without-zaptel." >&5
+echo "$as_me: *** including --without-zaptel." >&6;}
+	 exit 1
+      fi
+   fi
+fi
+
 EDITLINE_LIB=""
 if test "x$TERMCAP_LIB" != "x" ; then
   EDITLINE_LIB="$TERMCAP_LIB"

Modified: team/oej/codename-pineapple/configure.ac
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/configure.ac?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/configure.ac (original)
+++ team/oej/codename-pineapple/configure.ac Thu Nov 16 14:24:39 2006
@@ -851,6 +851,38 @@
 # or, try old zaptel (0.80 or so)
 AST_EXT_LIB_CHECK([ZAPTEL], [zaptel],, [zaptel.h],, [80])
 
+if test "${USE_ZAPTEL}" != "no"; then
+   if test "${PBX_ZAPTEL}" != "1"; then
+      AC_MSG_CHECKING(for ZT_DIAL_OP_CANCEL in zaptel.h)
+      saved_cppflags="${CPPFLAGS}"
+      if test "x${ZAPTEL_DIR}" != "x"; then
+	 CPPFLAGS="${CPPFLAGS} -I${ZAPTEL_DIR}/include"
+      fi
+      AC_COMPILE_IFELSE(
+	[
+	AC_LANG_PROGRAM(
+	[#include <zaptel.h>],
+	[int foo = ZT_DIAL_OP_CANCEL;])
+	],
+	[	AC_MSG_RESULT(yes) 
+		ac_cv_zaptel_h="yes" 
+	],
+	[	AC_MSG_RESULT(no) 
+		ac_cv_zaptel_h="no" 
+	]
+	)
+      CPPFLAGS="${saved_cppflags}"
+      if test "${ac_cv_zaptel_h}" = "yes"; then
+         AC_MSG_NOTICE(***)
+	 AC_MSG_NOTICE(*** The Zaptel installation on this system is too old)
+	 AC_MSG_NOTICE(*** to be useable with this version of Asterisk.)
+	 AC_MSG_NOTICE(*** Either upgrade your Zaptel installation, or run configure)
+	 AC_MSG_NOTICE(*** including --without-zaptel.)
+	 exit 1
+      fi
+   fi
+fi
+
 EDITLINE_LIB=""
 if test "x$TERMCAP_LIB" != "x" ; then
   EDITLINE_LIB="$TERMCAP_LIB"

Modified: team/oej/codename-pineapple/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/main/cli.c?view=diff&rev=47760&r1=47759&r2=47760
==============================================================================
--- team/oej/codename-pineapple/main/cli.c (original)
+++ team/oej/codename-pineapple/main/cli.c Thu Nov 16 14:24:39 2006
@@ -1441,7 +1441,10 @@
 	int quoted = 0;
 	int escaped = 0;
 	int whitespace = 1;
-
+	int dummy = 0;
+
+	if (trailingwhitespace == NULL)
+		trailingwhitespace = &dummy;
 	*trailingwhitespace = 0;
 	if (s == NULL)	/* invalid, though! */
 		return NULL;
@@ -1573,7 +1576,7 @@
 	int tws = 0;
 	char *dup = parse_args(text, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws);
 
-	if (!dup)	/* error */
+	if (!dup)	/* malloc error */
 		return NULL;
 	argindex = (!ast_strlen_zero(word) && x>0) ? x-1 : x;
 	/* rebuild the command, ignore tws */
@@ -1629,54 +1632,63 @@
 	char *args[AST_MAX_ARGS + 1];
 	struct ast_cli_entry *e;
 	int x;
-	char *dup;
-	int tws;
-	
-	if (!(dup = parse_args(s, &x, args + 1, AST_MAX_ARGS, &tws)))
+	int res;
+	char *dup = parse_args(s, &x, args + 1, AST_MAX_ARGS, NULL);
+
+	if (dup == NULL)
 		return -1;
 
-	/* We need at least one entry, or ignore */
-	if (x > 0) {
+	if (x < 1)	/* We need at least one entry, otherwise ignore */
+		goto done;
+
+	AST_LIST_LOCK(&helpers);
+	e = find_cli(args + 1, 0);
+	if (e)
+		ast_atomic_fetchadd_int(&e->inuse, 1);
+	AST_LIST_UNLOCK(&helpers);
+	if (e == NULL) {
+		ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(args + 1));
+		goto done;
+	}
+	/*
+	 * Within the handler, argv[-1] contains a pointer to the ast_cli_entry.
+	 * Remember that the array returned by parse_args is NULL-terminated.
+	 */
+	args[0] = (char *)e;
+
+	if (!e->new_handler)	/* old style */
+		res = e->handler(fd, x, args + 1);
+	else {
+		struct ast_cli_args a = {
+			.fd = fd, .argc = x, .argv = args+1 };
+		char *retval = e->new_handler(e, CLI_HANDLER, &a);
+
+		if (retval == CLI_SUCCESS)
+			res = RESULT_SUCCESS;
+		else if (retval == CLI_SHOWUSAGE)
+			res = RESULT_SHOWUSAGE;
+		else
+			res = RESULT_FAILURE;
+	}
+	switch (res) {
+	case RESULT_SHOWUSAGE:
+		ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n"));
+		break;
+
+	case RESULT_FAILURE:
+		ast_cli(fd, "Command '%s' failed.\n", s);
+		/* FALLTHROUGH */
+	default:
 		AST_LIST_LOCK(&helpers);
-		e = find_cli(args + 1, 0);
-		if (e)
-			e->inuse++;
+		if (e->deprecated == 1) {
+			ast_cli(fd, "The '%s' command is deprecated and will be removed in a future release. Please use '%s' instead.\n", e->_full_cmd, e->_deprecated_by);
+			e->deprecated = 2;
+		}
 		AST_LIST_UNLOCK(&helpers);
-		if (e) {
-			int res;
-			/* within calling the handler, argv[-1] contains a pointer
-			 * to the cli entry, and the array is null-terminated
-			 */
-			args[0] = (char *)e;
-			if (e->new_handler) {	/* new style */
-				struct ast_cli_args a = {
-					.fd = fd, .argc = x, .argv = args+1 };
-				res = (int)e->new_handler(e, CLI_HANDLER, &a);
-			} else {		/* old style */
-				res = e->handler(fd, x, args + 1);
-			}
-			switch (res) {
-			case RESULT_SHOWUSAGE:
-				if (e->usage)
-					ast_cli(fd, "%s", e->usage);
-				else
-					ast_cli(fd, "Invalid usage, but no usage information available.\n");
-				break;
-			default:
-				AST_LIST_LOCK(&helpers);
-				if (e->deprecated == 1) {
-					ast_cli(fd, "The '%s' command is deprecated and will be removed in a future release. Please use '%s' instead.\n", e->_full_cmd, e->_deprecated_by);
-					e->deprecated = 2;
-				}
-				AST_LIST_UNLOCK(&helpers);
-				break;
-			}
-		} else 
-			ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(args + 1));
-		if (e)
-			ast_atomic_fetchadd_int(&e->inuse, -1);
-	}
+		break;
+	}
+	ast_atomic_fetchadd_int(&e->inuse, -1);
+done:
 	free(dup);
-	
 	return 0;
 }



More information about the svn-commits mailing list