-+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+ X`20`20`20`20\1105bit; X\0E09po\CD0BreadMask\120Awrite\130E\F106\1406\F304ackIndex\7D030; X`09timerExpired\1308otset\0D06 X#ifdef`20DNDEBUG X\8905fprintf(stderr,`20"select:\BD04rt`5Cn"); X#endif`20/*`20\3B07`20*/ X/* X`20*`20Optimized`20channel`20listening`20setup`20loop. X`20*/ X`09for`20(fd_group`20=`200,`20i`20\0705j`20\A204\0703<`20width;`20++f\2907) X`09`7B X`09`09if`20(readfds->bits`5Bf\2107`5D)\1F03`7B X\CF05`09`09pos`20=`20-1; X`09`09`09while(`20_FFS(pos+1,`20((NBLW-1)-pos),`20`26\5517\1A03pos)) X\5807\6109`09bit\6203j`20+`20pos; X\1708\A104!ChanTableInfo`5Bbit`5D) X\2108\420A`09errno\4503EBADF;\180Areturn\BE05\1408`7D X\611F->readAstPend)`20 X\4D09status\6603issueRead`20((bit<<4)); X`09\5C04\0404\8F03lse X\1003j`20+=`20NBLW; X`09\1803LIB$MOVC5(`26zero,`20NULL,`20"`5C0",`20`26numBytes,`20(char`20*)`20 V`26readMask\5F04\AF04writefds)`20\4C32write\4D07/* X`09This`20is`20a`20future`20enhancement,`20currently`20omitted`20for`20time V`20considerations: X\9A05except\9B37\3D06\9C07*/\5206!stackIndex) X`09`7B X`09`09int`20sec`20=`200;\0F07us\1008\1104f`20(timeout)\0F03\3304`09s\2005 V\1607->tv_sec\3E04`09u\1B12usec\1C04`7D X\4D06\4E09`20`26`26`20(!(sec`20+`20usec))\6204`09timerExpired\4C031;\1503else V\7E05/* X`20*`20Here's`20the`20juicy`20part`20of`20select().`20`20Check`20for`20a\9008 V`20value`20to`20be`20setup.`20Then X\5303enable`20ASTs,`20c\3C0Any`20I/O`20completion,`20and`20disa\3008. X`20*/ X\BA03\DF04\DE08\1004`7B X\0503`09delta`5B0`5D`20=`20\ED05*`20-10000000)`20+`20(u\1509);\310B1`5D\3103-1 V\1306SYS$SETIMR`20(`200,`20delta,`20\6D07Ast,\0C08,`20\4707`7D X\0503ENABLE_ASTS;\1004HIBERNATE;\0E04DISA\1F0D\C104(!timerExpired)`20`26`26 V\D50A\D60Bstatus\A303SYS$CANTIM\2809\8409\5105VMSFAIL(\3206))`20LIB$SIGNA V\1409\B109\0403\0303\3604!stackIndex`20\8303\950E\2A03fprintf`20(stderr,`20"se Vlect:`20error`20-`20s\410A0`20\3F0C`200`5Cn"); X/* X`20*`20Now`20check`20the`20ast`20stack`20for`20completions.`20`20Mark`20any V\2F03annel's`20with`20I/O`20pending\5104on\4A05internal`20fd`20masks. X`20*/ X\DD05(t\CE0C\E004\F00C)) X`09`7B X\E303or`20(i`20=`200,`20lw\0806fd_group\0E04;`20lw`20<`20width;`20lw+=NBLW V\240A++) X`09\4A05\7505readfds)\1004`09r\0D06->bits`5Bf\3207`5D`20\5704\3108writef\3208 V\0E08\331Dexcept\3409\0F09\3518`7D X\0303`09else X\A903#ifdef`20DNDEBUG\1F03fprintf(stderr,`20"select:`20stackIndex`20%d`5Cn", V\120B); X#endif X\4103or`20(i`20\6E04`20i`20<\260B;`20i++\A604`7B X/* X`20*`09Note,`20read_iosb.status`20=`20SS$_LINKABORT,`20when`20the`20line`20die Vs!`20 X`20*/ X\F003if`20((stack`5Bi`5D.type`20==`20NET_CMD)`20`7C`7C`20(ChanTableInfo`5B( V\2D09channel>>4)`5D))\4D04`7B X\0503switch`20(\550D\1F0Acase\6008`20:\1709\8905processNetCmd(`26s\6A0F\6506 V\3007`09FD_SET(\2510,`20`26readMask); X\2A05totset++\0F06`7D X\0604break;\0B04\1005\9609RD\9510readfds)\7C0C\1804FD_IS\8216\3308\3406\3508 V\B22B\B30F\B407\0605\AF0EWRT`20:`20\B10Ewritef\B22E\3409\B329write\B429/* X`20*`09\B90BCMD`20:`20 X\1505`7B X\0705\A405exceptfds) X\1506\1D08\C220\390A\3A08\3B0A\C71B\3706\C807\2F08\CA0A\1207`7D X\0906\0807\0704/ X\0904`20/*`20switch\120CLINKABORT`20if`20\1806else\0804`7B X\4804errno`20=`20EBADF;\1305\7406\1403-1\1106break;\5405\0503`7D X/* X`20*`20Now`20"and"`20the`20two`20tables`20together`20to`20create\2205returned V`20fd`20table(s).\BF07for`20(lw`20=`200,`20fd_group\0E04;`20lw`20<`20width; V\0C03+=NBLW,`20++\2608) X\CB07if`20(readfds\1404`09`09\0D07->bits`5Bf\3007`5D`20`26=`20readMask.b\1B0D V\E405\4804writef\4908\0E08\4A14write\4B1Cexcept\4C09\0F09\4D14\1D06\4E17`7D X\0303#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"select:`20returning`20%d`5Cn",`20totset); X#endif X`09\2206\1807; X`7D X X`0C X/* X`20*`20setsockopt X\0E03Stub`20routine`20for`20emulation`20purposes`20right`20now. X`20*/ Xint Xs\4509`20(chan,`20level,`20optname\0905va\1106len) X`09unsigned`20short`20chan; X`09\1609long`20level\1611\5407; X`09char`20*optval\2714len; X`7B X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"s\C309:`20start`20-`20passed`20chan`20%d`5Cn V",`20chan); X#endif`20/*\5608`20*/ X`09ChanTableInfo`5B(chan>>4)`5D->o`5Bo\B606`5D.option`20=`20\B809\372Blen V\3A06len; X`09return`200; X`7D X X`0C X/* X`20*`20socket(): X\0D03Two`20channels`20are`20created`20as`20a`20result`20of`20this`20call, X\36031)`20mbxChannel`20-`20the`20network`20command`20mailbox`20throught`20whic Vh`20all`20low`20level`20 X`20*`09`09`20`20`20connect\F904informat\0C04\4806nagement`20crap`20flows X\85032)\7404\850E\CB07`20to`20\0F04NET`20device,`20used`20by\D603server\2404es Vt.\1103\8608DECnet`20object;`20\320Aclient`20to`20\A907\9A05perform`20I/O`20on V X\4507\7804aforementioned`20\5106. X\B503Note:`20only\BD0Cis`20"seen"`20by`20\C805alling`20layer`20program. X`20*/ Xunsigned`20short Xsocket`20(addrfam,`20type,`20proto) X`09u\2E08long`20\2507; X\180Ftype\1511proto; X`7B X`09int`20status; X X#ifdef`20DNDEBUG X\F203`20`09fprintf(stderr,`20"socket:`20start`5Cn"); X#endif`20/*`20\3B07\CD04\3E05connectN\C704); X`09if`20(!ChanTableInfo`5B(netChannel>>4)`5D)`20clearC\2508((\210E\4718mbxC V\471D\210E\4704return`20n\6009; X`7D X X`0C X/* X`20*`20socket_close\1004Emulation`20routine`20for`20closing`20channels. X`20*/ Xint X\400C`20(chan) X`20`20`20`20\0404unsigned`20short\3D05; X`7B X`09u\180EshiftChan`20=\2405>>4; X X#ifdef`20DNDEBUG X`09fprintf(stderr,`20"s\7A0B:`20linkTerm`20%d`5Cn",`20chan); X#endif X`09\1F09(s\6E08); X`09clearChanTable`20(\1D0Dreturn`200; X`7D X X`0C X/* X`20*`20s\7606ioctl X\1003Emualtion`20routine`20for`20stubbing`20purposes`20only. X`20*/ Xint Xs\460B`20(chan,`20request,`20argp) X`09unsigned`20short\D105; X`09\1609int\3308\C904har`20*argp; X`7B X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"s\840B:`20start`20-`20passed`20chan`20%d`5Cn V",`20chan); X#endif`20/*\5808\CD04`09if`20(chan`20>`20FD_SETSIZE) X`09`09return`20-1; X`09ChanTableInfo`5B(chan>>4)`5D->type`20=`20\C909`7D X X`0C X/* X`20*`20s\A006perror\1104Emulation`20for`20the`20same.`20`20Relatively`20weak V`20right`20now`20in`20that`20it`20ignores`20errno\4F04values. X\C704void Xs\710C`20(s) X`09char`20*s; X`7B X#ifdef\FC08 X`20`20`20`20`09fprintf(stderr,`20"s\430C:`20start`5Cn"); X#endif`20/*\4208\7704\410Cout,`20"%s",`20s); X`7D X X`0C X/* X\A903\5507read`20(chan,`20target,`20length) X\2603Routine`20to`20emulate`20the`20a`20streamed`20\4105on\1304ocket.`20`20Cur Vrently\2C05read\7105upports`20ONLY`20nonblocking`20I/O.`20`20That`20is,\3509 V`20will`20complete`20is\1A04re\4C04is`20ANYTHING`20in`20\3204channel`20buffer V\6003t`20depend\6204on`20\2404passed`20"length"`20field.\5104With`20b\910B V\8710wait`20until\1905\4206\4106`20request`20has X\4C03been`20statisfie\6005/ Xint Xsocket_r\5504(chan,`20target,`20l) X`20`20`20`20\0404unsigned`20short`20`20`20chan; X\1F08char`20\0803*target\190Aint\0805l; X`7B X`09int`09shiftChan`20=\4505>>4; X`09\4105*vmbase`20=`20ChanTableInfo`5B\3309`5D->base\300Bdelta`20\311Cdelta; X`09\8A04vmle\7804\2E1Alen\BD12remainder;\F112savt\F417movetot; X\F805pass\0B07status; X`09struct`20io_stat_blk`20iosb; X X#ifdef`20DNDEBUG X\4F04`09fprintf(stderr,`20"socket_read:`20start`20-`20passed\A104n`20%d`5Cn", V\0C05); X#endif`20/*\5708`20*/ X`09if`20(!ChanTableInfo`5BshiftChan`5D)`20return`20-1;\E00A\3204l)\1B08l; X X\1B08savtarget`20=`20\0906\370Amoveto\1A040; X/*`20Check`20the`20size`20of`20\0C04channel's`20read`20buffer`20`09`09`09*/ X\4A08remainder`20=`20(vmbase`20+`20vmlen)`20-`20vmdelta; X/* X`20*`20If`20this`20routine`20was`20called`20after`20an`20AST\7006notification V`20from`20select()`20and`20the\5304\2B05in\9E08\C005\57040,`20return`200`20now V`20so`20that`20a`20QIO`20is`20*not*`20performed.`20`20In\5508case`20of\2D03cal Vling`20program`20\4405does\4007use`20\9706/AST's\7604adAstDone`20will`20rema V\A1030. X`20*/ X`20`20`20`20`09if`20(ChanTableInfo`5BshiftChan`5D->r\420A) X\3005`7B X\0705`09C\3424`20=`200; X\3106if(!\8006der)`20return\1F09`7D X/*\EF04See`20if`20the`20VM`20area`20exists`20and,\1B04so,`20is`20there`20anyth Ving`20in`20there?`20`20If`20yes`20again, X\5403move`20it,`20updat\5905pointers,`20and\8C07.`20(Non`20block\5304I/O). X`20*/ X\A204\0404if`20(r\C309\1709`7B X`09`09pass\EE03MIN(\2209,`20l)\DF06\2A08\0404bcopy`20(vmdelta,`20target,`20pas Vs\2F13movetot`20+=\2205\2112savtarget\231A\6C07\210A`09`09ChanTableInfo`5Bshif VtChan`5D->base`20=`20vmbase\2B1E\5606\2C04delta\2D1Elen`20\2B04len\2904return V\DF08\B40A`7D X/* X`20*`20VM`20memory`20area`20is`20empty,`20so`20fill`20it`20up`20and`20update V`20the`20pointers. X`20*/ X`09if`20(!remainder) X`09`7B X\6808\0808status\9A03SYS$QIOW`20(0,`20chan,`20IO$_READVBLK,`20`26iosb,`200 V\0303,`20vmbase, X\4F10\0808MAX_QIO\2F08\0604);\2E11\A005(s\8306`26`20STS$M_SUCCESS)`20`7C`7C V`20!(iosb.s\2216) X\7F18return`20-1; X`09`09vmdelta\E403\B606\8812vmlen`20=`20iosb.msg_len; X#ifdef`20DNDEBUG\3505`09`09fprintf(stderr,"socket_read:\4006\4B04%d`20on`20cha Vnnel`20%d`5Cn",\5D0C,`20chan); X#endif X`09`09if`20(\8706<`20l)`20f\670E`20"\680D\DF06ed\2C03request`20%d/%\6705\CD06, V`20l)\E80A`7D X`09pass`20=`20MIN(\2113bcopy`20(vmdelta,`20savtarget,`20pass\2A0Bmovetot`20+= V\1A05\190A\3C07\190A`09ChanTableInfo`5BshiftChan`5D->base`20=`20vmbase\2A1D V\5406\2B04delta\2C1Dlen\2A05len; X`09return\B008; X`7D X X`0C X/* X`20*`20socket_write X\1003Emulation`20routine`20for`20writes`20to`20a`20given`20channel.`20`20Note V`20that`20I`20tried`20IO$M_NOW\5004but`20it`20had`20the`20effect`20of`20causin Vg`20an`20error`20(overflow`20I`20believe)\5F03\4504Does`20buffering`20occur? V`20`20Is\5B04detrimental\A104\6604works`20since\4D03don't`20check`20for\5104 V\D005`20completion? X`20*/ Xint Xsocket_w\2105(chan,`20\7A06,`20l)`20`20`20/*`20Issue`20writes,`20(IO$_WRITEVBL VK),`20over\8705logical`20link.*/ X\3E03\0303`20`20unsigned`20short`09chan; X\1D08char`20\0D08\0303*buffer\210Aint\200C`20l; X`7B X`09int`20status; X`09struct`20io_stat_blk`20iosb; X`09 X#ifdef`20DNDEBUG X\4104`09fprintf(stderr,`20"socket_write:`20start`20-`20passed`20chan`20%d`5Cn" V,`20chan); X#endif`20/*\5808`20*\EE0A\9606`20=`20SYS$QIOW`20(0\3A06,`20IO$_WRITEVBLK,`20 V`26iosb,`200,`200,`20\F806, X\ED0D\F80C\2908\0604); X\1808if`20(VMSFAIL(status))`20 X`09`7B X`09`09LIB$SIGNA\1A09; X`09`09return`20-1; X`09`7D X\4714iosb.s\4C19\1F0C\5112#ifdef`20DNDEBUG X`09fprintf(stderr,`20"socket_write:`20wrote`20%d/%d`20to`20channel`20%d`5Cn", V\6A05msg_len,`20l,`20chan); X#endif X`09\7A07\270C; X`7D X X`0C X/* X`20*`20s\6B0Bv X\1103Emulation`20routine`20for`20the`20ugly`20iov`20style`20\3A06`20writing. X`20*/ Xint Xs\520C(`20d,\3404\0505cnt) X`20`20`20\0303`20`20int`20d; X\0F08struct\2604ec`20*iov\1B0A\2A04\3E06; X`7B X\160C\0804totbytes\300E\0804\1717i; X X#ifdef`20DNDEBUG\2305`09fprintf(stderr,`20"s\C90C:`20start`20-`20passed`20chan V`20%d`5Cn",`20d); X#endif`20/*\5608`20*/ X\7C08for(i`20=`200,\B009\0E04;`20i`20<`20\DC07`20i++) X\3208\E90A\0808\3608\970C((short)`20d,`20iov`5Bi`5D.iov_base,`20MIN(MAX_QIO V\1E0Dlen)); X\6010\9909+=\6C06\2312if(b\2305\B505\500C\2B11`7B X#ifdef`20DNDEBUG\2111\0808fprintf(stderr,`20"Block`20occured`20in`20writev, V`20%d/%d`5Cn",bytes, X\5218\AE09\A30E; X#endif\3819socket_errno`20=`20EWOULDBLOCK; X\3418return`20totbytes\2912`7D X\0A0A\3519`7D $ call unpack [.DNET_SOCKET_LIBRARY]DNET_SOCKET_LIBRARY.C;83 - 1998254311 "FORMAT STREAM_LF;CARRIAGE_CONTROL CARRIAGE_RETURN" $! $ create 'f' X/* X`20*`20$NCDId:`20@(#)emulationlib.h,v`204.4`201992/01/31`2011:28:04`20hardison V`20Exp`20$ X\4703\0404Em\3F07`20defines,`20strutures`20and`20macros`20for`20the`20DNET_SOC VKET_LIBRARY X\4703OBH`20-`20NCD\06033/2/92 X`20*/ X#include`20nfbdef X X#ifndef`20_TIME_ X#define\0F09endif`20/*\1006*/ X Xtypedef`20unsigned`20short`20u_short; X\2011long`20u_long; X\6109BCMP(s1,`20s2,`20l)`20(memcmp`20((s1),`20(s2\0604l)))\330BOPY(s,`20d V\320Apy`20((d)\3104\3012ZERO(b,len)`20memset(b,`200\2D04ize_t)(len)\310ADNETAL VLOC(s)`09(dnMalloc((s\560CDNETFREE(a\2405Free((a)\220BENABLE_ASTS`20`20`20`20 V`20(SYS$SETAST(1\280BHIBERNATE`20\2705\2806HIBER()\700BIS\4F0D\4E0C0)\280AWAKE V_UP_DAMMIT`09(SYS$WAKE(0,`200\280BMAX_QIO`20\7507`200xffff X\1F08VMSFAIL(status)`20(0==(1`26(\1007\490BBITSPERBYT\C1078 X\640COPTION\1A064 X\1A0CLINK\CB05\030332\1B09NODNAMSIZ`0916\150AET_RD`20\AE091 X\1A0CWRT`20\1A08\490BET_CM\350A3 X\1A08TEMP_MBX\FC09\980DMSG`20\680928\E90AUF_QUO\1C15EWOULDBLOCK`20\6C055 X\6D09ASKOBJECT`09"TASK="\6E0CDNETNODES`093\860AHOST_NOT_FOUND\EE0DFB_MAX_FIELD V_ID_ENTRIES`201\3E0AAF_DECnet`0912\150CINET\BD09\1A0ADNET_PREFIX`20\1A04"DECNE VT/"\220EIV_MAXLEN`20`208\8F0ACBSIZE\560A56\360AECNET`20`09`09"\8E06\500ACPUTYP VE`20`09"Vax"\1709OPSYS`20`20`20`09"VMS\170AINADDR_ANY\6709\0505(u_long)0x00000 V000\3309FIONBIO`20`09126\1509SOCK_STREAM`20\40041`20\0705\200BL_SOCKET`20 V\19050xffff\200C_REUSEADDR\20060004 X\1F0BUSELOOPBACK\1F0640 X X#ifndef`20MIN\2C09MIN(a,b)`20((a)`20<`20(b)`20?`20\0C04:`20(b)) X#endif`20/*`20MIN`20*/ X\470AAX\470AAX\4714b)`20:`20(a)\470DAX\4705struct`20io_stat_blk X`7B X`20\F106`20short`20int`20status; X\1A08unsigned\2307msg_len;\2009\3404unused; X`7D;\6709astb\6209`09char`20type\5819cha\550B\3005\560Ctypedef`20union X\B80A\7E04astid; X`09s\7A0C\0704; X`7D\0704Param;\9A08\3D0B\6605func\CE0Eterminator\4104nfb`20=`20`7B`20NFB$C_DEC VLNAME,`200`20\EE0Bin_addr`20\5C0Au_long`20s_addr\C406\2C07sockaddr_in`20\300As Vhort`20\0803in_family\950Au_\1E06sin_port\1A0A\5307\8009sin_\7106\E40D\5807zer Vo`5B8`5D;\8E14 X`7B\6F0Ansigned`20\7607a_\9110\5509a_data`5B14`5D\550Dhostent X\540A\3208*h_name;\1912*h_aliases;\1D09in\DC03\0803h_addrtype\1C14length\5317d Vdr_list; X#define\4D07\0707_list`5B0`5D X\A913cput\730D\1C0Bopsy\A90B\730Cprotos\1C0Astruct`20socka\7904\9607esses; X`7D; X X\2208tack\0C06 X`7B\3F0Ahort\0803\8B0Eunsigned\1F07channel\4F06/* X`20*`20TYPES.H`20emulation X`20*/ X#define`20NBBY\48048`20\5208\0606`09/*`20number`20of`20bits`20in`20a`20byte V\400ELW\3004(NBBY*sizeof(long))\4318longword\4705ifndef`20FD_SETSIZE X\5A08\130A`20512 X#endif X\1E08CHANNELS\1F04\800416\B806/*`20Size\7204a`20channel`20*/ X Xtypedef`20long\2904fd_mask;\CA0AFDBITS`20(\C507\2107)`20*`20NBBY)`20\6106 V\6204\CC05per`20mask\C70Chowmany X\5408\1007(x,`20y)\3C03(((x)+((y)-1))/(y)) X\D907\A109struct\A004set`20`7B X\7808\9007\7D05`5Bh\5907FD_SETSIZE,`20\C107)`5D; X`7D`20\3F06; X\8B09\2A06(n,`20p)\4F04((p)->\4D05(n)/CHANNELSIZE/N\4906`5D`20`5C X\7D08\0808\0808`7C=`20(1`20<<\D204\3E0E)`20%N\8907)) X#\7E0ACLR(\7E47`26=`20`7E(1`20<<`20(((n)/CHANNELSIZE)`20%NFDBITS))) X#define`20FD_ISSET(n,`20p)`20`20((!((n)`20%`20C\3B0B)`20`26`26`20((p)->bits +-+-+-+-+-+-+-+- END OF PART 4 +-+-+-+-+-+-+-+-