static bool param_first(uint8_t limit, const uint8_t *payload) { hash_init(); hash_merge_progmem(image_secret, sizeof(image_secret)); hash_merge(payload, PAYLOAD); memcpy(&tmp, payload, sizeof(tmp)); failed = 0; return 1; }
static bool param_more(uint8_t seq, uint8_t limit, const uint8_t *payload) { switch (limit-seq) { default: hash_merge(payload, PAYLOAD); break; case 1: hash_end(); failed = !hash_eq(payload, PAYLOAD, 0); break; case 0: if (!hash_eq(payload, PAYLOAD, PAYLOAD)) failed = 1; if (failed) return 0; new_params(); break; } return 1; }
/** * Return a hash table pointer by its name. * Overwrite existing table if there was one sharing that name, only * if both tables have the same elements type * @param table * @param name * @return */ int hash_register(hash_t *table, char *name) { hash_t *h; int sz; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); h = hash_get(hash_hash, name); if (h) { if (h->type == ASPECT_TYPE_UNKNOW) h->type = table->type; if (h->type != table->type) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Incompatible hash tables", -1); if (h->elmnbr) h = hash_empty(name); hash_merge(h, table); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(hash_t), -1); sz = (table->size > table->elmnbr ? table->size : table->elmnbr); hash_init(h, name, sz, table->type); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); }