示例#1
0
文件: syslog.c 项目: Akheon23/lms
tscript_value * tscript_ext_syslog_syslog(tscript_value *arg)
{
	tscript_value *log;
	int n = LOG_INFO;

	if( arg->type == TSCRIPT_TYPE_ARRAY )
	{
		tscript_value *index, *level;
		
		index = tscript_value_create_number(0);
		log = tscript_value_convert_to_string(tscript_value_dereference(
			*tscript_value_array_item_ref(&arg, index)));
		tscript_value_free(index);

		index = tscript_value_create_number(1);
		level = tscript_value_convert_to_number(tscript_value_dereference(
			*tscript_value_array_item_ref(&arg, index)));
		tscript_value_free(index);
		
		n = tscript_value_as_number(level);

		tscript_value_free(level);
	}
	else
	{
		log = tscript_value_convert_to_string(arg);
	}

	syslog(n, "%s", tscript_value_as_string(log));

	tscript_value_free(log);

	return tscript_value_create_null();
}
示例#2
0
文件: net.c 项目: Pinki18/lms
tscript_value * tscript_ext_net_long2ip(tscript_value *arg)
{
	tscript_value *res;
	unsigned long n;

	n = strtoul(tscript_value_as_string(tscript_value_convert_to_string(arg)), NULL, 0);
	res = tscript_value_create_string(long2ip(n));
	
	return res;
}
示例#3
0
文件: net.c 项目: Pinki18/lms
tscript_value * tscript_ext_net_ip2long(tscript_value *arg)
{
	tscript_value *res;
	char *tmp;
	
	asprintf(&tmp, "%lu", ip2long(tscript_value_as_string(tscript_value_convert_to_string(arg))));
	res = tscript_value_create(TSCRIPT_TYPE_NUMBER, tmp);
	free(tmp);
	
	return res;
}
示例#4
0
文件: net.c 项目: Pinki18/lms
tscript_value * tscript_ext_net_mask2prefix(tscript_value *arg)
{
	return tscript_value_create_number(mask2prefix(
		tscript_value_as_string(tscript_value_convert_to_string(arg))));
}