From a05c09a69a82cec63f480e12d3c6acc01b801be7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 28 Nov 2007 20:44:18 +0000 Subject: [PATCH] add mime types to webserver git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6418 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 2 +- .../mod_voicemail/mod_voicemail.c | 21 ++++++++++++------- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 9 ++++++++ src/switch_core.c | 6 ++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 814db2934b..66ed314448 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1493,7 +1493,7 @@ SWITCH_DECLARE(void) switch_core_set_globals(void); */ SWITCH_DECLARE(uint8_t) switch_core_session_compare(switch_core_session_t *a, switch_core_session_t *b); - +SWITCH_DECLARE(switch_hash_index_t *) switch_core_mime_index(void); SWITCH_DECLARE(const char *) switch_core_mime_ext2type(const char *ext); SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, const char *ext); diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 8ad3573c51..eb3ed2bdb3 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -2250,7 +2250,7 @@ static int rss_callback(void *pArg, int argc, char **argv, char **columnNames) { struct holder *holder = (struct holder *) pArg; switch_xml_t x_tmp, x_link; - char *tmp, *del; + char *tmp, *del, *get; switch_time_exp_t tm; char create_date[80] = ""; char read_date[80] = ""; @@ -2319,19 +2319,24 @@ static int rss_callback(void *pArg, int argc, char **argv, char **columnNames) fname = argv[8]; } + get = switch_mprintf("http://%s:%s%s/get/%s", holder->host, holder->port, holder->uri, fname); del = switch_mprintf("http://%s:%s%s/del/%s", holder->host, holder->port, holder->uri, fname); x_link = switch_xml_add_child_d(holder->x_item, "fsvm:rmlink", 0); switch_xml_set_txt_d(x_link, del); - tmp = switch_mprintf("Last Heard: %s
Duration: %s
Delete This Message]]>", - strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", heard, duration_str, del); + tmp = switch_mprintf("" + "Last Heard: %s
Duration: %s
" + "Delete This Message
" + "]]>", + strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", heard, duration_str, del); switch_xml_set_txt_d(x_tmp, tmp); free(tmp); free(del); + x_tmp = switch_xml_add_child_d(holder->x_item, "pubDate", 0); switch_xml_set_txt_d(x_tmp, rss_date); @@ -2339,17 +2344,17 @@ static int rss_callback(void *pArg, int argc, char **argv, char **columnNames) switch_xml_set_txt_d(x_tmp, duration_str); - tmp = switch_mprintf("http://%s:%s%s/get/%s", holder->host, holder->port, holder->uri, fname); + x_tmp = switch_xml_add_child_d(holder->x_item, "guid", 0); - switch_xml_set_txt_d(x_tmp, tmp); + switch_xml_set_txt_d(x_tmp, get); x_link = switch_xml_add_child_d(holder->x_item, "link", 0); - switch_xml_set_txt_d(x_link, tmp); + switch_xml_set_txt_d(x_link, get); x_tmp = switch_xml_add_child_d(holder->x_item, "enclosure", 0); - switch_xml_set_attr_d(x_tmp, "url", tmp); - free(tmp); + switch_xml_set_attr_d(x_tmp, "url", get); + free(get); diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 706825e56b..9eea40771f 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -665,6 +665,9 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_xml_rpc_runtime) xmlrpc_registry *registryP; xmlrpc_env env; char logfile[512]; + switch_hash_index_t *hi; + const void *var; + void *val; globals.running = 1; @@ -679,6 +682,12 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_xml_rpc_runtime) MIMETypeInit(); MIMETypeAdd("text/html", "html"); + for(hi = switch_core_mime_index(); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &var, NULL, &val); + if (var && val) { + MIMETypeAdd((char *) val, (char *) var); + } + } snprintf(logfile, sizeof(logfile), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, "freeswitch_http.log"); ServerCreate(&abyssServer, "XmlRpcServer", globals.port, SWITCH_GLOBAL_dirs.htdocs_dir, logfile); diff --git a/src/switch_core.c b/src/switch_core.c index 7c27646f3a..973cfc8e13 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -557,6 +557,12 @@ SWITCH_DECLARE(const char *) switch_core_mime_ext2type(const char *ext) return (const char *) switch_core_hash_find(runtime.mime_types, ext); } + +SWITCH_DECLARE(switch_hash_index_t *) switch_core_mime_index(void) +{ + return switch_hash_first(NULL, runtime.mime_types); +} + SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, const char *ext) { const char *check = (const char *) switch_core_hash_find(runtime.mime_types, ext);