ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
label.c
Go to the documentation of this file.
1 
10 #include "label.h"
11 #include "tree.h"
12 #include "hashfn.h"
13 
14 Label str2label(char* s) {
15  return hashfn(s,strlen(s));
16 }
17 
18 void _labelSet(LabelTable *table,Label l,int *path){
19  table_elem *e;
20 
21  e = malloc(sizeof(struct table_elem)+(_t_path_depth(path)*sizeof(int)));
22  e->label = l;
23  _t_pathcpy(&e->path_s,path);
24 
25  HASH_ADD_INT(*table,label,e);
26 }
27 
28 int *_labelGet(LabelTable *table, Label l){
29  table_elem *e = 0;
30  HASH_FIND_INT( *table, &l, e );
31  if (e) return &e->path_s;
32  return 0;
33 }
34 
35 void labelSet(LabelTable *table, char *s,int *path) {
36  _labelSet(table,str2label(s),path);
37 }
38 
39 int *labelGet(LabelTable *table, char *s) {
40  return _labelGet(table, str2label(s));
41 }
42 
44 void _labelDelete(LabelTable *table,Label l) {
45 }
46 void lableDelete(LabelTable *table,char *s) {
47 }
48 
49 void lableTableFree(LabelTable *table) {
50  table_elem *cur,*tmp;
51  HASH_ITER(hh, *table, cur, tmp) {
52  HASH_DEL(*table,cur); /* delete; cur advances to next */
53  free(cur);
54  }
55 }
int _t_path_depth(int *p)
Definition: tree.c:1365
semantic trees header file
int path_s
first int of the path to the labeled item in the Receptor tree
Definition: ceptr_types.h:151
void _t_pathcpy(int *dst_p, int *src_p)
Definition: tree.c:1424
Label label
semantic key
Definition: ceptr_types.h:150
Label tables map human readable text strings to parts of semantic trees.