language_hashmap.h 926 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __LANGUAGE_HASHMAP_H
  2. #define __LANGUAGE_HASHMAP_H
  3. #define MAX_LEN 1024
  4. #define DELIMITER "|"
  5. enum {
  6. HASH_OK=0,
  7. HASH_REPEAT=-1,
  8. HASH_OVERFLOW=-2,
  9. HASH_MALLOC_FAIL=-3,
  10. };
  11. typedef struct HashEntry
  12. {
  13. char *key;
  14. char **value;
  15. int valueLength;
  16. struct HashEntry *next;
  17. } HashEntry;
  18. typedef struct HashTable
  19. {
  20. HashEntry **ptable;
  21. int size;
  22. } HashTable;
  23. unsigned int _hash(HashTable *table,const char *key) ;
  24. HashTable *create_hash_table(int size);
  25. // 在哈希表中插入键值对
  26. int insert_Newhash(HashTable *table, const char *key, const char value[][64],int valuelens);
  27. // 在哈希表中查找键对应的值
  28. const HashEntry*find_hash(HashTable *table, const char *key);
  29. // 释放哈希表占用的内存
  30. void free_hash_table(HashTable *table);
  31. // 替换管包裹字符
  32. void replace_sequences(char *str, HashTable *table);
  33. #endif