Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 507 → Rev 508

/svarcom/trunk/cmd.c
166,9 → 166,13
}
 
 
/* explodes a command into an array of arguments where last arg is NULL
/* explodes a command into an array of arguments where last arg is NULL.
* if argvlist is not NULL, it will be filled with pointers that point to buff
* locations. buff is filled with all the arguments, each argument being
* zero-separated. buff is terminated with an empty argument to mark the end
* of arguments.
* returns number of args */
static unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
int si = 0, argc = 0, i = 0;
for (;;) {
/* skip to next non-space character */
176,7 → 180,8
/* end of string? */
if (s[si] == 0) break;
/* set argv ptr */
argvlist[argc++] = buff + i;
if (argvlist) argvlist[argc] = buff + i;
argc++;
/* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
do {
buff[i++] = s[si++];
185,7 → 190,8
/* is this end of string? */
if (s[si] == 0) break;
}
argvlist[argc] = NULL;
buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
if (argvlist) argvlist[argc] = NULL;
return(argc);
}
 
/svarcom/trunk/cmd.h
30,4 → 30,12
/* process internal commands */
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ);
 
/* explodes a command into an array of arguments where last arg is NULL.
* if argvlist is not NULL, it will be filled with pointers that point to buff
* locations. buff is filled with all the arguments, each argument being
* zero-separated. buff is terminated with an empty argument to mark the end
* of arguments.
* returns number of args */
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist);
 
#endif
/svarcom/trunk/command.c
356,7 → 356,7
int lookup;
unsigned short i;
const char *ext;
char *cmd = buff + 256;
char *cmd = buff + 1024;
const char *cmdtail;
char far *rmod_execprog = MK_FP(rmod->rmodseg, RMOD_OFFSET_EXECPROG);
char far *rmod_cmdtail = MK_FP(rmod->rmodseg, 0x81);
416,8 → 416,11
/* copy truename of the bat file to rmod buff */
for (i = 0; cmdfile[i] != 0; i++) rmod->batfile[i] = cmdfile[i];
rmod->batfile[i] = 0;
/* copy args of the bat file to rmod buff */
for (i = 0; cmdtail[i] != 0; i++) rmod->batargs[i] = cmdtail[i];
 
/* explode args of the bat file and store them in rmod buff */
cmd_explode(buff, cmdline, NULL);
_fmemcpy(rmod->batargv, buff, sizeof(rmod->batargv));
 
/* reset the 'next line to execute' counter */
rmod->batnextline = 0;
/* remember the echo flag (in case bat file disables echo) */
661,7 → 664,23
 
/* digit? (bat arg) */
if ((line[1] >= '0') && (line[1] <= '9')) {
/* TODO */
unsigned short argid = line[1] - '0';
unsigned short i;
const char far *argv = rmod->batargv;
 
/* locate the proper arg */
for (i = 0; i != argid; i++) {
/* if string is 0, then end of list reached */
if (*argv == 0) break;
/* jump to next arg */
while (*argv != 0) argv++;
argv++;
}
 
/* copy the arg to result */
for (i = 0; (argv[i] != 0) && (reslen < ressz); i++) {
res[reslen++] = argv[i];
}
line++; /* skip the digit */
continue;
}
/svarcom/trunk/rmodinit.h
39,7 → 39,7
unsigned char flags; /* command line parameters */
unsigned char FFU; /* FOR FUTURE USE */
char batfile[130]; /* truename of batch file being processed */
char batargs[130]; /* arguments of the processed batch files */
char batargv[130]; /* args of the batch call (0-separated) */
unsigned long batnextline; /* offset in file of next bat line to process */
};
 
/svarcom/trunk/todo.txt
7,11 → 7,11
 
=== HIGH PRIORITY ============================================================
 
handling of %1 %2 %3 etc in BAT files
pipes redirections
DIR /A
ctrl+break handler
int 24h handler (abort, retry, fail, ignore)
advanced batch support: CALL, :labels, FOR, GOTO, IF EXIST/ERRORLEVEL, SHIFT
 
 
=== MEDIUM PRIORITY ==========================================================
38,7 → 38,6
dynamic resizing of environment space
CTTY
LOADHIGH/LH
advanced batch support: CALL, :labels, FOR, GOTO, IF EXIST/ERRORLEVEL, SHIFT
 
 
==============================================================================