taskrambler  0.1.9
Web server and task management solution.
hash/get.c File Reference
#include <stdio.h>
#include <search.h>
#include <sys/types.h>
#include "hash.h"
#include "tree.h"
#include "utils/hash.h"
+ Include dependency graph for hash/get.c:

Go to the source code of this file.

Functions

static int hashGetComp (const void *a, const void *b)
 
void * hashGet (Hash this, const char *search, size_t nsearch)
 
void * hashGetByVal (Hash this, unsigned long 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/get.c.

Function Documentation

void* hashGet ( Hash  this,
const char *  search,
size_t  nsearch 
)

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  this,
unsigned long  hash 
)

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:

static int hashGetComp ( const void *  a,
const void *  b 
)
inlinestatic

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

References hashableGetHash().

Referenced by hashGet(), and hashGetByVal().

36 {
37  unsigned long hash_a = hashableGetHash((void*)a);
38 
39  if (hash_a < *(const unsigned long*)b) {
40  return -1;
41  }
42 
43  if (hash_a > *(const unsigned long*)b) {
44  return 1;
45  }
46 
47  return 0;
48 }
unsigned long hashableGetHash(void *)
Definition: hashable.c:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function: