debug.c 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "debug.h"
  2. #ifdef DEBUG
  3. int debug_handle;
  4. #ifndef DEBUG_PATH
  5. #define DEBUG_PATH "\\\\crd0\\TeX.log"
  6. #endif
  7. #ifndef DEBUG_FILE
  8. #define DEBUG_FILE 10000
  9. #endif
  10. #ifndef DEBUG_SIZE
  11. #define DEBUG_SIZE 100
  12. #endif
  13. void debug_init(void)
  14. {
  15. char debug_path[] = DEBUG_PATH;
  16. unsigned short *bfile_path;
  17. int i=0;
  18. while(debug_path[i]) i++;
  19. bfile_path = calloc(i+1,2);
  20. for(i=0;debug_path[i];i++) bfile_path[i] = debug_path[i];
  21. bfile_path[i] = 0x0;
  22. Bfile_DeleteFile(bfile_path);
  23. Bfile_CreateFile(bfile_path,DEBUG_FILE);
  24. debug_handle = Bfile_OpenFile(bfile_path,_OPENMODE_WRITE);
  25. free(bfile_path);
  26. }
  27. void debug(const char *format, ...)
  28. {
  29. char ch[DEBUG_SIZE+1];
  30. va_list args;
  31. va_start(args,format);
  32. vsprintf(ch,format,args);
  33. va_end(args);
  34. ch[DEBUG_SIZE] = 0;
  35. Bfile_WriteFile(debug_handle,ch,strlen(ch));
  36. }
  37. void debug_quit(void)
  38. {
  39. Bfile_CloseFile(debug_handle);
  40. }
  41. #endif // DEBUG