FreeCalypso > hg > freecalypso-tools
annotate rvinterf/lowlevel/output.c @ 993:84c9869a3659
flash PPB erase: make internal API more consistent
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Dec 2023 04:58:50 +0000 |
parents | ec5f51d33fdc |
children |
rev | line source |
---|---|
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the output/logging function |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <string.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <strings.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <unistd.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <time.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern int no_output; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern FILE *logF; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern time_t logtime; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
899
a1065c17429c
rvinterf: implement TCH hiding mode and -v option for verbose
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
17 void (*output_hook)(); |
a1065c17429c
rvinterf: implement TCH hiding mode and -v option for verbose
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
18 |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static struct tm last_tm; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 void |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 output_line(item) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 char *item; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct tm *curtm; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
899
a1065c17429c
rvinterf: implement TCH hiding mode and -v option for verbose
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
27 if (output_hook) |
a1065c17429c
rvinterf: implement TCH hiding mode and -v option for verbose
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
28 output_hook(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!no_output) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 printf("%s\n", item); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (!logF) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 curtm = gmtime(&logtime); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (curtm->tm_year != last_tm.tm_year || |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 curtm->tm_mon != last_tm.tm_mon || |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 curtm->tm_mday != last_tm.tm_mday) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 curtm->tm_mon+1, curtm->tm_mday); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 curtm->tm_sec, item); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 bcopy(curtm, &last_tm, sizeof(struct tm)); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
928
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
43 |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
44 void |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
45 output_cont(item) |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
46 char *item; |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
47 { |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
48 if (!no_output) |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
49 printf("%s\n", item); |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
50 if (logF) |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
51 fprintf(logF, "%s\n", item); |
65953c172f24
rvinterf/lowlevel: new hex dump format
Mychaela Falconia <falcon@freecalypso.org>
parents:
899
diff
changeset
|
52 } |
940
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
53 |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
54 void |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
55 output_cont_logpref(item) |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
56 char *item; |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
57 { |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
58 if (logF) |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
59 fprintf(logF, "%s\n", item); |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
60 else if (!no_output) |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
61 printf("%s\n", item); |
ec5f51d33fdc
rvinterf code structure: factor out output_cont_logpref()
Mychaela Falconia <falcon@freecalypso.org>
parents:
928
diff
changeset
|
62 } |