4 * Copyright (c) 2010 project bchan
6 * This software is provided 'as-is', without any express or implied
7 * warranty. In no event will the authors be held liable for any damages
8 * arising from the use of this software.
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software
16 * in a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source
28 #include <bsys/queue.h>
31 #ifndef __RESIDHASH_H__
32 #define __RESIDHASH_H__
34 #ifndef RESIDHASH_BASE
35 #define RESIDHASH_BASE 10
38 typedef struct residhash_node_t_ {
48 residhash_node_t tbl[RESIDHASH_BASE];
50 typedef struct residhash_t_ residhash_t;
52 IMPORT W residhash_initialize(residhash_t *residhash);
53 IMPORT VOID residhash_finalize(residhash_t *residhash);
54 IMPORT W residhash_adddata(residhash_t *residhash, TC *idstr, W idstr_len, UW attr, COLOR color);
55 #define RESIDHASH_SEARCHDATA_NOTFOUND 0
56 #define RESIDHASH_SEARCHDATA_FOUND 1
57 IMPORT W residhash_searchdata(residhash_t *residhash, TC *idstr, W idstr_len, UW *attr, COLOR *color);
58 IMPORT VOID residhash_removedata(residhash_t *residhash, TC *idstr, W idstr_len);
59 IMPORT W residhash_datanum(residhash_t *residhash);
61 struct residhash_iterator_t_ {
62 residhash_t *residhash;
64 residhash_node_t *node;
66 typedef struct residhash_iterator_t_ residhash_iterator_t;
68 IMPORT VOID residhash_iterator_initialize(residhash_iterator_t *iter, residhash_t *target);
69 IMPORT VOID residhash_iterator_finalize(residhash_iterator_t *iter);
70 IMPORT Bool residhash_iterator_next(residhash_iterator_t *iter, TC **idstr, W *idstr_len, W *attr, W *color);