home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 13.ddi / NOTEBOOK.PAK / UTILS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  1.6 KB  |  56 lines

  1. //----------------------------------------------------------------------------
  2. //    utils.cpp - module for misc. non-class routines
  3. //----------------------------------------------------------------------------
  4. //    Copyright (c) 1993 Borland International
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <ctype.h>
  11. #include <string.h>
  12. #include <sys\timeb.h>
  13. #include <dir.h>
  14.  
  15. #include "utils.h"
  16. //----------------------------------------------------------------------------
  17. static char fmtbuff[1024];
  18. //----------------------------------------------------------------------------
  19. void alert(LPSTR caption, LPSTR message)
  20. {
  21.   MessageBox(NULL, message, caption, MB_OK | MB_ICONEXCLAMATION | 
  22.       MB_TASKMODAL);
  23. }
  24. //----------------------------------------------------------------------------
  25. void bugout(char *fmt, ...)
  26. {
  27.   char *p;
  28.  
  29.   p = (char *) &fmt;
  30.   wvsprintf(fmtbuff, fmt, p+4);
  31.   alert("BugOut", fmtbuff);
  32. }
  33. //----------------------------------------------------------------------------
  34. void log(char *fmt, ...)
  35. {
  36.   char msg[120];
  37.   char *p;
  38.   FILE *fh;
  39.   struct timeb t;
  40.   int secs;
  41.  
  42.   p = (char *) &fmt;
  43.   wvsprintf(msg, fmt, p+4);
  44.  
  45.   ftime(&t);
  46.   secs = (int) (t.time % 1000);
  47.   sprintf(fmtbuff, "@%d.%d: %s\n", secs, t.millitm, msg);
  48.  
  49.   fh = fopen(DEBUGLOG, "a");
  50.   if (fh) {
  51.     fwrite(fmtbuff, strlen(fmtbuff), 1, fh);
  52.     fclose(fh);
  53.   }
  54. }
  55. //----------------------------------------------------------------------------
  56.