Commit b5063244 authored by Eric S. Raymond's avatar Eric S. Raymond

ntptime is now JSON-enabled.

parent 66d5f6ca
......@@ -5,7 +5,9 @@
== Synopsis ==
["literal",subs="normal"]
{ntptime} [ -chr ] [ -e 'est_error' ] [ -f 'frequency' ] [ -m 'max_error' ] [ -o 'offset' ] [ -s 'status' ] [ -t 'time_constant']
{ntptime} [ -chr ] [ -e 'est_error' ] [ -f 'frequency' ] [-j]
[ -m 'max_error' ] [ -o 'offset' ] [ -s 'status' ]
[ -t 'time_constant']
== Description ==
......@@ -39,4 +41,8 @@ and `kerninfo` command.
`-t` 'time_constant'::
Specify time constant, an integer in the range 0-10.
== Bugs ==
The format for modes and status in the JSON report is less than ideal.
//end
......@@ -303,7 +303,8 @@ main(
ts.l_ui += JAN_1970;
ts.l_uf += ts_roundbit;
ts.l_uf &= ts_mask;
printf(json ? jfmt2 : ofmt2, prettydate(&ts), fdigits, (int)time_frac);
/* FIXME: ugly hack - we shouldn't use prettydate() here */
printf(json ? jfmt2 : ofmt2, prettydate(&ts) + (json?18:0), fdigits, (int)time_frac);
printf(json ? jfmt3 : ofmt3, (u_long)ntv.maxerror, (u_long)ntv.esterror);
if (rawtime)
printf(json ? jfmt4 : ofmt4,
......@@ -382,7 +383,8 @@ main(
(u_long)ntx.stbcnt, (u_long)ntx.errcnt);
}
if (json)
fputs("}\n", stdout);
/* hack to avoid trailing comma - not semabtically needed */
fputs("\"version\":\"" NTPS_VERSION_STRING "\"}\n", stdout);
exit(EXIT_SUCCESS);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment