comparison rvinterf/old/log.c @ 173:f42854da4563

rvinterf: beginning of refactoring
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 22 Nov 2013 05:56:07 +0000
parents rvinterf/log.c@4d8e4c58df71
children
comparison
equal deleted inserted replaced
172:019120585a1c 173:f42854da4563
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 }