[Asterisk-Users] Asterisk as a stand alone voice mail server

Siggi Langauf langausd at swt.uni-stuttgart.de
Fri Aug 8 08:43:46 MST 2003


Hi again,

struggling with localization issues (so the script is not "German only")
took me a week longer than expected. (Did anybody ever get PHP's gettext
extension working??)
But finally, I've wrapped something up:

On Thu, 24 Jul 2003, Dave Packham wrote:

> I would like to see your code...
>
> sounds great

Well, don't expect too much!

I've wrapped up an archive along with some elementary documentation. You
can download it from

  http://swt.uni-stuttgart.de/~langausd/asterisk/

You will need something like the attached patch, so app_voicemail2 writes
files in a way that allows PHP to read them.
If I ever understand how to add config options to asterisk applications,
I'll do it properly...

Note that I don't even have a proper name for the project, yet.
(suggestions are welcome!)

Due to the early stage of the project, I haven't really shipped it with
any usable license. If anybody really wants to use this now: please
contact me off-list! (It will probably be something like BSD Artistic
license if it ever becomes a real project...)
Otherwise: feel free to test this stuff, and rip out what you want!
(The only exception is: cisco-xmlapi.inc.php Please don't distribute that
 as-is. I'm currently revising the whole API...)

Cheers,
	Siggi

-------------- next part --------------
Index: apps/app_voicemail2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail2.c,v
retrieving revision 1.35
diff -u -r1.35 app_voicemail2.c
--- apps/app_voicemail2.c	2 Aug 2003 21:10:06 -0000	1.35
+++ apps/app_voicemail2.c	8 Aug 2003 15:55:52 -0000
@@ -58,6 +58,23 @@
 
 #define BASEMAXINLINE 256
 #define BASELINELEN 72
+<<<<<<< app_voicemail2.c
+
+/*############################################*/
+/* MOVE THIS TO CONFIG FILE ASAP!             */
+/*############################################*/
+#define FSYS_USER 0
+#define FSYS_GROUP 33  /* www-data */
+#define FILE_MODE 0660
+#define DIR_MODE 0770
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+=======
+>>>>>>> 1.35
 #define BASEMAXINLINE 256
 #define eol "\r\n"
 
@@ -810,7 +827,7 @@
 	if (maxtime)
 		time(&start);
 	for (x=0;x<fmtcnt;x++) {
-		others[x] = ast_writefile(recordfile, sfmt[x], comment, O_TRUNC, 0, 0700);
+		others[x] = ast_writefile(recordfile, sfmt[x], comment, O_TRUNC, 0, FILE_MODE);
 		ast_verbose( VERBOSE_PREFIX_3 "x=%i, open writing:  %s format: %s, %p\n", x, recordfile, sfmt[x], others[x]);
 			
 		if (!others[x]) {
@@ -996,14 +1013,14 @@
 			snprintf(prefile, sizeof(prefile), "voicemail/%s/%s/unavail", vmu->context, ext);
 		make_dir(dir, sizeof(dir), vmu->context, "", "");
 		/* It's easier just to try to make it than to check for its existence */
-		if (mkdir(dir, 0700) && (errno != EEXIST))
+		if (mkdir(dir, DIR_MODE) && (errno != EEXIST))
 			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
 		make_dir(dir, sizeof(dir), vmu->context, ext, "");
 		/* It's easier just to try to make it than to check for its existence */
-		if (mkdir(dir, 0700) && (errno != EEXIST))
+		if (mkdir(dir, DIR_MODE) && (errno != EEXIST))
 			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
 		make_dir(dir, sizeof(dir), vmu->context, ext, "INBOX");
-		if (mkdir(dir, 0700) && (errno != EEXIST))
+		if (mkdir(dir, DIR_MODE) && (errno != EEXIST))
 			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
 		if (ast_exists_extension(chan, strlen(chan->macrocontext) ? chan->macrocontext : chan->context, "o", 1, chan->callerid))
 			ecodes = "#0";
@@ -1195,7 +1212,7 @@
 		ast_log(LOG_WARNING, "Unable to open %s in read-only mode\n", infile);
 		return -1;
 	}
-	if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0) {
+	if ((ofd = open(outfile, O_WRONLY|O_TRUNC|O_CREAT, FILE_MODE)) < 0) {
 		ast_log(LOG_WARNING, "Unable to open %s in write-only mode\n", outfile);
 		close(ifd);
 		return -1;
@@ -1234,7 +1251,7 @@
 	int x;
 	make_file(sfn, sizeof(sfn), dir, msg);
 	make_dir(ddir, sizeof(ddir), context, username, dbox);
-	mkdir(ddir, 0700);
+	mkdir(ddir, DIR_MODE);
 	for (x=0;x<MAXMSG;x++) {
 		make_file(dfn, sizeof(dfn), ddir, x);
 		if (ast_fileexists(dfn, NULL, NULL) < 0)
@@ -2614,9 +2631,9 @@
 
 	if (valid) {
 		snprintf(vms.curdir, sizeof(vms.curdir), "%s/voicemail/%s", (char *)ast_config_AST_SPOOL_DIR, vmu->context);
-		mkdir(vms.curdir, 0700);
+		mkdir(vms.curdir, DIR_MODE);
 		snprintf(vms.curdir, sizeof(vms.curdir), "%s/voicemail/%s/%s", (char *)ast_config_AST_SPOOL_DIR, vmu->context, vms.username);
-		mkdir(vms.curdir, 0700);
+		mkdir(vms.curdir, DIR_MODE);
 		/* Retrieve old and new message counts */
 		open_mailbox(&vms, vmu, 1);
 		vms.oldmessages = vms.lastmsg + 1;


More information about the asterisk-users mailing list