]> www.average.org Git - pulsecounter.git/blob - linux/dbstore.c
edd443102fdcb1e4826c72b922a7b142e8cbe3e2
[pulsecounter.git] / linux / dbstore.c
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <time.h>
4
5 #include "dbstore.h"
6
7 int dbstore(uint8_t which, uint32_t val)
8 {
9         time_t t;
10         int i;
11         struct tm tm;
12         char buf[64];
13         char tstr[64];
14         char *table = (which == 1) ? "coldcnt" : "hotcnt";
15
16         t = time(NULL);
17         (void)gmtime_r(&t, &tm);
18         (void)strftime(tstr, sizeof(tstr), "%Y-%m-%d %H:%M:%S", &tm);
19         printf("insert into %s values (\"%s\",%u);\n", table, tstr, val);
20         return 0;
21 }