mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-10 22:50:01 +00:00
doh
This commit is contained in:
parent
7471ec17ed
commit
29f66f994c
@ -604,17 +604,8 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
char *newfile = NULL;
|
char *newfile = NULL;
|
||||||
switch_bool_t rval = SWITCH_FALSE;
|
switch_bool_t rval = SWITCH_FALSE;
|
||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
const char *stipped_file;
|
|
||||||
const char *new_type;
|
|
||||||
char *xext;
|
|
||||||
|
|
||||||
if (zstr(file)) {
|
if (!zstr(file) && !zstr(convert_cmd) && !zstr(convert_ext)) {
|
||||||
err = "Missing file";
|
|
||||||
rval = SWITCH_FALSE;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!zstr(convert_cmd) && !zstr(convert_ext)) {
|
|
||||||
if ((ext = strrchr(file, '.'))) {
|
if ((ext = strrchr(file, '.'))) {
|
||||||
dupfile = strdup(file);
|
dupfile = strdup(file);
|
||||||
if ((ext = strrchr(dupfile, '.'))) {
|
if ((ext = strrchr(dupfile, '.'))) {
|
||||||
@ -639,18 +630,14 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
|
|
||||||
switch_snprintf(filename, 80, "%s%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, (int) switch_epoch_time_now(NULL), rand() & 0xffff);
|
switch_snprintf(filename, 80, "%s%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, (int) switch_epoch_time_now(NULL), rand() & 0xffff);
|
||||||
|
|
||||||
if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) {
|
if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644)) > -1) {
|
||||||
err = "Failed to open temp file";
|
if (file) {
|
||||||
rval = SWITCH_FALSE;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ifd = open(file, O_RDONLY | O_BINARY)) < 0) {
|
if ((ifd = open(file, O_RDONLY | O_BINARY)) < 0) {
|
||||||
rval = SWITCH_FALSE;
|
rval = SWITCH_FALSE;
|
||||||
err = "Failed to open source file\n";
|
err = "Cannot open tmp file\n";
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
|
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
|
||||||
if (!write_buf(fd, buf)) {
|
if (!write_buf(fd, buf)) {
|
||||||
rval = SWITCH_FALSE;
|
rval = SWITCH_FALSE;
|
||||||
@ -689,11 +676,14 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stipped_file = switch_cut_path(file);
|
if (file) {
|
||||||
|
const char *stipped_file = switch_cut_path(file);
|
||||||
|
const char *new_type;
|
||||||
|
char *ext;
|
||||||
|
|
||||||
if ((xext = strrchr(stipped_file, '.'))) {
|
if ((ext = strrchr(stipped_file, '.'))) {
|
||||||
xext++;
|
ext++;
|
||||||
if ((new_type = switch_core_mime_ext2type(xext))) {
|
if ((new_type = switch_core_mime_ext2type(ext))) {
|
||||||
mime_type = new_type;
|
mime_type = new_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -734,7 +724,6 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
if (l > 0) {
|
if (l > 0) {
|
||||||
out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64];
|
out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l != 0)
|
if (l != 0)
|
||||||
while (l < 6) {
|
while (l < 6) {
|
||||||
out[bytes++] = '=', l += 2;
|
out[bytes++] = '=', l += 2;
|
||||||
@ -743,6 +732,8 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
rval = -1;
|
rval = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
|
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
|
||||||
|
|
||||||
if (!write_buf(fd, buf)) {
|
if (!write_buf(fd, buf)) {
|
||||||
@ -750,6 +741,8 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
err = "write error.";
|
err = "write error.";
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (zstr(from)) {
|
if (zstr(from)) {
|
||||||
from = "freeswitch";
|
from = "freeswitch";
|
||||||
@ -781,13 +774,14 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
if (fd > -1) {
|
if (fd < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
if (ifd > -1) {
|
if (ifd < 0) {
|
||||||
close(ifd);
|
close(ifd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (newfile) {
|
if (newfile) {
|
||||||
unlink(newfile);
|
unlink(newfile);
|
||||||
free(newfile);
|
free(newfile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user