home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / NOTEBOOK.PAK / UTILS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  1.5 KB  |  56 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1995 by Borland International, All Rights Reserved
  4. //    utils.cpp - module for misc. non-class routines
  5. //----------------------------------------------------------------------------
  6. #include <owl/pch.h>
  7. #include <owl/window.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.