comparison rvinterf/old/before-rvinterf/log.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
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
1 /*
2 * This module implements the 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 char pr_item[];
14
15 extern FILE *logF;
16 extern time_t logtime;
17
18 static struct tm last_tm;
19
20 log_item()
21 {
22 struct tm *curtm;
23
24 curtm = gmtime(&logtime);
25 if (curtm->tm_year != last_tm.tm_year ||
26 curtm->tm_mon != last_tm.tm_mon ||
27 curtm->tm_mday != last_tm.tm_mday)
28 fprintf(logF, "%d-%02d-%02d (gmtime):\n", curtm->tm_year + 1900,
29 curtm->tm_mon+1, curtm->tm_mday);
30 fprintf(logF, "[%02d:%02d:%02d] %s\n", curtm->tm_hour, curtm->tm_min,
31 curtm->tm_sec, pr_item);
32 bcopy(curtm, &last_tm, sizeof(struct tm));
33 }
34
35 log_sent_packet(pkt, pktlen)
36 u_char *pkt;
37 {
38 int i;
39 char *dp;
40
41 dp = pr_item;
42 strcpy(dp, "Sent");
43 dp += 4;
44 for (i = 0; i < pktlen; i++) {
45 sprintf(dp, " %02X", pkt[i]);
46 dp += 3;
47 }
48 *dp = '\0';
49 print_item();
50 }