taskrambler  0.1.9
Web server and task management solution.
application/controller/user/read.c File Reference
#include <sys/types.h>
#include <stdio.h>
#include "class.h"
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "utils/memory.h"
+ Include dependency graph for application/controller/user/read.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define USER_JSON   "{\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
 

Functions

char * controllerUserRead (Application app, Session sess, Hash args)
 

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 application/controller/user/read.c.

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file application/controller/user/read.c.

#define USER_JSON   "{\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"

Definition at line 36 of file application/controller/user/read.c.

Referenced by controllerUserRead().

Function Documentation

char* controllerUserRead ( Application  app,
Session  sess,
Hash  args 
)

Definition at line 40 of file application/controller/user/read.c.

References applicationGetUser(), CSTRA, hashGet(), memMalloc(), USER_JSON, and uuidParse().

41 {
42  char * buffer;
43  size_t nbuffer;
44  HashValue id = hashGet(args, CSTRA("id"));
45  Uuid search = uuidParse(id->value);
46  User user = applicationGetUser(app, search);
47 
48  nbuffer = snprintf(NULL, 0, USER_JSON,
49  user->email,
50  user->firstname,
51  user->surname);
52  buffer = memMalloc(nbuffer);
53  nbuffer = sprintf(buffer, USER_JSON,
54  user->email,
55  user->firstname,
56  user->surname);
57 
58  return buffer;
59 }
Uuid uuidParse(const UuidString)
Definition: uuid/parse.c:30
void * memMalloc(size_t)
Definition: memory.c:783
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void * hashGet(Hash, const char *, size_t)
Definition: hash/get.c:51
User applicationGetUser(Application, Uuid)
Definition: get_user.c:41

+ Here is the call graph for this function: