[Freeswitch-trunk] [commit] r6397 - in freeswitch/trunk/src: . include

Freeswitch SVN mikej at freeswitch.org
Mon Nov 26 12:43:43 EST 2007


Author: mikej
Date: Mon Nov 26 12:43:42 2007
New Revision: 6397

Modified:
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/switch_utils.c

Log:
little mailer rework.

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Mon Nov 26 12:43:42 2007
@@ -336,7 +336,7 @@
 #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
 SWITCH_DECLARE(size_t) switch_url_encode(const char *url, char *buf, size_t len);
 SWITCH_DECLARE(char *) switch_url_decode(char *s);
-SWITCH_DECLARE(switch_bool_t) switch_simple_email(char *to, char *from, char *headers, char *body, char *file);
+SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *from, const char *headers, const char *body, const char *file);
 
 /* malloc or DIE macros */
 #ifdef NDEBUG

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Mon Nov 26 12:43:42 2007
@@ -70,7 +70,7 @@
 
 
 
-static int write_buf(int fd, char *buf)
+static int write_buf(int fd, const char *buf)
 {
 
 	int len = (int) strlen(buf);
@@ -82,23 +82,22 @@
 	return 1;
 }
 
-SWITCH_DECLARE(switch_bool_t) switch_simple_email(char *to, char *from, char *headers, char *body, char *file)
+SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *from, const char *headers, const char *body, const char *file)
 {
 	char *bound = "XXXX_boundary_XXXX";
+	char *mime_type = "audio/x-WAV";
 	char filename[80], buf[B64BUFFLEN];
 	int fd = 0, ifd = 0;
 	int x = 0, y = 0, bytes = 0, ilen = 0;
 	unsigned int b = 0, l = 0;
 	unsigned char in[B64BUFFLEN];
 	unsigned char out[B64BUFFLEN + 512];
-	char *path = NULL;
 
     snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int)time(NULL), rand() & 0xffff);
     
     if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
         if (file) {
-            path = file;
-            if ((ifd = open(path, O_RDONLY)) < 1) {
+            if ((ifd = open(file, O_RDONLY)) < 1) {
                 return SWITCH_FALSE;
             }
 
@@ -127,9 +126,13 @@
         }
 
         if (file) {
-			snprintf(buf, B64BUFFLEN, "\n\n--%s\nContent-Type: audio/x-WAV; name=\"%s\"\n"
-                     "Content-Transfer-Encoding: base64\n"
-					 "Content-Description: Sound attachment.\n" "Content-Disposition: attachment; filename=\"%s\"\n\n", bound, switch_cut_path(file), switch_cut_path(file));
+			const char *filename = switch_cut_path(file);
+			snprintf(buf, B64BUFFLEN,
+					 "\n\n--%s\nContent-Type: %s; name=\"%s\"\n"
+					 "Content-Transfer-Encoding: base64\n"
+					 "Content-Description: Sound attachment.\n"
+					 "Content-Disposition: attachment; filename=\"%s\"\n\n",
+					 bound, mime_type, filename, filename);
             if (!write_buf(fd, buf))
                 return SWITCH_FALSE;
 



More information about the Freeswitch-trunk mailing list