| 101 | @*/ |
| 102 | #if defined(__CYGWIN__) || defined(__MINGW32__) |
| 103 | int log_open_default(const char*default_filename, const int mode, int *errsv) |
| 104 | { |
| 105 | char*filename; |
| 106 | char *path; |
| 107 | int result; |
| 108 | if(log_handle != NULL) |
| 109 | return 1; |
| 110 | path = getenv("USERPROFILE"); |
| 111 | if (path == NULL) |
| 112 | path = getenv("HOMEPATH"); |
| 113 | if(path == NULL) |
| 114 | return log_open(default_filename, mode, errsv); |
| 115 | /* Check to avoid buffer overflow may not be 100% bullet proof */ |
| 116 | if(strlen(path)+strlen(default_filename)+2 > 4096) |
| 117 | return log_open(default_filename, mode, errsv); |
| 118 | filename=(char*)MALLOC(4096); |
| 119 | #ifdef __CYGWIN__ |
| 120 | cygwin_conv_path(CCP_WIN_A_TO_POSIX, path, filename, 4096); |
| 121 | #else |
| 122 | strcpy(filename, path); |
| 123 | #endif |
| 124 | strcat(filename, "/"); |
| 125 | strcat(filename, default_filename); |
| 126 | result=log_open(filename, mode, errsv); |
| 127 | free(filename); |
| 128 | return result; |
| 129 | } |
| 130 | #else |
| 131 | int log_open_default(const char*default_filename, const int mode, int *errsv) |
| 132 | { |