summaryrefslogtreecommitdiff
path: root/map-server/altos-map/altos-map.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-10-07 10:32:48 -0700
committerKeith Packard <keithp@keithp.com>2018-10-07 10:32:48 -0700
commit581f700e08ec8a1c3bfc5a09e7186676c54a5460 (patch)
treee3cae42e170d613a4d2615ec53a70068a996ee06 /map-server/altos-map/altos-map.c
parent6f911b92652de890ebff67b3b28f21a36f300ebf (diff)
altos-map: Switch from json FD ops to json FILE ops
Older versions (in Debian stable) do not have the fd-based operations. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'map-server/altos-map/altos-map.c')
-rw-r--r--map-server/altos-map/altos-map.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/map-server/altos-map/altos-map.c b/map-server/altos-map/altos-map.c
index 690ec728..38701076 100644
--- a/map-server/altos-map/altos-map.c
+++ b/map-server/altos-map/altos-map.c
@@ -226,16 +226,23 @@ int main(int argc, char **argv)
if (s < 0)
fail(408, "Cannot connect AltOS map daemon");
+ FILE *sf = fdopen(s, "r+");
+
+ if (sf == NULL)
+ fail(400, "allocation failure");
+
json_t *request = json_pack("{s:f s:f s:i s:s}", "lat", lat, "lon", lon, "zoom", zoom, "remote_addr", remote_addr);
if (request == NULL)
fail(400, "Cannot create JSON request");
- if (json_dumpfd(request, s, 0) < 0)
+ if (json_dumpf(request, sf, 0) < 0)
fail(400, "Cannot write JSON request");
+ fflush(sf);
+
json_error_t error;
- json_t *reply = json_loadfd(s, 0, &error);
+ json_t *reply = json_loadf(sf, 0, &error);
if (!reply)
fail(400, "Cannot read JSON reply");