ReactOS  0.4.14-dev-358-gbef841c
trace.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define kTraceFileName   "trace"
 

Functions

void Trace (const int, const char *const,...)
 
void ErrorHook (const FTPCIPtr, char *)
 
void DebugHook (const FTPCIPtr, char *)
 
void SetDebug (int)
 
void UseTrace (void)
 
void OpenTrace (void)
 
void CloseTrace (void)
 

Macro Definition Documentation

◆ kTraceFileName

#define kTraceFileName   "trace"

Definition at line 11 of file trace.h.

Function Documentation

◆ CloseTrace()

void CloseTrace ( void  )

Definition at line 159 of file trace.c.

160 {
161  char pathName[256];
162  char pathName2[256];
163  char tName[32];
164 
165  if ((gOurDirectoryPath[0] == '\0') || (gTraceFile == NULL))
166  return;
167 
168  (void) sprintf(tName, "trace.%u", (unsigned int) getpid());
169  (void) OurDirectoryPath(pathName, sizeof(pathName), tName);
170  (void) OurDirectoryPath(pathName2, sizeof(pathName2), kTraceFileName);
171 
172  (void) time(&gTraceTime);
173  (void) fprintf(gTraceFile, "SESSION ENDED at: %s", ctime(&gTraceTime));
175 
176  (void) unlink(pathName2);
177  (void) rename(pathName, pathName2);
178 } /* CloseTrace */
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define unlink
Definition: syshdrs.h:54
char * OurDirectoryPath(char *const dst, const size_t siz, const char *const fname)
Definition: util.c:486
__u16 time
Definition: mkdosfs.c:366
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define kTraceFileName
Definition: trace.h:11
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
__u16 ctime
Definition: mkdosfs.c:362
_CRTIMP int __cdecl getpid(void)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
FILE * gTraceFile
Definition: trace.c:17
char gOurDirectoryPath[]
Definition: util.c:17
time_t gTraceTime
Definition: trace.c:16

Referenced by PostShell().

◆ DebugHook()

void DebugHook ( const  FTPCIPtr,
char  
)

◆ ErrorHook()

void ErrorHook ( const  FTPCIPtr,
char  
)

◆ OpenTrace()

void OpenTrace ( void  )

Definition at line 109 of file trace.c.

110 {
111  FILE *fp;
112  char pathName[256];
113  char tName[32];
114  int pid;
115  const char *cp;
116 #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
117  struct utsname u;
118 #endif
119 
120  if (gOurDirectoryPath[0] == '\0')
121  return; /* Don't create in root directory. */
122 
123  (void) sprintf(tName, "trace.%u", (unsigned int) (pid = getpid()));
124  (void) OurDirectoryPath(pathName, sizeof(pathName), tName);
125 
126  fp = fopen(pathName, FOPEN_WRITE_TEXT);
127  if (fp != NULL) {
128  (void) _chmod(pathName, 00600);
129 #ifdef HAVE_SETVBUF
130  (void) setvbuf(fp, gTraceLBuf, _IOLBF, sizeof(gTraceLBuf));
131 #endif /* HAVE_SETVBUF */
132  /* Opened the trace file. */
133  (void) time(&gTraceTime);
134  (void) fprintf(fp, "SESSION STARTED at: %s", ctime(&gTraceTime));
135  (void) fprintf(fp, " Program Version: %s\n", gVersion + 5);
136  (void) fprintf(fp, " Library Version: %s\n", gLibNcFTPVersion + 5);
137  (void) fprintf(fp, " Process ID: %u\n", pid);
138  if (gOS[0] != '\0')
139  (void) fprintf(fp, " Platform: %s\n", gOS);
140 #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
141  if (uname(&u) == 0) {
142  (void) fprintf(fp, " Uname: %.63s|%.63s|%.63s|%.63s|%.63s\r\n", u.sysname, u.nodename, u.release, u.version, u.machine);
143  }
144 #endif /* UNAME */
146  (void) fprintf(fp, " Hostname: %s (rc=%d)\n", gLib.ourHostName, gLib.hresult);
147  cp = (const char *) getenv("TERM");
148  if (cp == NULL)
149  cp = "unknown?";
150  (void) fprintf(fp, " Terminal: %s\n", cp);
151  gTraceFile = fp;
152  }
153 } /* OpenTrace */
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
char ourHostName[64]
Definition: ncftp.h:118
char * OurDirectoryPath(char *const dst, const size_t siz, const char *const fname)
Definition: util.c:486
#define FOPEN_WRITE_TEXT
Definition: syshdrs.h:83
__u16 time
Definition: mkdosfs.c:366
char gVersion[]
Definition: init.c:22
#define sprintf(buf, format,...)
Definition: sprintf.c:55
void FTPInitializeOurHostName(const FTPLIPtr)
Definition: open.c:63
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl _chmod(_In_z_ const char *_Filename, _In_ int _Mode)
__u16 ctime
Definition: mkdosfs.c:362
_CRTIMP int __cdecl getpid(void)
char gTraceLBuf[256]
Definition: trace.c:18
FTPLibraryInfo gLib
Definition: main.c:36
char gOS[]
Definition: version.c:12
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
FILE * gTraceFile
Definition: trace.c:17
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
int hresult
Definition: ncftp.h:119
char gLibNcFTPVersion[64]
Definition: ftp.c:11
char gOurDirectoryPath[]
Definition: util.c:17
time_t gTraceTime
Definition: trace.c:16
POINT cp
Definition: magnifier.c:59
_Check_return_opt_ _CRTIMP int __cdecl setvbuf(_Inout_ FILE *_File, _Inout_updates_opt_z_(_Size) char *_Buf, _In_ int _Mode, _In_ size_t _Size)
#define _IOLBF
Definition: stdio.h:129

◆ SetDebug()

void SetDebug ( int  )

Definition at line 88 of file trace.c.

89 {
90  gDebug = i;
91 } /* SetDebug */
int gDebug
Definition: trace.c:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by DebugCmd(), and InitConnectionInfo().

◆ Trace()

void Trace ( const int  ,
const char * const  ,
  ... 
)

Definition at line 30 of file trace.c.

31 {
32  va_list ap;
33  char buf[512];
34  struct tm *ltp;
35 
36  if ((gDebug >= level) || (level > 8)) {
37  va_start(ap, fmt);
38 #ifdef HAVE_VSNPRINTF
39  (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
40  buf[sizeof(buf) - 1] = '\0';
41 #else
42  (void) vsprintf(buf, fmt, ap);
43 #endif
44  va_end(ap);
45 
46  (void) time(&gTraceTime);
47  ltp = localtime(&gTraceTime);
48  if ((gTraceFile != NULL) && (ltp != NULL)) {
49  (void) fprintf(gTraceFile , "%02d:%02d:%02d %s",
50  ltp->tm_hour,
51  ltp->tm_min,
52  ltp->tm_sec,
53  buf
54  );
55  }
56  if (gDebug > level) {
57  (void) fprintf(stdout, "%s", buf);
58  }
59  }
60 } /* Trace */
#define vsnprintf
Definition: tif_win32.c:406
GLint level
Definition: gl.h:1546
int tm_min
Definition: time.h:78
int gDebug
Definition: trace.c:19
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const char * fmt
Definition: wsprintf.c:30
__u16 time
Definition: mkdosfs.c:366
FILE * stdout
#define va_end(ap)
Definition: acmsvcex.h:90
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:424
FILE * gTraceFile
Definition: trace.c:17
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
time_t gTraceTime
Definition: trace.c:16
int tm_sec
Definition: time.h:77
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
int tm_hour
Definition: time.h:79
Definition: dsound.c:943

Referenced by DebugHook().

◆ UseTrace()

void UseTrace ( void  )

Definition at line 97 of file trace.c.

98 {
100  gConn.debugLog = NULL;
102  gConn.errLog = NULL;
103 } /* UseTrace */
FTPConnectionInfo gConn
Definition: main.c:37
FTPLogProc errLogProc
Definition: ncftp.h:148
FILE * errLog
Definition: ncftp.h:146
smooth NULL
Definition: ftsmooth.c:416
FTPLogProc debugLogProc
Definition: ncftp.h:147
FILE * debugLog
Definition: ncftp.h:145
void ErrorHook(const FTPCIPtr UNUSED(cipUnused), char *msg)
Definition: trace.c:66
void DebugHook(const FTPCIPtr UNUSED(cipUnused), char *msg)
Definition: trace.c:78

Referenced by InitConnectionInfo().