]> git.karo-electronics.de Git - mdnsd.git/blob - shash.h
Add futher files to .gitignore
[mdnsd.git] / shash.h
1 #ifndef _SHASH_H_
2 #define _SHASH_H_
3
4 /*
5  * Copyright (c) 1998-1999 Jeremie Miller <jer@jabber.org>
6  * Copyright (C) 2013 Ole Reinhardt <ole.reinhardt@embedded-it.de>
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the copyright holders nor the names of
20  *    contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
30  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
33  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * For additional information see http://www.ethernut.de/
37  *
38  */
39
40 /* This code is based on
41  * Based on BSD licensed mdnsd implementation by Jer <jer@jabber.org>
42  * http://dotlocal.org/mdnsd/
43  *
44  * Unfortunately this site is now longer alive. You can still find it at:
45  * http://web.archive.org/web/20080705131510/http://dotlocal.org/mdnsd/
46  *
47  * mdnsd - embeddable Multicast DNS Daemon
48  * =======================================
49  *
50  * "mdnsd" is a very lightweight, simple, portable, and easy to integrate
51  * open source implementation of Multicast DNS (part of Zeroconf, also called
52  * Rendezvous by Apple) for developers. It supports both acting as a Query and
53  * a Responder, allowing any software to participate fully on the .localnetwork
54  * just by including a few files and calling a few functions.  All of the
55  * complexity of handling the Multicast DNS retransmit timing, duplicate
56  * suppression, probing, conflict detection, and other facets of the DNS
57  * protocol is hidden behind a very simple and very easy to use interface,
58  * described in the header file. The single small c source file has almost no
59  * dependencies, and is portable to almost any embedded platform.
60  * Multiple example applications and usages are included in the download,
61  * including a simple persistent query browser and a tool to advertise .local
62  * web sites.
63  *
64  * The code is licensed under both the GPL and BSD licenses, for use in any
65  * free software or commercial application. If there is a licensing need not
66  * covered by either of those, alternative licensing is available upon request.
67  *
68  */
69
70 /*!
71  * \file include/gorp/shash.h
72  * \brief Simple hastable implementation of a string ==> void* hashtable
73  *        Minimal and efficient
74  *
75  * \verbatim
76  *
77  * $Id$
78  *
79  * \endverbatim
80  */
81
82
83 /*!
84  * \addtogroup xgSHash
85  */
86 /*@{*/
87
88
89 /* Simple hastable implementation of a string ==> void* hashtable */
90 typedef struct string_hash_table_struct *SHASH;
91
92 /* Hash creation and cleanup functions */
93 SHASH  SHashInit(int prime);
94 void SHashFree(SHASH hash);
95
96 /* Hash manipulation and query functions */
97 void SHashSet(SHASH hash, char *key, void *val);
98 void SHashStore(SHASH hash, const char *key, int key_len, void *val, int value_len);
99 void *SHashGet(SHASH hash, const char *key);
100
101 /* Routine to iterate over the hash and call a callback for each entry */
102 typedef void (*SHASH_CB)(SHASH hash, const char *key, void *val, void *arg);
103 void SHashForEach(SHASH hash, SHASH_CB cb, void *arg);
104
105 /*@}*/
106
107 #endif
108