Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 478 → Rev 479

/svarcom/trunk/cmd.c
47,7 → 47,7
unsigned short env_seg; /* segment of environment block */
struct rmod_props far *rmod; /* rmod settings */
unsigned short argoffset; /* offset of cmdline where first argument starts */
const char far *cmdline; /* original cmdline (terminated by a NULL) */
const char *cmdline; /* original cmdline (terminated by a NULL) */
char BUFFER[BUFFER_SIZE]; /* a buffer for whatever is needed */
};
 
131,7 → 131,7
 
/* NULL if cmdline is not matching an internal command, otherwise returns a
* pointer to a CMD_ID struct */
static const struct CMD_ID *cmd_match(const char far *cmdline, unsigned short *argoffset) {
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
unsigned short i;
char buff[10];
 
189,7 → 189,7
}
 
 
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char far *cmdline, char *BUFFER) {
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, char *BUFFER) {
const struct CMD_ID *cmdptr;
unsigned short argoffset;
struct cmd_funcparam *p = (void *)BUFFER;
/svarcom/trunk/cmd.h
28,7 → 28,7
#include "rmodinit.h"
 
/* process internal commands */
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char far *cmdline, char *BUFFER);
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, char *BUFFER);
 
/* explodes a command into an array of arguments where last arg is NULL
* returns number of args */
/svarcom/trunk/command.c
79,6 → 79,7
#include "rmodinit.h"
#include "sayonara.h"
 
#include "rmodcore.h" /* rmod binary inside a BUFFER array */
 
struct config {
unsigned char flags; /* command.com flags, as defined in rmodinit.h */
349,7 → 350,7
}
 
 
static void run_as_external(char *buff, const char far *cmdline, unsigned short envseg, struct rmod_props far *rmod) {
static void run_as_external(char *buff, const char *cmdline, unsigned short envseg, struct rmod_props far *rmod) {
char *cmdfile = buff + 512;
const char far *pathptr;
int lookup;
356,7 → 357,7
unsigned short i;
const char *ext;
char *cmd = buff + 256;
const char far *cmdtail;
const char *cmdtail;
char far *rmod_execprog = MK_FP(rmod->rmodseg, RMOD_OFFSET_EXECPROG);
char far *rmod_cmdtail = MK_FP(rmod->rmodseg, 0x81);
_Packed struct {
524,9 → 525,8
}
 
 
/* fetches a line from batch file and write it to buff, increments
* rmod counter on success. returns 0 on success.
* buff starts with a length byte and is NULL-terminated */
/* fetches a line from batch file and write it to buff (NULL-terminated),
* increments rmod counter and returns 0 on success. */
static int getbatcmd(char *buff, struct rmod_props far *rmod) {
unsigned short i;
unsigned short batname_seg = FP_SEG(rmod->batfile);
535,8 → 535,6
unsigned short filepos_dx = rmod->batnextline & 0xffff;
unsigned char blen = 0;
 
buff++; /* make room for the len byte prefix */
 
/* open file, jump to offset filpos, and read data into buff.
* result in blen (unchanged if EOF or failure). */
_asm {
597,7 → 595,6
}
}
buff[i] = 0;
buff[-1] = i;
rmod->batnextline += i + 1;
 
return(0);
613,12 → 610,12
static struct config cfg;
static unsigned short far *rmod_envseg;
static unsigned short far *lastexitcode;
static unsigned char BUFFER[4096];
static struct rmod_props far *rmod;
static char *cmdline;
 
rmod = rmod_find();
rmod = rmod_find(BUFFER_len);
if (rmod == NULL) {
rmod = rmod_install(cfg.envsiz);
rmod = rmod_install(cfg.envsiz, BUFFER, BUFFER_len);
if (rmod == NULL) {
outputnl("ERROR: rmod_install() failed");
return(1);
651,8 → 648,6
}*/
 
do {
char far *cmdline;
 
if (rmod->flags & FLAG_ECHOFLAG) outputnl(""); /* terminate the previous command with a CR/LF */
 
SKIP_NEWLINE:
660,7 → 655,8
/* cancel any redirections that may have been set up before */
redir_revert();
 
cmdline = rmod->inputbuf + 2;
/* preset cmdline to point at the end of my general-purpose buffer */
cmdline = BUFFER + sizeof(BUFFER) - 130;
 
/* (re)load translation strings if needed */
nls_langreload(BUFFER, *rmod_envseg);
674,9 → 670,7
 
/* if batch file is being executed -> fetch next line */
if (rmod->batfile[0] != 0) {
char *tmpbuff = BUFFER + sizeof(BUFFER) - 256;
if (getbatcmd(tmpbuff, rmod) != 0) { /* end of batch */
redir_revert(); /* cancel redirections (if there were any) */
if (getbatcmd(cmdline, rmod) != 0) { /* end of batch */
/* restore echo flag as it was before running the bat file */
rmod->flags &= ~FLAG_ECHOFLAG;
if (rmod->flags & FLAG_ECHO_BEFORE_BAT) rmod->flags |= FLAG_ECHOFLAG;
684,30 → 678,25
}
/* output prompt and command on screen if echo on and command is not
* inhibiting it with the @ prefix */
if ((rmod->flags & FLAG_ECHOFLAG) && (tmpbuff[1] != '@')) {
if ((rmod->flags & FLAG_ECHOFLAG) && (cmdline[0] != '@')) {
build_and_display_prompt(BUFFER, *rmod_envseg);
outputnl(tmpbuff + 1);
outputnl(cmdline);
}
/* strip the @ prefix if present, it is no longer useful */
if (tmpbuff[1] == '@') {
memmove(tmpbuff + 1, tmpbuff + 2, tmpbuff[0] + 1);
tmpbuff[0] -= 1; /* update the length byte */
}
cmdline = tmpbuff + 1;
/* skip the @ prefix if present, it is no longer useful */
if (cmdline[0] == '@') cmdline++;
} else {
/* interactive mode: display prompt (if echo enabled) and wait for user
* command line */
if (rmod->flags & FLAG_ECHOFLAG) build_and_display_prompt(BUFFER, *rmod_envseg);
/* revert input history terminator to \r so DOS or DOSKEY are not confused */
cmdline[(unsigned short)(cmdline[-1])] = '\r';
/* collect user input */
cmdline_getinput(FP_SEG(rmod->inputbuf), FP_OFF(rmod->inputbuf));
/* replace \r by a zero terminator */
cmdline[(unsigned char)(cmdline[-1])] = 0;
/* copy it to local cmdline */
if (rmod->inputbuf[1] != 0) _fmemcpy(cmdline, rmod->inputbuf + 2, rmod->inputbuf[1]);
cmdline[(unsigned)(rmod->inputbuf[1])] = 0; /* zero-terminate local buff (oriignal is '\r'-terminated) */
}
 
/* if nothing entered, loop again (but without appending an extra CR/LF) */
if (cmdline[-1] == 0) goto SKIP_NEWLINE;
if (cmdline[0] == 0) goto SKIP_NEWLINE;
 
/* I jump here when I need to exec an initial command (/C or /K) */
EXEC_CMDLINE:
/svarcom/trunk/makefile
30,7 → 30,7
wcc $(CFLAGS) $<
 
rmodcore.h: file2c.com rmod.com
file2c rmod.com rmodcore.h rmodcore
file2c /s /l4096 rmod.com rmodcore.h BUFFER
 
deflang.h: file2c.com tlumacz\default.lng
file2c /l4096 tlumacz\default.lng deflang.h langblock
/svarcom/trunk/redir.c
32,7 → 32,7
/* parse commandline and performs necessary redirections. cmdline is
* modified so all redirections are cut out.
* returns 0 on success, non-zero otherwise */
int redir_parsecmd(char far *cmdline, char *BUFFER) {
int redir_parsecmd(char *cmdline, char *BUFFER) {
unsigned short i;
unsigned short rediroffset_stdin = 0;
unsigned short rediroffset_stdout = 0;
82,7 → 82,7
unsigned short openflag = 0x12; /* used during the int 21h,ah=6c call */
unsigned short errcode = 0;
unsigned short handle = 0;
char far *ptr;
char *ptr;
/* append? */
if (cmdline[rediroffset_stdout] == '>') {
openflag = 0x11;
/svarcom/trunk/redir.h
28,7 → 28,7
/* parse commandline and performs necessary redirections. cmdline is
* modified so all redirections are cut out.
* returns 0 on success, non-zero otherwise */
int redir_parsecmd(char far *cmdline, char *BUFFER);
int redir_parsecmd(char *cmdline, char *BUFFER);
 
/* restores previous stdout/stdin handlers if they have been redirected */
void redir_revert(void);
/svarcom/trunk/rmodcore.h
1,4 → 1,4
char rmodcore[] = {
static char BUFFER[4096] = {
131, 25,133, 25, 23, 32, 25, 32, 0, 0, 0, 0, 0, 0, 64, 58,
92, 67, 79, 77, 77, 65, 78, 68, 46, 67, 79, 77, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25,4 → 25,4
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 rmodcore_len 403
#define BUFFER_len 403
/svarcom/trunk/rmodinit.c
28,13 → 28,11
#include "env.h"
#include "helpers.h"
 
#include "rmodcore.h"
 
#include "rmodinit.h"
 
 
/* returns far pointer to rmod's settings block on success */
struct rmod_props far *rmod_install(unsigned short envsize) {
struct rmod_props far *rmod_install(unsigned short envsize, unsigned char *rmodcore, unsigned short rmodcore_len) {
char far *myptr, far *mcb;
unsigned short far *owner;
const unsigned short sizeof_rmodandprops_paras = (0x100 + rmodcore_len + sizeof(struct rmod_props) + 15) / 16;
184,7 → 182,7
 
/* look up my parent: if it's rmod then return a ptr to its props struct,
* otherwise return NULL */
struct rmod_props far *rmod_find(void) {
struct rmod_props far *rmod_find(unsigned short rmodcore_len) {
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};
/svarcom/trunk/rmodinit.h
50,8 → 50,8
#define RMOD_OFFSET_EXECPROG 0x12B
#define RMOD_OFFSET_ROUTINE 0x1AB
 
struct rmod_props far *rmod_install(unsigned short envsize);
struct rmod_props far *rmod_find(void);
struct rmod_props far *rmod_install(unsigned short envsize, unsigned char *rmodcore, unsigned short rmodcore_len);
struct rmod_props far *rmod_find(unsigned short rmodcore_len);
void rmod_updatecomspecptr(unsigned short rmod_seg, unsigned short env_seg);
 
#endif
/svarcom/trunk/todo.txt
9,7 → 9,6
 
pipes redirections
autoexec.bat processing (with F5 skipping)
make cmdline a near pointer for better performance (maybe a separate buffer)
 
 
=== AT SOME LATER TIME =======================================================