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

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define SESSION_JSON   "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"
 

Functions

char * controllerSessinfoRead (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/sessinfo/read.c.

Macro Definition Documentation

#define _GNU_SOURCE

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

#define SESSION_JSON   "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"

Definition at line 34 of file application/controller/sessinfo/read.c.

Referenced by controllerSessinfoRead().

Function Documentation

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

Definition at line 38 of file application/controller/sessinfo/read.c.

References memMalloc(), SESSION_JSON, and SESSION_LIVETIME.

42 {
43  char * buffer;
44  size_t nbuffer;
45 
46  nbuffer = snprintf(NULL, 0, SESSION_JSON,
47  (NULL != session)? session->id : "",
48  (NULL != session)? SESSION_LIVETIME : 0,
49  (NULL != session)? session->livetime - time(NULL) : 0);
50  buffer = memMalloc(nbuffer);
51  sprintf(buffer, SESSION_JSON,
52  (NULL != session)? session->id : "",
53  (NULL != session)? SESSION_LIVETIME : 0,
54  (NULL != session)? session->livetime - time(NULL) : 0);
55 
56  return buffer;
57 }
void * memMalloc(size_t)
Definition: memory.c:783
#define SESSION_LIVETIME
Definition: session.h:33

+ Here is the call graph for this function: