当前位置: 首页>>代码示例>>C++>>正文


C++ zstr函数代码示例

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


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

示例1: opus_load_config

static switch_status_t opus_load_config(switch_bool_t reload)
{
	char *cf = "opus.conf";
	switch_xml_t cfg, xml = NULL, param, settings;
	switch_status_t status = SWITCH_STATUS_SUCCESS;
    
	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opening of %s failed\n", cf);
		return status;
	}
    
	if ((settings = switch_xml_child(cfg, "settings"))) {
		for (param = switch_xml_child(settings, "param"); param; param = param->next) {
			char *key = (char *) switch_xml_attr_soft(param, "name");
			char *val = (char *) switch_xml_attr_soft(param, "value");
			
			if (!strcasecmp(key, "use-vbr") && !zstr(val)) {
				opus_prefs.use_vbr = atoi(val);
			} else if (!strcasecmp(key, "complexity")) {
				opus_prefs.complexity = atoi(val);
			} else if (!strcasecmp(key, "maxaveragebitrate")) {
				opus_prefs.maxaveragebitrate = atoi(val);
				if ( opus_prefs.maxaveragebitrate < 6000 || opus_prefs.maxaveragebitrate > 510000 ) {
					opus_prefs.maxaveragebitrate = 0; /* values outside the range between 6000 and 510000 SHOULD be ignored */
				}
			} else if (!strcasecmp(key, "maxplaybackrate")) {
				opus_prefs.maxplaybackrate = atoi(val);
				if ( opus_prefs.maxplaybackrate != 8000 && opus_prefs.maxplaybackrate != 12000 && opus_prefs.maxplaybackrate != 16000
							&& opus_prefs.maxplaybackrate != 24000 && opus_prefs.maxplaybackrate != 48000) {
					opus_prefs.maxplaybackrate = 0; /* value not supported */
				}
			}
		}
	}
    
    if (xml) {
        switch_xml_free(xml);
    }
    
    return status;
}
开发者ID:utkarsh301994,项目名称:localhost,代码行数:41,代码来源:mod_opus.c

示例2: initialise_ei

switch_status_t initialise_ei(struct ei_cnode_s *ec)
{
	char thisnodename[MAXNODELEN + 1];
	char thisalivename[MAXNODELEN + 1];
	char *atsign;

	if (zstr(listen_list.hostname) || !strncasecmp(prefs.ip, "0.0.0.0", 7) || !strncasecmp(prefs.ip, "::", 2)) {
		listen_list.hostname=(char *) switch_core_get_hostname();
	}
	if (strlen(listen_list.hostname) > EI_MAXHOSTNAMELEN) {
		*(listen_list.hostname+EI_MAXHOSTNAMELEN) = '\0';
	}

	/* copy the prefs.nodename into something we can modify */
	strncpy(thisalivename, prefs.nodename, MAXNODELEN);

	if ((atsign = strchr(thisalivename, '@'))) {
		/* we got a qualified node name, don't guess the host/domain */
		snprintf(thisnodename, MAXNODELEN + 1, "%s", prefs.nodename);
		/* truncate the alivename at the @ */
		*atsign = '\0';
	} else {
		if (prefs.shortname) {
			char *off;
			if ((off = strchr(listen_list.hostname, '.'))) {
				*off = '\0';
			}

		}
		snprintf(thisnodename, MAXNODELEN + 1, "%[email protected]%s", prefs.nodename, listen_list.hostname);
	}


	/* init the ei stuff */
	if (ei_connect_xinit(ec, listen_list.hostname, thisalivename, thisnodename, (Erl_IpAddr) listen_list.addr, prefs.cookie, 0) < 0) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to init ei connection\n");
		return SWITCH_STATUS_FALSE;
	}

	return SWITCH_STATUS_SUCCESS;
}
开发者ID:odmanV2,项目名称:freecenter,代码行数:41,代码来源:ei_helpers.c

示例3: 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,代码来源:mod_cidlookup.c

示例4: Event

SWITCH_DECLARE_CONSTRUCTOR Event::Event(const char *type, const char *subclass_name)
{
	switch_event_types_t event_id;
	
	if (switch_name_event(type, &event_id) != SWITCH_STATUS_SUCCESS) {
		event_id = SWITCH_EVENT_MESSAGE;
	}

	if (!zstr(subclass_name) && event_id != SWITCH_EVENT_CUSTOM) {
		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_WARNING, "Changing event type to custom because you specified a subclass name!\n");
		event_id = SWITCH_EVENT_CUSTOM;
	}

	if (switch_event_create_subclass(&event, event_id, subclass_name) != SWITCH_STATUS_SUCCESS) {
		switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to create event!\n");
		event = NULL;
	}

	serialized_string = NULL;
	mine = 1;
}
开发者ID:gujun,项目名称:sscore,代码行数:21,代码来源:switch_cpp.cpp

示例5: say_telephone_number

static switch_status_t say_telephone_number(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args)
{
	int silence = 0;
	char *p;

	for (p = tosay; !zstr(p); p++) {
		int a = tolower((int) *p);
		if (a >= '0' && a <= '9') {
			switch_say_file(sh, "digits/%c", a);
			silence = 0;
		} else if (a == '+' || (a >= 'a' && a <= 'z')) {
			switch_say_file(sh, "ascii/%d", a);
			silence = 0;
		} else if (!silence) {
			switch_say_file(sh, "silence_stream://100");
			silence = 1;
		}
	}

	return SWITCH_STATUS_SUCCESS;
}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:21,代码来源:mod_say_en.c

示例6: switch_core_alloc

/**
 * Add a definition for a tag
 * @param tag the name
 * @param attribs_fn the function to handle the tag attributes
 * @param cdata_fn the function to handler the tag CDATA
 * @param children_tags comma-separated list of valid child tag names
 * @return the definition
 */
static struct tag_def *add_tag_def(const char *tag, tag_attribs_fn attribs_fn, tag_cdata_fn cdata_fn, const char *children_tags)
{
	struct tag_def *def = switch_core_alloc(globals.pool, sizeof(*def));
	switch_core_hash_init(&def->children_tags, globals.pool);
	if (!zstr(children_tags)) {
		char *children_tags_dup = switch_core_strdup(globals.pool, children_tags);
		char *tags[32] = { 0 };
		int tag_count = switch_separate_string(children_tags_dup, ',', tags, sizeof(tags) / sizeof(tags[0]));
		if (tag_count) {
			int i;
			for (i = 0; i < tag_count; i++) {
				switch_core_hash_insert(def->children_tags, tags[i], tags[i]);
			}
		}
	}
	def->attribs_fn = attribs_fn;
	def->cdata_fn = cdata_fn;
	def->is_root = SWITCH_FALSE;
	switch_core_hash_insert(globals.tag_defs, tag, def);
	return def;
}
开发者ID:benlangfeld,项目名称:FreeSWITCH,代码行数:29,代码来源:nlsml.c

示例7:

switch_cache_db_handle_t *directory_get_db_handle(void)
{
    switch_cache_db_connection_options_t options = { {0} };
    switch_cache_db_handle_t *dbh = NULL;

    if (!zstr(globals.odbc_dsn)) {
        options.odbc_options.dsn = globals.odbc_dsn;
        options.odbc_options.user = globals.odbc_user;
        options.odbc_options.pass = globals.odbc_pass;

        if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) {
            dbh = NULL;
        }
        return dbh;
    } else {
        options.core_db_options.db_path = globals.dbname;
        if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) {
            dbh = NULL;
        }
        return dbh;
    }
}
开发者ID:jasonbourneh0810,项目名称:FreeSWITCH,代码行数:22,代码来源:mod_directory.c

示例8: set_global_facility

switch_status_t set_global_facility(const char *facility)
{
	const struct _facility_table_entry facilities[] = {
		{"auth", LOG_AUTH},
#if !defined (__SVR4) && !defined (__sun)
		{"authpriv", LOG_AUTHPRIV},
		{"ftp", LOG_FTP},
#endif
		{"cron", LOG_CRON},
		{"daemon", LOG_DAEMON},
		{"kern", LOG_KERN},
		{"local0", LOG_LOCAL0},
		{"local1", LOG_LOCAL1},
		{"local2", LOG_LOCAL2},
		{"local3", LOG_LOCAL3},
		{"local4", LOG_LOCAL4},
		{"local5", LOG_LOCAL5},
		{"local6", LOG_LOCAL6},
		{"local7", LOG_LOCAL7},
		{"lpr", LOG_LPR},
		{"mail", LOG_MAIL},
		{"news", LOG_NEWS},
		{"syslog", LOG_SYSLOG},
		{"user", LOG_USER},
		{"uucp", LOG_UUCP},
		{NULL, 0}
	};
	const struct _facility_table_entry *entry = facilities;

	while (!zstr(entry->description)) {
		if (!strcasecmp(entry->description, facility)) {
			globals.facility = entry->facility;
			return SWITCH_STATUS_SUCCESS;
		}
		entry++;
	}

	return SWITCH_STATUS_FALSE;
}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:39,代码来源:mod_syslog.c

示例9:

static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, const char *sql)
{
	char *name = NULL;
	char *newsql = NULL;
	char *err = NULL;
	callback_t cbt = { 0 };
	cbt.pool = pool;

	if (!zstr(globals.odbc_dsn)) {
		newsql = switch_event_expand_headers(event, sql);
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "SQL: %s\n", newsql);
		if (cidlookup_execute_sql_callback(newsql, cidlookup_callback, &cbt, &err)) {
			name = cbt.name;
		} else {
			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to lookup cid: %s\n", err ? err : "(null)");
		}
	}
	if (newsql != globals.sql) {
		switch_safe_free(newsql);
	}
	return name;
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:22,代码来源:mod_cidlookup.c

示例10: sip_outgoing_channel

static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
												switch_caller_profile_t *outbound_profile,
												switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
												switch_call_cause_t *cancel_cause)
{
	const char *profile;

	if (session) {
		profile = switch_channel_get_variable(switch_core_session_get_channel(session), "sip_profile");
	} else {
		profile = switch_core_get_variable("sip_profile");
	}
	if (zstr(profile)) {
		profile = "default";
	}

	outbound_profile->destination_number = switch_core_sprintf(outbound_profile->pool, "%s/%s", profile, outbound_profile->destination_number);

	UNPROTECT_INTERFACE(sip_endpoint_interface);

	return switch_core_session_outgoing_channel(session, var_event, "sofia", outbound_profile, new_session, pool, SOF_NONE, cancel_cause);
}
开发者ID:Deepwalker,项目名称:FreeSWITCH,代码行数:22,代码来源:mod_dialplan_asterisk.c

示例11: do_config

/**
 * Process module XML configuration
 * @param pool memory pool to allocate from
 * @param config_file to use
 * @return SWITCH_STATUS_SUCCESS on successful configuration
 */
static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_file)
{
	switch_xml_t cfg, xml;

	/* set defaults */
	globals.file_prefix = switch_core_sprintf(pool, "%s%s", SWITCH_GLOBAL_dirs.recordings_dir, SWITCH_PATH_SEPARATOR);

	if (!(xml = switch_xml_open_cfg(config_file, &cfg, NULL))) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", config_file);
		return SWITCH_STATUS_TERM;
	}

	/* get params */
	{
		switch_xml_t settings = switch_xml_child(cfg, "fax");
		if (settings) {
			switch_xml_t param;
			for (param = switch_xml_child(settings, "param"); param; param = param->next) {
				const char *var = switch_xml_attr_soft(param, "name");
				const char *val = switch_xml_attr_soft(param, "value");
				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param: %s = %s\n", var, val);
				if (!strcasecmp(var, "receivefax-file-prefix")) {
					if (!zstr(val)) {
						globals.file_prefix = switch_core_strdup(pool, val);
					}
				} else {
					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var);
				}
			}
		}
	}

	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "receivefax-file-prefix = %s\n", globals.file_prefix);

	switch_xml_free(xml);

	return SWITCH_STATUS_SUCCESS;
}
开发者ID:lzcykevin,项目名称:FreeSWITCH,代码行数:44,代码来源:rayo_fax_components.c

示例12: SWITCH_DECLARE

SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, const char *todup, const char *file, const char *func, int line)
{
	char *duped = NULL;
	switch_size_t len;
	switch_assert(pool != NULL);

	if (!todup) {
		return NULL;
	}

	if (zstr(todup)) {
		return SWITCH_BLANK_STRING;
	}
#ifdef LOCK_MORE
#ifdef USE_MEM_LOCK
	switch_mutex_lock(memory_manager.mem_lock);
#endif
#endif

	len = strlen(todup) + 1;

#ifdef DEBUG_ALLOC
	if (len > 500)
		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Strdup Allocate %s %d\n", 
						  (void *) pool, apr_pool_tag(pool, NULL), (int)len);
#endif

	duped = apr_pstrmemdup(pool, todup, len);
	switch_assert(duped != NULL);

#ifdef LOCK_MORE
#ifdef USE_MEM_LOCK
	switch_mutex_unlock(memory_manager.mem_lock);
#endif
#endif

	return duped;
}
开发者ID:odmanV2,项目名称:freecenter,代码行数:38,代码来源:switch_core_memory.c

示例13: conference_data_event_handler

void conference_data_event_handler(switch_event_t *event)
{
	switch_event_t *revent;
	char *name = switch_event_get_header(event, "conference-name");
	char *domain = switch_event_get_header(event, "conference-domain");
	conference_obj_t *conference = NULL;
	char *body = NULL;

	if (!zstr(name) && (conference = conference_find(name, domain))) {
		if (conference_utils_test_flag(conference, CFLAG_RFC4579)) {
			switch_event_dup(&revent, event);
			revent->event_id = SWITCH_EVENT_CONFERENCE_DATA;
			revent->flags |= EF_UNIQ_HEADERS;
			switch_event_add_header(revent, SWITCH_STACK_TOP, "Event-Name", "CONFERENCE_DATA");

			body = conference_cdr_rfc4579_render(conference, event, revent);
			switch_event_add_body(revent, "%s", body);
			switch_event_fire(&revent);
			switch_safe_free(body);
		}
		switch_thread_rwlock_unlock(conference->rwlock);
	}
}
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:23,代码来源:conference_event.c

示例14: utils_recover

switch_status_t utils_recover(char *profile_name)
{
    char arg[128];
    switch_stream_handle_t mystream = { 0 };

    if (!zstr(profile_name)) {
        switch_snprintf(arg, sizeof(arg),"profile %s recover",profile_name);
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"sofia %s\n", arg);
        SWITCH_STANDARD_STREAM(mystream);

        if (switch_api_execute("sofia", arg, NULL, &mystream) != SWITCH_STATUS_SUCCESS) {
            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"cannot recover profile %s\n", profile_name);
            return SWITCH_STATUS_FALSE;
        }
        switch_safe_free(mystream.data);
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"profile %s recovered\n", profile_name);
        return SWITCH_STATUS_SUCCESS;
    } else {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"Invalid profile name\n");
        return SWITCH_STATUS_FALSE;
    }
    return SWITCH_STATUS_FALSE;
}
开发者ID:VoiSmart,项目名称:freeswitch-mod-cpg,代码行数:23,代码来源:cpg_utils.c

示例15: SWITCH_DECLARE

SWITCH_DECLARE(int) EventConsumer::bind(const char *event_name, const char *subclass_name)
{
	switch_event_types_t event_id = SWITCH_EVENT_CUSTOM;
	switch_name_event(event_name, &event_id);

	if (!ready) {
		return 0;
	}


	if (zstr(subclass_name)) {
		subclass_name = NULL;
	}
	
	if (node_index <= SWITCH_EVENT_ALL && 
		switch_event_bind_removable(__FILE__, event_id, subclass_name, event_handler, this, &enodes[node_index]) == SWITCH_STATUS_SUCCESS) {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "bound to %s %s\n", event_name, switch_str_nil(subclass_name));
		node_index++;
		return 1;
	} else {
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot bind to %s %s\n", event_name, switch_str_nil(subclass_name));
		return 0;
	}
}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:24,代码来源:switch_cpp.cpp


注:本文中的zstr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。