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

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define RANDVAL_JSON   "{\"ctime\":%ld,\"vnext\":%ld,\"value\":\"%02d\"}"
 

Functions

char * controllerRandvalRead (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/randval/read.c.

Macro Definition Documentation

#define _GNU_SOURCE

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

#define RANDVAL_JSON   "{\"ctime\":%ld,\"vnext\":%ld,\"value\":\"%02d\"}"

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

Referenced by controllerRandvalRead().

Function Documentation

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

Definition at line 37 of file application/controller/randval/read.c.

References memMalloc(), and RANDVAL_JSON.

38 {
39  char * buffer;
40  size_t nbuffer;
41  time_t remaining;
42 
43  remaining = 10 - (time(NULL) - app->val->timestamp);
44 
45  nbuffer = snprintf(
46  NULL,
47  0,
49  app->val->timestamp,
50  remaining,
51  app->val->value);
52  buffer = memMalloc(nbuffer);
53  sprintf(
54  buffer,
56  app->val->timestamp,
57  remaining,
58  app->val->value);
59 
60  return buffer;
61 }
void * memMalloc(size_t)
Definition: memory.c:783

+ Here is the call graph for this function: