コード例 #1
0
exp_t *
exp_symbol(char *symbol)
{
	exp_t *exp;

	/*
	 * Check definitions
	 */
	exp = sht_lookup(exp_defs, symbol);
	if (exp)
	{
		free(symbol);

		return exp;
	}

	/*
	 * Check symbols
	 */
	if (acl_symbol_lookup(symbol) == NULL)
	{
		acl_parser_error("unknown symbol \"%s\"", symbol);
	}
		
	return exp_create(EX_SYMBOL, symbol);
}
コード例 #2
0
ファイル: msgmod.c プロジェクト: badzong/mopher
msgmod_target_t
msgmod_get_target(char *id)
{
	char **p;
	int i = 0;

	for (p = msgmod_targets; *p != NULL; ++p, ++i)
	{
		if(strcasecmp(*p, id) == 0)
		{
			free(id);
			return i;
		}
	}

	acl_parser_error("bad keyword: %s", id);

	return -1;
}
コード例 #3
0
exp_t *
exp_function(char *id, exp_t *args)
{
	exp_function_t *ef;

	if (acl_function_lookup(id) == NULL)
	{
		acl_parser_error("unknown function \"%s\"", id);
	}
		
	ef = (exp_function_t *) malloc(sizeof (exp_function_t));
	if (ef == NULL)
	{
		log_sys_die(EX_OSERR, "exp_function: malloc");
	}

	ef->ef_name = id;
	ef->ef_args = args;

	return exp_create(EX_FUNCTION, ef);
}
コード例 #4
0
exp_t *
exp_operation(int operator, exp_t *op1, exp_t *op2)
{
	exp_operation_t *eo;

	eo = (exp_operation_t *) malloc(sizeof (exp_operation_t));
	if (eo == NULL)
	{
		log_sys_die(EX_OSERR, "exp_operation: malloc");
	}

	eo->eo_operator = operator;
	eo->eo_operand[0] = op1;
	eo->eo_operand[1] = op2;

	if (operator == '=' && op1->ex_type != EX_VARIABLE)
	{
		acl_parser_error("bad use of '=' operator");
	}

	return exp_create(EX_OPERATION, eo);
}
コード例 #5
0
ファイル: msgmod.c プロジェクト: badzong/mopher
msgmod_t *
msgmod_create(msgmod_mod_t mod, msgmod_target_t target, ...)
{
	msgmod_t *mm;
	va_list ap;
	exp_t *exp;

	mm = (msgmod_t *) malloc(sizeof (msgmod_t));
	if (mm == NULL)
	{
		log_sys_die(EX_OSERR, "msgmod_create: malloc");
	}

	mm->mm_callback = msgmod_get_callback(mod, target);
	if (mm->mm_callback == NULL)
	{
		acl_parser_error("syntax error (msgmod callback)");

		// Not reached.
		return NULL;
	}
	
	mm->mm_args = ll_create();
	if (mm->mm_args == NULL)
	{
		log_die(EX_SOFTWARE, "msgmod_create: ll_create failed");
	}

	va_start(ap, target);
	while ((exp = va_arg(ap, exp_t *)))
	{
		if (LL_INSERT(mm->mm_args, exp) == -1)
		{
			log_die(EX_SOFTWARE, "msgmod_create: LL_INSERT failed");
		}
	}

	return mm;
}