[svn-commits] kpfleming: branch 1.4 r133226 - in /branches/1.4: apps/ channels/ include/ast...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 23 15:42:31 CDT 2008


Author: kpfleming
Date: Wed Jul 23 15:42:30 2008
New Revision: 133226

URL: http://svn.digium.com/view/asterisk?view=rev&rev=133226
Log:
make some more changes to the dahdi/zap channel name support stuff to ensure allthe globals are 'const', and clean up mmichelson's changes to app_chanspy to simplify the code

Modified:
    branches/1.4/apps/app_chanspy.c
    branches/1.4/apps/app_dahdibarge.c
    branches/1.4/apps/app_dahdiras.c
    branches/1.4/channels/chan_dahdi.c
    branches/1.4/include/asterisk/options.h
    branches/1.4/main/asterisk.c

Modified: branches/1.4/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_chanspy.c?view=diff&rev=133226&r1=133225&r2=133226
==============================================================================
--- branches/1.4/apps/app_chanspy.c (original)
+++ branches/1.4/apps/app_chanspy.c Wed Jul 23 15:42:30 2008
@@ -147,13 +147,6 @@
 });
 
 static int next_unique_id_to_use = 0;
-static int PSEUDO_CHAN_LEN;
-
-static void determine_pseudo_chan_len(void) 
-{
-	PSEUDO_CHAN_LEN = dahdi_chan_name_len + strlen("/pseudo");
-}
-
 
 struct chanspy_translation_helper {
 	/* spy data */
@@ -473,6 +466,11 @@
 {
 	struct ast_channel *this;
 	char channel_name[AST_CHANNEL_NAME];
+	static size_t PSEUDO_CHAN_LEN = 0;
+
+	if (!PSEUDO_CHAN_LEN) {
+		PSEUDO_CHAN_LEN = *dahdi_chan_name_len + strlen("/pseudo");
+	}
 
 redo:
 	if (spec)
@@ -865,7 +863,6 @@
 {
 	int res = 0;
 
-	determine_pseudo_chan_len();
 	res |= ast_register_application(app_chan, chanspy_exec, tdesc, desc_chan);
 	res |= ast_register_application(app_ext, extenspy_exec, tdesc, desc_ext);
 

Modified: branches/1.4/apps/app_dahdibarge.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_dahdibarge.c?view=diff&rev=133226&r1=133225&r2=133226
==============================================================================
--- branches/1.4/apps/app_dahdibarge.c (original)
+++ branches/1.4/apps/app_dahdibarge.c Wed Jul 23 15:42:30 2008
@@ -336,7 +336,7 @@
 {
 	int res = 0;
 
-	if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
+	if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
 		res |= ast_unregister_application(dahdi_app);
 	}
 
@@ -351,7 +351,7 @@
 {
 	int res = 0;
 
-	if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
+	if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
 		res |= ast_register_application(dahdi_app, exec_dahdi, dahdi_synopsis, dahdi_descrip);
 	}
 

Modified: branches/1.4/apps/app_dahdiras.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_dahdiras.c?view=diff&rev=133226&r1=133225&r2=133226
==============================================================================
--- branches/1.4/apps/app_dahdiras.c (original)
+++ branches/1.4/apps/app_dahdiras.c Wed Jul 23 15:42:30 2008
@@ -260,7 +260,7 @@
 {
 	int res = 0;
 
-	if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
+	if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
 		res |= ast_unregister_application(dahdi_app);
 	}
 
@@ -275,7 +275,7 @@
 {
 	int res = 0;
 
-	if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
+	if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
 		res |= ast_register_application(dahdi_app, exec, dahdi_synopsis, dahdi_descrip);
 	}
 

Modified: branches/1.4/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_dahdi.c?view=diff&rev=133226&r1=133225&r2=133226
==============================================================================
--- branches/1.4/channels/chan_dahdi.c (original)
+++ branches/1.4/channels/chan_dahdi.c Wed Jul 23 15:42:30 2008
@@ -5234,7 +5234,7 @@
 	int features;
 	char *b2 = NULL;
 	DAHDI_PARAMS ps;
-	char chanprefix[dahdi_chan_name_len + 4];
+	char chanprefix[*dahdi_chan_name_len + 4];
 
 	if (i->subs[index].owner) {
 		ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]);
@@ -10584,7 +10584,7 @@
 }
 
 #define local_astman_unregister(a) do { \
-					if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { \
+					if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { \
 						ast_manager_unregister("DAHDI" a); \
 					} \
 					ast_manager_unregister("Zap" a); \
@@ -11583,7 +11583,7 @@
 }
 
 #define local_astman_register(a, b, c, d) do { \
-						if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { \
+						if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { \
 							ast_manager_register("DAHDI" a, b, dahdi_ ## c, d); \
 						} \
 						ast_manager_register("Zap" a, b, zap_ ## c, d); \
@@ -11611,7 +11611,7 @@
 	if ((res = setup_dahdi(0))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
+	if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
 		chan_tech = &dahdi_tech;
 	} else {
 		chan_tech = &zap_tech;

Modified: branches/1.4/include/asterisk/options.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/options.h?view=diff&rev=133226&r1=133225&r2=133226
==============================================================================
--- branches/1.4/include/asterisk/options.h (original)
+++ branches/1.4/include/asterisk/options.h Wed Jul 23 15:42:30 2008
@@ -123,11 +123,11 @@
 extern char record_cache_dir[AST_CACHE_DIR_LEN];
 extern char debug_filename[AST_FILENAME_MAX];
 extern const char *dahdi_chan_name;
-extern int dahdi_chan_name_len;
-extern enum dahdi_chan_modes {
+extern const size_t *dahdi_chan_name_len;
+extern const enum dahdi_chan_modes {
 	CHAN_ZAP_MODE,
 	CHAN_DAHDI_PLUS_ZAP_MODE,
-} dahdi_chan_mode;
+} *dahdi_chan_mode;
 	
 extern int ast_language_is_prefix;
 

Modified: branches/1.4/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/asterisk.c?view=diff&rev=133226&r1=133225&r2=133226
==============================================================================
--- branches/1.4/main/asterisk.c (original)
+++ branches/1.4/main/asterisk.c Wed Jul 23 15:42:30 2008
@@ -173,16 +173,17 @@
 char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
 char debug_filename[AST_FILENAME_MAX] = "";
 #ifdef HAVE_ZAPTEL
-char _dahdi_chan_name[AST_CHANNEL_NAME] = "Zap";
-int _dahdi_chan_name_len = 3;
-enum dahdi_chan_modes dahdi_chan_mode = CHAN_ZAP_MODE;
+static char _dahdi_chan_name[AST_CHANNEL_NAME] = "Zap";
+static size_t _dahdi_chan_name_len = 3;
+static enum dahdi_chan_modes _dahdi_chan_mode = CHAN_ZAP_MODE;
 #else
-char _dahdi_chan_name[AST_CHANNEL_NAME] = "DAHDI";
-int _dahdi_chan_name_len = 5;
-enum dahdi_chan_modes dahdi_chan_mode = CHAN_DAHDI_PLUS_ZAP_MODE;
+static char _dahdi_chan_name[AST_CHANNEL_NAME] = "DAHDI";
+static size_t _dahdi_chan_name_len = 5;
+static enum dahdi_chan_modes _dahdi_chan_mode = CHAN_DAHDI_PLUS_ZAP_MODE;
 #endif
 const char *dahdi_chan_name;
-int dahdi_chan_name_len;
+const size_t *dahdi_chan_name_len;
+const enum dahdi_chan_modes *dahdi_chan_mode;
 
 static int ast_socket = -1;		/*!< UNIX Socket for allowing remote control */
 static int ast_consock = -1;		/*!< UNIX Socket for controlling another asterisk */
@@ -2597,13 +2598,13 @@
 			if (ast_true(v->value)) {
 				strcpy(_dahdi_chan_name, "DAHDI");
 				_dahdi_chan_name_len = 5;
-				dahdi_chan_mode = CHAN_DAHDI_PLUS_ZAP_MODE;
+				_dahdi_chan_mode = CHAN_DAHDI_PLUS_ZAP_MODE;
 			}
 #else
 			if (ast_false(v->value)) {
 				strcpy(_dahdi_chan_name, "Zap");
 				_dahdi_chan_name_len = 3;
-				dahdi_chan_mode = CHAN_ZAP_MODE;
+				_dahdi_chan_mode = CHAN_ZAP_MODE;
 			}
 #endif
 		}
@@ -2988,7 +2989,8 @@
 	}
 
 	dahdi_chan_name = _dahdi_chan_name;
-	dahdi_chan_name_len = _dahdi_chan_name_len;
+	dahdi_chan_name_len = &_dahdi_chan_name_len;
+	dahdi_chan_mode = &_dahdi_chan_mode;
 
 #ifdef HAVE_ZAPTEL
 	{




More information about the svn-commits mailing list