Пример #1
0
// Try to read a condition into DynaBuf and store copy pointer in
// given loopcond_t structure.
// If no condition given, NULL is written to structure.
// Call with GotByte = first interesting character
static void store_condition(loopcond_t* condition, char terminator) {
	void*	node_body;

	// write line number
	condition->line = Input_now->line_number;
	// Check for empty condition
	if(GotByte == terminator) {
		// Write NULL condition, then return
		condition->body = NULL;
		return;
	}
	// Seems as if there really *is* a condition.
	// Read UNTIL/WHILE keyword
	if(Input_read_and_lower_keyword()) {
		// Search for new tree item
		if(!Tree_easy_scan(condkey_tree, &node_body, GlobalDynaBuf)) {
			Throw_error(exception_syntax);
			condition->body = NULL;
			return;
		}
		condition->type = (enum cond_key_t) node_body;
		// Write given condition into buffer
		SKIPSPACE();
		DYNABUF_CLEAR(GlobalDynaBuf);
		Input_until_terminator(terminator);
		DynaBuf_append(GlobalDynaBuf, CHAR_EOS);// ensure terminator
		condition->body = DynaBuf_get_copy(GlobalDynaBuf);
	}
	return;
}
Пример #2
0
Файл: cpu.c Проект: Jedzia/acm3
// Try to find CPU type held in DynaBuf. Returns whether succeeded.
bool CPU_find_cpu_struct(struct cpu_t** target) {
	void*	node_body;

	if(!Tree_easy_scan(CPU_tree, &node_body, GlobalDynaBuf))
		return(FALSE);
	*target = node_body;
	return(TRUE);
}
Пример #3
0
// try to find CPU type held in DynaBuf. Returns whether succeeded.
int CPU_find_cpu_struct(struct cpu_t **target)
{
	void	*node_body;

	if (!Tree_easy_scan(CPU_tree, &node_body, GlobalDynaBuf))
		return 0;
	*target = node_body;
	return 1;
}
Пример #4
0
// lookup encoder held in DynaBuf and return its struct pointer (or NULL on failure)
const struct encoder *encoding_find(void)
{
	void	*node_body;

	// make sure tree is initialised
	if (encoder_tree == NULL)
		Tree_add_table(&encoder_tree, encoder_list);
	// perform lookup
	if (!Tree_easy_scan(encoder_tree, &node_body, GlobalDynaBuf)) {
		Throw_error("Unknown encoding.");
		return NULL;
	}

	return node_body;
}