/usr/include/I2util/table.h is in libi2util-dev 1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | /*
** $Id: table.h 216 2012-10-16 19:57:01Z aaron $
*/
/************************************************************************
* *
* Copyright (C) 2002 *
* Internet2 *
* All Rights Reserved *
* *
************************************************************************/
/*
** File: table.h
**
** Author: Anatoly Karp
** Jeff Boote
**
** Date: Thu Apr 19 13:47:17 EDT 2002
**
** Description: Simple hash table - header file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _I2util_table_h_
#define _I2util_table_h_
#include <I2util/util.h>
typedef struct I2Table *I2Table;
typedef uint32_t I2TableDataSizeT;
/*
** This type is used to represent keys and values in a hash.
*/
typedef struct {
void *dptr;
I2TableDataSizeT dsize;
} I2Datum;
typedef int (*I2HashCmpFunc)(
I2Datum x,
I2Datum y
);
typedef I2TableDataSizeT (*I2HashFunc)(
I2Datum key
);
/*
* These are basic hash-manipulation functions.
*/
/*
* The I2HashInit function is the initialization function for a new hash.
* hint indicates a good guess as to the size of the hash.
*/
extern I2Table I2HashInit(
I2ErrHandle eh,
size_t hint, /* guess on number of elements */
I2HashCmpFunc cmp,
I2HashFunc hash
);
extern I2Boolean
I2HashFetch(
I2Table hash,
I2Datum key,
I2Datum *ret
);
/* return 0 on success */
extern int I2HashStore(
I2Table table,
I2Datum key,
I2Datum value
);
extern int
I2HashDelete(
I2Table table,
I2Datum key
);
extern void
I2HashClean(
I2Table table
);
extern I2TableDataSizeT
I2HashNumEntries(
I2Table table
);
extern void
I2HashClose(
I2Table table
);
/*
* This function will be called on every key/value pair in the hash as
* long as the function returns true. The iteration terminates when this
* function returns false.
* The app_data passed into this function is the same one that is passed
* into I2HashIterate.
*
* The hash_iterate_func currently has some limitations:
* The only modification operation that may be done on the hash during
* the iteration is delete. All others will produce errors.
* (store/close)
*/
typedef I2Boolean (*I2HashIterateFunc)(
I2Datum key,
I2Datum value,
void *app_data
);
extern void
I2HashIterate(
I2Table table,
I2HashIterateFunc ifunc,
void *app_data
);
/*
* This example shows how a hash of string key/value
* pairs can be printed using the I2HashIterate functionality:
*
* First define the fuction:
*
* I2Boolean hash_print(
* const I2Datum *key,
* I2Datum *value,
* void *app_data
* )
* {
* FILE *fp = (FILE*)app_data;
*
* fprintf(fp,"key=%s\tvalue=%s\n",key->dptr,value->dptr);
*
* return True;
* }
*
* Then later in the code after storing hash values, to print the hash:
*
* I2HashIterate(table,hash_print,(void*)stdout);
*/
#endif
|