[asterisk-commits] branch oej/filenamelen r11011 - in /team/oej/filenamelen: ./ apps/ include/as...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Feb 24 04:17:20 MST 2006


Author: oej
Date: Fri Feb 24 05:17:11 2006
New Revision: 11011

URL: http://svn.digium.com/view/asterisk?rev=11011&view=rev
Log:
Hello? Is this a branch or the trunk or what? Guess we're trying again...
Todo: Make sure you always have branches, not copies of trunk in the same
      directory... :-)

Modified:
    team/oej/filenamelen/   (props changed)
    team/oej/filenamelen/apps/app_voicemail.c
    team/oej/filenamelen/config.c
    team/oej/filenamelen/include/asterisk/config.h
    team/oej/filenamelen/include/asterisk/utils.h
    team/oej/filenamelen/pbx/pbx_config.c
    team/oej/filenamelen/pbx/pbx_spool.c
    team/oej/filenamelen/res/res_musiconhold.c

Propchange: team/oej/filenamelen/
------------------------------------------------------------------------------
    svnmerge-integrated = /trunk:1-10989

Modified: team/oej/filenamelen/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/apps/app_voicemail.c?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/apps/app_voicemail.c (original)
+++ team/oej/filenamelen/apps/app_voicemail.c Fri Feb 24 05:17:11 2006
@@ -103,7 +103,8 @@
 #define eol "\r\n"
 
 #define MAX_DATETIME_FORMAT	512
-#define MAX_NUM_CID_CONTEXTS 10
+#define MAX_NUM_CID_CONTEXTS	10
+#define MSGNUM_LENGTH		80
 
 #define VM_REVIEW		(1 << 0)
 #define VM_OPERATOR		(1 << 1)
@@ -251,12 +252,12 @@
 };
 
 struct vm_state {
-	char curbox[80];
-	char username[80];
-	char curdir[256];
-	char vmbox[256];
-	char fn[256];
-	char fn2[256];
+	char curbox[80];		/*!< Current mailbox */
+	char username[80];		/*!< User name */
+	char curdir[AST_MAX_FILENAME_LEN];		/*!< Current directory */
+	char vmbox[256];		/*!< Voicemail box */
+	char fn[AST_MAX_FILENAME_LEN];
+	char fn2[AST_MAX_FILENAME_LEN];
 	int *deleted;
 	int *heard;
 	int curmsg;
@@ -299,7 +300,7 @@
 
 static char VM_SPOOL_DIR[AST_CONFIG_MAX_PATH];
 
-static char ext_pass_cmd[128];
+static char ext_pass_cmd[AST_MAX_SHELL_COMMAND];
 
 static char *tdesc = "Comedian Mail (Voicemail System)";
 
@@ -393,8 +394,8 @@
 static int maxmsg;
 static int silencethreshold = 128;
 static char serveremail[80];
-static char mailcmd[160];	/* Configurable mail cmd */
-static char externnotify[160]; 
+static char mailcmd[AST_MAX_SHELL_COMMAND];	/* Configurable mail cmd */
+static char externnotify[AST_MAX_SHELL_COMMAND]; 
 #ifdef WITH_SMDI
 static struct ast_smdi_interface *smdi_iface = NULL;
 #endif
@@ -763,8 +764,8 @@
 
 static void vm_change_password_shell(struct ast_vm_user *vmu, char *newpassword)
 {
-	char buf[255];
-	snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword);
+	char buf[AST_MAX_SHELL_COMMAND];
+	snprintf(buf, sizeof(buf), "%s %s %s %s", ext_pass_cmd, vmu->context, vmu->mailbox, newpassword);
 	if (!ast_safe_system(buf))
 		ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
 }
@@ -849,9 +850,9 @@
 	SQLULEN colsize;
 	FILE *f=NULL;
 	char rowdata[80];
-	char fn[256];
-	char full_fn[256];
-	char msgnums[80];
+	char fn[AST_MAX_FILENAME_LEN];
+	char full_fn[AST_MAX_FILENAME_LEN];
+	char msgnums[MSGNUM_LENGTH];
 	
 	odbc_obj *obj;
 	obj = fetch_odbc_obj(odbc_database, 0);
@@ -973,9 +974,9 @@
 
 static int remove_file(char *dir, int msgnum)
 {
-	char fn[256];
-	char full_fn[256];
-	char msgnums[80];
+	char fn[AST_MAX_FILENAME_LEN];
+	char full_fn[AST_MAX_FILENAME_LEN];
+	char msgnums[MSGNUM_LENGTH];
 	
 	if (msgnum > -1) {
 		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
@@ -1046,7 +1047,7 @@
 	SQLHSTMT stmt;
 	char sql[256];
 	char rowdata[20];
-	char msgnums[20];
+	char msgnums[MSGNUM_LENGTH];
 	
 	odbc_obj *obj;
 	obj = fetch_odbc_obj(odbc_database, 0);
@@ -1103,7 +1104,7 @@
 	int res;
 	SQLHSTMT stmt;
 	char sql[256];
-	char msgnums[20];
+	char msgnums[MSGNUM_LENGTH];
 	
 	odbc_obj *obj;
 	obj = fetch_odbc_obj(odbc_database, 0);
@@ -1141,8 +1142,8 @@
 	int res;
 	SQLHSTMT stmt;
 	char sql[512];
-	char msgnums[20];
-	char msgnumd[20];
+	char msgnums[MSGNUM_LENGTH];
+	char msgnumd[MSGNUM_LENGTH];
 	odbc_obj *obj;
 
 	delete_file(ddir, dmsg);
@@ -1200,9 +1201,9 @@
 	SQLHSTMT stmt;
 	SQLINTEGER len;
 	char sql[256];
-	char msgnums[20];
-	char fn[256];
-	char full_fn[256];
+	char msgnums[MSGNUM_LENGTH];
+	char fn[AST_MAX_FILENAME_LEN];
+	char full_fn[AST_MAX_FILENAME_LEN];
 	char fmt[80]="";
 	char *c;
 	char *context="", *macrocontext="", *callerid="", *origtime="", *duration="";
@@ -1319,8 +1320,8 @@
 	int res;
 	SQLHSTMT stmt;
 	char sql[256];
-	char msgnums[20];
-	char msgnumd[20];
+	char msgnums[MSGNUM_LENGTH];
+	char msgnumd[MSGNUM_LENGTH];
 	odbc_obj *obj;
 
 	delete_file(ddir, dmsg);
@@ -1395,9 +1396,9 @@
 
 static void rename_file(char *sfn, char *dfn)
 {
-	char stxt[256];
-	char dtxt[256];
-	ast_filerename(sfn,dfn,NULL);
+	char stxt[AST_MAX_FILENAME_LEN];
+	char dtxt[AST_MAX_FILENAME_LEN];
+	ast_filerename(sfn, dfn, NULL);
 	snprintf(stxt, sizeof(stxt), "%s.txt", sfn);
 	snprintf(dtxt, sizeof(dtxt), "%s.txt", dfn);
 	rename(stxt, dtxt);
@@ -1455,7 +1456,8 @@
 
 static void copy_file(char *frompath, char *topath)
 {
-	char frompath2[256],topath2[256];
+	char frompath2[AST_MAX_FILENAME_LEN], topath2[AST_MAX_FILENAME_LEN];
+
 	ast_filecopy(frompath, topath, NULL);
 	snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath);
 	snprintf(topath2, sizeof(topath2), "%s.txt", topath);
@@ -1468,7 +1470,7 @@
 static int last_message_index(struct ast_vm_user *vmu, char *dir)
 {
 	int x;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 
 	if (vm_lock_path(dir))
 		return ERROR_LOCK_PATH;
@@ -1682,10 +1684,10 @@
 	char host[MAXHOSTNAMELEN] = "";
 	char who[256];
 	char bound[256];
-	char fname[256];
+	char fname[AST_MAX_FILENAME_LEN];
 	char dur[256];
-	char tmp[80] = "/tmp/astmail-XXXXXX";
-	char tmp2[256];
+	char tmp[AST_MAX_FILENAME_LEN] = "/tmp/astmail-XXXXXX";
+	char mailcommand[AST_MAX_SHELL_COMMAND];
 	struct tm tm;
 
 	if (vmu && ast_strlen_zero(vmu->email)) {
@@ -1694,7 +1696,8 @@
 	}
 	if (!strcmp(format, "wav49"))
 		format = "WAV";
-	ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
 	/* Make a temporary file instead of piping directly to sendmail, in case the mail
 	   command hangs */
 	p = vm_mkftemp(tmp);
@@ -1801,9 +1804,10 @@
 			fprintf(p, "\n\n--%s--\n.\n", bound);
 		}
 		fclose(p);
-		snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
-		ast_safe_system(tmp2);
-		ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
+		snprintf(mailcommand, sizeof(mailcommand), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
+		ast_safe_system(mailcommand);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
 	}
 	return 0;
 }
@@ -1814,8 +1818,8 @@
 	char host[MAXHOSTNAMELEN]="";
 	char who[256];
 	char dur[256];
-	char tmp[80] = "/tmp/astmail-XXXXXX";
-	char tmp2[256];
+	char tmp[AST_MAX_FILENAME_LEN] = "/tmp/astmail-XXXXXX";
+	char mailcommand[AST_MAX_SHELL_COMMAND];
 	struct tm tm;
 	FILE *p = vm_mkftemp(tmp);
 
@@ -1850,7 +1854,7 @@
 		} else
 			fprintf(p, "From: Asterisk PBX <%s>\n", who);
 		fprintf(p, "To: %s\n", pager);
-               if (pagersubject) {
+		if (pagersubject) {
                        struct ast_channel *ast;
                        if ((ast = ast_channel_alloc(0))) {
                                char *passdata;
@@ -1884,9 +1888,10 @@
                                        "from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
                }
 		fclose(p);
-		snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
-		ast_safe_system(tmp2);
-		ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
+		snprintf(mailcommand, sizeof(mailcommand), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
+		ast_safe_system(mailcommand);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
 	}
 	return 0;
 }
@@ -1903,7 +1908,8 @@
 static int invent_message(struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
 {
 	int res;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
+
 	snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);
 	RETRIEVE(fn, -1);
 	if (ast_fileexists(fn, NULL, NULL) > 0) {
@@ -2158,11 +2164,12 @@
 {
 	DIR *dir;
 	struct dirent *de;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 	char tmp[256]="";
 	char *mb, *cur;
 	char *context;
 	int ret;
+
 	if (!folder)
 		folder = "INBOX";
 	/* If no mailbox, return immediately */
@@ -2206,11 +2213,12 @@
 {
 	DIR *dir;
 	struct dirent *de;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 	char tmp[256]="";
 	char *mb, *cur;
 	char *context;
 	int ret;
+
 	if (newmsgs)
 		*newmsgs = 0;
 	if (oldmsgs)
@@ -2279,7 +2287,7 @@
 
 static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt)
 {
-	char fromdir[256], todir[256], frompath[256], topath[256];
+	char fromdir[AST_MAX_FILENAME_LEN], todir[AST_MAX_FILENAME_LEN], frompath[AST_MAX_FILENAME_LEN], topath[AST_MAX_FILENAME_LEN];
 	char *frombox = mbox(imbox);
 	int recipmsgnum;
 
@@ -2313,8 +2321,8 @@
 
 static void run_externnotify(char *context, char *extension)
 {
-	char arguments[255];
-	char ext_context[256] = "";
+	char arguments[AST_MAX_SHELL_COMMAND];
+	char ext_context[AST_MAX_EXTENSION] = "";
 	int newvoicemails = 0, oldvoicemails = 0;
 #ifdef WITH_SMDI
 	struct ast_smdi_mwi_message *mwi_msg;
@@ -2351,7 +2359,8 @@
 			ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension);
 		} else {
 			snprintf(arguments, sizeof(arguments), "%s %s %s %d&", externnotify, context, extension, newvoicemails);
-			ast_log(LOG_DEBUG, "Executing %s\n", arguments);
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Executing external notification: %s\n", arguments);
 	  		ast_safe_system(arguments);
 		}
 	}
@@ -2364,7 +2373,7 @@
 
 static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_options *options)
 {
-	char txtfile[256];
+	char txtfile[AST_MAX_FILENAME_LEN];
 	char callerid[256];
 	FILE *txt;
 	int res = 0;
@@ -2374,14 +2383,14 @@
 	int ousemacro = 0;
 	char date[256];
 	char dir[256];
-	char fn[256];
-	char prefile[256]="";
-	char tempfile[256]="";
-	char ext_context[256] = "";
+	char fn[AST_MAX_FILENAME_LEN];
+	char prefile[AST_MAX_FILENAME_LEN]="";
+	char tempfile[AST_MAX_FILENAME_LEN]="";
+	char ext_context[AST_MAX_EXTENSION] = "";
 	char fmt[80];
 	char *context;
 	char ecodes[16] = "#";
-	char tmp[256] = "", *tmpptr;
+	char tmp[AST_MAX_EXTENSION] = "", *tmpptr;
 	struct ast_vm_user *vmu;
 	struct ast_vm_user svm;
 	const char *category = NULL;
@@ -2457,12 +2466,14 @@
 			if (ast_streamfile(chan, prefile, chan->language) > -1) 
 				res = ast_waitstream(chan, ecodes);
 		} else {
-			ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+			if (option_debug)
+				ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
 			res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
 		}
 		DISPOSE(prefile, -1);
 		if (res < 0) {
-			ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
 			free_user(vmu);
 			pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
 			return -1;
@@ -2654,8 +2665,8 @@
 	/* we know max messages, so stop process when number is hit */
 
 	int x,dest;
-	char sfn[256];
-	char dfn[256];
+	char sfn[AST_MAX_FILENAME_LEN];
+	char dfn[AST_MAX_FILENAME_LEN];
 
 	if (vm_lock_path(dir))
 		return ERROR_LOCK_PATH;
@@ -2687,11 +2698,12 @@
 
 static int save_to_folder(struct ast_vm_user *vmu, char *dir, int msg, char *context, char *username, int box)
 {
-	char sfn[256];
-	char dfn[256];
-	char ddir[256];
+	char sfn[AST_MAX_FILENAME_LEN];
+	char dfn[AST_MAX_FILENAME_LEN];
+	char ddir[AST_MAX_FILENAME_LEN];
 	char *dbox = mbox(box);
 	int x;
+
  	make_file(sfn, sizeof(sfn), dir, msg);
 	create_dirpath(ddir, sizeof(ddir), context, username, dbox);
 
@@ -2830,7 +2842,8 @@
 	bytes += adsi_voice_mode(buf + bytes, 0);
  	adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
 
-	ast_log(LOG_DEBUG, "Done downloading scripts...\n");
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Done downloading scripts...\n");
 
 #ifdef DISPLAY
 	/* Add last dot */
@@ -2838,7 +2851,8 @@
 	bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "   ......", "");
 	bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
 #endif
-	ast_log(LOG_DEBUG, "Restarting session...\n");
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Restarting session...\n");
 
 	bytes = 0;
 	/* Load the session now */
@@ -2855,6 +2869,7 @@
 static void adsi_begin(struct ast_channel *chan, int *useadsi)
 {
 	int x;
+
 	if (!adsi_available(chan))
 		return;
 	x = adsi_load_session(chan, adsifdn, adsiver, 1);
@@ -3203,15 +3218,16 @@
 	adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
 }
 
-/*--- get_folder: Folder menu ---*/
-/* Plays "press 1 for INBOX messages" etc
-   Should possibly be internationalized
+/*! get_folder: voicemail Folder menu 
+ * Plays "press 1 for INBOX messages" etc
+ * Should possibly be internationalized
  */
 static int get_folder(struct ast_channel *chan, int start)
 {
 	int x;
 	int d;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
+
 	d = ast_play_and_wait(chan, "vm-press");	/* "Press" */
 	if (d)
 		return d;
@@ -3298,7 +3314,8 @@
 
 static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname)
 {
-	char todir[256], fn[256], ext_context[256], *stringp;
+	char todir[AST_MAX_FILENAME_LEN], fn[AST_MAX_FILENAME_LEN];
+	char ext_context[AST_MAX_EXTENSION], *stringp;
 	int newmsgs = 0, oldmsgs = 0;
 	const char *category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY");
 
@@ -3345,15 +3362,15 @@
 			   char *fmt, int flag, signed char record_gain)
 {
 	char username[70]="";
-	char sys[256];
-	char todir[256];
+	char sys[AST_MAX_SHELL_COMMAND];
+	char todir[AST_MAX_FILENAME_LEN];
 	int todircount=0;
 	int duration;
 	struct ast_config *mif;
-	char miffile[256];
-	char fn[256];
+	char miffile[AST_MAX_FILENAME_LEN];
+	char fn[AST_MAX_FILENAME_LEN];
 	char callerid[512];
-	char ext_context[256]="";
+	char ext_context[AST_MAX_EXTENSION]="";
 	int res = 0, cmd = 0;
 	struct ast_vm_user *receiver = NULL, *vmtmp;
 	AST_LIST_HEAD_NOLOCK_STATIC(extensions, ast_vm_user);
@@ -3489,7 +3506,8 @@
 				snprintf(todir, sizeof(todir), "%s%s/%s/INBOX",  VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox);
 				snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir);
 				snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context);
-				ast_log(LOG_DEBUG, "%s", sys);
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Running cmd: %s", sys);
 				ast_safe_system(sys);
 		
 				res = count_messages(receiver, todir);
@@ -3509,11 +3527,13 @@
 					if (!strcasecmp(s, "wav49"))
 						s = "WAV";
 					snprintf(sys, sizeof(sys), "cp %s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s);
-					ast_log(LOG_DEBUG, "%s", sys);
+					if (option_debug)
+						ast_log(LOG_DEBUG, "Running cmd: %s", sys);
 					ast_safe_system(sys);
 				}
 				snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt %s/msg%04d.txt\n", dir, curmsg, todir, todircount);
-				ast_log(LOG_DEBUG, "%s", sys);
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Running cmd: %s", sys);
 				ast_safe_system(sys);
 				snprintf(fn, sizeof(fn), "%s/msg%04d", todir,todircount);
 
@@ -3670,7 +3690,7 @@
 	int res = 0;
 	int i;
 	char *callerid, *name;
-	char prefile[256]="";
+	char prefile[AST_MAX_FILENAME_LEN]="";
 	
 
 	/* If voicemail cid is not enabled, or we didn't get cid or context from the attribute file, leave now. */
@@ -3679,13 +3699,15 @@
 		return res;
 
 	/* Strip off caller ID number from name */
-	ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
+	if (option_debug > 1)
+		ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
 	ast_callerid_parse(cid, &name, &callerid);
 	if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) {
 		/* Check for internal contexts and only */
 		/* say extension when the call didn't come from an internal context in the list */
 		for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){
-			ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
 			if ((strcmp(cidinternalcontexts[i], context) == 0))
 				break;
 		}
@@ -3712,7 +3734,8 @@
 		}
 
 		else if (!res){
-			ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n", callerid);
 			/* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
 			if (!callback)
 				res = wait_file2(chan, vms, "vm-from-phonenumber");
@@ -3720,7 +3743,8 @@
 		}
 	} else {
 		/* Number unknown */
-		ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
+		if (option_debug > 1)
+			ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
 		/* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */
 		res = wait_file2(chan, vms, "vm-unknown-caller");
 	}
@@ -3740,7 +3764,8 @@
 	durations=atoi(duration);
 	durationm=(durations / 60);
 
-	ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
+	if (option_debug > 1)
+		ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
 
 	if((!res)&&(durationm>=minduration)) {
 		res = ast_say_number(chan, durationm, AST_DIGIT_ANY, chan->language, (char *) NULL);
@@ -3752,7 +3777,7 @@
 static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
 {
 	int res = 0;
-	char filename[256],*origtime, *cid, *context, *duration;
+	char filename[AST_MAX_FILENAME_LEN], *origtime, *cid, *context, *duration;
 	char *category;
 	struct ast_config *msg_cfg;
 
@@ -4581,11 +4606,12 @@
 	int tries = 0;
 	char newpassword[80] = "";
 	char newpassword2[80] = "";
-	char prefile[256]="";
-	unsigned char buf[256];
+	char prefile[AST_MAX_FILENAME_LEN]="";
 	int bytes=0;
 
 	if (adsi_available(chan)) {
+		unsigned char buf[256];
+
 		bytes += adsi_logo(buf + bytes);
 		bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "New User Setup", "");
 		bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", "");
@@ -4659,12 +4685,12 @@
 	int duration = 0;
 	char newpassword[80] = "";
 	char newpassword2[80] = "";
-	char prefile[256]="";
-	unsigned char buf[256];
+	char prefile[AST_MAX_FILENAME_LEN]="";
 	int bytes=0;
 
-	if (adsi_available(chan))
-	{
+	if (adsi_available(chan)) {
+		unsigned char buf[256];
+
 		bytes += adsi_logo(buf + bytes);
 		bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Options Menu", "");
 		bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", "");
@@ -4728,7 +4754,8 @@
 				vm_change_password(vmu,newpassword);
 			else 
 				vm_change_password_shell(vmu,newpassword);
-			ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "User %s set password to %s of length %d\n", vms->username, newpassword, (int)strlen(newpassword));
 			cmd = ast_play_and_wait(chan,"vm-passchanged");
 			break;
 		case '*': 
@@ -4754,7 +4781,7 @@
 	int cmd = 0;
 	int retries = 0;
 	int duration = 0;
-	char prefile[256]="";
+	char prefile[AST_MAX_FILENAME_LEN]="";
 	unsigned char buf[256];
 	int bytes=0;
 
@@ -5039,7 +5066,7 @@
 	int valid = 0;
 	struct localuser *u;
 	char prefixstr[80] ="";
-	char ext_context[256]="";
+	char ext_context[AST_MAX_EXTENSION]="";
 	int box;
 	int useadsi = 0;
 	int skipuser = 0;
@@ -5735,8 +5762,10 @@
 	struct ast_vm_user *vmu;
 	char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
 
-	if ((argc < 3) || (argc > 5) || (argc == 4)) return RESULT_SHOWUSAGE;
-	else if ((argc == 5) && strcmp(argv[3],"for")) return RESULT_SHOWUSAGE;
+	if ((argc < 3) || (argc > 5) || (argc == 4))
+		return RESULT_SHOWUSAGE;
+	else if ((argc == 5) && strcmp(argv[3],"for"))
+		return RESULT_SHOWUSAGE;
 
 	AST_LIST_LOCK(&users);
 	if (!AST_LIST_EMPTY(&users)) {
@@ -5757,7 +5786,7 @@
 			}
 		}
 		AST_LIST_TRAVERSE(&users, vmu, list) {
-			char dirname[256];
+			char dirname[AST_MAX_FILENAME_LEN];
 			DIR *vmdir;
 			struct dirent *vment;
 			int vmcount = 0;
@@ -5790,7 +5819,8 @@
 	struct vm_zone *zone = zones;
 	char *output_format = "%-15s %-20s %-45s\n";
 
-	if (argc != 3) return RESULT_SHOWUSAGE;
+	if (argc != 3)
+		return RESULT_SHOWUSAGE;
 
 	if (zone) {
 		ast_cli(fd, output_format, "Zone", "Timezone", "Message Format");
@@ -5961,7 +5991,8 @@
 		
 		if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) {
 			ast_copy_string(externnotify, notifystr, sizeof(externnotify));
-			ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
 #ifdef WITH_SMDI
 			if (!strcasecmp(externnotify, "smdi")) {
 				ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
@@ -6054,7 +6085,8 @@
 		ast_set2_flag((&globalflags), ast_true(astattach), VM_FORCEGREET);
 
 		if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
-			ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
 			stringp = ast_strdupa(s);
 			for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
 				if (!ast_strlen_zero(stringp)) {
@@ -6062,44 +6094,51 @@
 					while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
 						q++;
 					ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x]));
-					ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
+					if (option_debug > 1)
+						ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
 				} else {
 					cidinternalcontexts[x][0] = '\0';
 				}
 			}
 		}
 		if (!(astreview = ast_variable_retrieve(cfg, "general", "review"))){
-			ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
 			astreview = "no";
 		}
 		ast_set2_flag((&globalflags), ast_true(astreview), VM_REVIEW);	
 
 		if (!(astcallop = ast_variable_retrieve(cfg, "general", "operator"))){
-			ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
 			astcallop = "no";
 		}
 		ast_set2_flag((&globalflags), ast_true(astcallop), VM_OPERATOR);	
 
 		if (!(astsaycid = ast_variable_retrieve(cfg, "general", "saycid"))) {
-			ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
 			astsaycid = "no";
 		} 
 		ast_set2_flag((&globalflags), ast_true(astsaycid), VM_SAYCID);	
 
 		if (!(send_voicemail = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){
-			ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
 			send_voicemail = "no";
 		}
 		ast_set2_flag((&globalflags), ast_true(send_voicemail), VM_SVMAIL);
 	
 		if (!(asthearenv = ast_variable_retrieve(cfg, "general", "envelope"))) {
-			ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
 			asthearenv = "yes";
 		}
 		ast_set2_flag((&globalflags), ast_true(asthearenv), VM_ENVELOPE);	
 
 		if (!(astsaydurationinfo = ast_variable_retrieve(cfg, "general", "sayduration"))) {
-			ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
 			astsaydurationinfo = "yes";
 		}
 		ast_set2_flag((&globalflags), ast_true(astsaydurationinfo), VM_SAYDURATION);	
@@ -6114,28 +6153,32 @@
 		}
 
 		if (!(astskipcmd = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
-			ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
 			astskipcmd = "no";
 		}
 		ast_set2_flag((&globalflags), ast_true(astskipcmd), VM_SKIPAFTERCMD);
 
 		if ((dialoutcxt = ast_variable_retrieve(cfg, "general", "dialout"))) {
 			ast_copy_string(dialcontext, dialoutcxt, sizeof(dialcontext));
-			ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
 		} else {
 			dialcontext[0] = '\0';	
 		}
 		
 		if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) {
 			ast_copy_string(callcontext, callbackcxt, sizeof(callcontext));
-			ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
 		} else {
 			callcontext[0] = '\0';
 		}
 
 		if ((exitcxt = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
 			ast_copy_string(exitcontext, exitcxt, sizeof(exitcontext));
-			ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
 		} else {
 			exitcontext[0] = '\0';
 		}

Modified: team/oej/filenamelen/config.c
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/config.c?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/config.c (original)
+++ team/oej/filenamelen/config.c Fri Feb 24 05:17:11 2006
@@ -82,7 +82,7 @@
 };
 
 struct ast_category {
-	char name[80];
+	char name[AST_MAX_CONFIG_CATEGORY];
 	int ignored;			/* do not let user of the config see this category */
 	struct ast_variable *root;
 	struct ast_variable *last;
@@ -522,11 +522,11 @@
 
 static struct ast_config *config_text_file_load(const char *database, const char *table, const char *filename, struct ast_config *cfg)
 {
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 	char buf[8192];
 	char *new_buf, *comment_p, *process_buf;
 	FILE *f;
-	int lineno=0;
+	int lineno = 0;
 	int comment = 0, nest[MAX_NESTED_COMMENTS];
 	struct ast_category *cat = NULL;
 	int count = 0;
@@ -669,7 +669,7 @@
 int config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
 {
 	FILE *f;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 	char date[256]="";
 	time_t t;
 	struct ast_variable *var;
@@ -929,8 +929,8 @@
 
 struct ast_config *ast_config_internal_load(const char *filename, struct ast_config *cfg)
 {
-	char db[256];
-	char table[256];
+	char db[AST_MAX_FILENAME_LEN];
+	char table[AST_MAX_FILENAME_LEN];
 	struct ast_config_engine *loader = &text_file_engine;
 	struct ast_config *result;
 
@@ -983,8 +983,8 @@
 struct ast_variable *ast_load_realtime(const char *family, ...)
 {
 	struct ast_config_engine *eng;
-	char db[256]="";
-	char table[256]="";
+	char db[AST_MAX_FILENAME_LEN]="";
+	char table[AST_MAX_FILENAME_LEN]="";
 	struct ast_variable *res=NULL;
 	va_list ap;
 
@@ -1012,8 +1012,8 @@
 struct ast_config *ast_load_realtime_multientry(const char *family, ...)
 {
 	struct ast_config_engine *eng;
-	char db[256]="";
-	char table[256]="";
+	char db[AST_MAX_FILENAME_LEN]="";
+	char table[AST_MAX_FILENAME_LEN]="";
 	struct ast_config *res=NULL;
 	va_list ap;
 
@@ -1030,8 +1030,8 @@
 {
 	struct ast_config_engine *eng;
 	int res = -1;
-	char db[256]="";
-	char table[256]="";
+	char db[AST_MAX_FILENAME_LEN]="";
+	char table[AST_MAX_FILENAME_LEN]="";
 	va_list ap;
 
 	va_start(ap, lookup);

Modified: team/oej/filenamelen/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/include/asterisk/config.h?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/include/asterisk/config.h (original)
+++ team/oej/filenamelen/include/asterisk/config.h Fri Feb 24 05:17:11 2006
@@ -32,6 +32,10 @@
 struct ast_config;
 
 struct ast_category;
+
+#define AST_MAX_CONFIG_CATEGORY 80	/*!< Maximum length of configuration section, which also
+					     sets the maximum length of a device name in channels
+					     and a context in the dial plan */
 
 struct ast_variable {
 	char *name;

Modified: team/oej/filenamelen/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/include/asterisk/utils.h?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/include/asterisk/utils.h (original)
+++ team/oej/filenamelen/include/asterisk/utils.h Fri Feb 24 05:17:11 2006
@@ -142,14 +142,15 @@
 
 struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp);
 
-/* ast_md5_hash 
-	\brief Produces MD5 hash based on input string */
+/*! \brief Produces MD5 hash based on input string */
 void ast_md5_hash(char *output, char *input);
 /* ast_sha1_hash
 	\brief Produces SHA1 hash based on input string */
 void ast_sha1_hash(char *output, char *input);
 
+/*! \brief Encode string into Base 64 encoded string */
 int ast_base64encode(char *dst, const unsigned char *src, int srclen, int max);
+/*! \brief Decode Base 64 encoded string */
 int ast_base64decode(unsigned char *dst, const char *src, int max);
 
 /*! ast_uri_encode
@@ -166,7 +167,6 @@
 	\param buflen	Size of output buffer
 	\param doreserved	Convert reserved characters
 */
-
 char *ast_uri_encode(const char *string, char *outbuf, int buflen, int doreserved);
 
 /*!	\brief Decode URI, URN, URL (overwrite string)
@@ -217,14 +217,13 @@
 int ast_utils_init(void);
 int ast_wait_for_input(int fd, int ms);
 
-/*! Compares the source address and port of two sockaddr_in */
+/*! \brief Compares the source address and port of two sockaddr_in */
 static force_inline int inaddrcmp(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
 {
 	return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) 
 		|| (sin1->sin_port != sin2->sin_port));
 }
 
-#define AST_STACKSIZE 256 * 1024
 #define ast_pthread_create(a,b,c,d) ast_pthread_create_stack(a,b,c,d,0)
 int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize);
 
@@ -239,6 +238,10 @@
 #ifndef HAVE_GETLOADAVG
 int getloadavg(double *list, int nelem);
 #endif
+
+#define AST_STACKSIZE 256 * 1024
+#define AST_MAX_FILENAME_LEN	256	/*!< Maximum length of file names */
+#define AST_MAX_SHELL_COMMAND	512	/*!< Maximum length of shell commands */
 
 #ifdef linux
 #define ast_random random

Modified: team/oej/filenamelen/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/pbx/pbx_config.c?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/pbx/pbx_config.c (original)
+++ team/oej/filenamelen/pbx/pbx_config.c Fri Feb 24 05:17:11 2006
@@ -924,7 +924,7 @@
  */
 static int handle_save_dialplan(int fd, int argc, char *argv[])
 {
-	char filename[256];
+	char filename[AST_MAX_FILENAME_LEN];
 	struct ast_context *c;
 	struct ast_config *cfg;
 	struct ast_variable *v;

Modified: team/oej/filenamelen/pbx/pbx_spool.c
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/pbx/pbx_spool.c?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/pbx/pbx_spool.c (original)
+++ team/oej/filenamelen/pbx/pbx_spool.c Fri Feb 24 05:17:11 2006
@@ -57,7 +57,7 @@
 static char qdir[255];
 
 struct outgoing {
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 	/* Current number of retries */
 	int retries;
 	/* Maximum number of retries permitted */
@@ -78,8 +78,8 @@
 	char data[256];
 
 	/* If extension/context/priority */
-	char exten[256];
-	char context[256];
+	char exten[AST_MAX_EXTENSION];
+	char context[AST_MAX_CONTEXT];
 	int priority;
 
 	/* CallerID Information */
@@ -355,7 +355,7 @@
 	struct stat st;
 	DIR *dir;
 	struct dirent *de;
-	char fn[256];
+	char fn[AST_MAX_FILENAME_LEN];
 	int res;
 	time_t last = 0, next = 0, now;
 	for(;;) {

Modified: team/oej/filenamelen/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/oej/filenamelen/res/res_musiconhold.c?rev=11011&r1=11010&r2=11011&view=diff
==============================================================================
--- team/oej/filenamelen/res/res_musiconhold.c (original)
+++ team/oej/filenamelen/res/res_musiconhold.c Fri Feb 24 05:17:11 2006
@@ -124,7 +124,7 @@
 
 struct mohclass {
 	char name[MAX_MUSICCLASS];
-	char dir[256];
+	char dir[AST_MAX_FILENAME_LEN];
 	char args[256];
 	char mode[80];
 	char filearray[MAX_MOHFILES][MAX_MOHFILE_LEN];



More information about the asterisk-commits mailing list