• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pbx_builtin_setvar_helper函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: tryexec_exec

static int tryexec_exec(struct ast_channel *chan, void *data)
{
	int res=0;
	struct ast_module_user *u;
	char *s, *appname, *endargs, args[MAXRESULT] = "";
	struct ast_app *app;

	u = ast_module_user_add(chan);

	/* Check and parse arguments */
	if (data) {
		s = ast_strdupa(data);
		appname = strsep(&s, "(");
		if (s) {
			endargs = strrchr(s, ')');
			if (endargs)
				*endargs = '\0';
			pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
		}
		if (appname) {
			app = pbx_findapp(appname);
			if (app) {
				res = pbx_exec(chan, app, args);
				pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
			} else {
				ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
				pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
			}
		}
	}

	ast_module_user_remove(u);
	return 0;
}
开发者ID:commshare,项目名称:squeezeterisk,代码行数:34,代码来源:app_exec.c


示例2: speech_create

/*! \brief SpeechCreate() Dialplan Application */
static int speech_create(struct ast_channel *chan, const char *data)
{
	struct ast_speech *speech = NULL;
	struct ast_datastore *datastore = NULL;

	/* Request a speech object */
	speech = ast_speech_new(data, ast_channel_nativeformats(chan));
	if (speech == NULL) {
		/* Not available */
		pbx_builtin_setvar_helper(chan, "ERROR", "1");
		return 0;
	}

	datastore = ast_datastore_alloc(&speech_datastore, NULL);
	if (datastore == NULL) {
		ast_speech_destroy(speech);
		pbx_builtin_setvar_helper(chan, "ERROR", "1");
		return 0;
	}
	pbx_builtin_setvar_helper(chan, "ERROR", NULL);
	datastore->data = speech;
	ast_channel_lock(chan);
	ast_channel_datastore_add(chan, datastore);
	ast_channel_unlock(chan);

	return 0;
}
开发者ID:huangjingpei,项目名称:asterisk,代码行数:28,代码来源:app_speech_utils.c


示例3: speech_create

/*! \brief SpeechCreate() Dialplan Application */
static int speech_create(struct ast_channel *chan, void *data)
{
	struct ast_module_user *u = NULL;
	struct ast_speech *speech = NULL;
	struct ast_datastore *datastore = NULL;

	u = ast_module_user_add(chan);

	/* Request a speech object */
	speech = ast_speech_new(data, AST_FORMAT_SLINEAR);
	if (speech == NULL) {
		/* Not available */
		pbx_builtin_setvar_helper(chan, "ERROR", "1");
		ast_module_user_remove(u);
		return 0;
	}

	datastore = ast_channel_datastore_alloc(&speech_datastore, NULL);
	if (datastore == NULL) {
		ast_speech_destroy(speech);
		pbx_builtin_setvar_helper(chan, "ERROR", "1");
		ast_module_user_remove(u);
		return 0;
	}
	datastore->data = speech;
	ast_channel_datastore_add(chan, datastore);

	pbx_builtin_setvar_helper(chan, "ERROR", NULL);

	ast_module_user_remove(u);

	return 0;
}
开发者ID:pjalbrecht,项目名称:asterisk,代码行数:34,代码来源:app_speech_utils.c


示例4: tryexec_exec

static int tryexec_exec(struct ast_channel *chan, void *data)
{
	int res = 0;
	char *s, *appname, *endargs, args[MAXRESULT];
	struct ast_app *app;

	if (ast_strlen_zero(data))
		return 0;

	s = ast_strdupa(data);
	args[0] = 0;
	appname = strsep(&s, "(");
	if (s) {
		endargs = strrchr(s, ')');
		if (endargs)
			*endargs = '\0';
		pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
	}
	if (appname) {
		app = pbx_findapp(appname);
		if (app) {
			res = pbx_exec(chan, app, args);
			pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
		} else {
			ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
			pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
		}
	}

	return 0;
}
开发者ID:nicwolff,项目名称:asterisk-agi-mp3,代码行数:31,代码来源:app_exec.c


示例5: steal_channel

static int steal_channel(struct ast_channel *chan, void *pattern)
{
	int ret = 0;
	struct ast_module_user *u;
	struct ast_channel *cur;
	u = ast_module_user_add(chan);
	cur = find_matching_channel(chan, pattern, AST_STATE_UP);
	if (cur) {
		ast_verbose(VERBOSE_PREFIX_3 
			"Channel %s stole channel %s\n",
			chan->name, cur->name);
		pbx_builtin_setvar_helper(chan, "STEAL_CHANNEL", cur->name);
		if (chan->_state != AST_STATE_UP) {
			ast_answer(chan);
		}
		if (cur->_bridge) {
			if (!ast_mutex_lock(&cur->_bridge->lock)) {
				ast_moh_stop(cur->_bridge);
				ast_mutex_unlock(&cur->_bridge->lock);
			}
		}
			
		if (ast_channel_masquerade(cur, chan)) {
			ast_log(LOG_ERROR, "unable to masquerade\n");
			ret = -1;
		}
		ast_mutex_unlock(&cur->lock);
		ast_mutex_unlock(&chan->lock);
	} else {
		pbx_builtin_setvar_helper(chan, "STEAL_CHANNEL", "");
	}
	ast_module_user_remove(u);
	return(ret);
}
开发者ID:sipwise,项目名称:asterisk,代码行数:34,代码来源:app_pickup2.c


示例6: reload_module

static int reload_module(void)
{
	struct ast_flags flags = { CONFIG_FLAG_NOREALTIME };
	struct ast_config *cfg;
	struct ast_variable *var;

	if (!(cfg = ast_config_load("res_curl.conf", flags))) {
		return 0;
	} else if (cfg == CONFIG_STATUS_FILEINVALID) {
		ast_log(LOG_WARNING, "res_curl.conf could not be parsed!\n");
		return 0;
	}

	if (!(var = ast_variable_browse(cfg, "globals")) && !(var = ast_variable_browse(cfg, "global")) && !(var = ast_variable_browse(cfg, "general"))) {
		ast_log(LOG_WARNING, "[globals] not found in res_curl.conf\n");
		ast_config_destroy(cfg);
		return 0;
	}

	for (; var; var = var->next) {
		if (strncmp(var->name, "CURLOPT(", 8)) {
			char name[256];
			snprintf(name, sizeof(name), "CURLOPT(%s)", var->name);
			pbx_builtin_setvar_helper(NULL, name, var->value);
		} else {
			pbx_builtin_setvar_helper(NULL, var->name, var->value);
		}
	}
	ast_config_destroy(cfg);
	return 0;
}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:31,代码来源:res_config_curl.c


示例7: tryexec_exec

static int tryexec_exec(struct ast_channel *chan, const char *data)
{
	int res = 0;
	char *s, *appname, *endargs;
	struct ast_app *app;
	struct ast_str *args = NULL;

	if (ast_strlen_zero(data))
		return 0;

	s = ast_strdupa(data);
	appname = strsep(&s, "(");
	if (s) {
		endargs = strrchr(s, ')');
		if (endargs)
			*endargs = '\0';
		if ((args = ast_str_create(16))) {
			ast_str_substitute_variables(&args, 0, chan, s);
		}
	}
	if (appname) {
		app = pbx_findapp(appname);
		if (app) {
			res = pbx_exec(chan, app, args ? ast_str_buffer(args) : NULL);
			pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
		} else {
			ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
			pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
		}
	}

	ast_free(args);
	return 0;
}
开发者ID:GGGO,项目名称:asterisk,代码行数:34,代码来源:app_exec.c


示例8: sendtext_exec

static int sendtext_exec(struct ast_channel *chan, const char *data)
{
	char *status = "UNSUPPORTED";
	struct ast_str *str;

	/* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to
	 * send a zero-length message. */
	if (!data) {
		ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
		return -1;
	}

	if (!(str = ast_str_alloca(strlen(data) + 1))) {
		return -1;
	}

	ast_str_get_encoded_str(&str, -1, data);

	ast_channel_lock(chan);
	if (!chan->tech->send_text) {
		ast_channel_unlock(chan);
		/* Does not support transport */
		pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
		return 0;
	}
	status = "FAILURE";
	if (!ast_sendtext(chan, ast_str_buffer(str))) {
		status = "SUCCESS";
	}
	ast_channel_unlock(chan);
	pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
	return 0;
}
开发者ID:mtulio,项目名称:mtulio,代码行数:33,代码来源:app_sendtext.c


示例9: waituntil_exec

static int waituntil_exec(struct ast_channel *chan, void *data)
{
	int res;
	double fraction;
	struct timeval future = { 0, };
	struct timeval tv = ast_tvnow();
	int msec;

	if (ast_strlen_zero(data)) {
		ast_log(LOG_WARNING, "WaitUntil requires an argument(epoch)\n");
		pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE");
		return 0;
	}

	if (sscanf(data, "%ld%lf", (long *)&future.tv_sec, &fraction) == 0) {
		ast_log(LOG_WARNING, "WaitUntil called with non-numeric argument\n");
		pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE");
		return 0;
	}

	future.tv_usec = fraction * 1000000;

	if ((msec = ast_tvdiff_ms(future, tv)) < 0) {
		ast_log(LOG_NOTICE, "WaitUntil called in the past (now %ld, arg %ld)\n", (long)tv.tv_sec, (long)future.tv_sec);
		pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "PAST");
		return 0;
	}

	if ((res = ast_safe_sleep(chan, msec)))
		pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "HANGUP");
	else
		pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "OK");

	return res;
}
开发者ID:nicwolff,项目名称:asterisk-agi-mp3,代码行数:35,代码来源:app_waituntil.c


示例10: transmit

static int transmit(fax_session *s)
{
	int res = 0;

	/* Clear all channel variables which to be set by the application.
	   Pre-set status to error so in case of any problems we can just leave */
	pbx_builtin_setvar_helper(s->chan, "FAXSTATUS", "FAILED"); 
	pbx_builtin_setvar_helper(s->chan, "FAXERROR", "Channel problems"); 

	pbx_builtin_setvar_helper(s->chan, "FAXMODE", NULL);
	pbx_builtin_setvar_helper(s->chan, "REMOTESTATIONID", NULL);
	pbx_builtin_setvar_helper(s->chan, "FAXPAGES", "0");
	pbx_builtin_setvar_helper(s->chan, "FAXRESOLUTION", NULL);
	pbx_builtin_setvar_helper(s->chan, "FAXBITRATE", NULL); 

	if (ast_channel_state(s->chan) != AST_STATE_UP) {
		/* Shouldn't need this, but checking to see if channel is already answered
		 * Theoretically asterisk should already have answered before running the app */
		res = ast_answer(s->chan);
		if (res) {
			ast_log(LOG_WARNING, "Could not answer channel '%s'\n", ast_channel_name(s->chan));
			return res;
		}
	}

	s->t38state = ast_channel_get_t38_state(s->chan);
	if (s->t38state != T38_STATE_NEGOTIATED) {
		/* T38 is not negotiated on the channel yet. First start regular transmission. If it switches to T38, follow */	
		pbx_builtin_setvar_helper(s->chan, "FAXMODE", "audio"); 
		res = transmit_audio(s);
		if (res > 0) {
			/* transmit_audio reports switchover to T38. Update t38state */
			s->t38state = ast_channel_get_t38_state(s->chan);
			if (s->t38state != T38_STATE_NEGOTIATED) {
				ast_log(LOG_ERROR, "Audio loop reports T38 switchover but t38state != T38_STATE_NEGOTIATED\n");
			}
		}
	}

	if (s->t38state == T38_STATE_NEGOTIATED) {
		pbx_builtin_setvar_helper(s->chan, "FAXMODE", "T38"); 
		res = transmit_t38(s);
	}

	if (res) {
		ast_log(LOG_WARNING, "Transmission error\n");
		res = -1;
	} else if (s->finished < 0) {
		ast_log(LOG_WARNING, "Transmission failed\n");
	} else if (s->finished > 0) {
		ast_debug(1, "Transmission finished Ok\n");
	}

	return res;
}
开发者ID:bugrahantopall,项目名称:asterisk,代码行数:55,代码来源:app_fax.c


示例11: system_exec_helper

static int system_exec_helper(struct ast_channel *chan, const char *data, int failmode)
{
	int res = 0;
	struct ast_str *buf = ast_str_thread_get(&buf_buf, 16);
	char *cbuf;

	if (ast_strlen_zero(data)) {
		ast_log(LOG_WARNING, "System requires an argument(command)\n");
		pbx_builtin_setvar_helper(chan, chanvar, "FAILURE");
		return failmode;
	}

	ast_autoservice_start(chan);

	/* Do our thing here */
	ast_str_get_encoded_str(&buf, 0, (char *) data);
	cbuf = ast_str_buffer(buf);

	if (strchr("\"'", cbuf[0]) && cbuf[ast_str_strlen(buf) - 1] == cbuf[0]) {
		cbuf[ast_str_strlen(buf) - 1] = '\0';
		cbuf++;
		ast_log(LOG_NOTICE, "It is not necessary to quote the argument to the System application.\n");
	}

	res = ast_safe_system(cbuf);

	if ((res < 0) && (errno != ECHILD)) {
		ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
		pbx_builtin_setvar_helper(chan, chanvar, "FAILURE");
		res = failmode;
	} else if (res == 127) {
		ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
		pbx_builtin_setvar_helper(chan, chanvar, "FAILURE");
		res = failmode;
	} else {
		if (res < 0) 
			res = 0;
		if (res != 0)
			pbx_builtin_setvar_helper(chan, chanvar, "APPERROR");
		else
			pbx_builtin_setvar_helper(chan, chanvar, "SUCCESS");
		res = 0;
	} 

	ast_autoservice_stop(chan);

	return res;
}
开发者ID:mtulio,项目名称:mtulio,代码行数:48,代码来源:app_system.c


示例12: cw_log

static char *function_db_exists(struct cw_channel *chan, int argc, char **argv, char *buf, size_t len)
{
	char *key;

	if (argc != 1 || !argv[0][0] || !(key = strchr(argv[0], '/'))) {
		cw_log(LOG_ERROR, "Syntax: %s\n", db_exists_func_syntax);
		return NULL;
	}

	if (len < 2) {
		cw_log(LOG_ERROR, "Out of space in return buffer\n");
		return NULL;
	}

	*(key++) = '\0';

	if (cw_db_get(argv[0], key, buf, len-1))
		buf[0] = '0';
	else {
		pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
		buf[0] = '1';
	}
	buf[1] = '\0';
	
	return buf;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:26,代码来源:func_db.c


示例13: parking_timeout_set_caller_features

/*!
 * \internal
 * \brief Setup the caller features for when that channel is dialed.
 * \since 12.0.0
 *
 * \param chan Parked channel leaving the parking lot.
 * \param cfg Parking lot configuration.
 *
 * \return Nothing
 */
static void parking_timeout_set_caller_features(struct ast_channel *chan, struct parking_lot_cfg *cfg)
{
	char features[5];
	char *pos;

	/*
	 * We are setting the callee Dial flag values because in the
	 * timeout case, the caller is who is being called back.
	 */
	pos = features;
	if (cfg->parkedcalltransfers & AST_FEATURE_FLAG_BYCALLER) {
		*pos++ = 't';
	}
	if (cfg->parkedcallreparking & AST_FEATURE_FLAG_BYCALLER) {
		*pos++ = 'k';
	}
	if (cfg->parkedcallhangup & AST_FEATURE_FLAG_BYCALLER) {
		*pos++ = 'h';
	}
	if (cfg->parkedcallrecording & AST_FEATURE_FLAG_BYCALLER) {
		*pos++ = 'x';
	}
	*pos = '\0';

	pbx_builtin_setvar_helper(chan, "BRIDGE_FEATURES", features);
}
开发者ID:adaptiman,项目名称:asterisk,代码行数:36,代码来源:parking_bridge_features.c


示例14: record_dtmf_response

/*!
 * \internal
 * \brief Used to determine what action to take when DTMF is received while recording
 * \since 13.0.0
 *
 * \param chan channel being recorded
 * \param flags option flags in use by the record application
 * \param dtmf_integer the integer value of the DTMF key received
 * \param terminator key currently set to be pressed for normal termination
 *
 * \retval 0 do not exit
 * \retval -1 do exit
 */
static int record_dtmf_response(struct ast_channel *chan, struct ast_flags *flags, int dtmf_integer, int terminator)
{
	if ((dtmf_integer == OPERATOR_KEY) &&
		(ast_test_flag(flags, OPTION_OPERATOR_EXIT))) {
		pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "OPERATOR");
		return -1;
	}

	if ((dtmf_integer == terminator) ||
		(ast_test_flag(flags, OPTION_ANY_TERMINATE))) {
		pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "DTMF");
		return -1;
	}

	return 0;
}
开发者ID:lyx2014,项目名称:Asterisk,代码行数:29,代码来源:app_record.c


示例15: lua_set_variable_value

/*!
 * \brief [lua_CFunction] Used to set the value of a variable or dialplan
 * function (for access from lua, don't call directly)
 * 
 * This function is the 'set()' function in the following example as would be
 * seen in extensions.lua.
 *
 * \code
 * channel.variable:set("value")
 * \endcode
 */
static int lua_set_variable_value(lua_State *L)
{
	const char *name, *value;
	struct ast_channel *chan;
	int autoservice;

	if (!lua_istable(L, 1)) {
		lua_pushstring(L, "User probably used '.' instead of ':' for setting a channel variable");
		return lua_error(L);
	}

	lua_getfield(L, 1, "name");
	name = ast_strdupa(lua_tostring(L, -1));
	lua_pop(L, 1);

	value = luaL_checkstring(L, 2);
	
	lua_getfield(L, LUA_REGISTRYINDEX, "channel");
	chan = lua_touserdata(L, -1);
	lua_pop(L, 1);

	lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
	autoservice = lua_toboolean(L, -1);
	lua_pop(L, 1);

	if (autoservice)
		ast_autoservice_stop(chan);

	pbx_builtin_setvar_helper(chan, name, value);
	
	if (autoservice)
		ast_autoservice_start(chan);

	return 0;
}
开发者ID:mehulsbhatt,项目名称:asterisk,代码行数:46,代码来源:pbx_lua.c


示例16: eval_exec

static int eval_exec(struct cw_channel *chan, int argc, char **argv)
{
	static int dep_warning = 0;
	char tmp[MAXRESULT];
	struct localuser *u;
	char *newvar = NULL;
	int res = 0;

	if (!dep_warning) {
		cw_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n");
		dep_warning = 1;
	}

	LOCAL_USER_ADD(u);
	
	/* Check and parse arguments */
	if (argv[0]) {
		newvar = strsep(&argv[0], "=");
		if (newvar && (newvar[0] != '\0')) {
			pbx_substitute_variables_helper(chan, argv[0], tmp, sizeof(tmp));
			pbx_builtin_setvar_helper(chan, newvar, tmp);
		}
	}

	LOCAL_USER_REMOVE(u);
	return res;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:27,代码来源:app_eval.c


示例17: eval_exec

static int eval_exec(struct ast_channel *chan, void *data)
{
	int res=0;
	struct localuser *u;
	char *s, *newvar=NULL, tmp[MAXRESULT];
	static int dep_warning = 0;

	LOCAL_USER_ADD(u);
	
	if (!dep_warning) {
		ast_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n");
		dep_warning = 1;
	}

	/* Check and parse arguments */
	if (data) {
		s = ast_strdupa((char *)data);
		if (s) {
			newvar = strsep(&s, "=");
			if (newvar && (newvar[0] != '\0')) {
				memset(tmp, 0, MAXRESULT);
				pbx_substitute_variables_helper(chan, s, tmp, MAXRESULT - 1);
				pbx_builtin_setvar_helper(chan, newvar, tmp);
			}
		} else {
			ast_log(LOG_ERROR, "Out of memory\n");
			res = -1;
		}
	}

	LOCAL_USER_REMOVE(u);
	return res;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:33,代码来源:app_eval.c


示例18: test_chan_variable

static enum ast_test_result_state test_chan_variable(struct ast_test *test,
		struct ast_channel *c, const char *varname)
{
	const char *values[] = { "one", "three", "reallylongdinosaursoundingthingwithwordsinit" };
	int i, okay = 1;
	char workspace[4096];
	struct ast_str *str = ast_str_create(16);
	struct ast_str *var = ast_str_create(16);

	ast_str_set(&var, 0, "${%s}", varname);
	for (i = 0; i < ARRAY_LEN(values); i++) {
		pbx_builtin_setvar_helper(c, varname, values[i]);
		ast_str_substitute_variables(&str, 0, c, ast_str_buffer(var));
		pbx_substitute_variables_helper(c, ast_str_buffer(var), workspace, sizeof(workspace));
		ast_test_status_update(test, "Testing '%s' . . . . . %s\n",
				ast_str_buffer(var), okay ? "passed" : "FAILED");
		if (strcmp(values[i], ast_str_buffer(str)) != 0 || strcmp(values[i], workspace) != 0) {
			ast_test_status_update(test, "%s != %s != %s\n",
					values[i], ast_str_buffer(str), workspace);
			okay = 0;
		}
	}

	ast_free(str);
	ast_free(var);

	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
}
开发者ID:Djcd,项目名称:asterisk-opus,代码行数:28,代码来源:test_substitution.c


示例19: lua_set_variable

/*!
 * \brief [lua_CFunction] Set the value of a channel variable or dialplan
 * function (for access from lua, don't call directly)
 * 
 * This function is called to set a variable or dialplan function.  It would be
 * called in the following example as would be seen in extensions.lua.
 *
 * \code
 * channel.variable = "value"
 * \endcode
 */
static int lua_set_variable(lua_State *L)
{
	struct ast_channel *chan;
	int autoservice;
	const char *name = luaL_checkstring(L, 2);
	const char *value = luaL_checkstring(L, 3);

	lua_getfield(L, LUA_REGISTRYINDEX, "channel");
	chan = lua_touserdata(L, -1);
	lua_pop(L, 1);

	lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
	autoservice = lua_toboolean(L, -1);
	lua_pop(L, 1);

	if (autoservice)
		ast_autoservice_stop(chan);

	pbx_builtin_setvar_helper(chan, name, value);
	
	if (autoservice)
		ast_autoservice_start(chan);

	return 0;
}
开发者ID:mehulsbhatt,项目名称:asterisk,代码行数:36,代码来源:pbx_lua.c


示例20: lookupblacklist_exec

static int
lookupblacklist_exec (struct ast_channel *chan, void *data)
{
	char blacklist[1];
	struct ast_module_user *u;
	int bl = 0;
	int priority_jump = 0;
	static int dep_warning = 0;

	u = ast_module_user_add(chan);

	if (!dep_warning) {
		dep_warning = 1;
		ast_log(LOG_WARNING, "LookupBlacklist is deprecated.  Please use ${BLACKLIST()} instead.\n");
	}

	if (!ast_strlen_zero(data)) {
		if (strchr(data, 'j'))
			priority_jump = 1;
	}

	if (chan->cid.cid_num) {
		if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist))) {
			if (option_verbose > 2)
				ast_log(LOG_NOTICE, "Blacklisted number %s found\n",chan->cid.cid_num);
			bl = 1;
		}
	}
	if (chan->cid.cid_name) {
		if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist))) {
			if (option_verbose > 2)
				ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",chan->cid.cid_name);
			bl = 1;
		}
	}

	if (bl) {
		if (priority_jump || ast_opt_priority_jumping) 
			ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
		pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND");
	} else
		pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "NOTFOUND");	

	ast_module_user_remove(u);

	return 0;
}
开发者ID:axiatp,项目名称:asterisk,代码行数:47,代码来源:app_lookupblacklist.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pc函数代码示例发布时间:2022-05-30
下一篇:
C++ pbx_builtin_getvar_helper函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap