home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odtlktv4.zip / ODTLKT / TOOLKIT / BETA / SAMPLES / OPENDOC / PARTS / CNTNRPRT / DEBUG.CPP < prev    next >
C/C++ Source or Header  |  1995-09-27  |  3KB  |  134 lines

  1. // for the sake of a strcpy, include string.h
  2. #include <stdarg.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #define INCL_WIN
  6. #define INCL_BASE
  7. //#define INCL_DOSERRORS
  8.  
  9. //#ifndef _ODTYPES_
  10. //#include "ODTypes.h"
  11. //#endif
  12. #define INCL_ODAPI
  13. #include <os2.h>
  14.  
  15. #include "debug.hpp"
  16.  
  17. extern "C" {
  18.    int staticlinkdebughelper;
  19.  
  20.    //--------------------------------------------------------
  21.    VOID EXPENTRY fappend(char* FileName, char* Data)
  22.    {
  23. #if 0   // [133493] ced  - use somPrintf so output can be redirected
  24.       HFILE NewFileHandle;
  25.       ULONG ActionTaken=1;
  26.       ULONG BytesWritten;
  27.    
  28.       ULONG  NewLocation;
  29.       if(DosOpen((PSZ)FileName,&NewFileHandle,&ActionTaken,0L,0,0x11,0x00A1,0L)) return;
  30.       DosChgFilePtr(NewFileHandle,0L,2,&NewLocation);
  31.    
  32.         {
  33.         ULONG size =strlen((char*)&Data[0]);
  34.         DosWrite(NewFileHandle,
  35.                  (char*)&Data[0],
  36.                  size,
  37.                  &BytesWritten);
  38.         }
  39.    
  40.       DosClose(NewFileHandle);
  41. #endif
  42.       somPrintf("%s", Data);
  43.    }
  44.    #ifdef SYNCH_CLIB
  45.       CHAR CLibrary;
  46.    #endif
  47.    
  48.    //--------------------------------------------------------
  49.    VOID EXPENTRY vfappendf(char* FileName, char* Format, va_list args)
  50.    {
  51.       char string[270];
  52.    
  53.       string[0]='\0';
  54.       #ifdef SYNCH_CLIB
  55.          EnterMonitor(&CLibrary, 1);
  56.          vsprintf(string,Format,args);
  57.          ExitMonitor(&CLibrary);
  58.       #else
  59.          vsprintf( (char*)string,Format,args);
  60.       #endif
  61.       fappend( FileName, string);
  62.    }
  63.    
  64.    //--------------------------------------------------------
  65.    VOID fprintf2(char* FileName, char* Format, ...)
  66.    {
  67.       va_list args;
  68.    
  69.       va_start(args, Format);
  70.          vfappendf(FileName, Format, args);
  71.       va_end(args);
  72.    }
  73.    
  74.    //--------------------------------------------------------
  75.    VOID EXPENTRY fappenddate( char* FileName)
  76.    {
  77.       DATETIME DateTime;
  78.       USHORT rc;
  79.    
  80.       rc = DosGetDateTime(&DateTime);
  81.       fprintf2(FileName, "[%d-%02d-%02d %2d:%02d:%02d] ",
  82.                       DateTime.year,
  83.                       DateTime.month,
  84.                       DateTime.day,
  85.                       DateTime.hours,
  86.                       DateTime.minutes,
  87.                       DateTime.seconds);
  88.    }
  89.    
  90.    
  91.    
  92.    //--------------------------------------------------------
  93.    VOID rrprintf(char* Format, ...)    /*debug*/
  94.    {
  95.       va_list args;
  96.       char xxx[300];
  97.       strcpy( xxx, Format);
  98.    
  99.       {
  100.          strcat( xxx, "\r\n");
  101.          fappenddate("opendoc.log");
  102.       }
  103.       fappenddate("opendoc.log");
  104.       va_start(args, Format);
  105.          vfappendf("opendoc.log", xxx, args);
  106.       va_end(args);
  107.    }
  108.    
  109.    //--------------------------------------------------------
  110.    VOID beepprintf(char* Format, ...)    /*debug*/
  111.    {
  112.       va_list args;
  113.       char xxx[300];
  114.       strcpy( xxx, Format);
  115.    
  116.       {
  117.          strcat( xxx, "\r\n");
  118.          fappenddate("opendoc.log");
  119.       }
  120.       va_start(args, Format);
  121.          vfappendf("opendoc.log", xxx, args);
  122.       va_end(args);
  123.       DosBeep(200,30);
  124.    }
  125.    void EXPENTRY WinMBox( char* msg )
  126.    {
  127.       WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  128.                  (PSZ)msg, /*caption:*/(PSZ)"", /*id?*/5,
  129.                  MB_OK | MB_ERROR
  130.                  );
  131.    }
  132. };
  133.  
  134.