MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / log_open

Function log_open

src/log.c:73–95  ·  view source on GitHub ↗

@ @ requires separation: \separated(default_filename, errsv, log_handle, &errno); @ assigns log_handle; @ assigns \result,errno,*errsv; @*/

Source from the content-addressed store, hash-verified

71 @ assigns \result,errno,*errsv;
72 @*/
73int 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);

Callers 5

log_open_defaultFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
fidentify.cFile · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68