FEATURE: ocat --format payload (like RAW, but different)

This commit is contained in:
Jan-Piet Mens 2015-09-01 21:03:50 +02:00
parent 166ff17085
commit bcb052bde3
3 changed files with 12 additions and 1 deletions

6
ocat.c
View File

@ -132,6 +132,7 @@ void usage(char *prog)
printf(" geojson\n"); printf(" geojson\n");
printf(" gpx\n"); printf(" gpx\n");
printf(" raw\n"); printf(" raw\n");
printf(" payload\n");
printf(" --fields tst,lat,lon,... Choose fields for CSV. (dflt: ALL)\n"); printf(" --fields tst,lat,lon,... Choose fields for CSV. (dflt: ALL)\n");
printf(" --last -L JSON object with last users\n"); printf(" --last -L JSON object with last users\n");
printf(" --killdata requires -u and -d\n"); printf(" --killdata requires -u and -d\n");
@ -170,6 +171,7 @@ int main(int argc, char **argv)
case 'c': otype = CSV; break; case 'c': otype = CSV; break;
case 'g': otype = GEOJSON; break; case 'g': otype = GEOJSON; break;
case 'r': otype = RAW; break; case 'r': otype = RAW; break;
case 'p': otype = RAWPAYLOAD; break;
} }
} }
@ -234,6 +236,8 @@ int main(int argc, char **argv)
otype = GEOJSON; otype = GEOJSON;
else if (!strcmp(optarg, "raw")) else if (!strcmp(optarg, "raw"))
otype = RAW; otype = RAW;
else if (!strcmp(optarg, "payload"))
otype = RAWPAYLOAD;
else if (!strcmp(optarg, "gpx")) else if (!strcmp(optarg, "gpx"))
otype = GPX; otype = GPX;
else if (!strcmp(optarg, "csv")) else if (!strcmp(optarg, "csv"))
@ -409,7 +413,7 @@ int main(int argc, char **argv)
} else if (otype == CSV) { } else if (otype == CSV) {
csv_output(obj, CSV, fields); csv_output(obj, CSV, fields);
} else if (otype == RAW) { } else if (otype == RAW || otype == RAWPAYLOAD) {
/* We've already done what we need to do in locations() */ /* We've already done what we need to do in locations() */
} else if (otype == GEOJSON) { } else if (otype == GEOJSON) {
JsonNode *geojson = geo_json(locs); JsonNode *geojson = geo_json(locs);

View File

@ -525,6 +525,12 @@ static int candidate_line(char *line, void *param)
if (otype == RAW) { if (otype == RAW) {
printf("%s\n", line); printf("%s\n", line);
return (0); return (0);
} else if (otype == RAWPAYLOAD) {
char *bp;
if ((bp = strchr(line, '{')) != NULL) {
printf("%s\n", bp);
}
} }
} }

View File

@ -11,6 +11,7 @@ typedef enum {
JSON, JSON,
RAW, RAW,
GPX, GPX,
RAWPAYLOAD,
} output_type; } output_type;
JsonNode *lister(char *username, char *device, time_t s_lo, time_t s_hi, int reverse); JsonNode *lister(char *username, char *device, time_t s_lo, time_t s_hi, int reverse);