/svarcom/trunk/command.c |
---|
400,8 → 400,6 |
} |
RUNCMDFILE: |
/* TODO run command through INT 0x21 */ |
/* TODO copy environment and append full exec path */ |
/* TODO special handling of batch files */ |
if ((ext != NULL) && (imatch(ext, "bat"))) { |
outputnl("batch processing not supported yet"); |
516,14 → 514,11 |
int main(void) { |
static struct config cfg; |
static unsigned short rmod_seg; |
static unsigned short far *rmod_envseg; |
static unsigned short far *lastexitcode; |
static unsigned char BUFFER[4096]; |
static struct rmod_props far *rmod; |
parse_argv(&cfg); |
rmod = rmod_find(); |
if (rmod == NULL) { |
rmod = rmod_install(cfg.envsiz); |
531,16 → 526,24 |
outputnl("ERROR: rmod_install() failed"); |
return(1); |
} |
/* look at command line parameters */ |
parse_argv(&cfg); |
/* copy flags to rmod's storage */ |
rmod->flags = cfg.flags; |
/* printf("rmod installed at seg 0x%04X\r\n", rmod_seg); */ |
/* printf("rmod installed at %Fp\r\n", rmod); */ |
} else { |
/* printf("rmod found at seg 0x%04x\r\n", rmod_seg); */ |
/* printf("rmod found at %Fp\r\n", rmod); */ |
/* if I was spawned by rmod and FLAG_EXEC_AND_QUIT is set, then I should |
* die asap, because the command has been executed already, so I no longer |
* have a purpose in life */ |
if (rmod->flags & FLAG_EXEC_AND_QUIT) { |
printf("rmod + FLAG_EXEC_AND_QUIT\r\n"); |
sayonara(rmod); |
} |
} |
rmod_seg = rmod->rmodseg; |
rmod_envseg = MK_FP(rmod_seg, RMOD_OFFSET_ENVSEG); |
lastexitcode = MK_FP(rmod_seg, RMOD_OFFSET_LEXITCODE); |
rmod_envseg = MK_FP(rmod->rmodseg, RMOD_OFFSET_ENVSEG); |
lastexitcode = MK_FP(rmod->rmodseg, RMOD_OFFSET_LEXITCODE); |
/* make COMPSEC point to myself */ |
set_comspec_to_self(*rmod_envseg); |
550,7 → 553,7 |
unsigned short far *sizptr = MK_FP(*rmod_envseg - 1, 3); |
envsiz = *sizptr; |
envsiz *= 16; |
printf("rmod_inpbuff at %04X:%04X, env_seg at %04X:0000 (env_size = %u bytes)\r\n", rmod_seg, RMOD_OFFSET_INPBUFF, *rmod_envseg, envsiz); |
printf("rmod_inpbuff at %04X:%04X, env_seg at %04X:0000 (env_size = %u bytes)\r\n", rmod->rmodseg, RMOD_OFFSET_INPBUFF, *rmod_envseg, envsiz); |
}*/ |
do { |
606,7 → 609,7 |
while (*cmdline == ' ') cmdline++; |
/* update rmod's ptr to COMPSPEC so it is always up to date */ |
rmod_updatecomspecptr(rmod_seg, *rmod_envseg); |
rmod_updatecomspecptr(rmod->rmodseg, *rmod_envseg); |
/* handle redirections (if any) */ |
if (redir_parsecmd(cmdline, BUFFER) != 0) { |
627,8 → 630,8 |
/* revert stdout (in case it was redirected) */ |
redir_revert(); |
/* execvp() replaces the current process by the new one |
if I am still alive then external command failed to execute */ |
/* run_as_external() does not return on success, if I am still alive then |
* external command failed to execute */ |
outputnl("Bad command or file name"); |
} while ((rmod->flags & FLAG_EXEC_AND_QUIT) == 0); |
/svarcom/trunk/rmod.asm |
---|
69,7 → 69,7 |
mov dx, EXECPROG ; DS:DX - ASCIZ program name (preset at PSP[already) |
mov bx, EXEC_PARAM_REC ; ES:BX - parameter block pointer |
int 0x21 |
mov [EXECPROG], byte 0 ; make sure to spawn command.com after app exits |
mov [cs:EXECPROG], byte 0 ; do not run app again (+DS might have been changed) |
jmp short skipsig ; enforce valid ds/ss/etc (can be lost after int 21,4b) |
102,8 → 102,7 |
; prepare the exec param block |
mov ax, [PSP_ENVSEG] |
mov [EXEC_PARAM_REC], ax |
mov ax, CMDTAIL |
mov [EXEC_PARAM_REC+2], ax |
mov [EXEC_PARAM_REC+2], word CMDTAIL |
mov [EXEC_PARAM_REC+4], cs |
; execute command.com |
140,8 → 139,10 |
jmp skipsig |
; command.com tail arguments, in PSP format: length byte followed by args and |
; terminated with \r) |
CMDTAIL db 0x00, 0x0D |
; terminated with \r) - a single 0x0A byte is passed so SvarCOM knows it is |
; called as respawn (as opposed to being invoked as a normal application) |
; this allows multiple copies of SvarCOM to stack upon each other. |
CMDTAIL db 0x01, 0x0A, 0x0D |
ERRLOAD db "ERR x, FAILED TO LOAD COMMAND.COM", 13, 10, '$' |
/svarcom/trunk/rmod.h |
---|
10,19 → 10,19 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,140,200,142,216,142, |
192,142,208,188,143, 2,128, 14, 43, 1, 0,116, 18,184, 0, 75, |
186, 43, 1,187, 29, 1,205, 33,198, 6, 43, 1, 0,235,220,180, |
77,205, 33, 48,228,163, 10, 1,176, 0,185, 14, 0,191, 29, 1, |
252,243,170,186, 14, 1,131, 14, 12, 1, 0,116, 8,142, 6, 44, |
0,139, 22, 12, 1,161, 44, 0,163, 29, 1,184, 41, 2,163, 31, |
1,140, 14, 33, 1,184, 0, 75, 6, 31, 14, 7,187, 29, 1,205, |
33,115,152,140,203,142,219, 4, 48,162, 47, 2,180, 9,186, 43, |
2,205, 33,180, 8,205, 33,235,130, 0, 13, 69, 82, 82, 32,120, |
44, 32, 70, 65, 73, 76, 69, 68, 32, 84, 79, 32, 76, 79, 65, 68, |
32, 67, 79, 77, 77, 65, 78, 68, 46, 67, 79, 77, 13, 10, 36, 48, |
49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, |
49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, |
49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 48, |
49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70,120, |
120}; |
#define rmod_len 401 |
192,142,208,188,145, 2,128, 14, 43, 1, 0,116, 19,184, 0, 75, |
186, 43, 1,187, 29, 1,205, 33, 46,198, 6, 43, 1, 0,235,219, |
180, 77,205, 33, 48,228,163, 10, 1,176, 0,185, 14, 0,191, 29, |
1,252,243,170,186, 14, 1,131, 14, 12, 1, 0,116, 8,142, 6, |
44, 0,139, 22, 12, 1,161, 44, 0,163, 29, 1,199, 6, 31, 1, |
42, 2,140, 14, 33, 1,184, 0, 75, 6, 31, 14, 7,187, 29, 1, |
205, 33,115,151,140,203,142,219, 4, 48,162, 49, 2,180, 9,186, |
45, 2,205, 33,180, 8,205, 33,235,129, 1, 10, 13, 69, 82, 82, |
32,120, 44, 32, 70, 65, 73, 76, 69, 68, 32, 84, 79, 32, 76, 79, |
65, 68, 32, 67, 79, 77, 77, 65, 78, 68, 46, 67, 79, 77, 13, 10, |
36, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, |
70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, |
70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, |
70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, |
70,120,120}; |
#define rmod_len 403 |
/svarcom/trunk/rmodinit.c |
---|
40,7 → 40,7 |
const unsigned short sizeof_rmodandprops_paras = (0x100 + rmod_len + sizeof(struct rmod_props) + 15) / 16; |
unsigned short rmodseg = 0xffff; |
unsigned short envseg, origenvseg; |
struct rmod_props far *res = NULL; |
struct rmod_props far *res; |
/* read my current env segment from PSP and save it */ |
envseg = *((unsigned short *)0x2c); |
189,11 → 189,17 |
unsigned short *parent = (void *)0x0C; /* parent's seg in PSP[Ch] ("prev. int22 handler") */ |
unsigned short far *ptr; |
const unsigned short sig[] = {0x1983, 0x1985, 0x2017, 0x2019}; |
unsigned char *cmdtail = (void *)0x80; |
unsigned char i; |
/* is it rmod? */ |
ptr = MK_FP(*parent, 0x100); |
for (i = 0; i < 4; i++) if (ptr[i] != sig[i]) return(NULL); |
/* match successfull (rmod is my parent) */ |
/* match successfull (rmod is my parent) - but is it really a respawn? |
* command-line tail should contain a single character '\r' */ |
if ((cmdtail[0] != 1) || (cmdtail[1] != '\n')) return(NULL); |
cmdtail[0] = 0; |
cmdtail[1] = '\r'; |
/* */ |
return(MK_FP(*parent, 0x100 + rmod_len)); |
} |