#include "server_state.h"
#include "purge.h"
+static char *time_to_string(time_t t, char **ptr);
static int handle_specials(edg_wll_Context,time_t *);
#define sizofa(a) (sizeof(a)/sizeof((a)[0]))
int edg_wll_DumpEvents(edg_wll_Context ctx,const edg_wll_DumpRequest *req,edg_wll_DumpResult *result)
{
- char *from_s, *to_s, *stmt, *time_s;
+ char *from_s, *to_s, *stmt, *time_s, *ptr;
char *tmpfname;
time_t start,end;
edg_wll_Stmt q = NULL;
}
time(&end);
- time_s = strdup(edg_wll_TimeToDB(start));
+ time_s = time_to_string(start, &ptr);
edg_wll_SetServerState(ctx,EDG_WLL_STATE_DUMP_START,time_s);
- free(time_s);
+ free(ptr);
- time_s = strdup(edg_wll_TimeToDB(end));
+ time_s = time_to_string(end, &ptr);
edg_wll_SetServerState(ctx,EDG_WLL_STATE_DUMP_END,time_s);
- free(time_s);
+ free(ptr);
result->from = from;
result->to = to;
}
+static char *time_to_string(time_t t, char **ptr) {
+ char *s;
+
+ s = edg_wll_TimeToDB(t);
+ s[strlen(s) - 1] = '\0';
+ *ptr = s;
+
+ return s + 1;
+}
char *stmt = NULL;
trio_asprintf(&stmt,"insert into server_state (prefix,name,value) "
- "values ('https://%|Ss:%d','%|Ss',%s)",
+ "values ('https://%|Ss:%d','%|Ss','%|Ss')",
ctx->srvName,ctx->srvPort,name,val);
switch(edg_wll_ExecStmt(ctx,stmt,NULL)) {