OS/2-specific fixes, round II
[p5sagit/p5-mst-13.2.git] / os2 / OS2 / Process / Process.xs
index 97e5d2f..05befa0 100644 (file)
@@ -315,8 +315,6 @@ DeclWinFunc_CACHE(BOOL, CreateFrameControls,
 DeclWinFunc_CACHE(BOOL, OpenClipbrd, (HAB hab), (hab));
 DeclWinFunc_CACHE(BOOL, EmptyClipbrd, (HAB hab), (hab));
 DeclWinFunc_CACHE(BOOL, CloseClipbrd, (HAB hab), (hab));
-DeclWinFunc_CACHE(HWND, QueryClipbrdViewer, (HAB hab), (hab));
-DeclWinFunc_CACHE(HWND, QueryClipbrdOwner, (HAB hab), (hab));
 DeclWinFunc_CACHE(BOOL, QueryClipbrdFmtInfo, (HAB hab, ULONG fmt, PULONG prgfFmtInfo), (hab, fmt, prgfFmtInfo));
 DeclWinFunc_CACHE(ULONG, QueryClipbrdData, (HAB hab, ULONG fmt), (hab, fmt));
 DeclWinFunc_CACHE(HWND, SetClipbrdViewer, (HAB hab, HWND hwnd), (hab, hwnd));
@@ -324,10 +322,6 @@ DeclWinFunc_CACHE(HWND, SetClipbrdOwner, (HAB hab, HWND hwnd), (hab, hwnd));
 DeclWinFunc_CACHE(ULONG, EnumClipbrdFmts, (HAB hab, ULONG fmt), (hab, fmt));
 DeclWinFunc_CACHE(ATOM, AddAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
                  (hAtomTbl, pszAtomName));
-DeclWinFunc_CACHE(ATOM, FindAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
-                 (hAtomTbl, pszAtomName));
-DeclWinFunc_CACHE(ATOM, DeleteAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
-                 (hAtomTbl, pszAtomName));
 DeclWinFunc_CACHE(ULONG, QueryAtomUsage, (HATOMTBL hAtomTbl, ATOM atom),
                  (hAtomTbl, atom));
 DeclWinFunc_CACHE(ULONG, QueryAtomLength, (HATOMTBL hAtomTbl, ATOM atom),
@@ -338,7 +332,6 @@ DeclWinFunc_CACHE(ULONG, QueryAtomName,
 DeclWinFunc_CACHE(HATOMTBL, QuerySystemAtomTable, (VOID), ());
 DeclWinFunc_CACHE(HATOMTBL, CreateAtomTable, (ULONG initial, ULONG buckets),
                  (initial, buckets));
-DeclWinFunc_CACHE(HATOMTBL, DestroyAtomTable, (HATOMTBL hAtomTbl), (hAtomTbl));
 DeclWinFunc_CACHE(ULONG, MessageBox, (HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle), (hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle));
 DeclWinFunc_CACHE(ULONG, MessageBox2,
                  (HWND hwndParent, HWND hwndOwner, PCSZ pszText,
@@ -353,6 +346,13 @@ DeclWinFunc_CACHE(HPOINTER, QuerySysPointer,
 DeclWinFunc_CACHE(BOOL, Alarm, (HWND hwndDesktop, ULONG rgfType), (hwndDesktop, rgfType));
 DeclWinFunc_CACHE(BOOL, FlashWindow, (HWND hwndFrame, BOOL fFlash), (hwndFrame, fFlash));
 
+#if 0          /* Need to have the entry points described in the parent */
+DeclWinFunc_CACHE(BOOL, QueryClassInfo, (HAB hab, char* pszClassName, PCLASSINFO pClassInfo), (hab, pszClassName, pClassInfo));
+
+#define _QueryClassInfo(hab, pszClassName, pClassInfo) \
+       QueryClassInfo(hab, pszClassName, (PCLASSINFO)pClassInfo)
+
+#endif
 
 /* These functions do not croak on error */
 DeclWinFunc_CACHE_survive(BOOL, SetClipbrdData,
@@ -378,6 +378,16 @@ DeclWinFunc_CACHE_resetError(HWND, GetNextWindow, (HENUM henum), (henum))
 DeclWinFunc_CACHE_resetError(BOOL, IsWindowEnabled, (HWND hwnd), (hwnd))
 DeclWinFunc_CACHE_resetError(BOOL, IsWindowVisible, (HWND hwnd), (hwnd))
 DeclWinFunc_CACHE_resetError(BOOL, IsWindowShowing, (HWND hwnd), (hwnd))
+DeclWinFunc_CACHE_resetError(ATOM, FindAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
+                            (hAtomTbl, pszAtomName));
+DeclWinFunc_CACHE_resetError(ATOM, DeleteAtom, (HATOMTBL hAtomTbl, ATOM atom),
+                            (hAtomTbl, atom));
+DeclWinFunc_CACHE_resetError(HATOMTBL, DestroyAtomTable, (HATOMTBL hAtomTbl), (hAtomTbl));
+DeclWinFunc_CACHE_resetError(HWND, QueryClipbrdViewer, (HAB hab), (hab));
+DeclWinFunc_CACHE_resetError(HWND, QueryClipbrdOwner, (HAB hab), (hab));
+
+#define _DeleteAtom            DeleteAtom
+#define _DestroyAtomTable      DestroyAtomTable
 
 /* No die()ing on error */
 DeclWinFunc_CACHE_survive(BOOL, IsWindow, (HAB hab, HWND hwnd), (hab, hwnd))
@@ -521,15 +531,22 @@ myWinQueryActiveDesktopPathname()
 SV *
 myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl)
 {
-    ULONG len = QueryAtomLength(hAtomTbl, atom);
+  ULONG len = QueryAtomLength(hAtomTbl, atom);
+
+  if (len) {                   /* Probably always so... */
     SV *sv = newSVpvn("",0);
     STRLEN n_a;
 
     SvGROW(sv, len + 1);
-    QueryAtomName(hAtomTbl, atom, SvPV(sv, n_a), len);
-    SvCUR_set(sv, len);
-    *SvEND(sv) = 0;
-    return sv;
+    len = QueryAtomName(hAtomTbl, atom, SvPV(sv, n_a), len + 1);
+    if (len) {                 /* Probably always so... */
+      SvCUR_set(sv, len);
+      *SvEND(sv) = 0;
+      return sv;
+    }
+    SvREFCNT_dec(sv);
+  }
+  return &PL_sv_undef;
 }
 
 #define myWinQueryClipbrdFmtInfo       QueryClipbrdFmtInfo
@@ -539,26 +556,28 @@ void
 ClipbrdData_set(SV *sv, int convert_nl, unsigned long fmt, unsigned long rgfFmtInfo, HAB hab)
 {
     STRLEN len;
-    char *buf = SvPV_force(sv, len);
-    char *pByte = 0, *s = buf, c;
-    ULONG nls = 0, rc;
+    char *buf;
+    char *pByte = 0, *s, c;
+    ULONG nls = 0, rc, handle;
 
-    if (convert_nl) {
+    if (rgfFmtInfo & CFI_POINTER) {
+      s = buf = SvPV_force(sv, len);
+      if (convert_nl) {
        while ((c = *s++)) {
            if (c == '\r' && *s == '\n')
                s++;
            else if (c == '\n')
                nls++;
        }
-    }
+      }
 
-    if (CheckOSError(DosAllocSharedMem((PPVOID)&pByte, 0, len + nls + 1,
+      if (CheckOSError(DosAllocSharedMem((PPVOID)&pByte, 0, len + nls + 1,
                                       PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_GETTABLE)))
        croak_with_os2error("ClipbrdData_set: DosAllocSharedMem error");
 
-    if (!nls)
+      if (!nls)
        memcpy(pByte, buf, len + 1);
-    else {
+      else {
        char *t = pByte, *e = buf + len;
 
        while (buf < e) {
@@ -566,14 +585,56 @@ ClipbrdData_set(SV *sv, int convert_nl, unsigned long fmt, unsigned long rgfFmtI
            if (c == '\n' && (t == pByte + 1 || t[-2] != '\r'))
                t[-1] = '\r', *t++ = '\n';
        }
+      }
+      handle = (ULONG)pByte;
+    } else {
+      handle = (ULONG)SvUV(sv);
     }
 
-    if (!SetClipbrdData(hab, (ULONG)pByte, fmt, rgfFmtInfo)) {
-       DosFreeMem((PPVOID)&pByte);
+    if (!SetClipbrdData(hab, handle, fmt, rgfFmtInfo)) {
+       if (fmt & CFI_POINTER)
+           DosFreeMem((PPVOID)&pByte);
        croak_with_os2error("ClipbrdData_set: WinSetClipbrdData error");
     }
 }
 
+ULONG
+QueryMemoryRegionSize(ULONG addr, ULONG *flagp, ULONG len, I32 interrupt)
+{
+    ULONG l, f;                                /* Modifiable copy */
+    ULONG rc;
+
+    do {
+       l = len;
+       rc = DosQueryMem((void *)addr, &l, &f);
+    } while ( interrupt ? 0 : rc == ERROR_INTERRUPT );
+
+    /* We assume this is not about addr */
+/*
+    if (rc == ERROR_INVALID_ADDRESS)
+       return 0xFFFFFFFF;
+*/
+    os2cp_croak(rc,"QueryMemoryRegionSize");
+    if (flagp)
+       *flagp = f;
+    return l;
+}
+
+static ULONG
+default_fmtInfo(ULONG fmt)
+{
+   switch (fmt) {
+     case CF_PALETTE:  /* Actually, fmtInfo not documented for palette... */
+     case CF_BITMAP:
+     case CF_METAFILE:
+     case CF_DSPBITMAP:
+     case CF_DSPMETAFILE:
+       return CFI_HANDLE;
+     default:
+       return CFI_POINTER;
+   }
+}
+
 #if 0
 
 ULONG
@@ -889,7 +950,286 @@ bufsize(void)
     return i[0]*i[1]*2;
 #endif /* 0 */
 }
-    
+
+SV*
+_kbdChar(unsigned int nowait, int handle)
+{
+    KBDKEYINFO viob[2], *vio;
+    ULONG rc;
+
+    VIO_FROM_VIOB;
+
+    if (nowait > 2)
+       croak("unexpected nowait");
+    if (CheckOSError(nowait == 2
+                    ? KbdPeek( vio, handle )
+                    : KbdCharIn( vio, nowait == 1, handle )))
+       croak_with_os2error("Can't _kbdChar");
+    return newSVpvn((char*)vio, sizeof(*vio));
+}
+
+SV*
+_kbdStatus(int handle)
+{
+    KBDINFO viob[2], *vio;
+    ULONG rc;
+
+    VIO_FROM_VIOB;
+
+    vio->cb = sizeof(*vio);
+    if (CheckOSError(KbdGetStatus( vio, handle )))
+       croak_with_os2error("Can't _kbdStatus");
+    return newSVpvn((char*)vio, sizeof(*vio));
+}
+
+void
+_kbdStatus_set(SV* sv, int handle)
+{
+    KBDINFO viob[2], *vio;
+    ULONG rc;
+    STRLEN l;
+    char *s = SvPV(sv, l);
+
+    VIO_FROM_VIOB;
+
+    if (l != sizeof(*vio))
+       croak("unexpected datasize");
+    Copy((KBDINFO*)s, vio, 1, KBDINFO);
+    if (vio->cb != sizeof(*vio))
+       croak("unexpected datasize");
+    if (CheckOSError(KbdSetStatus( vio, handle )))
+       croak_with_os2error("Can't kbdStatus_set()");
+}
+
+SV*
+_vioConfig(int which, int handle)
+{
+    struct {VIOCONFIGINFO i; short a[20];} viob[2], *vio;
+    ULONG rc;
+
+    VIO_FROM_VIOB;
+
+    vio->i.cb = 2;
+    if (CheckOSError(VioGetConfig( which, &vio->i, handle )))
+       croak_with_os2error("Can't get VIO config size");
+    if (vio->i.cb > sizeof(*vio))
+       vio->i.cb = sizeof(*vio);
+    if (CheckOSError(VioGetConfig( which, &vio->i, handle )))
+       croak_with_os2error("Can't get VIO config");
+    return newSVpvn((char*)vio, vio->i.cb);
+}
+
+SV*
+_vioMode(void)
+{
+    VIOMODEINFO viob[2], *vio;
+    ULONG rc;
+
+    VIO_FROM_VIOB;
+
+    vio->cb = sizeof(*vio);
+    if (CheckOSError(VioGetMode( vio, 0 )))
+       croak_with_os2error("Can't get VIO mode");
+    return newSVpvn((char*)vio, sizeof(*vio));
+}
+
+void
+_vioMode_set(SV* sv)
+{
+    VIOMODEINFO viob[2], *vio;
+    ULONG rc;
+    STRLEN l;
+    char *s = SvPV(sv, l);
+
+    VIO_FROM_VIOB;
+
+    Copy((VIOMODEINFO*)s, vio, 1, VIOMODEINFO);
+    if (vio->cb != sizeof(*vio) || l != vio->cb)
+       croak("unexpected datasize");
+    if (CheckOSError(VioSetMode( vio, 0 )))
+       croak_with_os2error("Can't set VIO mode");
+}
+
+SV*
+vioFont(int type, int *w, int *h) /* 0 for actual RAM font, 1 for ROM font */
+{
+    VIOFONTINFO viob[2], *vio;
+    ULONG rc;
+    UCHAR b[1<<17];
+    UCHAR *buf = b;
+    SV *sv;
+
+    VIO_FROM_VIOB;
+
+    /* Should not cross 64K boundaries too: */
+    if (((ULONG)buf) & 0xFFFF)
+       buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
+
+    vio->cb = sizeof(*vio);
+    vio->type = type;                  /* BIOS or the loaded font. */
+    vio->cbData = 0xFFFF;              /* How large is my buffer? */
+    vio->pbData = _emx_32to16(buf);    /* Wants an 16:16 pointer */
+    if (CheckOSError(VioGetFont( vio, 0 )))
+       croak_with_os2error("Can't get VIO font");
+    *w = vio->cxCell;
+    *h = vio->cyCell;
+    return newSVpvn(buf,vio->cbData);
+}
+
+void
+vioFont_set(SV *sv, int cellwidth, int cellheight, int type)
+{
+    VIOFONTINFO viob[2], *vio;
+    ULONG rc;
+    UCHAR b[1<<17];
+    UCHAR *buf = b;
+    STRLEN l;
+    char *s = SvPV(sv, l);
+
+    VIO_FROM_VIOB;
+
+    /* Should not cross 64K boundaries too: */
+    if (((ULONG)buf) & 0xFFFF)
+       buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
+
+    if (l > 0xFFFF)
+       croak("length overflow of VIO font");
+    if (l != (cellwidth + 7)/8 * cellheight * 256)
+       warn("unexpected length of VIO font");
+    vio->cb = sizeof(*vio);
+    vio->type = type;                  /* BIOS or the loaded font. */
+    vio->cbData = l;                   /* How large is my buffer? */
+    vio->pbData = _emx_32to16(buf);    /* Wants an 16:16 pointer */
+    vio->cxCell = cellwidth;
+    vio->cyCell = cellheight;
+    Copy(s, buf, l, char);
+
+    if (CheckOSError(VioSetFont( vio, 0 )))
+       croak_with_os2error("Can't set VIO font");
+}
+
+/*
+  uses use32,os2def,os2base,crt,defs;
+  var   Plt :Plt256;
+  const Pal :VioPalState=(Cb:sizeof(VioPalState);rType:0;iFirst:0;
+    Acolor:($FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF));
+        CReg:VioColorReg=(Cb:sizeof(VioColorReg);rType:3;FirstColorReg:0;
+    NumColorRegs:256; ColorRegAddr:@Plt);
+  var   ii:Pointer;
+  begin
+   VioGetState(Pal,0);
+   Pal.Acolor[09]:=$0F;
+   Pal.Acolor[10]:=$A;
+   Pal.Acolor[13]:=$2F;
+   VioSetState(Pal,0); // ce smena EGA registrov
+   asm
+  lea   eax,Plt
+     call  DosFlatToSel
+     mov   ii,eax
+   end;
+   CReg.ColorRegAddr:=ii;
+   VioGetState(CReg,0);
+   Plt[10,0]:=$00;
+   Plt[10,1]:=$32;
+   Plt[10,2]:=$2A;
+   VioSetState(CReg,0); // a ce - VGA registrov
+  end.
+*/
+
+typedef union {
+  VIOPALSTATE pal;
+  struct { VIOPALSTATE pal; USHORT a[15]; } pal_padded;
+  VIOOVERSCAN overscan;
+  VIOINTENSITY intensity;
+  VIOCOLORREG colorreg;
+  struct { VIOCOLORREG reg; char rgb[3*256]; } colorreg_padded;
+  VIOSETULINELOC lineloc;
+  VIOSETTARGET target;
+} my_VIOSTATE;
+
+int
+vio_state_size(int what)
+{
+    static const char sizes[] = {
+       sizeof(VIOPALSTATE),
+       sizeof(VIOOVERSCAN),
+       sizeof(VIOINTENSITY),
+       sizeof(VIOCOLORREG),
+       6,                              /* Random number: Reserved entry */
+       sizeof(VIOSETULINELOC),
+       sizeof(VIOSETTARGET)
+    };
+    if (what < 0 || what >= sizeof(sizes))
+       croak("Unexpected VIO state type");
+    return sizes[what];
+}
+
+SV*
+_vioState(int what, int first, int count)
+{
+    my_VIOSTATE viob[2], *vio;
+    ULONG rc, size = vio_state_size(what);
+
+    VIO_FROM_VIOB;
+
+    vio->pal.cb = size;
+    vio->pal.type = what;
+    if (what == 0) {
+       vio->pal.iFirst = first;
+       if (first < 0 || first >= 16)
+           croak("unexpected palette start value");
+       if (count < 0 || count > 16)
+           croak("unexpected palette count");
+       vio->pal.cb = (size += (count - 1) * sizeof(short));
+    } else if (what == 3) {
+       /* Wants an 16:16 pointer */
+       if (count < 0 || count > 256)
+           croak("unexpected palette count");
+       vio->colorreg.colorregaddr = (PCH)_emx_32to16(vio->colorreg_padded.rgb);
+       vio->colorreg.numcolorregs = count;             /* 256 is max */
+       vio->colorreg.firstcolorreg = first;
+       size += 3 * count;
+    }
+    if (CheckOSError(VioGetState( (void*)vio, 0 )))
+       croak_with_os2error("Can't get VIO state");
+    return newSVpvn((char*)vio, size);
+}
+
+void
+_vioState_set(SV *sv)
+{
+    my_VIOSTATE viob[2], *ovio = (my_VIOSTATE*)SvPV_nolen(sv), *vio = ovio;
+    int what = ovio->pal.type, cb = ovio->pal.cb;
+    ULONG rc, size = vio_state_size(what);
+    STRLEN l;
+    char *s = SvPV(sv, l);
+
+    VIO_FROM_VIOB;
+
+    switch (what) {
+    case 0:
+       if ( cb < size || cb > size + 15*sizeof(SHORT) || l != cb)
+           croak("unexpected datasize");
+       size = l;
+       break;
+    case 3:
+       if (l != cb + 3 * ovio->colorreg.numcolorregs || cb != size)
+           croak("unexpected datasize");
+       size = l;
+       break;
+    default:
+       if (l != cb || l != size )
+           croak("unexpected datasize");
+       break;
+    }
+    Copy(s, (char*)vio, size, char);
+    if (what == 3)     /* We expect colors put after VIOCOLORREG */
+       vio->colorreg.colorregaddr = (PCH)_emx_32to16(vio->colorreg_padded.rgb);
+
+    if (CheckOSError(VioSetState( (void*)vio, 0 )))
+       croak_with_os2error("Can't set VIO state");
+}
+
 SV *
 screen(void)
 {
@@ -1016,6 +1356,55 @@ sidOf(int pid)
   return sid;
 }
 
+STRLEN
+StrLen(ULONG addr, ULONG lim, I32 unitsize)
+{
+    switch (unitsize) {
+      case 1:
+       {
+           char *s = (char *)addr;
+           char *s1 = s, *e = (char *)(addr + lim);
+
+           while (s < e && *s)
+               s++;
+           return s - s1;
+       }
+       break;
+      case 2:
+       {
+           short *s = (short *)addr;
+           short *s1 = s, *e = (short *)(addr + lim);
+
+           while (s < e && *s)
+               s++;
+           return (char*)s - (char*)s1;
+       }
+       break;
+      case 4:
+       {
+           int *s = (int *)addr;
+           int *s1 = s, *e = (int *)(addr + lim);
+
+           while (s < e && *s)
+               s++;
+           return (char*)s - (char*)s1;
+       }
+       break;
+      case 8:
+       {
+           long long *s = (long long *)addr;
+           long long *s1 = s, *e = (long long *)(addr + lim);
+
+           while (s < e && *s)
+               s++;
+           return (char*)s - (char*)s1;
+       }
+       break;
+      default:
+       croak("StrLen: unknown unitsize %d", (int)unitsize);
+    }
+}
+
 #define ulMPFROMSHORT(i)               ((unsigned long)MPFROMSHORT(i))
 #define ulMPVOID()                     ((unsigned long)MPVOID)
 #define ulMPFROMCHAR(i)                        ((unsigned long)MPFROMCHAR(i))
@@ -1088,6 +1477,8 @@ swentries_list()
 
 void
 ResetWinError()
+   POSTCALL:
+       XSRETURN_YES;
 
 int
 WindowText_set(HWND hwndFrame, char *title)
@@ -1216,25 +1607,70 @@ cursor(OUTLIST int stp, OUTLIST int ep, OUTLIST int wp, OUTLIST int ap)
 bool
 cursor_set(int s, int e, int w = cursor__(0), int a = cursor__(1))
 
+SV*
+_kbdChar(int nowait = 0, int handle = 0)
+
+SV*
+_kbdStatus(int handle = 0)
+
+void
+_kbdStatus_set(SV *sv, int handle = 0)
+   POSTCALL:
+       XSRETURN_YES;
+
+SV*
+_vioConfig(int which = 0, int handle = 0)
+
+SV*
+_vioMode()
+
+void
+_vioMode_set(SV *buffer)
+   POSTCALL:
+       XSRETURN_YES;
+
+SV*
+_vioState(int what, int first = -1, int count = -1)
+
+void
+_vioState_set(SV *buffer)
+   POSTCALL:
+       XSRETURN_YES;
+
+SV*
+vioFont( int type = 0, OUTLIST int w, OUTLIST int h)
+
+void
+vioFont_set(SV *buffer, int cellwidth, int cellheight, int type = 0)
+   POSTCALL:
+       XSRETURN_YES;
+
 NO_OUTPUT bool
-_ClipbrdData_set(unsigned long ulData, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = ((fmt == CF_TEXT || fmt == CF_DSPTEXT) ? CFI_POINTER : CFI_HANDLE), HAB hab = perl_hab_GET())
+_ClipbrdData_set(unsigned long ulData, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = default_fmtInfo(fmt), HAB hab = perl_hab_GET())
     PROTOTYPE: DISABLE
     C_ARGS: hab, ulData, fmt, rgfFmtInfo
     POSTCALL:
        if (CheckWinError(RETVAL))
            croak_with_os2error("_ClipbrdData_set() error");
+       XSRETURN_YES;
 
 void
-ClipbrdData_set(SV *text, int convert_nl = 1, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = ((fmt == CF_TEXT || fmt == CF_DSPTEXT) ? CFI_POINTER : CFI_HANDLE), HAB hab = perl_hab_GET())
+ClipbrdData_set(SV *text, int convert_nl = 1, unsigned long fmt = CF_TEXT, unsigned long rgfFmtInfo = default_fmtInfo(fmt), HAB hab = perl_hab_GET())
     PROTOTYPE: DISABLE
+    POSTCALL:
+       XSRETURN_YES;
 
 void
 ClipbrdOwner_set(HWND hwnd, HAB hab = perl_hab_GET())
     C_ARGS: hab, hwnd
+    POSTCALL:
+       XSRETURN_YES;
 
 void
 ClipbrdViewer_set(HWND hwnd, HAB hab = perl_hab_GET())
     C_ARGS: hab, hwnd
+    POSTCALL:
+       XSRETURN_YES;
 
 unsigned long
 EnumClipbrdFmts(unsigned long fmt = 0, HAB hab = perl_hab_GET())
@@ -1249,15 +1685,31 @@ FindAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
     C_ARGS: hAtomTbl, pszAtomName
 
 unsigned long
-DeleteAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
-    C_ARGS: hAtomTbl, pszAtomName
+_DeleteAtom(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
+    PROTOTYPE: DISABLE
+    C_ARGS: hAtomTbl, atom
+
+#if 0
+
+unsigned long
+WinDeleteAtom(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
+    C_ARGS: hAtomTbl, atom
+
+#endif
 
 void
 Alarm(unsigned long rgfType = WA_ERROR, HWND hwndDesktop = HWND_DESKTOP)
     C_ARGS: hwndDesktop, rgfType
+    POSTCALL:
+       XSRETURN_YES;
 
 void
 FlashWindow(HWND hwndFrame, bool fFlash)
+    POSTCALL:
+       XSRETURN_YES;
+
+STRLEN
+StrLen(ULONG addr, ULONG lim, I32 unitsize = 1)
 
 MODULE = OS2::Process          PACKAGE = OS2::Process  PREFIX = myQuery
 
@@ -1295,6 +1747,9 @@ QueryClipbrdData(unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
     C_ARGS: hab, fmt
     PROTOTYPE: DISABLE
 
+ULONG
+QueryMemoryRegionSize(ULONG addr, OUTLIST ULONG flagp, ULONG len = 0xFFFFFFFF - addr, I32 interrupt = 1)
+
 unsigned long
 QueryClipbrdViewer(HAB hab = perl_hab_GET())
 
@@ -1303,9 +1758,13 @@ QueryClipbrdOwner(HAB hab = perl_hab_GET())
 
 void
 CloseClipbrd(HAB hab = perl_hab_GET())
+    POSTCALL:
+       XSRETURN_YES;
 
 void
 EmptyClipbrd(HAB hab = perl_hab_GET())
+   POSTCALL:
+       XSRETURN_YES;
 
 bool
 OpenClipbrd(HAB hab = perl_hab_GET())
@@ -1317,6 +1776,9 @@ QueryAtomUsage(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
 unsigned long
 QueryAtomLength(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
     C_ARGS: hAtomTbl, atom
+   POSTCALL:
+       if (!RETVAL)
+           XSRETURN_EMPTY;
 
 unsigned long
 QuerySystemAtomTable()
@@ -1329,7 +1791,8 @@ unsigned long
 CreateAtomTable(unsigned long initial = 0, unsigned long buckets = 0)
 
 unsigned long
-DestroyAtomTable(HATOMTBL hAtomTbl)
+_DestroyAtomTable(HATOMTBL hAtomTbl)
+    PROTOTYPE: DISABLE
 
 
 MODULE = OS2::Process          PACKAGE = OS2::Process  PREFIX = myWinQuery
@@ -1364,20 +1827,20 @@ myWinSwitchToProgram(HSWITCH hsw = switch_of(NULLHANDLE, getpid()))
 #if 0
 
 unsigned long
-myWinMessageBox(unsigned long pszText, char* pszCaption = "Perl script error", unsigned long flStyle = MB_CANCEL | MB_ICONHAND, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = HWND_DESKTOP, unsigned long idWindow = 0)
+myWinMessageBox(unsigned long pszText, char* pszCaption = "Perl script message", unsigned long flStyle = MB_CANCEL | MB_ICONHAND, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = HWND_DESKTOP, unsigned long idWindow = 0)
     C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
 
 #endif
 
 unsigned long
-_MessageBox(char* pszText, char* pszCaption = "Perl script error", unsigned long flStyle = MB_CANCEL | MB_INFORMATION | MB_MOVEABLE, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
+_MessageBox(char* pszText, char* pszCaption = "Perl script message", unsigned long flStyle = MB_CANCEL | MB_INFORMATION | MB_MOVEABLE, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
     C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
     POSTCALL:
        if (RETVAL == MBID_ERROR)
            RETVAL = 0;
 
 unsigned long
-_MessageBox2(char *pszText, char* pmb2info, char *pszCaption, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
+_MessageBox2(char *pszText, char* pmb2info, char *pszCaption = "Perl script message", HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
     C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, (PMB2INFO)pmb2info
     POSTCALL:
        if (RETVAL == MBID_ERROR)