shash.h 4.1 KB

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