dict.h 465 B

123456789101112131415161718192021
  1. #ifndef CCAN_TOKENIZER_DICT_H
  2. #define CCAN_TOKENIZER_DICT_H
  3. #include <stdint.h>
  4. #include <ccan/talloc/talloc.h>
  5. //needed for freeing the struct dict*
  6. struct dict_entry {
  7. int id;
  8. const char *str;
  9. };
  10. struct dict {
  11. struct dict_entry *zero;
  12. struct dict_entry *by_first_letter[256];
  13. };
  14. struct dict *dict_build(void *ctx, const struct dict_entry *entries, size_t count);
  15. struct dict_entry *dict_lookup(struct dict *dict, const char **sp, const char *e);
  16. #endif