taskrambler  0.1.9
Web server and task management solution.
hash/hash.h File Reference
#include <sys/types.h>
#include "class.h"
#include "tree.h"
+ Include dependency graph for hash/hash.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HASH_IS_EMPTY(h)   ((h)->root)
 

Functions

 CLASS (Hash)
 
void * hashAdd (Hash, void *)
 
void * hashDelete (Hash, const char *, size_t)
 
void * hashGet (Hash, const char *, size_t)
 
void * hashGetFirst (Hash)
 
void * hashDeleteByVal (Hash, unsigned long)
 
void * hashGetByVal (Hash, unsigned long)
 
void hashEach (Hash, void(*)(const void *))
 
void hashCleanup (Hash)
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file hash/hash.h.

Macro Definition Documentation

#define HASH_IS_EMPTY (   h)    ((h)->root)

Definition at line 31 of file hash/hash.h.

Function Documentation

CLASS ( Hash  )

Definition at line 33 of file hash/hash.h.

33  {
34  Tree root;
35 };
void* hashAdd ( Hash  ,
void *   
)

Definition at line 48 of file add.c.

References hashableHandleDouble(), hashAddComp(), and treeInsert().

Referenced by applicationSessionGet(), applicationSessionStart(), assetPoolGet(), configCtor(), httpParserHeader(), httpParserPostVars(), httpParserRequestVars(), httpResponse304(), httpResponse404(), httpResponse500(), httpResponseAsset(), httpResponseJson(), httpWorkerAddCommonHeader(), httpWorkerAddComputedHeader(), main(), and readMimeTypes().

49 {
50  void * found = treeInsert(&this->root, operand, hashAddComp);
51 
52  if (NULL == found) {
53  return NULL;
54  }
55 
56  if (operand != found) {
57  hashableHandleDouble(found, operand);
58  delete(operand);
59  }
60 
61  return found;
62 }
static int hashAddComp(const void *a, const void *b)
Definition: add.c:31
void * treeInsert(Tree *, const void *, TreeComp)
Definition: insert.c:29
void hashableHandleDouble(void *, void *)
Definition: hashable.c:62

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void hashCleanup ( Hash  )

Definition at line 35 of file cleanup.c.

References tDelete(), and treeDestroy().

Referenced by applicationSessionCleanup(), and hashDtor().

36 {
37  treeDestroy(&(this->root), tDelete);
38 }
static void tDelete(const void *node, const int depth)
Definition: cleanup.c:29
void treeDestroy(Tree *, TreeAction)
Definition: destroy.c:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* hashDelete ( Hash  ,
const char *  ,
size_t   
)

Definition at line 48 of file hash/delete.c.

References hashDeleteComp(), sdbm(), and treeDelete().

Referenced by applicationSessionGet(), assetPoolRelease(), and main().

49 {
50  unsigned long hash = sdbm((const unsigned char *)search, nsearch);
51  void * found = NULL;
52 
53  found = treeDelete(&(this->root), &hash, hashDeleteComp);
54 
55  return found;
56 }
unsigned long sdbm(const unsigned char *, size_t)
Definition: utils/hash.c:45
static int hashDeleteComp(const void *a, const void *b)
Definition: hash/delete.c:32
void * treeDelete(Tree *, const void *, TreeComp)
Definition: tree/delete.c:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* hashDeleteByVal ( Hash  ,
unsigned  long 
)

Definition at line 59 of file hash/delete.c.

References hashDeleteComp(), and treeDelete().

Referenced by applicationSessionStop().

60 {
61  void * found = treeDelete(&(this->root), &hash, hashDeleteComp);
62 
63  return found;
64 }
static int hashDeleteComp(const void *a, const void *b)
Definition: hash/delete.c:32
void * treeDelete(Tree *, const void *, TreeComp)
Definition: tree/delete.c:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void hashEach ( Hash  ,
void(*)(const void *)   
)

Definition at line 38 of file each.c.

References cb, treeWalk(), and walk().

Referenced by assetPoolCleanup(), httpMessageHeaderSizeGet(), and httpMessageHeaderToString().

39 {
40  cb = callback;
41 
42  treeWalk(this->root, walk);
43 }
static void walk(const void *node, const int depth)
Definition: each.c:32
static void(* cb)(const void *)
Definition: each.c:27
void treeWalk(Tree, TreeAction)
Definition: walk.c:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* hashGet ( Hash  ,
const char *  ,
size_t   
)

Definition at line 51 of file hash/get.c.

References hashGetComp(), sdbm(), and treeFind().

Referenced by _controllerCreateUserFromArgs(), _controllerGetCredentialFromArgs(), _controllerGetUserFromArgs(), _controllerUpdateUserFromArgs(), assetPoolGet(), configGet(), controllerAuthenticateCreate(), controllerUserRead(), getMimeType(), getSessionId(), httpMessageHasKeepAlive(), httpParserParse(), and httpWorkerGetAsset().

52 {
53  unsigned long hash = sdbm((const unsigned char *)search, nsearch);
54  void * found = treeFind(this->root, &hash, hashGetComp);
55 
56  return found;
57 }
unsigned long sdbm(const unsigned char *, size_t)
Definition: utils/hash.c:45
static int hashGetComp(const void *a, const void *b)
Definition: hash/get.c:35
void * treeFind(Tree, const void *, TreeComp)
Definition: find.c:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* hashGetByVal ( Hash  ,
unsigned  long 
)

Definition at line 60 of file hash/get.c.

References hashGetComp(), and treeFind().

61 {
62  void * found = treeFind(this->root, &hash, hashGetComp);
63 
64  return found;
65 }
static int hashGetComp(const void *a, const void *b)
Definition: hash/get.c:35
void * treeFind(Tree, const void *, TreeComp)
Definition: find.c:26

+ Here is the call graph for this function:

void* hashGetFirst ( Hash  )

Definition at line 33 of file get_first.c.

34 {
35  return this->root;
36 }