/* Execute DOS .EXE file with standard handles redirected. Accept redirection arguments of the form: e -r file command : stdout and stderr to file. ( space opt. ) e -r #hnd command : stdout and stderr to handle hnd. ( space req.) e -rhnd file command : handle hnd to file. e -rhnd1 #hnd2 command : handle hnd1 to handle hnd2. Same as above with -a instead of -r will append. Standard handles are: 0 - standard input ( not useful here ) 1 - standard output. 2 - standard error. 3 - standard auxillary ( usually serial port ). 4 - standard printer ( usually parallel port ). Examples: e -r out masm test,,test; -- send all standard output and standard error output to the file 'out'. Note that due to the difference in the way C stream level stdout and stderr are handled, 'out' may contain output in a different order from that seen on the screen. e -r2 errors masm test; -- send all standard error output to the file errors. Standard out still goes to the console. e -r1 out -r2 errs masm test; -- send standard output to file 'out'. -- send standard error to file 'errs'. e -r4 #1 masm test; -- send printer output to console. */ #include #include #include #include #include #include #include #include /* Error return codes */ #define NO_ARGS 1 #define DUP 2 #define EXEC 3 #define OPEN 4 #define BAD_SWITCH 5 /* Known handles */ #define STDOUT 1 #define STDERR 2 #define SWITCHARS "-/" #define DIGITS "0123456789" #define FALSE 0 #define TRUE -1 int Redirect(); /***** ************ ***********************/ main( argc, argv ) int argc; char *argv[]; { int argcount = 1; if ( argc < 2 ) { puts( "Usage is: e [<-r|-a[hnd] filename|hnd>] <.EXE file> " ); exit( NO_ARGS ); } while( strcspn( argv[argcount], SWITCHARS ) == 0 ) argcount += Redirect( argv + argcount ); if ( execvp( argv[argcount], argv + argcount ) == -1 ) { printf( argv[argcount] ); perror( ": Exec Error" ); exit( EXEC ); } } /********* ********* ********** *************/ int Redirect( argv ) char *argv[]; { char * cur = argv[0] + 1; /* Start looking at second char */ int handle1 = -1; /* Handle directed from */ int handle2 = -1; /* Handle directed to */ int append = FALSE; /* Append to output file? */ int numargs = 2; /* Number of command line arguments used */ int index; /* Used for distinguishing cases */ switch ( *cur ) { case 'a' : append = TRUE; case 'r' : cur++; break; default : printf( "Mal-formed switch: '%s'\n", cur - 1 ); exit( BAD_SWITCH ); } index = strspn( cur, DIGITS ); /* Find first non-digit */ if ( cur[ index ] == '\0' && index ) /* If it's end-of-string, and string len > 1, then we're looking at -r# filename */ { if ( !sscanf( cur, "%d" , &handle1 ) ) { printf( "Bad handle in switch expression: '%s'\n", cur ); exit( BAD_SWITCH ); } cur = argv[1]; } else { /* If first char is nul, we're looking at -r filename */ if ( *cur == '\0' ) cur = argv[1]; else numargs = 1; /* Else we're looking at -rfilename */ } if ( *cur == '#' ) /* handle2 is in command string */ { if ( !sscanf( cur + 1, "%d", &handle2 ) ) { printf( "Bad handle in switch expression: '%s'", cur + 1 ); exit( BAD_SWITCH ); } } else /* handle2 must be generated with open() */ if ( (handle2 = open( cur , O_WRONLY | (append ? O_APPEND : O_TRUNC ) | O_CREAT, S_IWRITE )) == -1 ) { printf( cur ); perror( ": Open Error" ); exit( OPEN ); } if ( !(handle1 == -1) ) /* Handle to redirect is specified */ { if ( dup2( handle2, handle1 ) == -1 ) { perror( "Dup2 Error" ); exit( DUP ); } } else { if ( dup2( handle2, STDOUT ) == -1 ) { perror( "Dup2 Error on Standard Out" ); exit( DUP ); } if ( dup2( handle2, STDERR ) == -1 ) { perror( "Dup2 Error on Standard Error" ); exit( DUP ); } } return numargs; } MZ2 Äÿÿw—/±ÖÓ²t*Æ*U‹ì¸èdVÇFþƒ~}(¸PPèpƒÄ¸PèNƒÄë‹FþÑàFPècƒÄFþ¸ŽP‹^þÑã‹vÿ0è3ƒÄ ÀtÖ‹FþÑàFP‹^þÑã‹vÿ0è�ƒÄ@u$‹^þÑã‹vÿ0èÀƒÄ¸‘P譃ĸPèâƒÄ^‹å]ÃU‹ì¸ èÊV‹^‹@‰FþÇFöÿÿÇFôÿÿÇFüÇFú‹ØŠ˜=at=rt‹ÃHP¸žPècƒÄ¸Pè�ƒÄëÇFüÿÿÿFþ¸·PÿvþèσĉFø‹Ø‹vþ€8u9 Àt5�FöP¸ÂPVè�ƒÄ Àuÿvþ¸ÅPèƒÄ¸Pè=ƒÄ‹^‹G‰Fþë ‹^þ€?tíÇFú‹^þ€?#u*�FôP¸ìP‹Ã@Pè@ƒÄ ÀuV‹Fþ@P¸ïPèƒĸë;¸€Pƒ~üt¸ë¸ Pÿvþè@ƒÄ‰Fô@uÿvþè�ƒÄ¸Pè|ƒÄ¸P豃ă~öÿtÿvöÿvôètƒÄ@uM¸"ë7¸Pÿvôè_ƒÄ@u¸-Pè>ƒÄ¸PèsƒÄ¸Pÿvôè;ƒÄ@u¸HPè#include main() { fprintf( stdout, "Hello, standard out\n" ); fprintf( stderr, "Hello, standard error\n" ); fprintf( stdaux, "Hello, standard aux\n" ); fprintf( stdprn, "Hello, standard prn\n" ); } MZ„  Ãÿÿ›Üqe45f|ÎU‹ì3Àè9¸\P¸ºP苃ĸqP¸ÂPè}ƒÄ¸ˆP¸ÊPèoƒÄ¸�P¸ÒPèa‹å]ÃY‹Ü+Ør ;|r‹ãÿáé"¿0‹6+÷�þr¾úŽ×�Ä®ûsé�äþÿ6‰&‚6‰&€‹Æ±ÓàH6£~´0Í!<s*3ÀPº³´ Í!ËDOS 2.0 or later required $÷‰6ŒÃ+Þ÷Û´JÍ!6Œîü¿„¹°+Ï3Àóªèbèèn èn ¹+á¾ö‹üó¤èƒ3íè÷þPèz error 2000: Stack overflow error 2003: Integer divide by 0 error 2002: Floating point not loaded ±º2í»´@Í!¸ÿPèE±#º;ëå±)º^ëÞU‹ìƒìWVÿvè_ƒÄ‹ð�FPÿvÿvèكċøÿvVèõƒÄ‹Ç^_‹å]ÃU‹ìèð èn ät €~uÆFþÅâ¸%Í!‹pã»ÿn‹F´LÍ!U‹ìV‹vÿ@�þºu6öD u0ŠD˜‹ØÑãö‡Ru!ÇD°ŠD˜‹ØÑãÆ‡RÇD‹D‰¸ëh�þÂt�þÒuZöDuTŠD˜‹ØÑãö‡RuE�>¾°tÇD°ŠD˜£„ŠD˜‹ØÑãÆ‡R€dû멸PèØ ƒÄ‰D Àt ŠD˜£„€LëÜ3À^‹å]ÃU‹ìV‹vƒ~u¡¾9Du Vè ƒÄ3Àëhƒ~tb�þºuŠD˜PèX ƒÄ Àt Vèâ ƒÄë0�þÂt�þÒu8VèÍ ƒÄ „$DöDtÿtèA ƒÄ€d÷ë ŠD˜‹ØÑãÆ‡R3À‰‰D^‹å]ÃU‹ìV3ö¹52äü¬2àâû€ôUþ5uˆ&4ë ät º6»¹%´@Í!2À¢5^‹å]ÃU‹ìƒìWV‹6úë¸ P¸ÔPÿ4è6 ƒÄ ÀtƒÆƒ<uäƒ<t9‹<ƒÇ ÇFþŠG˜‰Fú늘=ÿu2À늋^þÿFþˆ‡ÿNúGƒ~úuÞÇ^_‹å]ûz�û€sSÿ[CCëòû¸DÍ!r ö€t€�@Kyìô0Í!£ôÃŽî&‹6,¸5Í!‰âŒä¸%º Í!6‹pã"6ÅrŒÚ3Û6ÿnsé6ý6ÅvŒÚ»6ÿnù3Ûö‡t´>Í!CâòÃU‹ìè, ÿvèBý‹å]ÃU‹ì¸bè¡ûWV‹v�†¢þ£’‹F£Ž‹F£ŠÇ Çž€<uéI€<%té ǘ3À£–£†£š£Œ£�£ˆ£¤£¦Ç” ë2€<-uÿ¦ë'€<+u ÿ–Ljë€< u ƒ>–u ÿˆëÿ¤FŠ˜PèƒÄ Àu¿V¸œP艃ċð€<.uÿ�FV¸˜PèrƒÄ‹ð€À“.ÿ§òÿšÇ¤¸ P臃ÄëP¸ëò¸ëí3ÀPè ëé¸ëõÿ¶žþèëÛ‹þëAà¼åååîîîîîîîÎîîîØî¸îîÓƒ> t¡žë Fé¦þ€=%tG€=uõ‹Ç+ÆPVèƒÄ‹÷éŠþ^_‹å]ÃU‹ì¸èøùWVƒ~ tÿšƒ>Œt‹Ž‹‹W‰Fø‰VúƒŽë)ƒ>št‹Ž‹‰FøÇFúë ‹Ž‹™‰Fø‰VúƒŽƒ>¤t ‹Fø Fút‹Fë3À£¢‹6’ƒ>šu*ƒ~ú}$ƒ~ uÆ-F‹Fø‹Vú÷؃Ò÷Ú‰Fø‰VúÇFöëÇFö‹ýƒïÿvWÿvúÿvøèƒÄƒ>�t W豃ċ˜+ȉNþëÆ0F‹FþÿNþ ÀòŠˆƒ>†tšu¡– ˆt ƒ~öu¸ë3ÀPèUƒÄ^_‹å]ÃU‹ì¸èÊøWVÇ” ƒ~t¾¡ŽƒŽ‰Füë3‹Ž‹‰FüƒŽ ÀuÇFü0ÿvüè ƒÄ‹ðƒ>�t 9˜s‹6˜‹>œ+þƒ>¦uWèƒÄVÿvüèmƒÄƒ>¦tWèöƒÄ^_‹å]ÃU‹ì¸è>ø¡Ž‰Fþƒ>�uǘÿ6†ÿ6˜ÿvÿ6’ÿvþè²ƒÄ ƒ~gtƒ~Guƒ>¤uƒ>˜t ÿ6’莃ă>¤tƒ>˜u ÿ6’èvƒÄƒŽÇ¢¡– ˆtÿvþèYƒÄ Àt¸ë3ÀPè$‹å]ÃU‹ì3ÀèŸ÷Vƒ> u8‹ŠÿOƒ|ŠF‹Š‹7ÿˆ*äë ÿ6ŠÿvèëƒÄ@uÿ ëÿž^‹å]ÃU‹ì¸èQ÷WVƒ> uQ‹v ö~Jë3‹ŠÿOƒ| ”‹Š‹?ÿˆ*äëÿ6Šÿ6”è’ƒÄ@uÿ ‹ÆN Àƃ> u‹Fž^_‹å]ÃU‹ì¸èèöWV‹v‹~ƒ> uLë5‹ŠÿOƒ|ЋЋÿ‹Ùˆ*äëÿ6ŠŠ˜Pè)ƒÄ@uÿ F‹ÇO Àuă> u‹Fž^_‹å]ÃU‹ì¸ è~öWV‹6’3À‰Fü‰Fø‹>œVèæƒÄ‰Fú+ø+~ƒ>¦u€<-uƒ>”0u ¬˜Pè�þƒÄƒ>”0t ÿ~ƒ>¦tƒ~tÿFøè^ƒ>¢tÿFüèpƒ>¦u&Wè±þƒÄƒ~t ƒ~øuè4ƒ>¢t ƒ~üuèCÿvúVèñþƒÄƒ>¦t Ç” WètþƒÄ^_‹å]ÃU‹ì3Àè½õƒ>–t¸+ë¸ Pèþ‹å]ÃU‹ì3Àèžõ¸0PèðýƒÄƒ>¢uƒ>†t¸Xë¸xPèÓýƒÄ‹å]ÃU‹ì¸èjõWV‹v€<*u‹ŽƒŽ‹?Fë:3ÿ€<0|3€<9.9>�u €<0uÇ”0¬˜‹ÏÑáÑáÏÑáȃé0‹ù€<0|€<9~ã‹^‰?‹Æ^_‹å]ÃU‹ì¸èõV¾7ë Š8Fu¸ëF€<uî3À^‹å]Ã�<Žî¾€¬˜3Ò&€>ôrePŽ,3À‹È÷Ñ‹øò®&8uùƒÇ‹È÷Ñ‹÷&ŠGA:àt<"t< t< uëX¾�ë+O+þ ÿtñ‹ÏB[‹ÃÁ%þÿ+à‹üó¤° ª‹Ë¾�ë‹È$þ+à‹ü¸C «ó¤‹Áª‹ôP‹Ü‹þ¬ Àt è=tôNVÿö¬è8ª Àt è)uòÆEÿëÚª‹ôKK;ós­‡‰Dþëò‹Ü Òuÿ‰&øÿ&<< t< Ã<"u¬ ÀtÏ<"u €}ÿ\uOë¬uªëèÃ�>Žî3É‹Á‹é‹ùI‹6, ötŽÆò®E®uúE—@$þ‹ýÑåÅè¯ó‹Ï‹üý‹ìŽÞ3öIã ‰~EE¬ª Àuúâó‰N‰&úÿ&>U‹ìƒìWV‹vŠD˜©ƒtöD@t €L ¸ÿÿéÒöDuð€L€dï3À‰D‹ø‰~þöDuŠD˜‹ØÑãö‡Rt0‹<+| ÿ~WÿtŠD˜P芃ĉFþ‹D@‰ÇDÿ‹\ŠFˆëhöDuL�þºu+ŠD˜PèùƒÄ Àu3ÿ@ÇD°ŠD˜‹ØÑãÆ‡RDZ뺸PèýƒÄ‰D Àt€Lë�€L¿W�FPŠD˜Pè ƒÄ‰Fþ9~þté)ÿŠF*ä^_‹å]û€�û‚sSÿ[CCëòû‚�û„sSÿ[CCëòÃè·óU‹ìƒìWV‹v3ÿVè|ƒÄŠD$<u<öDuŠD˜‹ØÑãö‡Rt'‹+D‰Fü À~PÿtŠD˜P胃Ä;Füt€L ¿ÿÿ‹D‰ÇD‹Ç^_‹å]ÃU‹ì‹^ƒû}ƒû| ö‡@t¸ë3À]ÃU‹ì‹^€Oþ‹å]ÃU‹ìVW»Bƒ?u)¸èÀu3À™ë$@$þ£B£D–ǃÆÇDþþÿ‰6H‹NŒØŽÀèj_^‹å]ÃU‹ìW‹~3À¹ÿÿò®‹Á@@÷Ø_]ÃU‹ìWV‹Nã.‹Ù‹~‹÷3À¹ÿÿò®A÷Ù;Ëv‹Ë‹þ‹vó¦ŠDÿ3É:EÿwtII÷Ñ‹Á^_]ÃU‹ì³é`é˃ùîsøA€áþ‹wü­‹þ¨tBH;Ás‹Ðð­¨t4‹÷‰Dþëæ‹þt ù‰Lþ+ÁH‰ëùþLþ‹ÆŒÚ�ú0t&ŒP‰Ã&ÆT=þÿt%‹þð­¨tò‹þH;Ás½‹Ðð­¨tâ‹÷‰Dþëæ‹G ÀtŽØë&þTtŒØ=0t&ŽL‹7뽋w3ÀèY;Æt $@@˜èMt þMþè t–NNëš3À™ÃQ‹Eþ¨t+ÈIAAºÿ&;RvÑêuõ‹ÁÆrÂr ÷Ò#Â+Æè u÷ÒÑêuå3ÀYÃRQètW‹þ‹ðòÇDþþÿ‰w‹Ö+×J‰UþXYZÃSP3ÒRRP¸Pè~ƒÄƒúÿZ[t ÒÃU‹ì‹^€gÏ]ÃU‹ìƒìWV¾²3ÿëŠD˜©ƒt VèKýƒÄ@tGƒÆ96zsã‹Ç^_‹å]ÃU‹ì‹^ö‡ t¸B3É‹ÑÍ!séáö‡€ué�‹N‹V3ÀüWV‹ð‹úãe¸ @ò®u2Q‹Ï+ÊIãÍ!œð�s´ ëI Àt/F¹ºV´@Í!s´ ë4 Àt Microsoft Macro Assembler 4.00 and Utilities Correction Notice Utility for Redirection December 11, 1985 With pre-4.0 versions of MASM, it is possible to redirect the Assembler's output. For example, MASM example; >errors.dat will send the Assembler's error messages to 'errors.dat', instead of to the console. However, the above command will not redirect error messages with MASM 4.0. MASM 4.0 sends error messages to standard error, one of the MS-DOS standard device handles. It is not possible to redirect output from MASM 4.0 because MS-DOS does not allow redirection of standard error from the console. This disk contains a utility which allows you to run MASM with standard handles redirected. The files on this disk are: WRITE.C WRITE.EXE E.C E.EXE README The following is a description of the files and their purpose: WRITE.EXE Allows you to determine where information for standard output, standard error, standard auxiliary (usually serial port), and standard printer (usually parallel port) will be directed. The source code for the program is WRITE.C. E.EXE Executes a program after redirection of standard handles has taken place. The program accepts arguments of the form: e -r file command stdout and stderr to file e -r #hnd command stdout and stderr to handle hnd e -rhnd file command handle hnd to file e -rhnd1 #hnd2 command handle hnd1 to handle hnd2 To append in addition to redirecting, use -a instead of -r. The standard handles are: 0 - standard input (not useful here) 1 - standard output 2 - standard error 3 - standard auxiliary 4 - standard printer The following are examples of command lines: e -r out.dat masm test,,test; send all standard output and standard error output to the file 'out.dat'. Note that due to the difference in the way C stream level stdout and stderr are handled, 'out.dat' may contain output in a different order from that seen on the screen. e -r #4 masm test,,test; send all standard output and standard error output to the standard printer e -r1 out.dat -r2 errs.dat masm test; -- send standard output to file 'out.dat' -- send standard error to file 'errs.dat' e -r4 #1 masm test; send standard printer data to standard output (console) e -r1 nul -a2 errlog.dat -r4 out.dat masm test; -- throw away standard output -- append standard error to errlog.dat -- send standard printer into out.dat The source code for the program is E.C.