|
a/src/utils/debuglog.cpp |
|
b/src/utils/debuglog.cpp |
|
... |
|
... |
19 |
#define __USE_GNU
|
19 |
#define __USE_GNU
|
20 |
#include <stdio.h>
|
20 |
#include <stdio.h>
|
21 |
#include <stdarg.h>
|
21 |
#include <stdarg.h>
|
22 |
#include <stdlib.h>
|
22 |
#include <stdlib.h>
|
23 |
#include <string.h>
|
23 |
#include <string.h>
|
24 |
#ifndef _WIN32
|
|
|
25 |
#include <fcntl.h>
|
24 |
#include <errno.h>
|
26 |
#endif
|
25 |
#include <safefcntl.h> // in case O_APPEND is in there
|
27 |
|
|
|
28 |
#ifdef INCLUDE_NEW_H
|
26 |
#ifdef INCLUDE_NEW_H
|
29 |
#include <new.h>
|
27 |
#include <new.h>
|
30 |
#endif
|
28 |
#endif
|
31 |
|
29 |
|
32 |
#include <string>
|
30 |
#include <string>
|
|
... |
|
... |
73 |
} else if (!strcmp(filename, "stderr")) {
|
71 |
} else if (!strcmp(filename, "stderr")) {
|
74 |
fp = stderr;
|
72 |
fp = stderr;
|
75 |
} else {
|
73 |
} else {
|
76 |
fp = fopen(filename, (truncate) ? "w" : "a");
|
74 |
fp = fopen(filename, (truncate) ? "w" : "a");
|
77 |
if (fp) {
|
75 |
if (fp) {
|
78 |
setvbuf(fp, 0, _IOLBF, 0);
|
76 |
setvbuf(fp, 0, _IOLBF, BUFSIZ);
|
79 |
#ifdef O_APPEND
|
77 |
#if defined(O_APPEND) && !defined(_WIN32)
|
80 |
{
|
78 |
{
|
81 |
int flgs = 0;
|
79 |
int flgs = 0;
|
82 |
fcntl(fileno(fp), F_GETFL, &flgs);
|
80 |
fcntl(fileno(fp), F_GETFL, &flgs);
|
83 |
fcntl(fileno(fp), F_SETFL, flgs|O_APPEND);
|
81 |
fcntl(fileno(fp), F_SETFL, flgs|O_APPEND);
|
84 |
}
|
82 |
}
|
85 |
#endif
|
83 |
#endif
|
86 |
}
|
84 |
} else {
|
|
|
85 |
fprintf(stderr, "Debuglog: could not open [%s] errno %d\n",
|
|
|
86 |
filename, errno);
|
|
|
87 |
}
|
87 |
}
|
88 |
}
|
88 |
return;
|
89 |
return;
|
89 |
}
|
90 |
}
|
90 |
|
91 |
|
91 |
void maybeclosefp() {
|
92 |
void maybeclosefp() {
|