util  tbl.c at [37cc6dd034]

File clib/tbl.c artifact 92768be859 part of check-in 37cc6dd034


/* [ʞ] tbl.c
 *  ~ lexi hale <lexi@hale.su>
 *  ? simple table-scanning function to make
 *    parsing easier */

struct tblrow { tbl_word_type val; const char* str; };

tbl_error_type tblget(size_t stacksz, const struct tblrow* haystack, const char* needle, tbl_word_type* val) {
	for (size_t i = 0; i<stacksz; ++i) {
		if (strcmp(haystack[i].str, needle) == ok) {
			*val = haystack[i].val;
			return tbl_ok;
		}
	}
	return tbl_error;
}