This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / os2 / OS2 / Process / Process.xs
CommitLineData
760ac839 1#include <process.h>
7f61b687
IZ
2#define INCL_DOS
3#define INCL_DOSERRORS
35bc1fdc
IZ
4#define INCL_DOSNLS
5#define INCL_WINSWITCHLIST
6#define INCL_WINWINDOWMGR
7#define INCL_WININPUT
8#define INCL_VIO
9#define INCL_KBD
18729d3e
JH
10#define INCL_WINCLIPBOARD
11#define INCL_WINATOM
7f61b687 12#include <os2.h>
760ac839 13
35bc1fdc
IZ
14#include "EXTERN.h"
15#include "perl.h"
16#include "XSUB.h"
17
760ac839 18static unsigned long
41cd3736 19constant(char *name, int arg)
760ac839
LW
20{
21 errno = 0;
22 if (name[0] == 'P' && name[1] == '_') {
23 if (strEQ(name, "P_BACKGROUND"))
24#ifdef P_BACKGROUND
25 return P_BACKGROUND;
26#else
27 goto not_there;
28#endif
29 if (strEQ(name, "P_DEBUG"))
30#ifdef P_DEBUG
31 return P_DEBUG;
32#else
33 goto not_there;
34#endif
35 if (strEQ(name, "P_DEFAULT"))
36#ifdef P_DEFAULT
37 return P_DEFAULT;
38#else
39 goto not_there;
40#endif
41 if (strEQ(name, "P_DETACH"))
42#ifdef P_DETACH
43 return P_DETACH;
44#else
45 goto not_there;
46#endif
47 if (strEQ(name, "P_FOREGROUND"))
48#ifdef P_FOREGROUND
49 return P_FOREGROUND;
50#else
51 goto not_there;
52#endif
53 if (strEQ(name, "P_FULLSCREEN"))
54#ifdef P_FULLSCREEN
55 return P_FULLSCREEN;
56#else
57 goto not_there;
58#endif
59 if (strEQ(name, "P_MAXIMIZE"))
60#ifdef P_MAXIMIZE
61 return P_MAXIMIZE;
62#else
63 goto not_there;
64#endif
65 if (strEQ(name, "P_MINIMIZE"))
66#ifdef P_MINIMIZE
67 return P_MINIMIZE;
68#else
69 goto not_there;
70#endif
71 if (strEQ(name, "P_NOCLOSE"))
72#ifdef P_NOCLOSE
73 return P_NOCLOSE;
74#else
75 goto not_there;
76#endif
77 if (strEQ(name, "P_NOSESSION"))
78#ifdef P_NOSESSION
79 return P_NOSESSION;
80#else
81 goto not_there;
82#endif
83 if (strEQ(name, "P_NOWAIT"))
84#ifdef P_NOWAIT
85 return P_NOWAIT;
86#else
87 goto not_there;
88#endif
89 if (strEQ(name, "P_OVERLAY"))
90#ifdef P_OVERLAY
91 return P_OVERLAY;
92#else
93 goto not_there;
94#endif
95 if (strEQ(name, "P_PM"))
96#ifdef P_PM
97 return P_PM;
98#else
99 goto not_there;
100#endif
101 if (strEQ(name, "P_QUOTE"))
102#ifdef P_QUOTE
103 return P_QUOTE;
104#else
105 goto not_there;
106#endif
107 if (strEQ(name, "P_SESSION"))
108#ifdef P_SESSION
109 return P_SESSION;
110#else
111 goto not_there;
112#endif
113 if (strEQ(name, "P_TILDE"))
114#ifdef P_TILDE
115 return P_TILDE;
116#else
117 goto not_there;
118#endif
119 if (strEQ(name, "P_UNRELATED"))
120#ifdef P_UNRELATED
121 return P_UNRELATED;
122#else
123 goto not_there;
124#endif
125 if (strEQ(name, "P_WAIT"))
126#ifdef P_WAIT
127 return P_WAIT;
128#else
129 goto not_there;
130#endif
131 if (strEQ(name, "P_WINDOWED"))
132#ifdef P_WINDOWED
133 return P_WINDOWED;
134#else
135 goto not_there;
136#endif
7f61b687
IZ
137 } else if (name[0] == 'T' && name[1] == '_') {
138 if (strEQ(name, "FAPPTYP_NOTSPEC"))
139#ifdef FAPPTYP_NOTSPEC
140 return FAPPTYP_NOTSPEC;
141#else
142 goto not_there;
143#endif
144 if (strEQ(name, "T_NOTWINDOWCOMPAT"))
145#ifdef FAPPTYP_NOTWINDOWCOMPAT
146 return FAPPTYP_NOTWINDOWCOMPAT;
147#else
148 goto not_there;
149#endif
150 if (strEQ(name, "T_WINDOWCOMPAT"))
151#ifdef FAPPTYP_WINDOWCOMPAT
152 return FAPPTYP_WINDOWCOMPAT;
153#else
154 goto not_there;
155#endif
156 if (strEQ(name, "T_WINDOWAPI"))
157#ifdef FAPPTYP_WINDOWAPI
158 return FAPPTYP_WINDOWAPI;
159#else
160 goto not_there;
161#endif
162 if (strEQ(name, "T_BOUND"))
163#ifdef FAPPTYP_BOUND
164 return FAPPTYP_BOUND;
165#else
166 goto not_there;
167#endif
168 if (strEQ(name, "T_DLL"))
169#ifdef FAPPTYP_DLL
170 return FAPPTYP_DLL;
171#else
172 goto not_there;
173#endif
174 if (strEQ(name, "T_DOS"))
175#ifdef FAPPTYP_DOS
176 return FAPPTYP_DOS;
177#else
178 goto not_there;
179#endif
180 if (strEQ(name, "T_PHYSDRV"))
181#ifdef FAPPTYP_PHYSDRV
182 return FAPPTYP_PHYSDRV;
183#else
184 goto not_there;
185#endif
186 if (strEQ(name, "T_VIRTDRV"))
187#ifdef FAPPTYP_VIRTDRV
188 return FAPPTYP_VIRTDRV;
189#else
190 goto not_there;
191#endif
192 if (strEQ(name, "T_PROTDLL"))
193#ifdef FAPPTYP_PROTDLL
194 return FAPPTYP_PROTDLL;
195#else
196 goto not_there;
197#endif
198 if (strEQ(name, "T_32BIT"))
199#ifdef FAPPTYP_32BIT
200 return FAPPTYP_32BIT;
201#else
202 goto not_there;
203#endif
760ac839
LW
204 }
205
206 errno = EINVAL;
207 return 0;
208
209not_there:
210 errno = ENOENT;
211 return 0;
212}
213
7f61b687
IZ
214const char* const ptypes[] = { "FS", "DOS", "VIO", "PM", "DETACH" };
215
216static char *
217my_type()
218{
219 int rc;
220 TIB *tib;
221 PIB *pib;
222
223 if (!(_emx_env & 0x200)) return (char*)ptypes[1]; /* not OS/2. */
224 if (CheckOSError(DosGetInfoBlocks(&tib, &pib)))
225 return NULL;
226
227 return (pib->pib_ultype <= 4 ? (char*)ptypes[pib->pib_ultype] : "UNKNOWN");
228}
229
230static ULONG
231file_type(char *path)
232{
233 int rc;
234 ULONG apptype;
235
236 if (!(_emx_env & 0x200))
237 croak("file_type not implemented on DOS"); /* not OS/2. */
238 if (CheckOSError(DosQueryAppType(path, &apptype))) {
18729d3e 239#if 0
7f61b687
IZ
240 if (rc == ERROR_INVALID_EXE_SIGNATURE)
241 croak("Invalid EXE signature");
242 else if (rc == ERROR_EXE_MARKED_INVALID) {
243 croak("EXE marked invalid");
244 }
18729d3e
JH
245#endif
246 croak_with_os2error("DosQueryAppType");
7f61b687
IZ
247 }
248
249 return apptype;
250}
251
30500b05
IZ
252/* These use different type of wrapper. Good to check wrappers. ;-) */
253/* XXXX This assumes DOS type return type, without SEVERITY?! */
35bc1fdc
IZ
254DeclFuncByORD(HSWITCH, myWinQuerySwitchHandle, ORD_WinQuerySwitchHandle,
255 (HWND hwnd, PID pid), (hwnd, pid))
256DeclFuncByORD(ULONG, myWinQuerySwitchEntry, ORD_WinQuerySwitchEntry,
257 (HSWITCH hsw, PSWCNTRL pswctl), (hsw, pswctl))
258DeclFuncByORD(ULONG, myWinSetWindowText, ORD_WinSetWindowText,
259 (HWND hwnd, char* text), (hwnd, text))
260DeclFuncByORD(BOOL, myWinQueryWindowProcess, ORD_WinQueryWindowProcess,
261 (HWND hwnd, PPID ppid, PTID ptid), (hwnd, ppid, ptid))
35bc1fdc
IZ
262DeclFuncByORD(ULONG, XmyWinSwitchToProgram, ORD_WinSwitchToProgram,
263 (HSWITCH hsw), (hsw))
264#define myWinSwitchToProgram(hsw) (!CheckOSError(XmyWinSwitchToProgram(hsw)))
265
35bc1fdc 266
18729d3e 267/* These function croak if the return value is 0. */
30500b05
IZ
268DeclWinFunc_CACHE(HWND, QueryWindow, (HWND hwnd, LONG cmd), (hwnd, cmd))
269DeclWinFunc_CACHE(BOOL, QueryWindowPos, (HWND hwnd, PSWP pswp),
270 (hwnd, pswp))
271DeclWinFunc_CACHE(LONG, QueryWindowText,
272 (HWND hwnd, LONG cchBufferMax, PCH pchBuffer),
273 (hwnd, cchBufferMax, pchBuffer))
274DeclWinFunc_CACHE(LONG, QueryClassName, (HWND hwnd, LONG cchMax, PCH pch),
275 (hwnd, cchMax, pch))
276DeclWinFunc_CACHE(HWND, QueryFocus, (HWND hwndDesktop), (hwndDesktop))
277DeclWinFunc_CACHE(BOOL, SetFocus, (HWND hwndDesktop, HWND hwndFocus),
278 (hwndDesktop, hwndFocus))
279DeclWinFunc_CACHE(BOOL, ShowWindow, (HWND hwnd, BOOL fShow), (hwnd, fShow))
280DeclWinFunc_CACHE(BOOL, EnableWindow, (HWND hwnd, BOOL fEnable),
281 (hwnd, fEnable))
282DeclWinFunc_CACHE(BOOL, SetWindowPos,
283 (HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y,
284 LONG cx, LONG cy, ULONG fl),
285 (hwnd, hwndInsertBehind, x, y, cx, cy, fl))
286DeclWinFunc_CACHE(HENUM, BeginEnumWindows, (HWND hwnd), (hwnd))
287DeclWinFunc_CACHE(BOOL, EndEnumWindows, (HENUM henum), (henum))
288DeclWinFunc_CACHE(BOOL, EnableWindowUpdate, (HWND hwnd, BOOL fEnable),
289 (hwnd, fEnable))
290DeclWinFunc_CACHE(BOOL, SetWindowBits,
291 (HWND hwnd, LONG index, ULONG flData, ULONG flMask),
292 (hwnd, index, flData, flMask))
293DeclWinFunc_CACHE(BOOL, SetWindowPtr, (HWND hwnd, LONG index, PVOID p),
294 (hwnd, index, p))
295DeclWinFunc_CACHE(BOOL, SetWindowULong, (HWND hwnd, LONG index, ULONG ul),
296 (hwnd, index, ul))
297DeclWinFunc_CACHE(BOOL, SetWindowUShort, (HWND hwnd, LONG index, USHORT us),
298 (hwnd, index, us))
299DeclWinFunc_CACHE(HWND, IsChild, (HWND hwnd, HWND hwndParent),
300 (hwnd, hwndParent))
301DeclWinFunc_CACHE(HWND, WindowFromId, (HWND hwnd, ULONG id), (hwnd, id))
302DeclWinFunc_CACHE(HWND, EnumDlgItem, (HWND hwndDlg, HWND hwnd, ULONG code),
303 (hwndDlg, hwnd, code))
304DeclWinFunc_CACHE(HWND, QueryDesktopWindow, (HAB hab, HDC hdc), (hab, hdc));
305DeclWinFunc_CACHE(BOOL, SetActiveWindow, (HWND hwndDesktop, HWND hwnd),
306 (hwndDesktop, hwnd));
18729d3e
JH
307DeclWinFunc_CACHE(BOOL, QueryActiveDesktopPathname, (PSZ pszPathName, ULONG ulSize),
308 (pszPathName, ulSize));
309DeclWinFunc_CACHE(BOOL, InvalidateRect,
310 (HWND hwnd, /*RECTL*/ char *prcl, BOOL fIncludeChildren),
311 (hwnd, prcl, fIncludeChildren));
312DeclWinFunc_CACHE(BOOL, CreateFrameControls,
313 (HWND hwndFrame, /*PFRAMECDATA*/ char* pfcdata, PCSZ pszTitle),
314 (hwndFrame, pfcdata, pszTitle));
315DeclWinFunc_CACHE(BOOL, OpenClipbrd, (HAB hab), (hab));
316DeclWinFunc_CACHE(BOOL, EmptyClipbrd, (HAB hab), (hab));
317DeclWinFunc_CACHE(BOOL, CloseClipbrd, (HAB hab), (hab));
318DeclWinFunc_CACHE(HWND, QueryClipbrdViewer, (HAB hab), (hab));
319DeclWinFunc_CACHE(HWND, QueryClipbrdOwner, (HAB hab), (hab));
320DeclWinFunc_CACHE(BOOL, QueryClipbrdFmtInfo, (HAB hab, ULONG fmt, PULONG prgfFmtInfo), (hab, fmt, prgfFmtInfo));
321DeclWinFunc_CACHE(ULONG, QueryClipbrdData, (HAB hab, ULONG fmt), (hab, fmt));
322DeclWinFunc_CACHE(HWND, SetClipbrdViewer, (HAB hab, HWND hwnd), (hab, hwnd));
323DeclWinFunc_CACHE(HWND, SetClipbrdOwner, (HAB hab, HWND hwnd), (hab, hwnd));
324DeclWinFunc_CACHE(ULONG, EnumClipbrdFmts, (HAB hab, ULONG fmt), (hab, fmt));
325DeclWinFunc_CACHE(ATOM, AddAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
326 (hAtomTbl, pszAtomName));
327DeclWinFunc_CACHE(ATOM, FindAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
328 (hAtomTbl, pszAtomName));
329DeclWinFunc_CACHE(ATOM, DeleteAtom, (HATOMTBL hAtomTbl, PCSZ pszAtomName),
330 (hAtomTbl, pszAtomName));
331DeclWinFunc_CACHE(ULONG, QueryAtomUsage, (HATOMTBL hAtomTbl, ATOM atom),
332 (hAtomTbl, atom));
333DeclWinFunc_CACHE(ULONG, QueryAtomLength, (HATOMTBL hAtomTbl, ATOM atom),
334 (hAtomTbl, atom));
335DeclWinFunc_CACHE(ULONG, QueryAtomName,
336 (HATOMTBL hAtomTbl, ATOM atom, PSZ pchBuffer, ULONG cchBufferMax),
337 (hAtomTbl, atom, pchBuffer, cchBufferMax));
338DeclWinFunc_CACHE(HATOMTBL, QuerySystemAtomTable, (VOID), ());
339DeclWinFunc_CACHE(HATOMTBL, CreateAtomTable, (ULONG initial, ULONG buckets),
340 (initial, buckets));
341DeclWinFunc_CACHE(HATOMTBL, DestroyAtomTable, (HATOMTBL hAtomTbl), (hAtomTbl));
342DeclWinFunc_CACHE(ULONG, MessageBox, (HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle), (hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle));
343DeclWinFunc_CACHE(ULONG, MessageBox2,
344 (HWND hwndParent, HWND hwndOwner, PCSZ pszText,
345 PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info),
346 (hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info));
347DeclWinFunc_CACHE(HPOINTER, LoadPointer,
348 (HWND hwndDesktop, HMODULE hmod, ULONG idres),
349 (hwndDesktop, hmod, idres));
350DeclWinFunc_CACHE(HPOINTER, QuerySysPointer,
351 (HWND hwndDesktop, LONG lId, BOOL fCopy),
352 (hwndDesktop, lId, fCopy));
353DeclWinFunc_CACHE(BOOL, Alarm, (HWND hwndDesktop, ULONG rgfType), (hwndDesktop, rgfType));
354DeclWinFunc_CACHE(BOOL, FlashWindow, (HWND hwndFrame, BOOL fFlash), (hwndFrame, fFlash));
355
356
357/* These functions do not croak on error */
358DeclWinFunc_CACHE_survive(BOOL, SetClipbrdData,
359 (HAB hab, ULONG ulData, ULONG fmt, ULONG rgfFmtInfo),
360 (hab, ulData, fmt, rgfFmtInfo));
361
362#define get_InvalidateRect InvalidateRect
363#define get_CreateFrameControls CreateFrameControls
30500b05
IZ
364
365/* These functions may return 0 on success; check $^E/Perl_rc on res==0: */
366DeclWinFunc_CACHE_resetError(PVOID, QueryWindowPtr, (HWND hwnd, LONG index),
367 (hwnd, index))
368DeclWinFunc_CACHE_resetError(ULONG, QueryWindowULong, (HWND hwnd, LONG index),
369 (hwnd, index))
370DeclWinFunc_CACHE_resetError(SHORT, QueryWindowUShort, (HWND hwnd, LONG index),
371 (hwnd, index))
372DeclWinFunc_CACHE_resetError(LONG, QueryWindowTextLength, (HWND hwnd), (hwnd))
373DeclWinFunc_CACHE_resetError(HWND, QueryActiveWindow, (HWND hwnd), (hwnd))
374DeclWinFunc_CACHE_resetError(BOOL, PostMsg,
375 (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2),
376 (hwnd, msg, mp1, mp2))
377DeclWinFunc_CACHE_resetError(HWND, GetNextWindow, (HENUM henum), (henum))
378DeclWinFunc_CACHE_resetError(BOOL, IsWindowEnabled, (HWND hwnd), (hwnd))
379DeclWinFunc_CACHE_resetError(BOOL, IsWindowVisible, (HWND hwnd), (hwnd))
380DeclWinFunc_CACHE_resetError(BOOL, IsWindowShowing, (HWND hwnd), (hwnd))
381
382/* No die()ing on error */
383DeclWinFunc_CACHE_survive(BOOL, IsWindow, (HAB hab, HWND hwnd), (hab, hwnd))
384
385/* These functions are called frow complicated wrappers: */
35bc1fdc
IZ
386ULONG (*pWinQuerySwitchList) (HAB hab, PSWBLOCK pswblk, ULONG usDataLength);
387ULONG (*pWinChangeSwitchEntry) (HSWITCH hsw, __const__ SWCNTRL *pswctl);
35bc1fdc
IZ
388HWND (*pWinWindowFromPoint)(HWND hwnd, __const__ POINTL *pptl, BOOL fChildren);
389
30500b05
IZ
390
391/* These functions have different names/signatures than what is
392 declared above */
393#define QueryFocusWindow QueryFocus
394#define FocusWindow_set(hwndFocus, hwndDesktop) SetFocus(hwndDesktop, hwndFocus)
395#define WindowPos_set(hwnd, x, y, fl, cx, cy, hwndInsertBehind) \
396 SetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl)
397#define myWinQueryWindowPtr(hwnd, i) ((ULONG)QueryWindowPtr(hwnd, i))
18729d3e
JH
398#define _ClipbrdData_set SetClipbrdData
399#define ClipbrdOwner_set SetClipbrdOwner
400#define ClipbrdViewer_set SetClipbrdViewer
35bc1fdc
IZ
401
402int
403WindowText_set(HWND hwnd, char* text)
404{
405 return !CheckWinError(myWinSetWindowText(hwnd, text));
406}
407
35bc1fdc 408SV *
30500b05 409myQueryWindowText(HWND hwnd)
35bc1fdc 410{
30500b05
IZ
411 LONG l = QueryWindowTextLength(hwnd), len;
412 SV *sv;
35bc1fdc
IZ
413 STRLEN n_a;
414
30500b05
IZ
415 if (l == 0) {
416 if (Perl_rc) /* Last error */
417 return &PL_sv_undef;
418 return &PL_sv_no;
419 }
420 sv = newSVpvn("", 0);
35bc1fdc 421 SvGROW(sv, l + 1);
18729d3e 422 len = QueryWindowText(hwnd, l + 1, SvPV_force(sv, n_a));
30500b05
IZ
423 if (len != l) {
424 Safefree(sv);
425 croak("WinQueryWindowText() uncompatible with WinQueryWindowTextLength()");
426 }
35bc1fdc
IZ
427 SvCUR_set(sv, l);
428 return sv;
429}
430
431SWP
432QueryWindowSWP_(HWND hwnd)
433{
434 SWP swp;
435
30500b05 436 if (!QueryWindowPos(hwnd, &swp))
35bc1fdc
IZ
437 croak("WinQueryWindowPos() error");
438 return swp;
439}
440
441SV *
442QueryWindowSWP(HWND hwnd)
443{
444 SWP swp = QueryWindowSWP_(hwnd);
445
446 return newSVpvn((char*)&swp, sizeof(swp));
447}
448
449SV *
30500b05 450myQueryClassName(HWND hwnd)
35bc1fdc
IZ
451{
452 SV *sv = newSVpvn("",0);
453 STRLEN l = 46, len = 0, n_a;
454
35bc1fdc
IZ
455 while (l + 1 >= len) {
456 if (len)
457 len = 2*len + 10; /* Grow quick */
458 else
459 len = l + 2;
460 SvGROW(sv, len);
30500b05 461 l = QueryClassName(hwnd, len, SvPV_force(sv, n_a));
35bc1fdc 462 }
30500b05 463 SvCUR_set(sv, l);
35bc1fdc
IZ
464 return sv;
465}
466
467HWND
35bc1fdc
IZ
468WindowFromPoint(long x, long y, HWND hwnd, BOOL fChildren)
469{
470 POINTL ppl;
471
472 ppl.x = x; ppl.y = y;
473 if (!pWinWindowFromPoint)
474 AssignFuncPByORD(pWinWindowFromPoint, ORD_WinWindowFromPoint);
475 return SaveWinError(pWinWindowFromPoint(hwnd, &ppl, fChildren));
476}
477
18729d3e
JH
478static HSWITCH
479switch_of(HWND hwnd, PID pid)
7f61b687 480{
7f61b687 481 HSWITCH hSwitch;
7f61b687
IZ
482
483 if (!(_emx_env & 0x200))
484 croak("switch_entry not implemented on DOS"); /* not OS/2. */
7f61b687 485 if (CheckWinError(hSwitch =
35bc1fdc 486 myWinQuerySwitchHandle(hwnd, pid)))
18729d3e
JH
487 croak_with_os2error("WinQuerySwitchHandle");
488 return hSwitch;
489}
490
491
492static void
493fill_swentry(SWENTRY *swentryp, HWND hwnd, PID pid)
494{
495 int rc;
496 HSWITCH hSwitch = switch_of(hwnd, pid);
497
35bc1fdc
IZ
498 swentryp->hswitch = hSwitch;
499 if (CheckOSError(myWinQuerySwitchEntry(hSwitch, &swentryp->swctl)))
18729d3e 500 croak_with_os2error("WinQuerySwitchEntry");
7f61b687
IZ
501}
502
35bc1fdc
IZ
503static void
504fill_swentry_default(SWENTRY *swentryp)
505{
506 fill_swentry(swentryp, NULLHANDLE, getpid());
507}
508
18729d3e
JH
509static SV*
510myWinQueryActiveDesktopPathname()
511{
512 SV *buf = newSVpv("",0);
513 STRLEN n_a;
514
515 SvGROW(buf, MAXPATHLEN);
516 QueryActiveDesktopPathname(SvPV(buf,n_a), MAXPATHLEN);
517 SvCUR_set(buf, strlen(SvPV(buf, n_a)));
518 return buf;
519}
520
521SV *
522myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl)
523{
524 ULONG len = QueryAtomLength(hAtomTbl, atom);
525 SV *sv = newSVpvn("",0);
526 STRLEN n_a;
527
528 SvGROW(sv, len + 1);
529 QueryAtomName(hAtomTbl, atom, SvPV(sv, n_a), len);
530 SvCUR_set(sv, len);
531 *SvEND(sv) = 0;
532 return sv;
533}
534
535#define myWinQueryClipbrdFmtInfo QueryClipbrdFmtInfo
536
537/* Put data into shared memory, then call SetClipbrdData */
538void
539ClipbrdData_set(SV *sv, int convert_nl, unsigned long fmt, unsigned long rgfFmtInfo, HAB hab)
540{
541 STRLEN len;
542 char *buf = SvPV_force(sv, len);
543 char *pByte = 0, *s = buf, c;
544 ULONG nls = 0, rc;
545
546 if (convert_nl) {
547 while ((c = *s++)) {
548 if (c == '\r' && *s == '\n')
549 s++;
550 else if (c == '\n')
551 nls++;
552 }
553 }
554
555 if (CheckOSError(DosAllocSharedMem((PPVOID)&pByte, 0, len + nls + 1,
556 PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_GETTABLE)))
557 croak_with_os2error("ClipbrdData_set: DosAllocSharedMem error");
558
559 if (!nls)
560 memcpy(pByte, buf, len + 1);
561 else {
562 char *t = pByte, *e = buf + len;
563
564 while (buf < e) {
565 c = *t++ = *buf++;
566 if (c == '\n' && (t == pByte + 1 || t[-2] != '\r'))
567 t[-1] = '\r', *t++ = '\n';
568 }
569 }
570
571 if (!SetClipbrdData(hab, (ULONG)pByte, fmt, rgfFmtInfo)) {
572 DosFreeMem((PPVOID)&pByte);
573 croak_with_os2error("ClipbrdData_set: WinSetClipbrdData error");
574 }
575}
576
577#if 0
578
579ULONG
580myWinMessageBox(HWND hwndParent, HWND hwndOwner, PCSZ pszText, PCSZ pszCaption, ULONG idWindow, ULONG flStyle)
581{
582 ULONG rc = MessageBox(hwndParent, hwndOwner, pszText, pszCaption,
583 idWindow, flStyle);
584
585 if (rc == MBID_ERROR)
586 rc = 0;
587 if (CheckWinError(rc))
588 croak_with_os2error("MessageBox");
589 return rc;
590}
591
592ULONG
593myWinMessageBox2(HWND hwndParent, HWND hwndOwner, PCSZ pszText,
594 PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info)
595{
596 ULONG rc = MessageBox2(hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info);
597
598 if (rc == MBID_ERROR)
599 rc = 0;
600 if (CheckWinError(rc))
601 croak_with_os2error("MessageBox2");
602 return rc;
603}
604#endif
605
7f61b687
IZ
606/* static ULONG (* APIENTRY16 pDosSmSetTitle)(ULONG, PSZ); */
607ULONG _THUNK_FUNCTION(DosSmSetTitle)(ULONG, PSZ);
608
609#if 0 /* Does not work. */
610static ULONG (*pDosSmSetTitle)(ULONG, PSZ);
611
612static void
35bc1fdc 613sesmgr_title_set(char *s)
7f61b687 614{
35bc1fdc 615 SWENTRY swentry;
7f61b687
IZ
616 static HMODULE hdosc = 0;
617 BYTE buf[20];
618 long rc;
619
35bc1fdc 620 fill_swentry_default(&swentry);
7f61b687
IZ
621 if (!pDosSmSetTitle || !hdosc) {
622 if (CheckOSError(DosLoadModule(buf, sizeof buf, "sesmgr", &hdosc)))
623 croak("Cannot load SESMGR: no `%s'", buf);
624 if (CheckOSError(DosQueryProcAddr(hdosc, 0, "DOSSMSETTITLE",
625 (PFN*)&pDosSmSetTitle)))
626 croak("Cannot load SESMGR.DOSSMSETTITLE, err=%ld", rc);
627 }
628/* (pDosSmSetTitle)(swcntrl.idSession,s); */
629 rc = ((USHORT)
630 (_THUNK_PROLOG (2+4);
631 _THUNK_SHORT (swcntrl.idSession);
632 _THUNK_FLAT (s);
633 _THUNK_CALLI (*pDosSmSetTitle)));
634 if (CheckOSError(rc))
635 warn("*DOSSMSETTITLE: err=%ld, ses=%ld, addr=%x, *paddr=%x",
636 rc, swcntrl.idSession, &_THUNK_FUNCTION(DosSmSetTitle),
637 pDosSmSetTitle);
638}
639
640#else /* !0 */
641
642static bool
35bc1fdc 643sesmgr_title_set(char *s)
7f61b687 644{
35bc1fdc 645 SWENTRY swentry;
7f61b687
IZ
646 long rc;
647
35bc1fdc 648 fill_swentry_default(&swentry);
7f61b687
IZ
649 rc = ((USHORT)
650 (_THUNK_PROLOG (2+4);
35bc1fdc 651 _THUNK_SHORT (swentry.swctl.idSession);
7f61b687
IZ
652 _THUNK_FLAT (s);
653 _THUNK_CALL (DosSmSetTitle)));
654#if 0
655 if (CheckOSError(rc))
656 warn("DOSSMSETTITLE: err=%ld, ses=%ld, addr=%x",
657 rc, swcntrl.idSession, _THUNK_FUNCTION(DosSmSetTitle));
658#endif
659 return !CheckOSError(rc);
660}
661#endif /* !0 */
662
663#if 0 /* Does not work. */
664USHORT _THUNK_FUNCTION(Win16SetTitle) ();
665
666static void
667set_title2(char *s)
668{
669 long rc;
670
671 rc = ((USHORT)
672 (_THUNK_PROLOG (4);
673 _THUNK_FLAT (s);
674 _THUNK_CALL (Win16SetTitle)));
675 if (CheckWinError(rc))
676 warn("Win16SetTitle: err=%ld", rc);
677}
678#endif
760ac839 679
35bc1fdc 680SV *
18729d3e 681process_swentry(unsigned long pid, HWND hwnd)
35bc1fdc
IZ
682{
683 SWENTRY swentry;
684
685 if (!(_emx_env & 0x200))
686 croak("process_swentry not implemented on DOS"); /* not OS/2. */
687 fill_swentry(&swentry, hwnd, pid);
688 return newSVpvn((char*)&swentry, sizeof(swentry));
689}
690
691SV *
692swentries_list()
693{
694 int num, n = 0;
695 STRLEN n_a;
696 PSWBLOCK pswblk;
697 SV *sv = newSVpvn("",0);
698
699 if (!(_emx_env & 0x200))
700 croak("swentries_list not implemented on DOS"); /* not OS/2. */
701 if (!pWinQuerySwitchList)
702 AssignFuncPByORD(pWinQuerySwitchList, ORD_WinQuerySwitchList);
703 num = pWinQuerySwitchList(0, NULL, 0); /* HAB is not required */
704 if (!num)
705 croak("(Unknown) error during WinQuerySwitchList()");
706 /* Allow one extra entry to allow overflow detection (may happen
707 if the list has been changed). */
708 while (num > n) {
709 if (n == 0)
710 n = num + 1;
711 else
712 n = 2*num + 10; /* Enlarge quickly */
713 SvGROW(sv, sizeof(ULONG) + sizeof(SWENTRY) * n + 1);
714 pswblk = (PSWBLOCK) SvPV_force(sv, n_a);
715 num = pWinQuerySwitchList(0, pswblk, SvLEN(sv));
716 }
717 SvCUR_set(sv, sizeof(ULONG) + sizeof(SWENTRY) * num);
718 *SvEND(sv) = 0;
719 return sv;
720}
721
722SWENTRY
723swentry( char *title, HWND sw_hwnd, HWND icon_hwnd, HPROGRAM owner_phandle,
724 PID owner_pid, ULONG owner_sid, ULONG visible, ULONG nonswitchable,
725 ULONG jumpable, ULONG ptype, HSWITCH sw_entry)
726{
727 SWENTRY e;
728
729 strncpy(e.swctl.szSwtitle, title, MAXNAMEL);
730 e.swctl.szSwtitle[60] = 0;
731 e.swctl.hwnd = sw_hwnd;
732 e.swctl.hwndIcon = icon_hwnd;
733 e.swctl.hprog = owner_phandle;
734 e.swctl.idProcess = owner_pid;
735 e.swctl.idSession = owner_sid;
736 e.swctl.uchVisibility = ((visible ? SWL_VISIBLE : SWL_INVISIBLE)
737 | (nonswitchable ? SWL_GRAYED : 0));
738 e.swctl.fbJump = (jumpable ? SWL_JUMPABLE : 0);
739 e.swctl.bProgType = ptype;
740 e.hswitch = sw_entry;
741 return e;
742}
743
744SV *
745create_swentry( char *title, HWND owner_hwnd, HWND icon_hwnd, HPROGRAM owner_phandle,
746 PID owner_pid, ULONG owner_sid, ULONG visible, ULONG nonswitchable,
747 ULONG jumpable, ULONG ptype, HSWITCH sw_entry)
748{
749 SWENTRY e = swentry(title, owner_hwnd, icon_hwnd, owner_phandle, owner_pid,
750 owner_sid, visible, nonswitchable, jumpable, ptype,
751 sw_entry);
752
753 return newSVpvn((char*)&e, sizeof(e));
754}
755
756int
757change_swentrysw(SWENTRY *sw)
758{
759 ULONG rc; /* For CheckOSError */
760
761 if (!(_emx_env & 0x200))
762 croak("change_entry() not implemented on DOS"); /* not OS/2. */
763 if (!pWinChangeSwitchEntry)
764 AssignFuncPByORD(pWinChangeSwitchEntry, ORD_WinChangeSwitchEntry);
765 return !CheckOSError(pWinChangeSwitchEntry(sw->hswitch, &sw->swctl));
766}
767
768int
769change_swentry(SV *sv)
770{
771 STRLEN l;
772 PSWENTRY pswentry = (PSWENTRY)SvPV(sv, l);
773
774 if (l != sizeof(SWENTRY))
775 croak("Wrong structure size %ld!=%ld in change_swentry()", (long)l, (long)sizeof(SWENTRY));
776 return change_swentrysw(pswentry);
777}
778
779
780#define swentry_size() (sizeof(SWENTRY))
781
782void
783getscrsize(int *wp, int *hp)
784{
785 int i[2];
786
787 _scrsize(i);
788 *wp = i[0];
789 *hp = i[1];
790}
791
792/* Force vio to not cross 64K-boundary: */
793#define VIO_FROM_VIOB \
794 vio = viob; \
795 if (!_THUNK_PTR_STRUCT_OK(vio)) \
796 vio++
797
798bool
799scrsize_set(int w, int h)
800{
801 VIOMODEINFO viob[2], *vio;
802 ULONG rc;
803
804 VIO_FROM_VIOB;
805
806 if (h == -9999)
807 h = w, w = 0;
808 vio->cb = sizeof(*vio);
809 if (CheckOSError(VioGetMode( vio, 0 )))
810 return 0;
811
812 if( w > 0 )
813 vio->col = (USHORT)w;
814
815 if( h > 0 )
816 vio->row = (USHORT)h;
817
818 vio->cb = 8;
819 if (CheckOSError(VioSetMode( vio, 0 )))
820 return 0;
821 return 1;
822}
823
824void
825cursor(int *sp, int *ep, int *wp, int *ap)
826{
827 VIOCURSORINFO viob[2], *vio;
828 ULONG rc;
829
830 VIO_FROM_VIOB;
831
832 if (CheckOSError(VioGetCurType( vio, 0 )))
18729d3e 833 croak_with_os2error("VioGetCurType() error");
35bc1fdc
IZ
834
835 *sp = vio->yStart;
836 *ep = vio->cEnd;
837 *wp = vio->cx;
838 *ep = vio->attr;
839}
840
841bool
842cursor__(int is_a)
843{
844 int s,e,w,a;
845
846 cursor(&s, &e, &w, &a);
847 if (is_a)
848 return a;
849 else
850 return w;
851}
852
853bool
854cursor_set(int s, int e, int w, int a)
855{
856 VIOCURSORINFO viob[2], *vio;
857 ULONG rc;
858
859 VIO_FROM_VIOB;
860
861 vio->yStart = s;
862 vio->cEnd = e;
863 vio->cx = w;
864 vio->attr = a;
865 return !CheckOSError(VioSetCurType( vio, 0 ));
866}
867
868static int
869bufsize(void)
870{
871#if 1
872 VIOMODEINFO viob[2], *vio;
873 ULONG rc;
874
875 VIO_FROM_VIOB;
876
877 vio->cb = sizeof(*vio);
878 if (CheckOSError(VioGetMode( vio, 0 )))
18729d3e 879 croak_with_os2error("Can't get size of buffer for screen");
35bc1fdc
IZ
880#if 0 /* buf=323552247, full=1118455, partial=0 */
881 croak("Lengths: buf=%d, full=%d, partial=%d",vio->buf_length,vio->full_length,vio->partial_length);
882 return newSVpvn((char*)vio->buf_addr, vio->full_length);
883#endif
884 return vio->col * vio->row * 2; /* How to get bytes/cell? 2 or 4? */
885#else /* 0 */
886 int i[2];
887
888 _scrsize(i);
889 return i[0]*i[1]*2;
890#endif /* 0 */
891}
892
893SV *
894screen(void)
895{
896 ULONG rc;
897 USHORT bufl = bufsize();
898 char b[(1<<16) * 3]; /* This/3 is enough for 16-bit calls, we need
899 2x overhead due to 2 vs 4 issue, and extra
900 64K due to alignment logic */
901 char *buf = b;
902
903 if (((ULONG)buf) & 0xFFFF)
904 buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
905 if ((sizeof(b) - (buf - b)) < 2*bufl)
906 croak("panic: VIO buffer allocation");
907 if (CheckOSError(VioReadCellStr( buf, &bufl, 0, 0, 0 )))
908 return &PL_sv_undef;
909 return newSVpvn(buf,bufl);
910}
911
912bool
913screen_set(SV *sv)
914{
915 ULONG rc;
916 STRLEN l = SvCUR(sv), bufl = bufsize();
917 char b[(1<<16) * 2]; /* This/2 is enough for 16-bit calls, we need
918 extra 64K due to alignment logic */
919 char *buf = b;
920
921 if (((ULONG)buf) & 0xFFFF)
922 buf += 0x10000 - (((ULONG)buf) & 0xFFFF);
923 if (!SvPOK(sv) || ((l != bufl) && (l != 2*bufl)))
924 croak("Wrong size %d of saved screen data", SvCUR(sv));
925 if ((sizeof(b) - (buf - b)) < l)
926 croak("panic: VIO buffer allocation");
927 Copy(SvPV(sv,l), buf, bufl, char);
928 if (CheckOSError(VioWrtCellStr( buf, bufl, 0, 0, 0 )))
929 return 0;
930 return 1;
931}
932
933int
934process_codepages()
935{
936 ULONG cps[4], cp, rc;
937
938 if (CheckOSError(DosQueryCp( sizeof(cps), cps, &cp )))
18729d3e 939 croak_with_os2error("DosQueryCp()");
35bc1fdc
IZ
940 return cp;
941}
942
943int
944out_codepage()
945{
946 USHORT cp, rc;
947
948 if (CheckOSError(VioGetCp( 0, &cp, 0 )))
18729d3e 949 croak_with_os2error("VioGetCp()");
35bc1fdc
IZ
950 return cp;
951}
952
953bool
954out_codepage_set(int cp)
955{
956 USHORT rc;
957
958 return !(CheckOSError(VioSetCp( 0, cp, 0 )));
959}
960
961int
962in_codepage()
963{
964 USHORT cp, rc;
965
966 if (CheckOSError(KbdGetCp( 0, &cp, 0 )))
18729d3e 967 croak_with_os2error("KbdGetCp()");
35bc1fdc
IZ
968 return cp;
969}
970
971bool
972in_codepage_set(int cp)
973{
974 USHORT rc;
975
976 return !(CheckOSError(KbdSetCp( 0, cp, 0 )));
977}
978
979bool
980process_codepage_set(int cp)
981{
982 USHORT rc;
983
984 return !(CheckOSError(DosSetProcessCp( cp )));
985}
986
987int
988ppidOf(int pid)
989{
990 PQTOPLEVEL psi;
991 int ppid;
992
993 if (!pid)
994 return -1;
995 psi = get_sysinfo(pid, QSS_PROCESS);
996 if (!psi)
997 return -1;
998 ppid = psi->procdata->ppid;
999 Safefree(psi);
1000 return ppid;
1001}
1002
1003int
1004sidOf(int pid)
1005{
1006 PQTOPLEVEL psi;
1007 int sid;
1008
1009 if (!pid)
1010 return -1;
1011 psi = get_sysinfo(pid, QSS_PROCESS);
1012 if (!psi)
1013 return -1;
1014 sid = psi->procdata->sessid;
1015 Safefree(psi);
1016 return sid;
1017}
1018
30500b05
IZ
1019#define ulMPFROMSHORT(i) ((unsigned long)MPFROMSHORT(i))
1020#define ulMPVOID() ((unsigned long)MPVOID)
1021#define ulMPFROMCHAR(i) ((unsigned long)MPFROMCHAR(i))
1022#define ulMPFROM2SHORT(x1,x2) ((unsigned long)MPFROM2SHORT(x1,x2))
1023#define ulMPFROMSH2CH(s, c1, c2) ((unsigned long)MPFROMSH2CH(s, c1, c2))
1024#define ulMPFROMLONG(x) ((unsigned long)MPFROMLONG(x))
1025
18729d3e
JH
1026#define _MessageBox MessageBox
1027#define _MessageBox2 MessageBox2
1028
760ac839
LW
1029MODULE = OS2::Process PACKAGE = OS2::Process
1030
30500b05 1031PROTOTYPES: ENABLE
760ac839
LW
1032
1033unsigned long
1034constant(name,arg)
1035 char * name
1036 int arg
1037
7f61b687
IZ
1038char *
1039my_type()
1040
1041U32
1042file_type(path)
1043 char *path
1044
35bc1fdc
IZ
1045SV *
1046swentry_expand( SV *sv )
7f61b687
IZ
1047 PPCODE:
1048 {
35bc1fdc
IZ
1049 STRLEN l;
1050 PSWENTRY pswentry = (PSWENTRY)SvPV(sv, l);
1051
1052 if (l != sizeof(SWENTRY))
1053 croak("Wrong structure size %ld!=%ld in swentry_expand()", (long)l, (long)sizeof(SWENTRY));
1054 EXTEND(sp,11);
1055 PUSHs(sv_2mortal(newSVpv(pswentry->swctl.szSwtitle, 0)));
1056 PUSHs(sv_2mortal(newSVnv(pswentry->swctl.hwnd)));
1057 PUSHs(sv_2mortal(newSVnv(pswentry->swctl.hwndIcon)));
1058 PUSHs(sv_2mortal(newSViv(pswentry->swctl.hprog)));
1059 PUSHs(sv_2mortal(newSViv(pswentry->swctl.idProcess)));
1060 PUSHs(sv_2mortal(newSViv(pswentry->swctl.idSession)));
1061 PUSHs(sv_2mortal(newSViv(pswentry->swctl.uchVisibility & SWL_VISIBLE)));
1062 PUSHs(sv_2mortal(newSViv(pswentry->swctl.uchVisibility & SWL_GRAYED)));
1063 PUSHs(sv_2mortal(newSViv(pswentry->swctl.fbJump == SWL_JUMPABLE)));
1064 PUSHs(sv_2mortal(newSViv(pswentry->swctl.bProgType)));
1065 PUSHs(sv_2mortal(newSViv(pswentry->hswitch)));
7f61b687
IZ
1066 }
1067
35bc1fdc
IZ
1068SV *
1069create_swentry( char *title, unsigned long sw_hwnd, unsigned long icon_hwnd, unsigned long owner_phandle, unsigned long owner_pid, unsigned long owner_sid, unsigned long visible, unsigned long switchable, unsigned long jumpable, unsigned long ptype, unsigned long sw_entry)
30500b05 1070PROTOTYPE: DISABLE
35bc1fdc
IZ
1071
1072int
1073change_swentry( SV *sv )
1074
7f61b687 1075bool
35bc1fdc 1076sesmgr_title_set(s)
7f61b687 1077 char *s
35bc1fdc
IZ
1078
1079SV *
18729d3e 1080process_swentry(unsigned long pid = getpid(), HWND hwnd = NULLHANDLE);
30500b05 1081 PROTOTYPE: DISABLE
35bc1fdc
IZ
1082
1083int
1084swentry_size()
1085
1086SV *
1087swentries_list()
1088
30500b05
IZ
1089void
1090ResetWinError()
1091
35bc1fdc 1092int
18729d3e 1093WindowText_set(HWND hwndFrame, char *title)
35bc1fdc
IZ
1094
1095bool
18729d3e 1096FocusWindow_set(HWND hwndFocus, HWND hwndDesktop = HWND_DESKTOP)
35bc1fdc
IZ
1097
1098bool
18729d3e 1099ShowWindow(HWND hwnd, bool fShow = TRUE)
35bc1fdc
IZ
1100
1101bool
18729d3e 1102EnableWindow(HWND hwnd, bool fEnable = TRUE)
30500b05
IZ
1103
1104bool
18729d3e 1105PostMsg(HWND hwnd, unsigned long msg, unsigned long mp1 = 0, unsigned long mp2 = 0)
30500b05 1106 C_ARGS: hwnd, msg, (MPARAM)mp1, (MPARAM)mp2
35bc1fdc
IZ
1107
1108bool
18729d3e 1109WindowPos_set(HWND hwnd, long x, long y, unsigned long fl = SWP_MOVE, long cx = 0, long cy = 0, HWND hwndInsertBehind = HWND_TOP)
30500b05 1110 PROTOTYPE: DISABLE
35bc1fdc
IZ
1111
1112unsigned long
18729d3e 1113BeginEnumWindows(HWND hwnd)
35bc1fdc
IZ
1114
1115bool
1116EndEnumWindows(unsigned long henum)
1117
1118unsigned long
1119GetNextWindow(unsigned long henum)
1120
1121bool
18729d3e 1122IsWindowVisible(HWND hwnd)
30500b05
IZ
1123
1124bool
18729d3e 1125IsWindowEnabled(HWND hwnd)
30500b05
IZ
1126
1127bool
18729d3e 1128IsWindowShowing(HWND hwnd)
35bc1fdc
IZ
1129
1130unsigned long
18729d3e 1131QueryWindow(HWND hwnd, long cmd)
35bc1fdc
IZ
1132
1133unsigned long
18729d3e 1134IsChild(HWND hwnd, HWND hwndParent)
35bc1fdc
IZ
1135
1136unsigned long
18729d3e 1137WindowFromId(HWND hwndParent, unsigned long id)
35bc1fdc
IZ
1138
1139unsigned long
18729d3e 1140WindowFromPoint(long x, long y, HWND hwnd = HWND_DESKTOP, bool fChildren = TRUE)
30500b05 1141PROTOTYPE: DISABLE
35bc1fdc
IZ
1142
1143unsigned long
18729d3e 1144EnumDlgItem(HWND hwndDlg, unsigned long code, HWND hwnd = NULLHANDLE)
35bc1fdc
IZ
1145 C_ARGS: hwndDlg, hwnd, code
1146
30500b05 1147bool
18729d3e 1148EnableWindowUpdate(HWND hwnd, bool fEnable = TRUE)
30500b05
IZ
1149
1150bool
18729d3e 1151SetWindowBits(HWND hwnd, long index, unsigned long flData, unsigned long flMask)
30500b05
IZ
1152
1153bool
18729d3e 1154SetWindowPtr(HWND hwnd, long index, unsigned long p)
30500b05
IZ
1155 C_ARGS: hwnd, index, (PVOID)p
1156
1157bool
18729d3e 1158SetWindowULong(HWND hwnd, long index, unsigned long i)
30500b05
IZ
1159
1160bool
18729d3e 1161SetWindowUShort(HWND hwnd, long index, unsigned short i)
30500b05
IZ
1162
1163bool
18729d3e 1164IsWindow(HWND hwnd, HAB hab = Acquire_hab())
30500b05
IZ
1165 C_ARGS: hab, hwnd
1166
1167BOOL
18729d3e 1168ActiveWindow_set(HWND hwnd, HWND hwndDesktop = HWND_DESKTOP)
30500b05
IZ
1169 CODE:
1170 RETVAL = SetActiveWindow(hwndDesktop, hwnd);
1171
18729d3e
JH
1172unsigned long
1173LoadPointer(unsigned long idres, unsigned long hmod = 0, HWND hwndDesktop = HWND_DESKTOP)
1174 C_ARGS: hwndDesktop, hmod, idres
1175
35bc1fdc
IZ
1176int
1177out_codepage()
1178
1179bool
1180out_codepage_set(int cp)
1181
1182int
1183in_codepage()
1184
1185bool
1186in_codepage_set(int cp)
1187
1188SV *
1189screen()
1190
1191bool
1192screen_set(SV *sv)
1193
1194SV *
1195process_codepages()
1196 PPCODE:
1197 {
1198 ULONG cps[4], c, i = 0, rc;
1199
1200 if (CheckOSError(DosQueryCp( sizeof(cps), cps, &c )))
1201 c = 0;
1202 c /= sizeof(ULONG);
1203 if (c >= 3)
1204 EXTEND(sp, c);
1205 while (i < c)
1206 PUSHs(sv_2mortal(newSViv(cps[i++])));
1207 }
1208
1209bool
1210process_codepage_set(int cp)
1211
30500b05
IZ
1212void
1213cursor(OUTLIST int stp, OUTLIST int ep, OUTLIST int wp, OUTLIST int ap)
1214 PROTOTYPE:
1215
1216bool
1217cursor_set(int s, int e, int w = cursor__(0), int a = cursor__(1))
1218
18729d3e
JH
1219NO_OUTPUT bool
1220_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())
1221 PROTOTYPE: DISABLE
1222 C_ARGS: hab, ulData, fmt, rgfFmtInfo
1223 POSTCALL:
1224 if (CheckWinError(RETVAL))
1225 croak_with_os2error("_ClipbrdData_set() error");
1226
1227void
1228ClipbrdData_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())
1229 PROTOTYPE: DISABLE
1230
1231void
1232ClipbrdOwner_set(HWND hwnd, HAB hab = perl_hab_GET())
1233 C_ARGS: hab, hwnd
1234
1235void
1236ClipbrdViewer_set(HWND hwnd, HAB hab = perl_hab_GET())
1237 C_ARGS: hab, hwnd
1238
1239unsigned long
1240EnumClipbrdFmts(unsigned long fmt = 0, HAB hab = perl_hab_GET())
1241 C_ARGS: hab, fmt
1242
1243unsigned long
1244AddAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1245 C_ARGS: hAtomTbl, pszAtomName
1246
1247unsigned long
1248FindAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1249 C_ARGS: hAtomTbl, pszAtomName
1250
1251unsigned long
1252DeleteAtom(char *pszAtomName, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1253 C_ARGS: hAtomTbl, pszAtomName
1254
1255void
1256Alarm(unsigned long rgfType = WA_ERROR, HWND hwndDesktop = HWND_DESKTOP)
1257 C_ARGS: hwndDesktop, rgfType
1258
1259void
1260FlashWindow(HWND hwndFrame, bool fFlash)
1261
30500b05
IZ
1262MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myQuery
1263
1264SV *
18729d3e 1265myQueryWindowText(HWND hwnd)
30500b05
IZ
1266
1267SV *
18729d3e 1268myQueryClassName(HWND hwnd)
30500b05 1269
35bc1fdc
IZ
1270MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = Query
1271
1272unsigned long
18729d3e 1273QueryFocusWindow(HWND hwndDesktop = HWND_DESKTOP)
35bc1fdc
IZ
1274
1275long
18729d3e 1276QueryWindowTextLength(HWND hwnd)
35bc1fdc
IZ
1277
1278SV *
18729d3e 1279QueryWindowSWP(HWND hwnd)
35bc1fdc 1280
30500b05 1281unsigned long
18729d3e 1282QueryWindowULong(HWND hwnd, long index)
35bc1fdc 1283
30500b05 1284unsigned short
18729d3e
JH
1285QueryWindowUShort(HWND hwnd, long index)
1286
1287unsigned long
1288QueryActiveWindow(HWND hwnd = HWND_DESKTOP)
1289
1290unsigned long
1291QueryDesktopWindow(HAB hab = Acquire_hab(), unsigned long hdc = NULLHANDLE)
1292
1293unsigned long
1294QueryClipbrdData(unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
1295 C_ARGS: hab, fmt
1296 PROTOTYPE: DISABLE
1297
1298unsigned long
1299QueryClipbrdViewer(HAB hab = perl_hab_GET())
1300
1301unsigned long
1302QueryClipbrdOwner(HAB hab = perl_hab_GET())
1303
1304void
1305CloseClipbrd(HAB hab = perl_hab_GET())
1306
1307void
1308EmptyClipbrd(HAB hab = perl_hab_GET())
1309
1310bool
1311OpenClipbrd(HAB hab = perl_hab_GET())
1312
1313unsigned long
1314QueryAtomUsage(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1315 C_ARGS: hAtomTbl, atom
1316
1317unsigned long
1318QueryAtomLength(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
1319 C_ARGS: hAtomTbl, atom
1320
1321unsigned long
1322QuerySystemAtomTable()
1323
1324unsigned long
1325QuerySysPointer(long lId, bool fCopy = 1, HWND hwndDesktop = HWND_DESKTOP)
1326 C_ARGS: hwndDesktop, lId, fCopy
30500b05
IZ
1327
1328unsigned long
18729d3e 1329CreateAtomTable(unsigned long initial = 0, unsigned long buckets = 0)
30500b05
IZ
1330
1331unsigned long
18729d3e
JH
1332DestroyAtomTable(HATOMTBL hAtomTbl)
1333
30500b05
IZ
1334
1335MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWinQuery
1336
1337unsigned long
18729d3e 1338myWinQueryWindowPtr(HWND hwnd, long index)
35bc1fdc
IZ
1339
1340NO_OUTPUT BOOL
18729d3e 1341myWinQueryWindowProcess(HWND hwnd, OUTLIST unsigned long pid, OUTLIST unsigned long tid)
30500b05 1342 PROTOTYPE: $
35bc1fdc
IZ
1343 POSTCALL:
1344 if (CheckWinError(RETVAL))
18729d3e
JH
1345 croak_with_os2error("WindowProcess() error");
1346
1347SV *
1348myWinQueryActiveDesktopPathname()
1349
1350void
1351myWinQueryClipbrdFmtInfo(OUTLIST unsigned long prgfFmtInfo, unsigned long fmt = CF_TEXT, HAB hab = perl_hab_GET())
1352 C_ARGS: hab, fmt, &prgfFmtInfo
1353
1354SV *
1355myWinQueryAtomName(ATOM atom, HATOMTBL hAtomTbl = QuerySystemAtomTable())
35bc1fdc 1356
30500b05 1357MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWin
35bc1fdc
IZ
1358
1359int
18729d3e 1360myWinSwitchToProgram(HSWITCH hsw = switch_of(NULLHANDLE, getpid()))
35bc1fdc
IZ
1361 PREINIT:
1362 ULONG rc;
1363
18729d3e
JH
1364#if 0
1365
1366unsigned long
1367myWinMessageBox(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)
1368 C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
1369
1370#endif
1371
1372unsigned long
1373_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)
1374 C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, flStyle
1375 POSTCALL:
1376 if (RETVAL == MBID_ERROR)
1377 RETVAL = 0;
1378
1379unsigned long
1380_MessageBox2(char *pszText, char* pmb2info, char *pszCaption, HWND hwndParent = HWND_DESKTOP, HWND hwndOwner = NULLHANDLE, unsigned long idWindow = 0)
1381 C_ARGS: hwndParent, hwndOwner, pszText, pszCaption, idWindow, (PMB2INFO)pmb2info
1382 POSTCALL:
1383 if (RETVAL == MBID_ERROR)
1384 RETVAL = 0;
1385
30500b05 1386MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = myWinQuery
35bc1fdc
IZ
1387
1388MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = get
1389
1390int
1391getppid()
1392
1393int
1394ppidOf(int pid = getpid())
1395
1396int
1397sidOf(int pid = getpid())
1398
1399void
1400getscrsize(OUTLIST int wp, OUTLIST int hp)
30500b05 1401 PROTOTYPE:
35bc1fdc
IZ
1402
1403bool
1404scrsize_set(int w_or_h, int h = -9999)
30500b05 1405
18729d3e
JH
1406void
1407get_InvalidateRect(HWND hwnd, char *prcl, bool fIncludeChildren)
1408
1409void
1410get_CreateFrameControls(HWND hwndFrame, char *pfcdata, char* pszTitle)
1411
30500b05
IZ
1412MODULE = OS2::Process PACKAGE = OS2::Process PREFIX = ul
1413
1414unsigned long
1415ulMPFROMSHORT(unsigned short i)
1416
1417unsigned long
1418ulMPVOID()
1419
1420unsigned long
1421ulMPFROMCHAR(unsigned char i)
1422
1423unsigned long
1424ulMPFROM2SHORT(unsigned short x1, unsigned short x2)
1425 PROTOTYPE: DISABLE
1426
1427unsigned long
1428ulMPFROMSH2CH(unsigned short s, unsigned char c1, unsigned char c2)
1429 PROTOTYPE: DISABLE
1430
1431unsigned long
1432ulMPFROMLONG(unsigned long x)
1433