All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tprintf.cpp File Reference
#include <stdio.h>
#include <stdarg.h>
#include "ccutil.h"
#include "params.h"
#include "strngs.h"
#include "tprintf.h"

Go to the source code of this file.

Macros

#define MAX_MSG_LEN   65536
 
#define EXTERN
 

Functions

DLLSYM void tprintf_internal (const char *format,...)
 

Variables

DLLSYM char * debug_file = ""
 

Macro Definition Documentation

#define EXTERN

Definition at line 34 of file tprintf.cpp.

#define MAX_MSG_LEN   65536

Definition at line 32 of file tprintf.cpp.

Function Documentation

DLLSYM void tprintf_internal ( const char *  format,
  ... 
)

Definition at line 39 of file tprintf.cpp.

41  {
43  va_list args; // variable args
44  static FILE *debugfp = NULL; // debug file
45  // debug window
46  inT32 offset = 0; // into message
47  static char msg[MAX_MSG_LEN + 1];
48 
49  va_start(args, format); // variable list
50  // Format into msg
51  #ifdef _WIN32
52  offset += _vsnprintf(msg + offset, MAX_MSG_LEN - offset, format, args);
53  if (strcmp(debug_file.string(), "/dev/null") == 0)
54  debug_file.set_value("nul");
55  #else
56  offset += vsnprintf(msg + offset, MAX_MSG_LEN - offset, format, args);
57  #endif
58  va_end(args);
59 
60  if (debugfp == NULL && strlen(debug_file.string()) > 0) {
61  debugfp = fopen(debug_file.string(), "wb");
62  } else if (debugfp != NULL && strlen(debug_file.string()) == 0) {
63  fclose(debugfp);
64  debugfp = NULL;
65  }
66  if (debugfp != NULL)
67  fprintf(debugfp, "%s", msg);
68  else
69  fprintf(stderr, "%s", msg);
71 }
#define MAX_MSG_LEN
Definition: tprintf.cpp:32
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:51
#define NULL
Definition: host.h:144
DLLSYM char * debug_file
Definition: tprintf.cpp:36
int inT32
Definition: host.h:102

Variable Documentation

DLLSYM char* debug_file = ""

"File to send tprintf output to"

Definition at line 36 of file tprintf.cpp.