mirror of
https://github.com/owntracks/recorder.git
synced 2026-05-05 02:36:45 +00:00
2
http.c
2
http.c
@@ -386,7 +386,7 @@ static int dispatch(struct mg_connection *conn, const char *uri)
|
||||
if ((arr = json_find_member(json, "results")) != NULL) {
|
||||
JsonNode *f;
|
||||
json_foreach(f, arr) {
|
||||
locations(f->string_, obj, locs, s_lo, s_hi, otype, limit, NULL);
|
||||
locations(f->string_, obj, locs, s_lo, s_hi, otype, limit, NULL, NULL, NULL);
|
||||
// printf("%s\n", f->string_);
|
||||
}
|
||||
}
|
||||
|
||||
5
ocat.c
5
ocat.c
@@ -519,7 +519,7 @@ int main(int argc, char **argv)
|
||||
int n;
|
||||
|
||||
for (n = 0; n < argc; n++) {
|
||||
locations(argv[n], obj, locs, s_lo, s_hi, otype, 0, fields);
|
||||
locations(argv[n], obj, locs, s_lo, s_hi, otype, 0, fields, NULL, NULL);
|
||||
}
|
||||
} else {
|
||||
JsonNode *arr, *f;
|
||||
@@ -532,7 +532,8 @@ int main(int argc, char **argv)
|
||||
if ((json = lister(username, device, s_lo, s_hi, (limit > 0) ? TRUE : FALSE)) != NULL) {
|
||||
if ((arr = json_find_member(json, "results")) != NULL) { // get array
|
||||
json_foreach(f, arr) {
|
||||
locations(f->string_, obj, locs, s_lo, s_hi, otype, limit, fields);
|
||||
// locations(f->string_, obj, locs, s_lo, s_hi, otype, limit, fields, username, device);
|
||||
locations(f->string_, obj, locs, s_lo, s_hi, otype, limit, fields, NULL, NULL);
|
||||
// printf("%s\n", f->string_);
|
||||
}
|
||||
}
|
||||
|
||||
22
storage.c
22
storage.c
@@ -513,6 +513,8 @@ struct jparam {
|
||||
output_type otype;
|
||||
int limit; /* if non-zero, we're searching backwards */
|
||||
JsonNode *fields;
|
||||
char *username;
|
||||
char *device;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -600,6 +602,8 @@ static int candidate_line(char *line, void *param)
|
||||
time_t s_hi = jarg->s_hi;
|
||||
JsonNode *fields = jarg->fields;
|
||||
output_type otype = jarg->otype;
|
||||
char *username = jarg->username;
|
||||
char *device = jarg->device;
|
||||
|
||||
if (obj == NULL || obj->tag != JSON_OBJECT)
|
||||
return (-1);
|
||||
@@ -658,6 +662,16 @@ static int candidate_line(char *line, void *param)
|
||||
// fprintf(stderr, "-->[%s]\n", line);
|
||||
|
||||
if ((o = line_to_location(line)) != NULL) {
|
||||
|
||||
/*
|
||||
* Username/device are added typically for multilister() only.
|
||||
*/
|
||||
|
||||
if (username)
|
||||
json_append_member(o, "username", json_mkstring(username));
|
||||
if (device)
|
||||
json_append_member(o, "device", json_mkstring(device));
|
||||
|
||||
if (fields) {
|
||||
/* Create a new object, copying members we're interested in into it */
|
||||
JsonNode *f, *node;
|
||||
@@ -672,6 +686,7 @@ static int candidate_line(char *line, void *param)
|
||||
}
|
||||
json_delete(o);
|
||||
o = newo;
|
||||
|
||||
}
|
||||
json_append_element(locs, o);
|
||||
++counter;
|
||||
@@ -689,9 +704,12 @@ static int candidate_line(char *line, void *param)
|
||||
* contains `arr'.
|
||||
* If limit is zero, we're going forward, else backwards.
|
||||
* Fields, if not NULL, is a JSON array of desired element names.
|
||||
*
|
||||
* If username & device are not NULL, populate the JSON locations
|
||||
* with them for multilister().
|
||||
*/
|
||||
|
||||
void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t s_hi, output_type otype, int limit, JsonNode *fields)
|
||||
void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t s_hi, output_type otype, int limit, JsonNode *fields, char *username, char *device)
|
||||
{
|
||||
struct jparam jarg;
|
||||
|
||||
@@ -705,6 +723,8 @@ void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t
|
||||
jarg.otype = otype;
|
||||
jarg.limit = limit;
|
||||
jarg.fields = fields;
|
||||
jarg.username = username;
|
||||
jarg.device = device;
|
||||
|
||||
if (limit == 0) {
|
||||
cat(filename, candidate_line, &jarg);
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef enum {
|
||||
|
||||
JsonNode *lister(char *username, char *device, time_t s_lo, time_t s_hi, int reverse);
|
||||
JsonNode *multilister(JsonNode *udpairs, time_t s_lo, time_t s_hi, int reverse);
|
||||
void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t s_hi, output_type otype, int limit, JsonNode *fields);
|
||||
void locations(char *filename, JsonNode *obj, JsonNode *arr, time_t s_lo, time_t s_hi, output_type otype, int limit, JsonNode *fields, char *username, char *device);
|
||||
int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_to);
|
||||
JsonNode *geo_json(JsonNode *json);
|
||||
JsonNode *geo_linestring(JsonNode *location_array);
|
||||
|
||||
Reference in New Issue
Block a user