FreeCalypso > hg > freecalypso-tools
annotate librftab/rdcommon.c @ 407:19e5a3e2f9c0
fcup-settime: moved time() retrieval a little closer to the output
A fundamental problem with all simple time transfer tools is that there is
always some delay between the time retrieval on the source system and that
transmitted time being set on the destination, and the resulting time
on the destination system is off by that delay amount. This delay cannot
be fully eliminated when working in a simple environment like ours,
but we should make our best effort to minimize it. In the present case,
moving the atinterf_init() call before the time() retrieval should make
a teensy-tiny improvement.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Aug 2018 21:52:17 +0000 |
parents | a0f79bba0ad8 |
children |
rev | line source |
---|---|
314
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C file is not a compilation unit in itself, but is the common piece |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * (a set of static variables and functions) included in the librftab modules |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * responsible for reading different kinds of ASCII tables. |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #define MAX_FIELDS_PER_LINE 64 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 static char *filename; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 static FILE *rdfile; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 static unsigned lineno; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static char linebuf[256], *line_fields[MAX_FIELDS_PER_LINE]; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static unsigned line_nfields, line_field_ptr; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 static int |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 read_line() |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 char *cp; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (!fgets(linebuf, sizeof linebuf, rdfile)) |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return(0); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 lineno++; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 cp = linebuf; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 for (line_nfields = 0; ; ) { |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 while (isspace(*cp)) |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 cp++; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (*cp == '\0' || *cp == '#') |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 break; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (line_nfields >= MAX_FIELDS_PER_LINE) { |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 printf("%s line %d: too many fields on one line\n", |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 filename, lineno); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return(-1); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 line_fields[line_nfields++] = cp; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 while (*cp && !isspace(*cp)) |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 cp++; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (*cp) |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 *cp++ = '\0'; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 return(1); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 static |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 get_field(retp) |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 char **retp; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 { |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 int rc; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (line_field_ptr < line_nfields) { |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 *retp = line_fields[line_field_ptr++]; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 return(1); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 do { |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 rc = read_line(); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (rc <= 0) |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 return(rc); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } while (!line_nfields); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 *retp = line_fields[0]; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 line_field_ptr = 1; |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 return(1); |
a0f79bba0ad8
librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |