您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ switch_safe_free函数代码示例

51自学网 2021-06-03 08:35:37
  C++
这篇教程C++ switch_safe_free函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中switch_safe_free函数的典型用法代码示例。如果您正苦于以下问题:C++ switch_safe_free函数的具体用法?C++ switch_safe_free怎么用?C++ switch_safe_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了switch_safe_free函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SWITCH_DECLARE

SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *dest, int timeout, switch_state_handler_table_t *handlers){	switch_core_session_t *aleg_core_session = NULL;	this_check(0);	cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;	if (a_leg_session != NULL) {		aleg_core_session = a_leg_session->session;	}	// this session has no valid switch_core_session_t at this point, and therefore	// no valid channel.  since the threadstate is stored in the channel, and there 	// is none, if we try to call begin_alllow_threads it will fail miserably.	// use the 'a leg session' to do the thread swapping stuff.    if (a_leg_session) a_leg_session->begin_allow_threads();	if (switch_ivr_originate(aleg_core_session, 							 &session, 							 &cause, 							 dest, 							 timeout,							 handlers, 							 NULL, 							 NULL, 							 NULL,							 NULL,							 SOF_NONE,							 NULL) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]/n", dest);		goto failed;	}    if (a_leg_session) a_leg_session->end_allow_threads();	channel = switch_core_session_get_channel(session);	allocated = 1;	switch_safe_free(uuid);	uuid = strdup(switch_core_session_get_uuid(session));	switch_channel_set_state(switch_core_session_get_channel(session), CS_SOFT_EXECUTE);	return SWITCH_STATUS_SUCCESS; failed:    if (a_leg_session) a_leg_session->end_allow_threads();	return SWITCH_STATUS_FALSE;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:49,


示例2: channelList_callback

static int channelList_callback(void *pArg, int argc, char **argv, char **columnNames){	chan_entry_t *entry;	netsnmp_tdata_row *row;	switch_zmalloc(entry, sizeof(chan_entry_t));	row = netsnmp_tdata_create_row();	if (!row) {		switch_safe_free(entry);		return 0;	}	row->data = entry;	entry->idx = idx++;	strncpy(entry->uuid, switch_str_nil(argv[0]), sizeof(entry->uuid));	strncpy(entry->direction, switch_str_nil(argv[1]), sizeof(entry->direction));	entry->created_epoch = atoi(argv[3]);	strncpy(entry->name, switch_str_nil(argv[4]), sizeof(entry->name));	strncpy(entry->state, switch_str_nil(argv[5]), sizeof(entry->state));	strncpy(entry->cid_name, switch_str_nil(argv[6]), sizeof(entry->cid_name));	strncpy(entry->cid_num, switch_str_nil(argv[7]), sizeof(entry->cid_num));	strncpy(entry->dest, switch_str_nil(argv[9]), sizeof(entry->dest));	strncpy(entry->application, switch_str_nil(argv[10]), sizeof(entry->application));	strncpy(entry->application_data, switch_str_nil(argv[11]), sizeof(entry->application_data));	strncpy(entry->dialplan, switch_str_nil(argv[12]), sizeof(entry->dialplan));	strncpy(entry->context, switch_str_nil(argv[13]), sizeof(entry->context));	strncpy(entry->read_codec, switch_str_nil(argv[14]), sizeof(entry->read_codec));	entry->read_rate = atoi(switch_str_nil(argv[15]));	entry->read_bitrate = atoi(switch_str_nil(argv[16]));	strncpy(entry->write_codec, switch_str_nil(argv[17]), sizeof(entry->write_codec));	entry->write_rate = atoi(switch_str_nil(argv[18]));	entry->write_bitrate = atoi(switch_str_nil(argv[19]));	memset(&entry->ip_addr, 0, sizeof(entry->ip_addr));	if (strchr(switch_str_nil(argv[8]), ':')) {		switch_inet_pton(AF_INET6, switch_str_nil(argv[8]), &entry->ip_addr);		entry->addr_family = AF_INET6;	} else {		switch_inet_pton(AF_INET, switch_str_nil(argv[8]), &entry->ip_addr);		entry->addr_family = AF_INET;	}	netsnmp_tdata_row_add_index(row, ASN_INTEGER, &entry->idx, sizeof(entry->idx));	netsnmp_tdata_add_row(ch_table, row);	return 0;}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:49,


示例3: SWITCH_DECLARE

SWITCH_DECLARE(const char *) API::executeString(const char *cmd){	char *arg;	switch_stream_handle_t stream = { 0 };	char *mycmd = NULL;	this_check("");	mycmd = strdup(cmd);	switch_assert(mycmd);	if ((arg = strchr(mycmd, ' '))) {		*arg++ = '/0';	}	switch_safe_free(last_data);		SWITCH_STANDARD_STREAM(stream);	switch_api_execute(mycmd, arg, session, &stream);	last_data = (char *) stream.data;	switch_safe_free(mycmd);	return last_data;}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:24,


示例4: setup_dir

/** * Empties the entire cache * @param cache the cache to empty */static void setup_dir(url_cache_t *cache){	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting up %s/n", cache->location);	switch_dir_make_recursive(cache->location, SWITCH_DEFAULT_DIR_PERMS, cache->pool);	for (int i = 0x00; i <= 0xff; i++) {		switch_dir_t *dir = NULL;		char *dirname = switch_mprintf("%s%s%02x", cache->location, SWITCH_PATH_SEPARATOR, i);		if (switch_dir_open(&dir, dirname, cache->pool) == SWITCH_STATUS_SUCCESS) {			char filenamebuf[256] = { 0 };			const char *filename = NULL;			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "deleting cache files in %s.../n", dirname);			for(filename = switch_dir_next_file(dir, filenamebuf, sizeof(filenamebuf)); filename;					filename = switch_dir_next_file(dir, filenamebuf, sizeof(filenamebuf))) {				char *path = switch_mprintf("%s%s%s", dirname, SWITCH_PATH_SEPARATOR, filename);				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "deleting: %s/n", path);				switch_file_remove(path, cache->pool);				switch_safe_free(path);			}			switch_dir_close(dir);		}		switch_safe_free(dirname);	}}
开发者ID:AricGod,项目名称:FreeSWITCH,代码行数:28,


示例5: rayo_file_close

/** * Close SSML document. * @param handle * @return SWITCH_STATUS_SUCCESS */static switch_status_t rayo_file_close(switch_file_handle_t *handle){	struct rayo_file_context *context = (struct rayo_file_context *)handle->private_info;	if (context && context->component) {		struct output_component *output = OUTPUT_COMPONENT(context->component);		/* send completion and destroy */		if (output->stop) {			rayo_component_send_complete(context->component, COMPONENT_COMPLETE_STOP);		} else {			if (!strcmp(RAYO_ACTOR(context->component)->type, RAT_CALL_COMPONENT)) {				/* call output... check for hangup */				switch_core_session_t *session = switch_core_session_locate(RAYO_ACTOR(context->component)->parent->id);				if (session) {					if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {						rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP);					} else {						rayo_component_send_complete(context->component, OUTPUT_FINISH);					}					switch_core_session_rwunlock(session);				} else {					/* session is gone */					rayo_component_send_complete(context->component, COMPONENT_COMPLETE_HANGUP);				}			} else {				/* mixer output... finished */				rayo_component_send_complete(context->component, OUTPUT_FINISH);			}		}		/* TODO timed out */		/* cleanup internals */		switch_safe_free(context->ssml);		context->ssml = NULL;		if (output->document) {			iks_delete(output->document);			output->document = NULL;		}		/* close SSML file */		if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)) {			return switch_core_file_close(&context->fh);		}	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:53,


示例6: remove_fetch_handler

static switch_status_t remove_fetch_handler(ei_node_t *ei_node, erlang_pid *from, switch_xml_binding_t *binding) {    ei_xml_agent_t *agent;    ei_xml_client_t *client;    fetch_handler_t *fetch_handler, *prev = NULL;    int found = 0;    agent = (ei_xml_agent_t *)switch_xml_get_binding_user_data(binding);    /* write-lock the agent */    switch_thread_rwlock_wrlock(agent->lock);    if (!(client = find_xml_client(ei_node, agent))) {        switch_thread_rwlock_unlock(agent->lock);        return SWITCH_STATUS_SUCCESS;    }    fetch_handler = client->fetch_handlers;    while (fetch_handler != NULL) {        if (ei_compare_pids(&fetch_handler->pid, from) == SWITCH_STATUS_SUCCESS) {            found = 1;            break;        }        prev = fetch_handler;        fetch_handler = fetch_handler->next;    }    if (found) {        if (!prev) {            client->fetch_handlers = fetch_handler->next;        } else {            prev->next = fetch_handler->next;        }        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Removed %s XML handler %s <%d.%d.%d>/n"                          ,xml_section_to_string(agent->section)                          ,fetch_handler->pid.node                          ,fetch_handler->pid.creation                          ,fetch_handler->pid.num                          ,fetch_handler->pid.serial);        switch_safe_free(fetch_handler);    }    switch_thread_rwlock_unlock(agent->lock);    return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:47,


示例7: tts_commandline_speech_feed_tts

static switch_status_t tts_commandline_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags){	switch_status_t ret=SWITCH_STATUS_SUCCESS;	char *message, *tmp, *mtmp, *rate;	tts_commandline_t *info = (tts_commandline_t *) sh->private_info;	assert(info != NULL);	if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {		switch_core_file_close(info->fh);		unlink(info->file);	}	tmp = switch_util_quote_shell_arg(text);	message = switch_string_replace(globals.command, "${text}", tmp);	switch_safe_free(tmp); mtmp=message;	tmp = switch_util_quote_shell_arg(info->voice_name);	message = switch_string_replace(mtmp, "${voice}", tmp);	switch_safe_free(tmp); switch_safe_free(mtmp); mtmp=message;	rate = switch_core_sprintf(sh->memory_pool, "%d", info->rate);	message = switch_string_replace(mtmp, "${rate}", rate);	switch_safe_free(mtmp); mtmp=message;	tmp = switch_util_quote_shell_arg(info->file);	message = switch_string_replace(mtmp, "${file}", tmp);	switch_safe_free(tmp); switch_safe_free(mtmp); mtmp=message;	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing: %s/n", message);	if (switch_system(message, SWITCH_TRUE) < 0) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to execute command: %s/n", message);		ret = SWITCH_STATUS_FALSE; goto done;	}	if (switch_core_file_open(info->fh, info->file, 0,	//number_of_channels,							  info->rate,	//samples_per_second,							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file: %s/n", info->file);		ret = SWITCH_STATUS_FALSE; goto done;	}	sh->private_info = info; done:	switch_safe_free(mtmp);	return ret;}
开发者ID:benlangfeld,项目名称:FreeSWITCH,代码行数:49,


示例8: xmlrpc_decompose_value

static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * const paramArrayP, void *const userData, void *const callInfo){	char *command = NULL, *arg = NULL;	switch_stream_handle_t stream = { 0 };	xmlrpc_value *val = NULL;	switch_bool_t freed = 0;	/* Parse our argument array. */	xmlrpc_decompose_value(envP, paramArrayP, "(ss)", &command, &arg);	if (envP->fault_occurred) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Request!/n");		return NULL;	}	if (!is_authorized((const TSession *) callInfo, command)) {		val = xmlrpc_build_value(envP, "s", "UNAUTHORIZED!");		goto end;	}	if (switch_stristr("unload", command) && switch_stristr("mod_xml_rpc", arg)) {		switch_safe_free(command);		switch_safe_free(arg);		freed = 1;		command = "bgapi";		arg = "unload mod_xml_rpc";	} else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) {		switch_safe_free(command);		switch_safe_free(arg);		freed = 1;		command = "bgapi";		arg = "reload mod_xml_rpc";	}	SWITCH_STANDARD_STREAM(stream);	if (switch_api_execute(command, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {		/* Return our result. */		val = xmlrpc_build_value(envP, "s", stream.data);		free(stream.data);	} else {		val = xmlrpc_build_value(envP, "s", "ERROR!");	}  end:	/* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */	if (!freed) {		switch_safe_free(command);		switch_safe_free(arg);	}	return val;}
开发者ID:jrd,项目名称:FreeSWITCH,代码行数:54,


示例9: utils_hupall

void utils_hupall(char *profile_name){    char cmd[128];    char arg[128];    switch_stream_handle_t mystream = { 0 };    switch_snprintf(cmd, sizeof(cmd),"hupall");    switch_snprintf(arg, sizeof(arg),"normal_clearing sofia_profile_name %s",profile_name);    SWITCH_STANDARD_STREAM(mystream);    if (switch_api_execute(cmd, arg, NULL, &mystream) != SWITCH_STATUS_SUCCESS) {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"cannot hupall for %s/n",profile_name);        return;    }    switch_safe_free(mystream.data);    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"hupall for %s done/n",profile_name);    return;}
开发者ID:VoiSmart,项目名称:freeswitch-mod-cpg,代码行数:17,


示例10: skinny_session_walk_lines_by_call_id

switch_status_t skinny_session_walk_lines_by_call_id(skinny_profile_t *profile, uint32_t call_id, switch_core_db_callback_func_t callback, void *data){	char *sql;	if ((sql = switch_mprintf(					"SELECT skinny_lines.*, channel_uuid, call_id, call_state "					"FROM skinny_active_lines "					"INNER JOIN skinny_lines "					"ON skinny_active_lines.device_name = skinny_lines.device_name "					"AND skinny_active_lines.device_instance = skinny_lines.device_instance "					"AND skinny_active_lines.line_instance = skinny_lines.line_instance "					"WHERE call_id='%d'",					call_id))) {		skinny_execute_sql_callback(profile, profile->sql_mutex, sql, callback, data);		switch_safe_free(sql);	}	return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:17,


示例11: SWITCH_DECLARE

SWITCH_DECLARE(char *) CoreSession::getXMLCDR(){		switch_xml_t cdr;	this_check((char *)"");	sanity_check((char *)"");	switch_safe_free(xml_cdr_text);	if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {		xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);		switch_xml_free(cdr);	}	return (char *) (xml_cdr_text ? xml_cdr_text : "");}
开发者ID:gujun,项目名称:sscore,代码行数:17,


示例12: subscribe

/** * Request signals */static void subscribe(const char *uuid, const char *signal_type, const char *jid){    char *key = switch_mprintf("%s:%s", uuid, signal_type);    switch_mutex_lock(globals.subscribers_mutex);    {        switch_hash_t *signal_subscribers = switch_core_hash_find(globals.subscribers, key);        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Subscribe %s => %s/n", signal_type, jid);        if (!signal_subscribers) {            switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Create %s subscriber hash/n", signal_type);            switch_core_hash_init(&signal_subscribers);            switch_core_hash_insert(globals.subscribers, key, signal_subscribers);        }        switch_core_hash_insert(signal_subscribers, jid, "1");    }    switch_mutex_unlock(globals.subscribers_mutex);    switch_safe_free(key);}
开发者ID:bodji,项目名称:freeswitch,代码行数:20,


示例13: set_cache

switch_bool_t set_cache(switch_memory_pool_t *pool, char *number, cid_data_t *cid){	char *cmd;	switch_bool_t success = SWITCH_TRUE;	switch_stream_handle_t stream = { 0 };	SWITCH_STANDARD_STREAM(stream);	cmd = switch_core_sprintf(pool, "set fs:cidlookup:name:%s '%s' %d", number, cid->name, globals.cache_expire);	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "memcache: %s/n", cmd);	if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) {		if (strncmp("-ERR", stream.data, 4)) {			success = SWITCH_TRUE;		} else {			success = SWITCH_FALSE;			goto done;		}	}	SWITCH_REWIND_STREAM(stream);	cmd = switch_core_sprintf(pool, "set fs:cidlookup:area:%s '%s' %d", number, cid->area, globals.cache_expire);	if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) {		if (strncmp("-ERR", stream.data, 4)) {			success = SWITCH_TRUE;		} else {			success = SWITCH_FALSE;			goto done;		}	}	SWITCH_REWIND_STREAM(stream);	cmd = switch_core_sprintf(pool, "set fs:cidlookup:src:%s '%s' %d", number, cid->src, globals.cache_expire);	if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) {		if (strncmp("-ERR", stream.data, 4)) {			success = SWITCH_TRUE;		} else {			success = SWITCH_FALSE;			goto done;		}	}  done:	switch_safe_free(stream.data);	return success;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:45,


示例14: get_file_from_macro

/** * Try to get file(s) from say module * @param parsed_data * @param to_say * @return 1 if successful */static int get_file_from_macro(struct ssml_parser *parsed_data, char *to_say){	struct ssml_node *cur_node = parsed_data->cur_node;	struct macro *say_macro = cur_node->say_macro;	struct voice *say_voice = find_say_voice(cur_node);	struct language *language;	char *file_string = NULL;	char *gender = NULL;	switch_say_interface_t *si;	/* voice is required */	if (!say_voice) {		return 0;	}	language = switch_core_hash_find(globals.language_map, say_voice->language);	/* language is required */	if (!language) {		return 0;	}	/* TODO need to_say gender, not voice gender */	gender = "neuter";	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Trying macro: %s, %s, %s, %s, %s/n", language->language, to_say, say_macro->type, say_macro->method, gender);	if ((si = switch_loadable_module_get_say_interface(language->say_module)) && si->say_string_function) {		switch_say_args_t say_args = {0};		say_args.type = switch_ivr_get_say_type_by_name(say_macro->type);		say_args.method = switch_ivr_get_say_method_by_name(say_macro->method);		say_args.gender = switch_ivr_get_say_gender_by_name(gender);		say_args.ext = "wav";		si->say_string_function(NULL, to_say, &say_args, &file_string);	}	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding macro: /"%s/", prefix=/"%s/"/n", file_string, say_voice->prefix);	if (!zstr(file_string)) {		parsed_data->files[parsed_data->num_files].name = switch_core_strdup(parsed_data->pool, file_string);		parsed_data->files[parsed_data->num_files++].prefix = switch_core_strdup(parsed_data->pool, say_voice->prefix);		return 1;	}	switch_safe_free(file_string);	return 0;}
开发者ID:alleywind,项目名称:FreeSWITCH,代码行数:50,


示例15: switch_core_session_get_channel

char *sofia_media_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type){	char *extra_headers = NULL;	switch_stream_handle_t stream = { 0 };	switch_event_header_t *hi = NULL;	int x = 0;	switch_channel_t *channel = switch_core_session_get_channel(session);	const char *boundary = switch_core_session_get_uuid(session);	SWITCH_STANDARD_STREAM(stream);	if ((hi = switch_channel_variable_first(channel))) {		for (; hi; hi = hi->next) {			const char *name = (char *) hi->name;			char *value = (char *) hi->value;			if (!strncasecmp(name, prefix, strlen(prefix))) {				const char *hname = name + strlen(prefix);				if (*value == '~') {					stream.write_function(&stream, "--%s/nContent-Type: %s/nContent-Length: %d/n%s/n", boundary, hname, strlen(value), value + 1);				} else {					stream.write_function(&stream, "--%s/nContent-Type: %s/nContent-Length: %d/n/n%s/n", boundary, hname, strlen(value) + 1, value);				}				x++;			}		}		switch_channel_variable_last(channel);	}	if (x) {		*mp_type = switch_core_session_sprintf(session, "multipart/mixed; boundary=%s", boundary);		if (sdp) {			stream.write_function(&stream, "--%s/nContent-Type: application/sdp/nContent-Length: %d/n/n%s/n", boundary, strlen(sdp) + 1, sdp);		}		stream.write_function(&stream, "--%s--/n", boundary);	}	if (!zstr((char *) stream.data)) {		extra_headers = stream.data;	} else {		switch_safe_free(stream.data);	}	return extra_headers;}
开发者ID:syam218,项目名称:FreeSWITCH,代码行数:44,


示例16: SWITCH_DECLARE

SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_send_query(switch_pgsql_handle_t *handle, const char* sql){#ifdef SWITCH_HAVE_PGSQL    char *err_str;    switch_safe_free(handle->sql);    handle->sql = strdup(sql);    if (!PQsendQuery(handle->con, sql)) {        err_str = switch_pgsql_handle_get_error(handle);        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to send query (%s) to database: %s/n", sql, err_str);        switch_pgsql_finish_results(handle);        goto error;    }    return SWITCH_PGSQL_SUCCESS;error:#endif    return SWITCH_PGSQL_FAIL;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:19,


示例17: switch_mprintf

/*login是否成功*/bool CBaseModule::isLoginSuc(string username,							 string userpwd){	//临时方案:目前根据文件读取	bool bRes = false;	switch_xml_t x_NEs,x_ne;	const char *errmsg[1]={ 0 };	const char *name=NULL;	const char *pwd=NULL;	char *nefile = switch_mprintf("%s%s%s", 		SWITCH_GLOBAL_dirs.conf_dir, 		SWITCH_PATH_SEPARATOR, 		CARI_CCP_OPUSER_XML_FILE		);	if (!cari_common_isExistedFile(nefile)){		goto end;	}	//将内容转换成xml的结构(注意:中文字符问题)	x_NEs = cari_common_parseXmlFromFile(nefile);	if (!x_NEs){		goto end;	}	//遍历查找	x_ne = switch_xml_child(x_NEs, "opuser");	for (; x_ne; x_ne = x_ne->next) {		name = switch_xml_attr(x_ne, "name");		pwd = switch_xml_attr(x_ne, "pwd");		if (isEqualStr(username.c_str(),name)			&& isEqualStr(userpwd.c_str(),pwd)){				bRes = true;				break;		}		}end:	switch_safe_free(nefile);	return bRes;}
开发者ID:gujun,项目名称:sscore,代码行数:45,


示例18: pocketsphinx_asr_close

/*! function to close the asr interface */static switch_status_t pocketsphinx_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags){	pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;	switch_mutex_lock(ps->flag_mutex);	if (switch_test_flag(ps, PSFLAG_ALLOCATED)) {		if (switch_test_flag(ps, PSFLAG_READY)) {			ps_end_utt(ps->ps);		}		ps_free(ps->ps);		ps->ps = NULL;	}	switch_safe_free(ps->grammar);	switch_mutex_unlock(ps->flag_mutex);	switch_clear_flag(ps, PSFLAG_HAS_TEXT);	switch_clear_flag(ps, PSFLAG_READY);	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Port Closed./n");	switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED);	return SWITCH_STATUS_SUCCESS;}
开发者ID:hsaid,项目名称:FreeSWITCH,代码行数:21,


示例19: rayo_component_send_start

/** * Start execution of call output component * @param component to start * @param session the session to output to * @param output the output request * @param iq the original request */static iks *start_call_output(struct rayo_component *component, switch_core_session_t *session, iks *output, iks *iq){	switch_stream_handle_t stream = { 0 };	/* acknowledge command */	rayo_component_send_start(component, iq);	/* build playback command */	SWITCH_STANDARD_STREAM(stream);	stream.write_function(&stream, "{id=%s,session=%s,pause=%s",		RAYO_JID(component), switch_core_session_get_uuid(session),		OUTPUT_COMPONENT(component)->start_paused ? "true" : "false");	if (OUTPUT_COMPONENT(component)->max_time_ms > 0) {		stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time_ms);	}	if (OUTPUT_COMPONENT(component)->start_offset_ms > 0) {		stream.write_function(&stream, ",start_offset_ms=%i", OUTPUT_COMPONENT(component)->start_offset_ms);	}	stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component));	if (switch_ivr_displace_session(session, stream.data, 0, "m") == SWITCH_STATUS_SUCCESS) {		RAYO_RELEASE(component);	} else {		if (component->complete) {			/* component is already destroyed */			RAYO_RELEASE(component);		} else {			/* need to destroy component */			if (OUTPUT_COMPONENT(component)->document) {				iks_delete(OUTPUT_COMPONENT(component)->document);			}			if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {				rayo_component_send_complete(component, COMPONENT_COMPLETE_HANGUP);			} else {				rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR);			}		}	}	switch_safe_free(stream.data);	return NULL;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:48,


示例20: config_callback_dsn

static switch_status_t config_callback_dsn(switch_xml_config_item_t *data, const char *newvalue, switch_config_callback_type_t callback_type,										   switch_bool_t changed){	switch_status_t status = SWITCH_STATUS_SUCCESS;	switch_cache_db_handle_t *dbh = NULL;	if (!switch_odbc_available()) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC is not compiled in.  Do not configure odbc-dsn parameter!/n");		return SWITCH_STATUS_FALSE;	}	if ((callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) && changed) {		if (zstr(newvalue)) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No local database defined./n");		} else {			switch_safe_free(globals.odbc_dsn);			globals.odbc_dsn = strdup(newvalue);			if ((globals.odbc_user = strchr(globals.odbc_dsn, ':'))) {				*globals.odbc_user++ = '/0';				if ((globals.odbc_pass = strchr(globals.odbc_user, ':'))) {					*globals.odbc_pass++ = '/0';				}			}			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connecting to dsn: %s/n", globals.odbc_dsn);			if (!(dbh = cidlookup_get_db_handle())) {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!/n");				switch_goto_status(SWITCH_STATUS_FALSE, done);			}		}	}	switch_goto_status(SWITCH_STATUS_SUCCESS, done);  done:	switch_cache_db_release_db_handle(&dbh);	return status;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:41,


示例21: SWITCH_DECLARE

SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool){	/* try free dynamic data structures prior to resetting to 0 */	FreeUPNPUrls(&nat_globals.urls);	switch_safe_free(nat_globals.descURL);	memset(&nat_globals, 0, sizeof(nat_globals));	if (first_init) {		memset(&nat_globals_perm, 0, sizeof(nat_globals_perm));		nat_globals_perm.pool = pool;	}	switch_find_local_ip(nat_globals.pvt_addr, sizeof(nat_globals.pvt_addr), NULL, AF_INET);	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Scanning for NAT/n");	init_pmp();	if (!nat_globals.nat_type) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for UPnP/n");		init_upnp();	}	if (nat_globals.nat_type) {		switch_core_set_variable("nat_public_addr", nat_globals.pub_addr);		switch_core_set_variable("nat_private_addr", nat_globals.pvt_addr);		switch_core_set_variable("nat_type", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp");		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "NAT detected type: %s, ExtIP: '%s'/n",						  nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp", nat_globals.pub_addr);		if (!nat_thread_p) {			switch_nat_thread_start();		}	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No PMP or UPnP NAT devices detected!/n");	}	first_init = SWITCH_FALSE;	initialized = SWITCH_TRUE;}
开发者ID:moises-silva,项目名称:mod_handsfree,代码行数:41,


示例22: cdr_mongo_authenticate

static switch_status_t cdr_mongo_authenticate() {	switch_status_t status = SWITCH_STATUS_SUCCESS;	mongo_error_t db_status;	char *ns_tmp, *ns_split[2];	/* Split namespace db.collection into separate vars */	switch_strdup(ns_tmp, globals.mongo_namespace);	switch_separate_string(ns_tmp, '.', ns_split, 2);	db_status = mongo_cmd_authenticate(globals.mongo_conn, ns_split[0], globals.mongo_username, globals.mongo_password);	if (db_status != MONGO_OK) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mongo_cmd_authenticate: authentication failed/n");		status = SWITCH_STATUS_FALSE;	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Successfully authenticated %[email
C++ switch_separate_string函数代码示例
C++ switch_mutex_unlock函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。