2
* /src/NTP/ntp-4/libparse/data_mbg.c,v 4.3 1999/02/21 12:17:42 kardel RELEASE_19991128_A
2
* /src/NTP/REPOSITORY/ntp4-dev/libparse/data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
4
* data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
4
6
* $Created: Sun Jul 20 12:08:14 1997 $
6
* Copyright (C) 1997, 1998 by Frank Kardel
8
* Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in the
17
* documentation and/or other materials provided with the distribution.
18
* 3. Neither the name of the author nor the names of its contributors
19
* may be used to endorse or promote products derived from this software
20
* without specific prior written permission.
22
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20
47
#include "ieee754io.h"
22
49
static void get_mbg_tzname P((unsigned char **, char *));
23
static void mbg_time_status_str P((unsigned char **, unsigned int));
50
static void mbg_time_status_str P((char **, unsigned int, int));
25
52
#if 0 /* no actual floats on Meinberg binary interface */
26
53
static offsets_t mbg_float = { 1, 0, 3, 2, 0, 0, 0, 0 }; /* byte order for meinberg floats */
183
210
mbg_time_status_str(
184
unsigned char **buffpp,
190
int flag; /* bit flag */
191
const char *string; /* bit name */
194
{ TM_UTC, "UTC CORR" },
195
{ TM_LOCAL, "LOCAL TIME" },
196
{ TM_DL_ANN, "DST WARN" },
197
{ TM_DL_ENB, "DST" },
198
{ TM_LS_ANN, "LEAP WARN" },
199
{ TM_LS_ENB, "LEAP SEC" },
218
int flag; /* bit flag */
219
const char *string; /* bit name */
222
{ TM_UTC, "UTC CORR" },
223
{ TM_LOCAL, "LOCAL TIME" },
224
{ TM_DL_ANN, "DST WARN" },
225
{ TM_DL_ENB, "DST" },
226
{ TM_LS_ANN, "LEAP WARN" },
227
{ TM_LS_ENB, "LEAP SEC" },
210
for (s = states; s->flag; s++)
212
if (s->flag & status)
238
for (s = states; s->flag; s++)
240
if (s->flag & status)
244
strncpy(p, ", ", size - (p - start));
247
strncpy(p, s->string, size - (p - start));
219
strcpy((char *)p, s->string);
220
p += strlen((char *)p);
229
unsigned char **buffpp,
233
sprintf((char *)*buffpp, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ",
234
tmp->year, tmp->month, tmp->mday,
235
tmp->hour, tmp->minute, tmp->second, tmp->frac,
236
(tmp->offs_from_utc < 0) ? '-' : '+',
237
abs(tmp->offs_from_utc) / 3600,
238
(abs(tmp->offs_from_utc) / 60) % 60);
239
*buffpp += strlen((char *)*buffpp);
240
mbg_time_status_str(buffpp, tmp->status);
264
snprintf(*buffpp, size, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ",
265
tmp->year, tmp->month, tmp->mday,
266
tmp->hour, tmp->minute, tmp->second, tmp->frac,
267
(tmp->offs_from_utc < 0) ? '-' : '+',
268
abs(tmp->offs_from_utc) / 3600,
269
(abs(tmp->offs_from_utc) / 60) % 60);
270
*buffpp += strlen(*buffpp);
272
mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
245
unsigned char **buffpp,
249
sprintf((char *)*buffpp, "week %d + %ld days + %ld.%07ld sec",
250
tgpsp->wn, tgpsp->sec / 86400,
251
tgpsp->sec % 86400, tgpsp->tick);
252
*buffpp += strlen((char *)*buffpp);
282
snprintf(*buffpp, size, "week %d + %ld days + %ld.%07ld sec",
283
tgpsp->wn, tgpsp->sec / 86400,
284
tgpsp->sec % 86400, tgpsp->tick);
285
*buffpp += strlen(*buffpp);
511
* Revision 4.8 2006/06/22 18:40:01 kardel
512
* clean up signedness (gcc 4)
514
* Revision 4.7 2005/10/07 22:11:10 kardel
515
* bounded buffer implementation
517
* Revision 4.6.2.1 2005/09/25 10:23:06 kardel
518
* support bounded buffers
520
* Revision 4.6 2005/04/16 17:32:10 kardel
523
* Revision 4.5 2004/11/14 15:29:41 kardel
524
* support PPSAPI, upgrade Copyright to Berkeley style
478
526
* Revision 4.3 1999/02/21 12:17:42 kardel
479
527
* 4.91f reconcilation