void init_factoids() { char line[512]; strmap_init(&factoids); factoid_file = fopen("factoids", "r"); if (factoid_file == NULL) return; while (fgets(line, 512, factoid_file)) { strmap_insert(&factoids, line, line + strlen(line) + 1); } fclose(factoid_file); }
char *factoid_set(array *args, struct irc_message *msg) { size_t i; char value[512]; char *s; if (array_count(args) < 2) return NULL; join_string(args, 1, value, " "); /* value[0] = 0; for (i = 1; i != array_count(args); ++i) { s = *(char**)array_at(args, i); strcat(value, s); strcat(value, " "); } */ strmap_insert(&factoids, *(char**)array_at(args, 0), value); return NULL; }
void push_label(const char* name) { Function* curf = cur_func(); // check if label already exists Label** foundl = strmap_find(curf->labels, name); if(foundl != NULL) yyerrerf("A label with the name '%s' has already been defined in function '%s'.", name, curf->name); /*llist_foreach(LabelList, curf->labels, l) { if(strcmp(l->name, name) == 0) { } }*/ Label* l = new_label(name); curlabels = llist_prepend(l, curlabels); strmap_insert(curf->labels, name, l); //curf->labels = llist_prepend(l, curf->labels); }