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-2016 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 
62 int symbol_add (sym_table_t* symTab, const char* name, int addr);
63 
70 char* symbol_find_by_addr (sym_table_t* symTab, int addr);
71 
82 symbol_t* symbol_find_by_name (sym_table_t* symTab, const char* name);
83 
92 sym_table_t* symbol_init (int table_size);
93 
99 void symbol_reset (sym_table_t* symTab);
100 
111 struct node* symbol_search (sym_table_t* symTab, const char* name, int* hash, int* index);
112 
118 void symbol_term(sym_table_t* symTab);
119 
140 typedef void (*iterate_fnc_t)(symbol_t* sym, void* data);
141 
149 void symbol_iterate (sym_table_t* symTab, iterate_fnc_t fnc, void* data);
150 
156 void symbol_remove_by_addr (sym_table_t* symTab, int addr1, int addr2);
157 
158 #endif /* __SYMBOL_H__ */
159 
sym_table_t * symbol_init(int table_size)
Definition: symbol.c:59
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
void symbol_remove_by_addr(sym_table_t *symTab, int addr1, int addr2)
Definition: symbol.c:97
char * name
Definition: symbol.h:51
struct symbol symbol_t
void(* iterate_fnc_t)(symbol_t *sym, void *data)
Definition: symbol.h:140
int hash
Definition: symbol.c:30
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