forked from ossec/ossec-hids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash_op.h
57 lines (43 loc) · 1.42 KB
/
hash_op.h
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
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation.
*/
/* Common API for dealing with hash operations */
#ifndef _OS_HASHOP
#define _OS_HASHOP
/* Node structure */
typedef struct _OSHashNode {
struct _OSHashNode *next;
char *key;
void *data;
} OSHashNode;
typedef struct _OSHash {
unsigned int rows;
unsigned int initial_seed;
unsigned int constant;
OSHashNode **table;
} OSHash;
/* Prototypes */
/* Create and initialize hash */
OSHash *OSHash_Create(void);
/* Free the memory used by the hash */
void *OSHash_Free(OSHash *self) __attribute__((nonnull));
/* Returns 0 on error
* Returns 1 on duplicated key (not added)
* Returns 2 on success
* Key must not be NULL
*/
int OSHash_Add(OSHash *hash, const char *key, void *data) __attribute__((nonnull(1, 2)));
int OSHash_Update(OSHash *hash, const char *key, void *data) __attribute__((nonnull(1, 2)));
void *OSHash_Delete(OSHash *self, const char *key) __attribute__((nonnull));
/* Returns NULL on error (key not found)
* Returns the key otherwise
* Key must not be NULL
*/
void *OSHash_Get(const OSHash *self, const char *key) __attribute__((nonnull));
int OSHash_setSize(OSHash *self, unsigned int new_size) __attribute__((nonnull));
#endif