-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.c
More file actions
82 lines (61 loc) · 1.08 KB
/
Copy pathlog.c
File metadata and controls
82 lines (61 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "includes.h"
#include "knightcap.h"
static FILE *logfile;
static FILE *cfile;
void log_close(void)
{
fclose(logfile);
logfile = NULL;
}
int lprintf(int level, char *format_str, ...)
{
va_list ap;
char fmt[4096];
char *p;
if (!logfile) {
#if APLINUX
logfile = fopen("/ddv/data/tridge/knightcap.log","w");
#else
logfile = fopen("knightcap.log","w");
#endif
setlinebuf(logfile);
}
va_start(ap, format_str);
strcpy(fmt, format_str);
if (sizeof(short) == sizeof(etype)) {
while ((p = strstr(fmt, "%e"))) {
p[1] = 'd';
}
} else {
while ((p = strstr(fmt, "%f"))) {
p[1] = 'd';
}
}
if (level == 0) {
vfprintf(stdout,fmt,ap);
}
va_end(ap);
va_start(ap, format_str);
if (logfile) {
vfprintf(logfile,fmt,ap);
}
va_end(ap);
return(0);
}
void lindent(int level, int ply)
{
while (ply--)
lprintf(level, "\t");
}
int cprintf(int level, char *format_str, ...)
{
va_list ap;
if (!cfile) {
cfile = fopen("wnorm.dat", "w");
setlinebuf(cfile);
}
va_start(ap, format_str);
vfprintf(cfile,format_str,ap);
va_end(ap);
return(0);
}