reshash.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef RESHASH_H
  13. #define RESHASH_H
  14. /**********************************************************************
  15. Hash --> Tree --> ValueList
  16. ValueList: language per item, each list associated with one key
  17. Tree: contains multiple keys
  18. Hash: Based on hash to decide withc tree to use for lookup
  19. ***********************************************************************/
  20. /*
  21. Valuelist, each item contains
  22. language: ISO two or four letters
  23. value: UTF-8 encoding strings
  24. */
  25. typedef struct ValueNode {
  26. char *language;
  27. char *value;
  28. struct ValueNode *next;
  29. } ValueNode;
  30. /*
  31. Current: BINARY TREE
  32. Future: balanced tree for high search performance
  33. */
  34. typedef struct TreeNodeStruct {
  35. ValueNode *vlist;
  36. char *key;
  37. char *value;
  38. struct TreeNodeStruct *left;
  39. struct TreeNodeStruct *right;
  40. } TreeNode;
  41. typedef struct ResHash {
  42. char *name; /* name of hash table */
  43. TreeNode *treelist;
  44. } ResHash;
  45. ResHash * ResHashCreate(char * name);
  46. int ResHashAdd(ResHash *res, char *key, char *value, char *language);
  47. const char *ResHashSearch(ResHash *res, char *key, char *language);
  48. void ResHashDestroy(ResHash *res);
  49. #endif