[Asterisk-cvs] asterisk file.c,1.34,1.35 sounds.txt,1.16,1.17

martinp at lists.digium.com martinp at lists.digium.com
Fri Dec 19 12:14:54 CST 2003


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv21612

Modified Files:
	file.c sounds.txt 
Log Message:
Add voicemail prepending feature plus forwarding to many extensions if you specify exten1*exten2*.....#


Index: file.c
===================================================================
RCS file: /usr/cvsroot/asterisk/file.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- file.c	25 Oct 2003 18:15:04 -0000	1.34
+++ file.c	19 Dec 2003 18:06:28 -0000	1.35
@@ -499,6 +499,15 @@
 	return NULL;
 }
 
+struct ast_frame *ast_readframe(struct ast_filestream *s)
+{
+	struct ast_frame *f = NULL;
+	int whennext = 0;	
+	if (s && s->fmt)
+		f = s->fmt->read(s, &whennext);
+	return f;
+}
+
 static int ast_readaudio_callback(void *data)
 {
 	struct ast_filestream *s = data;
@@ -726,10 +735,58 @@
 	return -1;
 }
 
+struct ast_filestream *ast_readfile(char *filename, char *type, char *comment, int flags, int check, mode_t mode)
+{
+	int fd,myflags = 0;
+	struct ast_format *f;
+	struct ast_filestream *fs=NULL;
+	char *fn;
+	char *ext;
+	if (ast_mutex_lock(&formatlock)) {
+		ast_log(LOG_WARNING, "Unable to lock format list\n");
+		return NULL;
+	}
+	f = formats;
+	while(f) {
+		if (!strcasecmp(f->name, type)) {
+			char *stringp=NULL;
+			/* XXX Implement check XXX */
+			ext = strdup(f->exts);
+			stringp=ext;
+			ext = strsep(&stringp, "|");
+			fn = build_filename(filename, ext);
+			fd = open(fn, flags | myflags);
+			if (fd >= 0) {
+				errno = 0;
+				if ((fs = f->open(fd))) {
+					fs->trans = NULL;
+					fs->fmt = f;
+					fs->flags = flags;
+					fs->mode = mode;
+					fs->filename = strdup(filename);
+					fs->vfs = NULL;
+				} else {
+					ast_log(LOG_WARNING, "Unable to open %s\n", fn);
+					close(fd);
+					unlink(fn);
+				}
+			} else if (errno != EEXIST)
+				ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno));
+			free(fn);
+			free(ext);
+			break;
+		}
+		f = f->next;
+	}
+	ast_mutex_unlock(&formatlock);
+	if (!f) 
+		ast_log(LOG_WARNING, "No such format '%s'\n", type);
+	return fs;
+}
 
 struct ast_filestream *ast_writefile(char *filename, char *type, char *comment, int flags, int check, mode_t mode)
 {
-	int fd,myflags;
+	int fd,myflags = 0;
 	struct ast_format *f;
 	struct ast_filestream *fs=NULL;
 	char *fn;
@@ -738,9 +795,12 @@
 		ast_log(LOG_WARNING, "Unable to lock format list\n");
 		return NULL;
 	}
-	myflags = 0;
 	/* set the O_TRUNC flag if and only if there is no O_APPEND specified */
-	if (!(flags & O_APPEND)) myflags = O_TRUNC;
+	if (!(flags & O_APPEND)) 
+		myflags = O_TRUNC;
+	
+	myflags |= O_WRONLY | O_CREAT;
+
 	f = formats;
 	while(f) {
 		if (!strcasecmp(f->name, type)) {
@@ -750,7 +810,7 @@
 			stringp=ext;
 			ext = strsep(&stringp, "|");
 			fn = build_filename(filename, ext);
-			fd = open(fn, flags | myflags | O_WRONLY | O_CREAT, mode);
+			fd = open(fn, flags | myflags, mode);
 			if (fd >= 0) {
 				errno = 0;
 				if ((fs = f->rewrite(fd, comment))) {

Index: sounds.txt
===================================================================
RCS file: /usr/cvsroot/asterisk/sounds.txt,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sounds.txt	3 Sep 2003 17:06:12 -0000	1.16
+++ sounds.txt	19 Dec 2003 18:06:28 -0000	1.17
@@ -392,3 +392,5 @@
 
 %minutes.gsm%minutes
 
+%vm-forwardoptions.gsm%press 1 to prepend a message or 2 to forward the
+ message without prepending




More information about the svn-commits mailing list