int exec(const char *cmd, char *cmdLine, const unsigned segOfEnv) { #ifdef FEATURE_XMS_SWAP # define buf dosCMDTAIL # define memcpy _fmemcpy #else unsigned char buf[128]; #endif struct fcb fcb1, fcb2; struct ExecBlock execBlock; int retval; assert(cmd); assert(cmdLine); assert(strlen(cmdLine) <= 125); invalidateNLSbuf(); /* generate Pascal string from the command line */ memcpy(&buf[1], cmdLine, buf[0] = strlen(cmdLine)); memcpy(&buf[1] + buf[0], "\xd", 2); /* fill FCBs */ if ((cmdLine = parsfnm(cmdLine, &fcb1, 1)) != 0) parsfnm(cmdLine, &fcb2, 1); saveSession(); #ifdef FEATURE_XMS_SWAP if(XMSisactive() && swapOnExec == TRUE) { /* Copy the prepared values into the buffers in CSWAP.ASM module */ _fmemcpy(dosFCB1, &fcb1, sizeof(fcb1)); _fmemcpy(dosFCB2, &fcb2, sizeof(fcb1)); assert(strlen(cmd) < 128); _fstrcpy(dosCMDNAME, cmd); dosParamDosExec.envSeg = segOfEnv; retval = XMSexec(); } else #endif { /* fill execute structure */ execBlock.segOfEnv = segOfEnv; execBlock.cmdLine = (char far *)buf; execBlock.fcb1 = (struct fcb far *)&fcb1; execBlock.fcb2 = (struct fcb far *)&fcb2; retval = lowLevelExec((char far*)cmd, (struct ExecBlock far*)&execBlock); } restoreSession(); return decode_exec_result(retval); }
int DriveExists(unsigned char drive) { struct fcb fcb; char a[20] = " :foo.oof"; a[0]=drive+64; return (int)(parsfnm(a,&fcb,1)); }