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

Go to the source code of this file.

Functions

void printUser (Storage users, const char *key, size_t nkey)
 
void insertUser (Storage users, const char *email, size_t nemail, const char *firstname, size_t nfirstname, const char *surname, size_t nsurname)
 
int main (int argc, char *argv[])
 

Function Documentation

void insertUser ( Storage  users,
const char *  email,
size_t  nemail,
const char *  firstname,
size_t  nfirstname,
const char *  surname,
size_t  nsurname 
)

Definition at line 35 of file usertest.c.

Referenced by main().

40 {
41  User insert = new(User,
42  email, nemail,
43  firstname, nfirstname,
44  surname, nsurname);
45 
46  userSave(insert, users);
47  delete(insert);
48 }

+ Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 51 of file usertest.c.

References CSTRA, insertUser(), memCleanup(), and printUser().

52 {
53  Storage users = new(Storage, CSTRA("./users.db"));
54 
55  if (NULL == users) {
56  fprintf(stderr, "%s\n", gdbm_strerror(gdbm_errno));
57  fprintf(stderr, "%s\n", strerror(errno));
58  return 1;
59  }
60 
61  insertUser(
62  users,
63  CSTRA("georg"),
64  CSTRA("Georg"),
65  CSTRA("Hopp"));
66  insertUser(
67  users,
68  CSTRA("georg@steffers.org"),
69  CSTRA("Georg"),
70  CSTRA("Hopp"));
71  insertUser(
72  users,
73  CSTRA("drachenfrau1982@gmx.net"),
74  CSTRA("Gundula"),
75  CSTRA("Hopp"));
76 
77  printUser(users, CSTRA("foo@bar.de"));
78  puts("");
79  printUser(users, CSTRA("drachenfrau1982@gmx.net"));
80  puts("");
81  printUser(users, CSTRA("georg@steffers.org"));
82 
83  delete(users);
84 
85  users = new(Storage, CSTRA("./users.db"));
86 
87  insertUser(
88  users,
89  CSTRA("drachenfrau1982@gmx.net"),
90  CSTRA("Stefanie"),
91  CSTRA("Hopp"));
92 
93  puts("");
94  printUser(users, CSTRA("foo@bar.de"));
95  puts("");
96  printUser(users, CSTRA("drachenfrau1982@gmx.net"));
97  puts("");
98  printUser(users, CSTRA("georg@steffers.org"));
99 
100  delete(users);
101 
102  memCleanup();
103 
104  return 0;
105 }
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void insertUser(Storage users, const char *email, size_t nemail, const char *firstname, size_t nfirstname, const char *surname, size_t nsurname)
Definition: usertest.c:35
void printUser(Storage users, const char *key, size_t nkey)
Definition: usertest.c:15
void memCleanup()
Definition: memory.c:862

+ Here is the call graph for this function:

void printUser ( Storage  users,
const char *  key,
size_t  nkey 
)

Definition at line 15 of file usertest.c.

Referenced by main().

16 {
17  User user = new(User, NULL);
18 
19  user->email = (char *)key,
20  user->nemail = &nkey;
21 
22  if (NULL == userLoad(user, users)) {
23  fprintf(stderr, "can't find user: %s\n", key);
24  } else {
25  puts("found user:");
26  puts(user->email);
27  puts(user->firstname);
28  puts(user->surname);
29 
30  delete(user);
31  }
32 }

+ Here is the caller graph for this function: