FreeCalypso > hg > freecalypso-sw
comparison rvinterf/lowlevel/output.c @ 174:3256dc6e84ae
rvinterf: refactored rvtdump compiles and works
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 22 Nov 2013 07:41:31 +0000 |
parents | rvinterf/old/log.c@f42854da4563 |
children | 549e6cd1e77d |
comparison
equal
deleted
inserted
replaced
173:f42854da4563 | 174:3256dc6e84ae |
---|---|
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 background; | |
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 (!background) | |
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 } |