fix debug.c to use platform independent includes
[git-cheetah/kirill.git] / common / debug.c
blob9732f085eccef57660b5f8d1d155ef8286e77792
1 #include "git-compat-util.h"
2 #include "debug.h"
4 static char debug_git_file[MAX_PATH];
5 static FILE * debug_git_fd = NULL;
7 void debug_git_set_file(const char * filename)
9 if (debug_git_fd)
11 fclose(debug_git_fd);
12 debug_git_fd = NULL;
15 strncpy(debug_git_file, filename, MAX_PATH);
16 debug_git_file[MAX_PATH-1] = '\0';
18 debug_git_fd = fopen(debug_git_file, "a+");
21 void debug_git(char * format, ...)
23 if (!debug_git_fd)
25 debug_git_set_file(DEFAULT_DEBUG_GIT_FILE);
28 /* Check again in case the above debug_git_set_file failed. */
29 if (debug_git_fd)
31 va_list params;
32 char buffer[1024];
33 int length = 0;
35 va_start(params, format);
36 length = vsnprintf(buffer, sizeof(buffer), format, params);
37 va_end(params);
38 fwrite(buffer, sizeof(char), length, debug_git_fd);
39 fputc('\n', debug_git_fd);
40 fflush(debug_git_fd);
44 void debug_git_mbox(char *format, ...)
46 va_list params;
47 char buffer[1024];
49 va_start(params, format);
50 vsnprintf(buffer, sizeof(buffer), format, params);
51 va_end(params);
52 message_box(buffer);