taskrambler  v0.1.8
Web server and task management solution.
storage/get.c File Reference
#include <gdbm.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include "class.h"
#include "storage/storage.h"
#include "utils/memory.h"
+ Include dependency graph for storage/get.c:

Go to the source code of this file.

Functions

void storageGet (Storage this, char *_key, size_t nkey, char **data, size_t *ndata)
 

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 storage/get.c.

Function Documentation

void storageGet ( Storage  this,
char *  _key,
size_t  nkey,
char **  data,
size_t *  ndata 
)

Definition at line 34 of file storage/get.c.

References MEM_FREE, and memMalloc().

Referenced by applicationGetUser(), applicationLogin(), and authStorageAuthenticate().

38 {
39  char * key = memMalloc(nkey);
40  datum gdbm_key = {key, nkey};
41  datum value;
42 
43  if (NULL == this) {
44  *data = NULL;
45  *ndata = 0;
46  }
47 
48  memcpy(key, _key, nkey);
49  value = gdbm_fetch(this->gdbm, gdbm_key);
50  MEM_FREE(key);
51 
52  if (NULL != value.dptr) {
53  *ndata = value.dsize;
54  *data = memMalloc(value.dsize);
55  memcpy(*data, value.dptr, value.dsize);
56 
57  free(value.dptr);
58  } else {
59  *data = NULL;
60  *ndata = 0;
61  }
62 }
#define MEM_FREE(seg)
Definition: memory.h:28
void * memMalloc(size_t)
Definition: memory.c:783

+ Here is the call graph for this function:

+ Here is the caller graph for this function: