[svn-commits] seanbright: branch group/asterisk-cpp r167252 - in /team/group/asterisk-cpp: ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 6 12:43:03 CST 2009


Author: seanbright
Date: Tue Jan  6 12:43:02 2009
New Revision: 167252

URL: http://svn.digium.com/view/asterisk?view=rev&rev=167252
Log:
util/astman.c and util/stereoize.c compile now

Modified:
    team/group/asterisk-cpp/include/asterisk/linkedlists.h
    team/group/asterisk-cpp/utils/astman.c
    team/group/asterisk-cpp/utils/frame.c
    team/group/asterisk-cpp/utils/frame.h
    team/group/asterisk-cpp/utils/stereorize.c

Modified: team/group/asterisk-cpp/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-cpp/include/asterisk/linkedlists.h?view=diff&rev=167252&r1=167251&r2=167252
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/linkedlists.h (original)
+++ team/group/asterisk-cpp/include/asterisk/linkedlists.h Tue Jan  6 12:43:02 2009
@@ -220,8 +220,8 @@
   \brief Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK
 */
 #define AST_LIST_HEAD_NOLOCK_INIT_VALUE	{	\
-	.first = NULL,					\
-	.last = NULL,					\
+	NULL,					\
+	NULL,					\
 	}
 
 /*!

Modified: team/group/asterisk-cpp/utils/astman.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-cpp/utils/astman.c?view=diff&rev=167252&r1=167251&r2=167252
==============================================================================
--- team/group/asterisk-cpp/utils/astman.c (original)
+++ team/group/asterisk-cpp/utils/astman.c Tue Jan  6 12:43:02 2009
@@ -50,14 +50,6 @@
 #define MAX_HEADERS 80
 #define MAX_LEN 256
 
-/*
- * 2005.05.27 - different versions of newt define the type of the buffer
- * for the 5th argument to newtEntry() as char ** or const char ** . To 
- * let the code compile cleanly with -Werror, we cast it to void * through 
- * _NEWT_CAST.
- */
-#define _NEWT_CAST (void *)
-
 #define DEFAULT_MANAGER_PORT 5038
 
 struct message {
@@ -123,7 +115,7 @@
 		if (!strcmp(name, chan->name))
 			return chan;
 	}
-	chan = malloc(sizeof(struct ast_chan));
+	chan = (struct ast_chan *) malloc(sizeof(struct ast_chan));
 	if (chan) {
 		memset(chan, 0, sizeof(struct ast_chan));
 		strncpy(chan->name, name, sizeof(chan->name) - 1);
@@ -161,21 +153,20 @@
 	}
 }
 
-static char *get_header(struct message *m, char *var)
+static char *get_header(struct message *m, const char *var)
 {
 	char cmp[80];
-	int x;
 	snprintf(cmp, sizeof(cmp), "%s: ", var);
-	for (x=0;x<m->hdrcount;x++)
+	for (unsigned int x = 0; x < m->hdrcount; x++)
 		if (!strncasecmp(cmp, m->headers[x], strlen(cmp)))
 			return m->headers[x] + strlen(cmp);
-	return "";
+	return (char *) "";
 }
 
 static int event_newstate(struct ast_mansession *s, struct message *m)
 {
 	struct ast_chan *chan;
-	chan = find_chan(get_header(m, "Channel"));
+    chan = find_chan(get_header(m, "Channel"));
 	strncpy(chan->state, get_header(m, "State"), sizeof(chan->state) - 1);
 	return 0;
 }
@@ -230,35 +221,35 @@
 	return 0;
 }
 static struct event {
-	char *event;
+	const char *event;
 	int (*func)(struct ast_mansession *s, struct message *m);
 } events[] = {
-	{ "Newstate", event_newstate },
-	{ "Newchannel", event_newchannel },
-	{ "Newexten", event_newexten },
-	{ "Hangup", event_hangup },
-	{ "Rename", event_rename },
-	{ "Status", event_status },
-	{ "Link", event_ignore },
-	{ "Unlink", event_ignore },
+	{ "Newstate",       event_newstate },
+	{ "Newchannel",     event_newchannel },
+	{ "Newexten",       event_newexten },
+	{ "Hangup",         event_hangup },
+	{ "Rename",         event_rename },
+	{ "Status",         event_status },
+	{ "Link",           event_ignore },
+	{ "Unlink",         event_ignore },
 	{ "StatusComplete", event_ignore },
-	{ "Dial", event_ignore },
-	{ "PeerStatus", event_ignore },
+	{ "Dial",           event_ignore },
+	{ "PeerStatus",     event_ignore },
 	{ "MessageWaiting", event_ignore },
-	{ "Newcallerid", event_ignore },
-	{ "AGIExec", event_ignore},
-	{ "VarSet", event_ignore},
-	{ "MeetmeTalking", event_ignore},
-	{ "MeetmeJoin", event_ignore},
-	{ "MeetmeLeave", event_ignore},
-	{ "MeetmeEnd", event_ignore},
-	{ "MeetmeMute", event_ignore},
-	{ "Masquerade", event_ignore},
+	{ "Newcallerid",    event_ignore },
+	{ "AGIExec",        event_ignore},
+	{ "VarSet",         event_ignore},
+	{ "MeetmeTalking",  event_ignore},
+	{ "MeetmeJoin",     event_ignore},
+	{ "MeetmeLeave",    event_ignore},
+	{ "MeetmeEnd",      event_ignore},
+	{ "MeetmeMute",     event_ignore},
+	{ "Masquerade",     event_ignore},
 };
 
 static int process_message(struct ast_mansession *s, struct message *m)
 {
-	int x;
+	unsigned int x;
 	char event[80] = "";
 	strncpy(event, get_header(m, "Event"), sizeof(event) - 1);
 	if (!strlen(event)) {
@@ -278,7 +269,7 @@
 	for (x=0;x<m->hdrcount;x++) {
 		printf("Header: %s\n", m->headers[x]);
 	}
-#endif	
+#endif
 	return 0;
 }
 
@@ -293,8 +284,8 @@
 	newtListboxClear(c);
 	AST_LIST_TRAVERSE(&chans, chan, list) {
 		snprintf(tmpn, sizeof(tmpn), "%s (%s)", chan->name, chan->callerid);
-		if (strlen(chan->exten)) 
-			snprintf(tmp, sizeof(tmp), "%-30s %8s -> %s@%s:%s", 
+		if (strlen(chan->exten))
+			snprintf(tmp, sizeof(tmp), "%-30s %8s -> %s@%s:%s",
 				tmpn, chan->state,
 				chan->exten, chan->context, chan->priority);
 		else
@@ -310,9 +301,8 @@
 
 static int has_input(struct ast_mansession *s)
 {
-	int x;
-	for (x=1;x<s->inlen;x++) 
-		if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) 
+	for (int x = 1; x < s->inlen; x++)
+		if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r'))
 			return 1;
 	return 0;
 }
@@ -321,10 +311,9 @@
 {
 	/* output must have at least sizeof(s->inbuf) space */
 	int res;
-	int x;
 	struct timeval tv = {0, 0};
 	fd_set fds;
-	for (x=1;x<s->inlen;x++) {
+	for (int x = 1; x < s->inlen; x++) {
 		if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) {
 			/* Copy output data up to and including \r\n */
 			memcpy(output, s->inbuf, x + 1);
@@ -335,8 +324,8 @@
 			s->inlen -= (x + 1);
 			return 1;
 		}
-	} 
-	if (s->inlen >= sizeof(s->inbuf) - 1) {
+	}
+	if (s->inlen >= (int) sizeof(s->inbuf) - 1) {
 		fprintf(stderr, "Dumping long line with no return from %s: %s\n", inet_ntoa(s->sin.sin_addr), s->inbuf);
 		s->inlen = 0;
 	}
@@ -417,7 +406,7 @@
 }
 
 
-static int __attribute__((format(printf, 2, 3))) manager_action(char *action, char *fmt, ...)
+static int __attribute__((format(printf, 2, 3))) manager_action(const char *action, const char *fmt, ...)
 {
 	struct ast_mansession *s;
 	char tmp[4096];
@@ -425,18 +414,18 @@
 	int res;
 
 	s = &session;
-	fdprintf(s->fd, "Action: %s\r\n", action);
+	fdprintf(s->fd, (char *) "Action: %s\r\n", action);
 	va_start(ap, fmt);
 	vsnprintf(tmp, sizeof(tmp), fmt, ap);
 	va_end(ap);
 	if ((res = write(s->fd, tmp, strlen(tmp))) < 0) {
-		fprintf(stderr, "write() failed: %s\n", strerror(errno));
-	}
-	fdprintf(s->fd, "\r\n");
-	return 0;
-}
-
-static int show_message(char *title, char *msg)
+		fprintf(stderr, (char *) "write() failed: %s\n", strerror(errno));
+	}
+	fdprintf(s->fd, (char *) "\r\n");
+	return 0;
+}
+
+static int show_message(const char *title, const char *msg)
 {
 	newtComponent form;
 	newtComponent label;
@@ -456,7 +445,7 @@
 }
 
 static newtComponent showform;
-static int show_doing(char *title, char *tmp)
+static int show_doing(const char *title, const char *tmp)
 {
 	struct newtExitStruct es;
 	newtComponent label;
@@ -487,14 +476,14 @@
 		show_message("Status Failed Failed", get_header(m, "Message"));
 	}
 }
-	
+
 
 static void try_hangup(newtComponent c)
 {
 	struct ast_chan *chan;
 	struct message *m;
 
-	chan = newtListboxGetCurrent(c);
+	chan = (struct ast_chan *) newtListboxGetCurrent(c);
 	if (chan) {
 		manager_action("Hangup", "Channel: %s\r\n", chan->name);
 		m = wait_for_response(10000);
@@ -504,7 +493,7 @@
 			show_message("Hangup Failed", get_header(m, "Message"));
 		}
 	}
-	
+
 }
 
 static int get_user_input(char *msg, char *buf, int buflen)
@@ -519,14 +508,14 @@
 
 	newtCenteredWindow(60,7, msg);
 
-	inpfield = newtEntry(5, 2, "", 50, _NEWT_CAST &input, 0);
+	inpfield = newtEntry(5, 2, "", 50, &input, 0);
 	ok = newtButton(22, 3, "OK");
 	cancel = newtButton(32, 3, "Cancel");
 	form = newtForm(NULL, NULL, 0);
 	newtFormAddComponents(form, inpfield, ok, cancel, NULL);
 	newtFormRun(form, &es);
 	strncpy(buf, input, buflen - 1);
-	if (es.u.co == ok) 
+	if (es.u.co == ok)
 		res = 0;
 	else
 		res = -1;
@@ -544,11 +533,11 @@
 	char tmp[80];
 	char *context;
 
-	chan = newtListboxGetCurrent(c);
+	chan = (struct ast_chan *) newtListboxGetCurrent(c);
 	if (chan) {
 		strncpy(channame, chan->name, sizeof(channame) - 1);
 		snprintf(tmp, sizeof(tmp), "Enter new extension for %s", channame);
-		if (get_user_input(tmp, dest, sizeof(dest))) 
+		if (get_user_input(tmp, dest, sizeof(dest)))
 			return;
 		if ((context = strchr(dest, '@'))) {
 			*context = '\0';
@@ -564,7 +553,7 @@
 			show_message("Hangup Failed", get_header(m, "Message"));
 		}
 	}
-	
+
 }
 
 static int manage_calls(char *host)
@@ -579,23 +568,23 @@
 
 	/* Mark: If there's one thing you learn from this code, it is this...
 	   Never, ever fly Air France.  Their customer service is absolutely
-	   the worst.  I've never heard the words "That's not my problem" as 
+	   the worst.  I've never heard the words "That's not my problem" as
 	   many times as I have from their staff -- It should, without doubt
-	   be their corporate motto if it isn't already.  Don't bother giving 
+	   be their corporate motto if it isn't already.  Don't bother giving
 	   them business because you're just a pain in their side and they
 	   will be sure to let you know the first time you speak to them.
-	   
+
 	   If you ever want to make me happy just tell me that you, too, will
 	   never fly Air France again either (in spite of their excellent
-	   cuisine). 
-	
+	   cuisine).
+
 	   Update by oej: The merger with KLM has transferred this
-	   behaviour to KLM as well. 
+	   behaviour to KLM as well.
 	   Don't bother giving them business either...
 
 	   Only if you want to travel randomly without luggage, you
 	   might pick either of them.
-	   
+
 	*/
 	snprintf(tmp, sizeof(tmp), "Asterisk Manager at %s", host);
 	newtCenteredWindow(74, 20, tmp);
@@ -608,19 +597,19 @@
 	channels = newtListbox(1,1,14, NEWT_FLAG_SCROLL);
 	newtFormAddComponents(form, channels, redirect, hangup, quit, NULL);
 	newtListboxSetWidth(channels, 72);
-	
+
 	show_doing("Getting Status", "Retrieving system status...");
 	try_status();
 	hide_doing();
 
 	for(;;) {
 		newtFormRun(form, &es);
-		if (has_input(&session) || (es.reason == NEWT_EXIT_FDREADY)) {
+		if (has_input(&session) || (es.reason == newtExitStruct::NEWT_EXIT_FDREADY)) {
 			if (input_check(&session, NULL)) {
 				show_message("Disconnected", "Disconnected from remote host");
 				break;
 			}
-		} else if (es.reason == NEWT_EXIT_COMPONENT) {
+		} else if (es.reason == newtExitStruct::NEWT_EXIT_COMPONENT) {
 			if (es.u.co == quit)
 				break;
 			if (es.u.co == hangup) {
@@ -652,18 +641,18 @@
 	char tmp[55];
 	struct hostent *hp;
 	int res = -1;
-	
+
 	session.fd = socket(AF_INET, SOCK_STREAM, 0);
 	if (session.fd < 0) {
 		snprintf(tmp, sizeof(tmp), "socket() failed: %s\n", strerror(errno));
 		show_message("Socket failed", tmp);
 		return -1;
 	}
-	
+
 	snprintf(tmp, sizeof(tmp), "Looking up %s\n", hostname);
 	show_doing("Connecting....", tmp);
-	
-	
+
+
 	hp = gethostbyname(hostname);
 	if (!hp) {
 		snprintf(tmp, sizeof(tmp), "No such address: %s\n", hostname);
@@ -683,25 +672,25 @@
 		show_message("Connect Failed", tmp);
 		return -1;
 	}
-	
+
 	hide_doing();
-	
+
 	login = newtButton(5, 6, "Login");
 	cancel = newtButton(25, 6, "Cancel");
 	newtCenteredWindow(40, 10, "Asterisk Manager Login");
 	snprintf(tmp, sizeof(tmp), "Host:     %s", hostname);
 	label = newtLabel(4,1, tmp);
-	
+
 	ulabel = newtLabel(4,2,"Username:");
 	plabel = newtLabel(4,3,"Password:");
-	
-	username = newtEntry(14, 2, "", 20, _NEWT_CAST &user, 0);
-	password = newtEntry(14, 3, "", 20, _NEWT_CAST &pass, NEWT_FLAG_HIDDEN);
-	
+
+	username = newtEntry(14, 2, "", 20, &user, 0);
+	password = newtEntry(14, 3, "", 20, &pass, NEWT_FLAG_HIDDEN);
+
 	form = newtForm(NULL, NULL, 0);
 	newtFormAddComponents(form, username, password, login, cancel, label, ulabel, plabel,NULL);
 	newtFormRun(form, &es);
-	if (es.reason == NEWT_EXIT_COMPONENT) {
+	if (es.reason == newtExitStruct::NEWT_EXIT_COMPONENT) {
 		if (es.u.co == login) {
 			snprintf(tmp, sizeof(tmp), "Logging in '%s'...", user);
 			show_doing("Logging in", tmp);
@@ -735,7 +724,7 @@
 				}
 			} else {
 				memset(m, 0, sizeof(m));
-				manager_action("Login", 
+				manager_action("Login",
 					"Username: %s\r\n"
 					"Secret: %s\r\n",
 						user, pass);

Modified: team/group/asterisk-cpp/utils/frame.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-cpp/utils/frame.c?view=diff&rev=167252&r1=167251&r2=167252
==============================================================================
--- team/group/asterisk-cpp/utils/frame.c (original)
+++ team/group/asterisk-cpp/utils/frame.c Tue Jan  6 12:43:02 2009
@@ -632,7 +632,7 @@
    Reports an error due to parsing the string 's' encountered on the
    command line. 'code' indicates the type of error.
    -------------------------------------------------------------------- */
-void argerrornum(char *s, Errornum code)
+void argerrornum(const char *s, Errornum code)
 {
   char *message;
 
@@ -701,7 +701,7 @@
    Reports an error due to parsing the string 's' encountered on the
    command line. 'message' explains the type of error.
    -------------------------------------------------------------------- */
-void argerrortxt(char *s, char *message)
+void argerrortxt(const char *s, const char *message)
 {
   if (s != NULL)
     error ("Error parsing option -%s:\n\t", s);

Modified: team/group/asterisk-cpp/utils/frame.h
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-cpp/utils/frame.h?view=diff&rev=167252&r1=167251&r2=167252
==============================================================================
--- team/group/asterisk-cpp/utils/frame.h (original)
+++ team/group/asterisk-cpp/utils/frame.h Tue Jan  6 12:43:02 2009
@@ -43,11 +43,11 @@
 extern int wavout;         /* TRUE iff out file is .WAV file */
 extern int iswav;          /* TRUE iff in file was found to be a .WAV file */
 extern FILE *in, *out;
-extern char *infilename, *outfilename;
+extern const char *infilename, *outfilename;
 extern int verboselevel;
-extern char *version;      /* String to be issued as version string. Should
+extern const char *version;      /* String to be issued as version string. Should
 			      be set by application. */
-extern char *usage;        /* String to be issued as usage string. Should be
+extern const char *usage;        /* String to be issued as usage string. Should be
 			      set by application. */
 
 #define DEFAULTFREQ 44100
@@ -224,13 +224,13 @@
    Reports an error due to parsing the string 's' encountered on the
    command line. 'code' indicates the type of error.
    -------------------------------------------------------------------- */
-extern void argerrornum(char *s, Errornum code);
+extern void argerrornum(const char *s, Errornum code);
 
 /* --------------------------------------------------------------------
    Reports an error due to parsing the string 's' encountered on the
    command line. 'message' explains the type of error.
    -------------------------------------------------------------------- */
-extern void argerrortxt(char *s, char *message);
+extern void argerrortxt(const char *s, const char *message);
 
 /* --------------------------------------------------------------------
    Check for any remaining arguments and complain about their existence.

Modified: team/group/asterisk-cpp/utils/stereorize.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-cpp/utils/stereorize.c?view=diff&rev=167252&r1=167251&r2=167252
==============================================================================
--- team/group/asterisk-cpp/utils/stereorize.c (original)
+++ team/group/asterisk-cpp/utils/stereorize.c Tue Jan  6 12:43:02 2009
@@ -18,8 +18,8 @@
 #include <assert.h>
 #include "frame.h"
 
-static char *Version = "stereorize 1.1, November 5th 2000";
-static char *Usage =
+static const char *Version = "stereorize 1.1, November 5th 2000";
+static const char *Usage =
 "Usage: stereorize [options] infile-left infile-right outfile\n\n"
 
 "Example:\n"
@@ -34,7 +34,7 @@
    int i, k[2], maxk, stdin_in_use=FALSE;
    short *leftsample, *rightsample, *stereosample;
    FILE *channel[2];
-   char *filename[2], *tempname;
+   const char *filename[2], *tempname;
 
    version = Version;
    usage = Usage;
@@ -96,9 +96,9 @@
 
    checknoargs(argcount, args);      /* Check that no arguments are left */
 
-   leftsample = malloc( sizeof(*leftsample) * BUFFSIZE);
-   rightsample = malloc( sizeof(*leftsample) * BUFFSIZE);
-   stereosample = malloc( sizeof(*leftsample) * 2 * BUFFSIZE);
+   leftsample = (short *) malloc( sizeof(*leftsample) * BUFFSIZE);
+   rightsample = (short *) malloc( sizeof(*leftsample) * BUFFSIZE);
+   stereosample = (short *) malloc( sizeof(*leftsample) * 2 * BUFFSIZE);
    if (leftsample == NULL || rightsample == NULL || stereosample == NULL)
      fatalperror ("");
 




More information about the svn-commits mailing list