// // Created by xemon on 01.11.22. // #include #include #include "XfcProtTable.h" void XfcProtTable_Init(tXfcProtTable *env, tXfcProtProcessor *allocatedMem, uint16_t memLimit) { env->limit = memLimit; env->items = allocatedMem; env->count = 0; memset(env->items, 0, env->limit * sizeof(tXfcProtProcessor)); } bool XfcProtTable_Add( tXfcProtTable *env, char *staticStringTextId, uint8_t textIdLen, tXfcProtMethod method, void *args ) { if (env->limit <= env->count) { return false; } tXfcProtProcessor *proc = env->items + env->count; proc->textId = staticStringTextId; proc->textIdLen = textIdLen; proc->args = args; proc->process = method; ++env->count; return true; } tXfcProtProcessor *XfcProtTable_GetForId(tXfcProtTable *env, uint16_t id) { if ((id < env->count) && env->items[id].process) { return &env->items[id]; } else { return NULL; } }