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

📄 process.xs

📁 source of perl for linux application,
💻 XS
📖 第 1 页 / 共 4 页
字号:
#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);}voidvioFont_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;intvio_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){    ULONG rc;    USHORT bufl = bufsize();    char b[(1<<16) * 3]; /* This/3 is enough for 16-bit calls, we need			    2x overhead due to 2 vs 4 issue, and extra			    64K due to alignment logic */    char *buf = b;        if (((ULONG)buf) & 0xFFFF)	buf += 0x10000 - (((ULONG)buf) & 0xFFFF);    if ((sizeof(b) - (buf - b)) < 2*bufl)	croak("panic: VIO buffer allocation");    if (CheckOSError(VioReadCellStr( buf, &bufl, 0, 0, 0 )))	return &PL_sv_undef;    return newSVpvn(buf,bufl);}boolscreen_set(SV *sv){    ULONG rc;    STRLEN l = SvCUR(sv), bufl = bufsize();    char b[(1<<16) * 2]; /* This/2 is enough for 16-bit calls, we need			    extra 64K due to alignment logic */    char *buf = b;        if (((ULONG)buf) & 0xFFFF)	buf += 0x10000 - (((ULONG)buf) & 0xFFFF);    if (!SvPOK(sv) || ((l != bufl) && (l != 2*bufl)))	croak("Wrong size %d of saved screen data", SvCUR(sv));    if ((sizeof(b) - (buf - b)) < l)	croak("panic: VIO buffer allocation");    Copy(SvPV(sv,l), buf, bufl, char);    if (CheckOSError(VioWrtCellStr( buf, bufl, 0, 0, 0 )))	return 0;    return 1;}intprocess_codepages(){    ULONG cps[4], cp, rc;    if (CheckOSError(DosQueryCp( sizeof(cps), cps, &cp )))	croak_with_os2error("DosQueryCp()");    return cp;}intout_codepage(){    USHORT cp, rc;    if (CheckOSError(VioGetCp( 0, &cp, 0 )))	croak_with_os2error("VioGetCp()");    return cp;}boolout_codepage_set(int cp){    USHORT rc;    return !(CheckOSError(VioSetCp( 0, cp, 0 )));}intin_codepage(){    USHORT cp, rc;    if (CheckOSError(KbdGetCp( 0, &cp, 0 )))	croak_with_os2error("KbdGetCp()");    return cp;}boolin_codepage_set(int cp){    USHORT rc;    return !(CheckOSError(KbdSetCp( 0, cp, 0 )));}boolprocess_codepage_set(int cp){    USHORT rc;    return !(CheckOSError(DosSetProcessCp( cp )));}intppidOf(int pid){  PQTOPLEVEL psi;  int ppid;  if (!pid)      return -1;  psi = get_sysinfo(pid, QSS_PROCESS);  if (!psi)      return -1;  ppid = psi->procdata->ppid;  Safefree(psi);  return ppid;}intsidOf(int pid){  PQTOPLEVEL psi;  int sid;  if (!pid)      return -1;  psi = get_sysinfo(pid, QSS_PROCESS);  if (!psi)      return -1;  sid = psi->procdata->sessid;  Safefree(psi);  return sid;}STRLENStrLen(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))#define ulMPFROM2SHORT(x1,x2)		((unsigned long)MPFROM2SHORT(x1,x2))#define ulMPFROMSH2CH(s, c1, c2)	((unsigned long)MPFROMSH2CH(s, c1, c2))#define ulMPFROMLONG(x)			((unsigned long)MPFROMLONG(x))#define _MessageBox			MessageBox#define _MessageBox2			MessageBox2MODULE = OS2::Process		PACKAGE = OS2::ProcessPROTOTYPES: ENABLEunsigned longconstant(name,arg)	char *		name	int		arg

⌨️ 快捷键说明

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