taskrambler  v0.1.8
Web server and task management solution.
application/controller/user/update.c File Reference
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "user.h"
#include "utils/memory.h"
#include "commons.h"
+ Include dependency graph for application/controller/user/update.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

char * controllerCurrentuserRead (Application, Session, Hash)
 
int _controllerUpdateUserFromArgs (Hash, User *)
 
char * controllerUserUpdate (Application application, Session session, 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/update.c.

Macro Definition Documentation

#define _GNU_SOURCE

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

Function Documentation

int _controllerUpdateUserFromArgs ( Hash  ,
User *   
)

Definition at line 33 of file _update_user_from_args.c.

References CSTRA, FALSE, hashGet(), and TRUE.

Referenced by controllerUserUpdate().

34 {
35  HashValue email = hashGet(args, CSTRA("email"));
36  HashValue firstname = hashGet(args, CSTRA("firstname"));
37  HashValue surname = hashGet(args, CSTRA("surname"));
38  User new_user;
39 
40  if (
41  NULL == email ||
42  NULL == firstname ||
43  NULL == surname)
44  {
45  return FALSE;
46  }
47 
48  new_user = new(User,
49  (char *)((*user)->username), *(*user)->nusername,
50  (char *)(email->value), email->nvalue,
51  (char *)(firstname->value), firstname->nvalue,
52  (char *)(surname->value), surname->nvalue);
53 
54  delete(*user);
55  *user = new_user;
56 
57  return TRUE;
58 }
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
#define FALSE
Definition: commons.h:28
void * hashGet(Hash, const char *, size_t)
Definition: hash/get.c:51
#define TRUE
Definition: commons.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* controllerCurrentuserRead ( Application  ,
Session  ,
Hash   
)

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

References memMalloc(), and USER_JSON.

Referenced by controllerUserUpdate().

41 {
42  char * buffer;
43  size_t nbuffer;
44 
45  nbuffer = snprintf(NULL, 0, USER_JSON,
46  (NULL != sess->user)? sess->user->username : "",
47  (NULL != sess->user)? sess->user->email : "",
48  (NULL != sess->user)? sess->user->firstname : "",
49  (NULL != sess->user)? sess->user->surname : "");
50  buffer = memMalloc(nbuffer);
51  nbuffer = sprintf(buffer, USER_JSON,
52  (NULL != sess->user)? sess->user->username : "",
53  (NULL != sess->user)? sess->user->email : "",
54  (NULL != sess->user)? sess->user->firstname : "",
55  (NULL != sess->user)? sess->user->surname : "");
56 
57  return buffer;
58 }
void * memMalloc(size_t)
Definition: memory.c:783

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* controllerUserUpdate ( Application  application,
Session  session,
Hash  args 
)

Definition at line 37 of file application/controller/user/update.c.

References _controllerUpdateUserFromArgs(), applicationUpdateUser(), controllerCurrentuserRead(), uuidCompare(), and uuidZero.

41 {
42  Uuid user_id;
43 
44  if (! _controllerUpdateUserFromArgs(args, &(session->user))) {
45  return NULL;
46  }
47 
48  user_id = applicationUpdateUser(application, session->user);
49  if (0 == uuidCompare(uuidZero, user_id)) {
50  return NULL;
51  }
52  delete(user_id);
53 
54  return controllerCurrentuserRead(application, session, NULL);
55 }
int uuidCompare(Uuid, Uuid)
Definition: compare.c:30
char * controllerCurrentuserRead(Application, Session, Hash)
Uuid applicationUpdateUser(Application, User)
Definition: update_user.c:43
Uuid uuidZero
int _controllerUpdateUserFromArgs(Hash, User *)

+ Here is the call graph for this function: