summaryrefslogtreecommitdiffstats
path: root/lib/libsi18n/reshash.h
blob: b2b7d79722766223a25b2e55c36d7c294d8aeac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
#ifndef RESHASH_H
#define RESHASH_H
/**********************************************************************
    Hash  --> Tree --> ValueList      

    ValueList: language per item, each list associated with one key
    Tree:  contains multiple keys
    Hash:  Based on hash to decide withc tree to use for lookup

***********************************************************************/

/* 
  Valuelist, each item contains 
    language:  ISO two or four letters 
    value:     UTF-8 encoding strings
 */
typedef struct ValueNode {
	char *language;
	char *value;
    struct ValueNode *next;
} ValueNode;


/*  
  Current: BINARY TREE
  Future: balanced tree for high search performance
 */
typedef struct TreeNodeStruct {
	ValueNode *vlist;
    char *key;
	char *value;
    struct TreeNodeStruct *left;
    struct TreeNodeStruct *right;
} TreeNode;


typedef struct ResHash {
    char *name;  /* name of hash table */
    TreeNode *treelist;
} ResHash;


ResHash * ResHashCreate(char * name);
int ResHashAdd(ResHash *res, char *key, char *value, char *language);
const char *ResHashSearch(ResHash *res, char *key, char *language);
void ResHashDestroy(ResHash *res);

#endif