My Project
symbol.h
Go to the documentation of this file.
1 #ifndef __SYMBOL_H__
2 #define __SYMBOL_H__
3 
4 /*
5  * "Copyright (c) 2014 by Fritz Sieker."
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation for any purpose, without fee, and without written
9  * agreement is hereby granted, provided that the above copyright notice
10  * and the following two paragraphs appear in all copies of this software.
11  *
12  * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
13  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
14  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR
15  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16  *
17  * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
20  * BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
21  * UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
22  */
23 
36 #define SYM_TAB_SIZE 997
37 
44 typedef struct sym_table sym_table_t;
45 
50 typedef struct symbol {
51  char* name;
52  int addr;
53 } symbol_t;
54 
64 int symbol_add (sym_table_t* symTab, const char* name, int addr);
65 
72 char* symbol_find_by_addr (sym_table_t* symTab, int addr);
73 
80 symbol_t* symbol_find_by_name (sym_table_t* symTab, const char* name);
81 
90 sym_table_t* symbol_init (int table_size, int lookup_by_addr);
91 
97 void symbol_reset (sym_table_t* symTab);
98 
109 struct node* symbol_search (sym_table_t* symTab, const char* name, int* hash, int* index);
110 
116 void symbol_term(sym_table_t* symTab);
117 
136 typedef void (*iterate_fnc_t)(symbol_t* sym, void* data);
137 
145 void symbol_iterate (sym_table_t* symTab, iterate_fnc_t fnc, void* data);
146 
147 #endif /* __SYMBOL_H__ */
148 
Definition: symbol.c:28
int addr
Definition: symbol.h:52
struct node * symbol_search(sym_table_t *symTab, const char *name, int *hash, int *index)
Definition: symbol.c:77
void symbol_iterate(sym_table_t *symTab, iterate_fnc_t fnc, void *data)
Definition: symbol.c:93
char * name
Definition: symbol.h:51
struct symbol symbol_t
void(* iterate_fnc_t)(symbol_t *sym, void *data)
Definition: symbol.h:136
int hash
Definition: symbol.c:30
sym_table_t * symbol_init(int table_size, int lookup_by_addr)
Definition: symbol.c:59
char * symbol_find_by_addr(sym_table_t *symTab, int addr)
Definition: symbol.c:88
symbol_t * symbol_find_by_name(sym_table_t *symTab, const char *name)
Definition: symbol.c:83
Definition: symbol.c:35
Definition: symbol.h:50
void symbol_reset(sym_table_t *symTab)
Definition: symbol.c:68
int symbol_add(sym_table_t *symTab, const char *name, int addr)
Definition: symbol.c:72
void symbol_term(sym_table_t *symTab)
Definition: symbol.c:64