FreeCalypso > hg > freecalypso-tools
comparison rvinterf/lowlevel/output.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | a1065c17429c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * This module implements the output/logging function | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <string.h> | |
8 #include <strings.h> | |
9 #include <stdlib.h> | |
10 #include <unistd.h> | |
11 #include <time.h> | |
12 | |
13 extern int no_output; | |
14 extern FILE *logF; | |
15 extern time_t logtime; | |
16 | |
17 static struct tm last_tm; | |
18 | |
19 void | |
20 output_line(item) | |
21 char *item; | |
22 { | |
23 struct tm *curtm; | |
24 | |
25 if (!no_output) | |
26 printf("%s\n", item); | |
27 if (!logF) | |
28 return; | |
29 curtm = gmtime(&logtime); | |
30 if (curtm->tm_year != last_tm.tm_year || | |
31 curtm->tm_mon != last_tm.tm_mon || | |
32 curtm->tm_mday != last_tm.tm_mday) | |
33 fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900, | |
34 curtm->tm_mon+1, curtm->tm_mday); | |
35 fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min, | |
36 curtm->tm_sec, item); | |
37 bcopy(curtm, &last_tm, sizeof(struct tm)); | |
38 } |