X-Git-Url: http://www.average.org/gitweb/?p=pulsecounter.git;a=blobdiff_plain;f=linux%2Fdbstore.c;fp=linux%2Fdbstore.c;h=edd443102fdcb1e4826c72b922a7b142e8cbe3e2;hp=0000000000000000000000000000000000000000;hb=bf310cc703ac0ed8be107c8f93b63d646b711f26;hpb=a1d335a2895b04b965d678167ecfd14ab4245960 diff --git a/linux/dbstore.c b/linux/dbstore.c new file mode 100644 index 0000000..edd4431 --- /dev/null +++ b/linux/dbstore.c @@ -0,0 +1,21 @@ +#include +#include +#include + +#include "dbstore.h" + +int dbstore(uint8_t which, uint32_t val) +{ + time_t t; + int i; + struct tm tm; + char buf[64]; + char tstr[64]; + char *table = (which == 1) ? "coldcnt" : "hotcnt"; + + t = time(NULL); + (void)gmtime_r(&t, &tm); + (void)strftime(tstr, sizeof(tstr), "%Y-%m-%d %H:%M:%S", &tm); + printf("insert into %s values (\"%s\",%u);\n", table, tstr, val); + return 0; +}