home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PMDEBUG.ZIP / PMDEBFUN.C next >
C/C++ Source or Header  |  1990-03-05  |  1KB  |  70 lines

  1. #define INCL_DOS
  2. #define INCL_GPI
  3. #define INCL_WIN
  4. #include "os2.h"
  5. #define PASFAR pascal far
  6.  
  7. writequeue(char far *txt, USHORT mode, USHORT len)
  8. {
  9.    SEL selector, qownersel;
  10.    char far *p;
  11.    char far *ptr;
  12.    int i;
  13.    static HQUEUE hq=NULL;
  14.    static char queuename[] = "\\QUEUES\\PMDEBUG";
  15.    static int pid;
  16.  
  17.    if (!hq && DosOpenQueue((USHORT*)&pid, &hq, queuename))
  18.       return -1;
  19.  
  20.    if (DosAllocSeg( len, &selector,SEG_GIVEABLE))
  21.       return -2;
  22.  
  23.    ptr = MAKEP(selector,0);
  24.  
  25.    for (i=0; i<len; i++)
  26.       ptr[i] = txt[i];
  27.  
  28.    if (DosGiveSeg(selector, pid, &qownersel))
  29.       return -3;
  30.  
  31.    ptr = MAKEP(qownersel,0);
  32.  
  33.    if(DosWriteQueue(hq ,mode, len, (PBYTE)ptr,0))
  34.       return -4;
  35.  
  36.    DosFreeSeg(selector);
  37. }
  38.  
  39. int PASFAR debug_puts(char far *txt)
  40. {
  41.    USHORT i; char far *p;
  42.  
  43.    p = txt;
  44.    i = 0;
  45.  
  46.    while (*p)  { p++; i++; } 
  47.    return writequeue(txt,0,i);
  48. }
  49.  
  50. int PASFAR debug_logmessage(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2, char far *txt)
  51. {
  52.    QMSG q;
  53.    int i; char far *p;
  54.    p = txt;
  55.    i = 0;
  56.  
  57.    while (*p)  { p++; i++; } 
  58.  
  59.    if (i = writequeue(txt,0,i)) return i;
  60.  
  61.    q.msg  = msg;
  62.    q.hwnd = hwnd;
  63.    q.mp1 = mp1;
  64.    q.mp2 = mp2;
  65.  
  66.    if (i = writequeue((void far *) &q, 1, sizeof(QMSG)))
  67.       return i;
  68.    return 0;
  69. }
  70.