| 1 | /**************************************************************************** |
| 2 | * |
| 3 | * fthash.h |
| 4 | * |
| 5 | * Hashing functions (specification). |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | /* |
| 10 | * Copyright 2000 Computing Research Labs, New Mexico State University |
| 11 | * Copyright 2001-2015 |
| 12 | * Francesco Zappa Nardelli |
| 13 | * |
| 14 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 15 | * copy of this software and associated documentation files (the "Software"), |
| 16 | * to deal in the Software without restriction, including without limitation |
| 17 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 18 | * and/or sell copies of the Software, and to permit persons to whom the |
| 19 | * Software is furnished to do so, subject to the following conditions: |
| 20 | * |
| 21 | * The above copyright notice and this permission notice shall be included in |
| 22 | * all copies or substantial portions of the Software. |
| 23 | * |
| 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 27 | * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY |
| 28 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT |
| 29 | * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
| 30 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 31 | */ |
| 32 | |
| 33 | /************************************************************************** |
| 34 | * |
| 35 | * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 |
| 36 | * |
| 37 | * taken from Mark Leisher's xmbdfed package |
| 38 | * |
| 39 | */ |
| 40 | |
| 41 | |
| 42 | #ifndef FTHASH_H_ |
| 43 | #define FTHASH_H_ |
| 44 | |
| 45 | |
| 46 | #include <freetype/freetype.h> |
| 47 | |
| 48 | |
| 49 | FT_BEGIN_HEADER |
| 50 | |
| 51 | |
| 52 | typedef union FT_Hashkey_ |
| 53 | { |
| 54 | FT_Int num; |
| 55 | const char* str; |
| 56 | |
| 57 | } FT_Hashkey; |
| 58 | |
| 59 | |
| 60 | typedef struct FT_HashnodeRec_ |
| 61 | { |
| 62 | FT_Hashkey key; |
| 63 | size_t data; |
| 64 | |
| 65 | } FT_HashnodeRec; |
| 66 | |
| 67 | typedef struct FT_HashnodeRec_ *FT_Hashnode; |
| 68 | |
| 69 | |
| 70 | typedef FT_ULong |
| 71 | (*FT_Hash_LookupFunc)( FT_Hashkey* key ); |
| 72 | |
| 73 | typedef FT_Bool |
| 74 | (*FT_Hash_CompareFunc)( FT_Hashkey* a, |
| 75 | FT_Hashkey* b ); |
| 76 | |
| 77 | |
| 78 | typedef struct FT_HashRec_ |
| 79 | { |
| 80 | FT_UInt limit; |
| 81 | FT_UInt size; |
| 82 | FT_UInt used; |
| 83 | |
| 84 | FT_Hash_LookupFunc lookup; |
| 85 | FT_Hash_CompareFunc compare; |
| 86 | |
| 87 | FT_Hashnode* table; |
| 88 | |
| 89 | } FT_HashRec; |
| 90 | |
| 91 | typedef struct FT_HashRec_ *FT_Hash; |
| 92 | |
| 93 | |
| 94 | FT_Error |
| 95 | ft_hash_str_init( FT_Hash hash, |
| 96 | FT_Memory memory ); |
| 97 | |
| 98 | FT_Error |
| 99 | ft_hash_num_init( FT_Hash hash, |
| 100 | FT_Memory memory ); |
| 101 | |
| 102 | void |
| 103 | ft_hash_str_free( FT_Hash hash, |
| 104 | FT_Memory memory ); |
| 105 | |
| 106 | #define ft_hash_num_free ft_hash_str_free |
| 107 | |
| 108 | FT_Error |
| 109 | ft_hash_str_insert( const char* key, |
| 110 | size_t data, |
| 111 | FT_Hash hash, |
| 112 | FT_Memory memory ); |
| 113 | |
| 114 | FT_Error |
| 115 | ft_hash_num_insert( FT_Int num, |
| 116 | size_t data, |
| 117 | FT_Hash hash, |
| 118 | FT_Memory memory ); |
| 119 | |
| 120 | size_t* |
| 121 | ft_hash_str_lookup( const char* key, |
| 122 | FT_Hash hash ); |
| 123 | |
| 124 | size_t* |
| 125 | ft_hash_num_lookup( FT_Int num, |
| 126 | FT_Hash hash ); |
| 127 | |
| 128 | |
| 129 | FT_END_HEADER |
| 130 | |
| 131 | |
| 132 | #endif /* FTHASH_H_ */ |
| 133 | |
| 134 | |
| 135 | /* END */ |
| 136 | |