@ @ requires separation: \separated(default_filename, errsv, log_handle, &errno); @ assigns log_handle; @ assigns \result,errno,*errsv; @*/
| 71 | @ assigns \result,errno,*errsv; |
| 72 | @*/ |
| 73 | int log_open(const char*default_filename, const int mode, int *errsv) |
| 74 | { |
| 75 | log_handle=fopen(default_filename,(mode==TD_LOG_CREATE?"w":"a")); |
| 76 | *errsv=errno; |
| 77 | #if defined(__CYGWIN__) || defined(__MINGW32__) |
| 78 | if(log_handle!=NULL && mode!=TD_LOG_CREATE) |
| 79 | { |
| 80 | /* append doesn't work when running the executable via wine */ |
| 81 | if(fprintf(log_handle, "\n")<=0 || fflush(log_handle)!=0) |
| 82 | { |
| 83 | fclose(log_handle); |
| 84 | log_handle=fopen(default_filename,"w"); |
| 85 | *errsv=errno; |
| 86 | } |
| 87 | } |
| 88 | #endif |
| 89 | if(log_handle==NULL) |
| 90 | return 0; |
| 91 | #if defined(HAVE_DUP2) |
| 92 | dup2(fileno(log_handle),2); |
| 93 | #endif |
| 94 | return 1; |
| 95 | } |
| 96 | |
| 97 | /*@ |
| 98 | @ requires separation: \separated(default_filename, errsv, log_handle, &errno); |
no outgoing calls