</pre>
*/
typedef enum {
+ SFF_NONE = 0,
SFF_CNG = (1 << 0),
SFF_RAW_RTP = (1 << 1)
} switch_frame_flag_t;
///\brief open the Core xml root
///\param reload if it's is already open close it and open it again as soon as permissable (blocking)
+///\param err a pointer to set error strings
///\return the xml root node or NULL
-SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload);
+SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **err);
///\brief initilize the core XML backend
///\param pool a memory pool to use
+///\param err a pointer to set error strings
///\return SWITCH_STATUS_SUCCESS if successful
-SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool, const char **err);
SWITCH_DECLARE(switch_status_t) switch_xml_destroy(void);
SWITCH_DECLARE(switch_status_t) switch_core_init(char *console)
{
-
+ const char *err = NULL;
memset(&runtime, 0, sizeof(runtime));
switch_core_set_globals();
}
if (apr_pool_create(&runtime.memory_pool, NULL) != SWITCH_STATUS_SUCCESS) {
+ apr_terminate();
fprintf(stderr, "FATAL ERROR! Could not allocate memory pool\n");
- switch_core_destroy();
return SWITCH_STATUS_MEMERR;
}
- if (switch_xml_init(runtime.memory_pool) != SWITCH_STATUS_SUCCESS) {
- fprintf(stderr, "FATAL ERROR! Could not open XML Registry\n");
- switch_core_destroy();
+ if (switch_xml_init(runtime.memory_pool, &err) != SWITCH_STATUS_SUCCESS) {
+ apr_terminate();
+ fprintf(stderr, "FATAL ERROR! Could not open XML Registry %s\n", err);
return SWITCH_STATUS_MEMERR;
}
return MAIN_XML_ROOT;
}
-SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload)
+SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **err)
{
char path_buf[1024];
uint8_t hasmain = 0;
snprintf(path_buf, sizeof(path_buf), "%s/%s", SWITCH_GLOBAL_dirs.conf_dir, "freeswitch.xml");
if ((MAIN_XML_ROOT = switch_xml_parse_file(path_buf))) {
- switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT);
+ *err = switch_xml_error(MAIN_XML_ROOT);
+
+ if (!switch_strlen_zero(*err)) {
+ switch_xml_free(MAIN_XML_ROOT);
+ MAIN_XML_ROOT = NULL;
+ } else {
+ switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT);
+ }
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open XML Root!\n");
}
}
-SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool, const char **err)
{
switch_xml_t xml;
XML_MEMORY_POOL = pool;
+ *err = "Success";
+
switch_mutex_init(&XML_LOCK, SWITCH_MUTEX_NESTED, XML_MEMORY_POOL);
switch_thread_rwlock_create(&RWLOCK, XML_MEMORY_POOL);
assert(pool != NULL);
- if((xml=switch_xml_open_root(FALSE))) {
+ if((xml=switch_xml_open_root(FALSE, err))) {
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
} else {