mirror of
https://github.com/owntracks/recorder.git
synced 2024-11-15 09:58:40 -07:00
use safewrite() for monitor hook file so that it cannot disappear temporarily
This commit is contained in:
parent
1ad7b59a80
commit
cbbf16a1a1
12
Makefile
12
Makefile
@ -17,14 +17,14 @@ ot-reader: ot-reader.c json.o utstring.h ghash.o mkpath.o jget.o
|
||||
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 $(LIBS)
|
||||
|
||||
geo.o: geo.h geo.c udata.h
|
||||
geohash.o: geohash.h geohash.c udata.h
|
||||
file.o: file.h file.c config.h misc.h
|
||||
geo.o: geo.h geo.c udata.h Makefile config.mk
|
||||
geohash.o: geohash.h geohash.c udata.h Makefile config.mk
|
||||
file.o: file.h file.c config.h misc.h Makefile config.mk
|
||||
base64.o: base64.h base64.c
|
||||
ghash.o: ghash.h ghash.c config.h udata.h misc.h
|
||||
ghash.o: ghash.h ghash.c config.h udata.h misc.h Makefile config.mk
|
||||
safewrite.o: safewrite.h safewrite.c
|
||||
jget.o: jget.c jget.h json.h
|
||||
misc.o: misc.c misc.h udata.h
|
||||
jget.o: jget.c jget.h json.h Makefile config.mk
|
||||
misc.o: misc.c misc.h udata.h Makefile config.mk
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
11
misc.c
11
misc.c
@ -4,6 +4,7 @@
|
||||
#include "ctype.h"
|
||||
#include "udata.h"
|
||||
#include "misc.h"
|
||||
#include "safewrite.h"
|
||||
|
||||
char *bindump(char *buf, long buflen)
|
||||
{
|
||||
@ -41,13 +42,13 @@ void monitorhook(struct udata *userdata, time_t now, char *topic)
|
||||
#else
|
||||
if (ud->usefiles) {
|
||||
char mpath[BUFSIZ];
|
||||
FILE *fp;
|
||||
static UT_string *us = NULL;
|
||||
|
||||
utstring_renew(us);
|
||||
utstring_printf(us, "%ld %s\n", now, topic);
|
||||
|
||||
sprintf(mpath, "%s/monitor", JSONDIR);
|
||||
if ((fp = fopen(mpath, "w")) != NULL) {
|
||||
fprintf(fp, "%ld %s\n", now, topic);
|
||||
fclose(fp);
|
||||
}
|
||||
safewrite(mpath, utstring_body(us));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef SAFEWRITE_H_INCLUDED
|
||||
# define SAFEWRITE_H_INCLUDED
|
||||
|
||||
int safewrite(char *filename, char *buf);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user