⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 process.xs

📁 source of perl for linux application,
💻 XS
📖 第 1 页 / 共 4 页
字号:
#include <process.h>#define INCL_DOS#define INCL_DOSERRORS#define INCL_DOSNLS#define INCL_WINSWITCHLIST#define INCL_WINWINDOWMGR#define INCL_WININPUT#define INCL_VIO#define INCL_KBD#define INCL_WINCLIPBOARD#define INCL_WINATOM#include <os2.h>#include "EXTERN.h"#include "perl.h"#include "XSUB.h"static unsigned longconstant(char *name, int arg){    errno = 0;    if (name[0] == 'P' && name[1] == '_') {	if (strEQ(name, "P_BACKGROUND"))#ifdef P_BACKGROUND	    return P_BACKGROUND;#else	    goto not_there;#endif	if (strEQ(name, "P_DEBUG"))#ifdef P_DEBUG	    return P_DEBUG;#else	    goto not_there;#endif	if (strEQ(name, "P_DEFAULT"))#ifdef P_DEFAULT	    return P_DEFAULT;#else	    goto not_there;#endif	if (strEQ(name, "P_DETACH"))#ifdef P_DETACH	    return P_DETACH;#else	    goto not_there;#endif	if (strEQ(name, "P_FOREGROUND"))#ifdef P_FOREGROUND	    return P_FOREGROUND;#else	    goto not_there;#endif	if (strEQ(name, "P_FULLSCREEN"))#ifdef P_FULLSCREEN	    return P_FULLSCREEN;#else	    goto not_there;#endif	if (strEQ(name, "P_MAXIMIZE"))#ifdef P_MAXIMIZE	    return P_MAXIMIZE;#else	    goto not_there;#endif	if (strEQ(name, "P_MINIMIZE"))#ifdef P_MINIMIZE	    return P_MINIMIZE;#else	    goto not_there;#endif	if (strEQ(name, "P_NOCLOSE"))#ifdef P_NOCLOSE	    return P_NOCLOSE;#else	    goto not_there;#endif	if (strEQ(name, "P_NOSESSION"))#ifdef P_NOSESSION	    return P_NOSESSION;#else	    goto not_there;#endif	if (strEQ(name, "P_NOWAIT"))#ifdef P_NOWAIT	    return P_NOWAIT;#else	    goto not_there;#endif	if (strEQ(name, "P_OVERLAY"))#ifdef P_OVERLAY	    return P_OVERLAY;#else	    goto not_there;#endif	if (strEQ(name, "P_PM"))#ifdef P_PM	    return P_PM;#else	    goto not_there;#endif	if (strEQ(name, "P_QUOTE"))#ifdef P_QUOTE	    return P_QUOTE;#else	    goto not_there;#endif	if (strEQ(name, "P_SESSION"))#ifdef P_SESSION	    return P_SESSION;#else	    goto not_there;#endif	if (strEQ(name, "P_TILDE"))#ifdef P_TILDE	    return P_TILDE;#else	    goto not_there;#endif	if (strEQ(name, "P_UNRELATED"))#ifdef P_UNRELATED	    return P_UNRELATED;#else	    goto not_there;#endif	if (strEQ(name, "P_WAIT"))#ifdef P_WAIT	    return P_WAIT;#else	    goto not_there;#endif	if (strEQ(name, "P_WINDOWED"))#ifdef P_WINDOWED	    return P_WINDOWED;#else	    goto not_there;#endif    } else if (name[0] == 'T' && name[1] == '_') {	if (strEQ(name, "FAPPTYP_NOTSPEC"))#ifdef FAPPTYP_NOTSPEC	    return FAPPTYP_NOTSPEC;#else	    goto not_there;#endif	if (strEQ(name, "T_NOTWINDOWCOMPAT"))#ifdef FAPPTYP_NOTWINDOWCOMPAT	    return FAPPTYP_NOTWINDOWCOMPAT;#else	    goto not_there;#endif	if (strEQ(name, "T_WINDOWCOMPAT"))#ifdef FAPPTYP_WINDOWCOMPAT	    return FAPPTYP_WINDOWCOMPAT;#else	    goto not_there;#endif	if (strEQ(name, "T_WINDOWAPI"))#ifdef FAPPTYP_WINDOWAPI	    return FAPPTYP_WINDOWAPI;#else	    goto not_there;#endif	if (strEQ(name, "T_BOUND"))#ifdef FAPPTYP_BOUND	    return FAPPTYP_BOUND;#else	    goto not_there;#endif	if (strEQ(name, "T_DLL"))#ifdef FAPPTYP_DLL	    return FAPPTYP_DLL;#else	    goto not_there;#endif	if (strEQ(name, "T_DOS"))#ifdef FAPPTYP_DOS	    return FAPPTYP_DOS;#else	    goto not_there;#endif	if (strEQ(name, "T_PHYSDRV"))#ifdef FAPPTYP_PHYSDRV	    return FAPPTYP_PHYSDRV;#else	    goto not_there;#endif	if (strEQ(name, "T_VIRTDRV"))#ifdef FAPPTYP_VIRTDRV	    return FAPPTYP_VIRTDRV;#else	    goto not_there;#endif	if (strEQ(name, "T_PROTDLL"))#ifdef FAPPTYP_PROTDLL	    return FAPPTYP_PROTDLL;#else	    goto not_there;#endif	if (strEQ(name, "T_32BIT"))#ifdef FAPPTYP_32BIT	    return FAPPTYP_32BIT;#else	    goto not_there;#endif    }    errno = EINVAL;    return 0;not_there:    errno = ENOENT;    return 0;}const char* const ptypes[] = { "FS", "DOS", "VIO", "PM", "DETACH" };static char *my_type(){    int rc;    TIB *tib;    PIB *pib;        if (!(_emx_env & 0x200)) return (char*)ptypes[1]; /* not OS/2. */    if (CheckOSError(DosGetInfoBlocks(&tib, &pib))) 	return NULL;         return (pib->pib_ultype <= 4 ? (char*)ptypes[pib->pib_ultype] : "UNKNOWN");}static ULONGfile_type(char *path){    int rc;    ULONG apptype;        if (!(_emx_env & 0x200)) 	croak("file_type not implemented on DOS"); /* not OS/2. */    if (CheckOSError(DosQueryAppType(path, &apptype))) {#if 0	if (rc == ERROR_INVALID_EXE_SIGNATURE) 	    croak("Invalid EXE signature"); 	else if (rc == ERROR_EXE_MARKED_INVALID) {	    croak("EXE marked invalid"); 	}#endif	croak_with_os2error("DosQueryAppType");     }        return apptype;}/* These use different type of wrapper.  Good to check wrappers. ;-)  *//* XXXX This assumes DOS type return type, without SEVERITY?! */DeclFuncByORD(HSWITCH, myWinQuerySwitchHandle,  ORD_WinQuerySwitchHandle,		  (HWND hwnd, PID pid), (hwnd, pid))DeclFuncByORD(ULONG, myWinQuerySwitchEntry,  ORD_WinQuerySwitchEntry,		  (HSWITCH hsw, PSWCNTRL pswctl), (hsw, pswctl))DeclFuncByORD(ULONG, myWinSetWindowText,  ORD_WinSetWindowText,		  (HWND hwnd, char* text), (hwnd, text))DeclFuncByORD(BOOL, myWinQueryWindowProcess,  ORD_WinQueryWindowProcess,		  (HWND hwnd, PPID ppid, PTID ptid), (hwnd, ppid, ptid))DeclFuncByORD(ULONG, XmyWinSwitchToProgram,  ORD_WinSwitchToProgram,		  (HSWITCH hsw), (hsw))#define myWinSwitchToProgram(hsw) (!CheckOSError(XmyWinSwitchToProgram(hsw)))/* These function croak if the return value is 0. */DeclWinFunc_CACHE(HWND, QueryWindow, (HWND hwnd, LONG cmd), (hwnd, cmd))DeclWinFunc_CACHE(BOOL, QueryWindowPos, (HWND hwnd, PSWP pswp),		  (hwnd, pswp))DeclWinFunc_CACHE(LONG, QueryWindowText,		  (HWND hwnd, LONG cchBufferMax, PCH pchBuffer),		  (hwnd, cchBufferMax, pchBuffer))DeclWinFunc_CACHE(LONG, QueryClassName, (HWND hwnd, LONG cchMax, PCH pch),		  (hwnd, cchMax, pch))DeclWinFunc_CACHE(HWND, QueryFocus, (HWND hwndDesktop), (hwndDesktop))DeclWinFunc_CACHE(BOOL, SetFocus, (HWND hwndDesktop, HWND hwndFocus),		  (hwndDesktop, hwndFocus))DeclWinFunc_CACHE(BOOL, ShowWindow, (HWND hwnd, BOOL fShow), (hwnd, fShow))DeclWinFunc_CACHE(BOOL, EnableWindow, (HWND hwnd, BOOL fEnable),		      (hwnd, fEnable))DeclWinFunc_CACHE(BOOL, SetWindowPos,		  (HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y,		   LONG cx, LONG cy, ULONG fl),		  (hwnd, hwndInsertBehind, x, y, cx, cy, fl))DeclWinFunc_CACHE(HENUM, BeginEnumWindows, (HWND hwnd), (hwnd))DeclWinFunc_CACHE(BOOL, EndEnumWindows, (HENUM henum), (henum))DeclWinFunc_CACHE(BOOL, EnableWindowUpdate, (HWND hwnd, BOOL fEnable),		  (hwnd, fEnable))DeclWinFunc_CACHE(BOOL, SetWindowBits,		  (HWND hwnd, LONG index, ULONG flData, ULONG flMask),		  (hwnd, index, flData, flMask))DeclWinFunc_CACHE(BOOL, SetWindowPtr, (HWND hwnd, LONG index, PVOID p),		  (hwnd, index, p))DeclWinFunc_CACHE(BOOL, SetWindowULong, (HWND hwnd, LONG index, ULONG ul),		  (hwnd, index, ul))DeclWinFunc_CACHE(BOOL, SetWindowUShort, (HWND hwnd, LONG index, USHORT us),		  (hwnd, index, us))DeclWinFunc_CACHE(HWND, IsChild, (HWND hwnd, HWND hwndParent),		  (hwnd, hwndParent))DeclWinFunc_CACHE(HWND, WindowFromId, (HWND hwnd, ULONG id), (hwnd, id))DeclWinFunc_CACHE(HWND, EnumDlgItem, (HWND hwndDlg, HWND hwnd, ULONG code),		  (hwndDlg, hwnd, code))DeclWinFunc_CACHE(HWND, QueryDesktopWindow, (HAB hab, HDC hdc), (hab, hdc));DeclWinFunc_CACHE(BOOL, SetActiveWindow, (HWND hwndDesktop, HWND hwnd),		  (hwndDesktop, hwnd));DeclWinFunc_CACHE(BOOL, QueryActiveDesktopPathname, (PSZ pszPathName, ULONG ulSize),		  (pszPathName, ulSize));DeclWinFunc_CACHE(BOOL, InvalidateRect,		  (HWND hwnd, /*RECTL*/ char *prcl, BOOL fIncludeChildren),		  (hwnd, prcl, fIncludeChildren));DeclWinFunc_CACHE(BOOL, CreateFrameControls,		  (HWND hwndFrame, /*PFRAMECDATA*/ char* pfcdata, PCSZ pszTitle),		  (hwndFrame, pfcdata, pszTitle));DeclWinFunc_CACHE(BOOL, OpenClipbrd, (HAB hab), (hab));DeclWinFunc_CACHE(BOOL, EmptyClipbrd, (HAB hab), (hab));DeclWinFunc_CACHE(BOOL, CloseClipbrd, (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));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(ULONG, QueryAtomUsage, (HATOMTBL hAtomTbl, ATOM atom),		  (hAtomTbl, atom));DeclWinFunc_CACHE(ULONG, QueryAtomLength, (HATOMTBL hAtomTbl, ATOM atom),		  (hAtomTbl, atom));DeclWinFunc_CACHE(ULONG, QueryAtomName,		  (HATOMTBL hAtomTbl, ATOM atom, PSZ pchBuffer, ULONG cchBufferMax),		  (hAtomTbl, atom, pchBuffer, cchBufferMax));DeclWinFunc_CACHE(HATOMTBL, QuerySystemAtomTable, (VOID), ());DeclWinFunc_CACHE(HATOMTBL, CreateAtomTable, (ULONG initial, ULONG buckets),		  (initial, buckets));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,		   PCSZ pszCaption, ULONG idWindow, PMB2INFO pmb2info),		  (hwndParent, hwndOwner, pszText, pszCaption, idWindow, pmb2info));DeclWinFunc_CACHE(HPOINTER, LoadPointer,		  (HWND hwndDesktop, HMODULE hmod, ULONG idres),		  (hwndDesktop, hmod, idres));DeclWinFunc_CACHE(HPOINTER, QuerySysPointer,		  (HWND hwndDesktop, LONG lId, BOOL fCopy),		  (hwndDesktop, lId, fCopy));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,			  (HAB hab, ULONG ulData, ULONG fmt, ULONG rgfFmtInfo),			  (hab, ulData, fmt, rgfFmtInfo));#define get_InvalidateRect	InvalidateRect#define get_CreateFrameControls	CreateFrameControls/* These functions may return 0 on success; check $^E/Perl_rc on res==0: */DeclWinFunc_CACHE_resetError(PVOID, QueryWindowPtr, (HWND hwnd, LONG index),			     (hwnd, index))DeclWinFunc_CACHE_resetError(ULONG, QueryWindowULong, (HWND hwnd, LONG index),			     (hwnd, index))DeclWinFunc_CACHE_resetError(SHORT, QueryWindowUShort, (HWND hwnd, LONG index),			     (hwnd, index))DeclWinFunc_CACHE_resetError(LONG,  QueryWindowTextLength, (HWND hwnd), (hwnd))DeclWinFunc_CACHE_resetError(HWND,  QueryActiveWindow, (HWND hwnd), (hwnd))DeclWinFunc_CACHE_resetError(BOOL, PostMsg,			     (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2),			     (hwnd, msg, mp1, mp2))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))/* These functions are called frow complicated wrappers: */ULONG (*pWinQuerySwitchList) (HAB hab, PSWBLOCK pswblk, ULONG usDataLength);ULONG (*pWinChangeSwitchEntry) (HSWITCH hsw, __const__ SWCNTRL *pswctl);HWND (*pWinWindowFromPoint)(HWND hwnd, __const__ POINTL *pptl, BOOL fChildren);/* These functions have different names/signatures than what is   declared above */#define QueryFocusWindow QueryFocus#define FocusWindow_set(hwndFocus, hwndDesktop) SetFocus(hwndDesktop, hwndFocus)#define WindowPos_set(hwnd, x, y, fl, cx, cy, hwndInsertBehind)	\	SetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl)#define myWinQueryWindowPtr(hwnd, i)	((ULONG)QueryWindowPtr(hwnd, i))#define _ClipbrdData_set SetClipbrdData#define ClipbrdOwner_set SetClipbrdOwner#define ClipbrdViewer_set SetClipbrdViewerintWindowText_set(HWND hwnd, char* text){   return !CheckWinError(myWinSetWindowText(hwnd, text));}SV *myQueryWindowText(HWND hwnd){    LONG l = QueryWindowTextLength(hwnd), len;    SV *sv;    STRLEN n_a;    if (l == 0) {	if (Perl_rc)		/* Last error */	    return &PL_sv_undef;	return &PL_sv_no;    }    sv = newSVpvn("", 0);    SvGROW(sv, l + 1);    len = QueryWindowText(hwnd, l + 1, SvPV_force(sv, n_a));    if (len != l) {	Safefree(sv);	croak("WinQueryWindowText() uncompatible with WinQueryWindowTextLength()");    }    SvCUR_set(sv, l);    return sv;}SWPQueryWindowSWP_(HWND hwnd){    SWP swp;    if (!QueryWindowPos(hwnd, &swp))	croak("WinQueryWindowPos() error");    return swp;}SV *QueryWindowSWP(HWND hwnd){    SWP swp = QueryWindowSWP_(hwnd);    return newSVpvn((char*)&swp, sizeof(swp));}SV *myQueryClassName(HWND hwnd){    SV *sv = newSVpvn("",0);    STRLEN l = 46, len = 0, n_a;    while (l + 1 >= len) {	if (len)	    len = 2*len + 10;		/* Grow quick */	else	    len = l + 2;	SvGROW(sv, len);	l = QueryClassName(hwnd, len, SvPV_force(sv, n_a));    }    SvCUR_set(sv, l);    return sv;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -