mirror of
https://github.com/owntracks/recorder.git
synced 2026-02-13 20:49:51 +00:00
5
Makefile
5
Makefile
@@ -5,8 +5,8 @@ all: ot-recorder #### ot-reader
|
||||
ot-reader: ot-reader.c json.o utstring.h ghash.o mkpath.o jget.o
|
||||
cc $(CFLAGS) ot-reader.c -o ot-reader json.o ghash.o mkpath.o jget.o -lhiredis
|
||||
|
||||
ot-recorder: ot-recorder.c json.o utarray.h utstring.h geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o config.h udata.h
|
||||
cc $(CFLAGS) ot-recorder.c -o ot-recorder json.o geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o -lmosquitto -lcurl -lhiredis
|
||||
ot-recorder: ot-recorder.c json.o utarray.h utstring.h geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o config.h udata.h misc.o
|
||||
cc $(CFLAGS) ot-recorder.c -o ot-recorder json.o geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o misc.o -lmosquitto -lcurl -lhiredis
|
||||
|
||||
geo.o: geo.h geo.c udata.h
|
||||
geohash.o: geohash.h geohash.c udata.h
|
||||
@@ -15,3 +15,4 @@ base64.o: base64.h base64.c
|
||||
ghash.o: ghash.h ghash.c config.h udata.h
|
||||
safewrite.o: safewrite.h safewrite.c
|
||||
jget.o: jget.c jget.h json.h
|
||||
misc.o: misc.c misc.h
|
||||
|
||||
23
misc.c
Normal file
23
misc.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "utstring.h"
|
||||
#include "ctype.h"
|
||||
#include "misc.h"
|
||||
|
||||
char *bindump(char *buf, long buflen)
|
||||
{
|
||||
static UT_string *out = NULL;
|
||||
int i, ch;
|
||||
|
||||
utstring_renew(out);
|
||||
|
||||
for (i = 0; i < buflen; i++) {
|
||||
ch = buf[i];
|
||||
if (isprint(ch)) {
|
||||
utstring_printf(out, "%c", ch);
|
||||
} else {
|
||||
utstring_printf(out, " %02X ", ch & 0xFF);
|
||||
}
|
||||
}
|
||||
return (utstring_body(out));
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "file.h"
|
||||
#include "safewrite.h"
|
||||
#include "base64.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
@@ -372,7 +373,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s %s\n", m->topic, m->payload); fflush(stdout);
|
||||
printf("%s %s\n", m->topic, bindump(m->payload, m->payloadlen)); fflush(stdout);
|
||||
|
||||
|
||||
utstring_renew(ts);
|
||||
@@ -420,8 +421,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m
|
||||
if (ud->usefiles) {
|
||||
if ((fp = pathn("a", "rec", username, device, "rec")) != NULL) {
|
||||
|
||||
/* TODO: check payload for binary characters and hex-dump? */
|
||||
fprintf(fp, RECFORMAT, isotime(now), utstring_body(rest), m->payload);
|
||||
fprintf(fp, RECFORMAT, isotime(now), utstring_body(rest), bindump(m->payload, m->payloadlen));
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user