/svarcom/trunk/cmd/_notimpl.c |
---|
26,7 → 26,7 |
* handler for all "not implemented yet" commands |
*/ |
static int cmd_notimpl(struct cmd_funcparam *p) { |
static enum cmd_result cmd_notimpl(struct cmd_funcparam *p) { |
outputnl("This command is not implemented yet. Sorry!"); |
return(-1); |
return(CMD_FAIL); |
} |
/svarcom/trunk/cmd/break.c |
---|
26,7 → 26,7 |
* break |
*/ |
static int cmd_break(struct cmd_funcparam *p) { |
static enum cmd_result cmd_break(struct cmd_funcparam *p) { |
unsigned char brkflag = 0; |
if (cmd_ishlp(p)) { |
35,7 → 35,7 |
outputnl("BREAK [ON | OFF]"); |
outputnl(""); |
outputnl("Type BREAK without a parameter to display the current BREAK setting."); |
return(-1); |
return(CMD_OK); |
} |
/* no params: display current break state */ |
56,13 → 56,13 |
} else { |
outputnl("BREAK is on"); |
} |
return(-1); |
return(CMD_OK); |
} |
/* too many params? */ |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
/* exactly 1 parameter - "on" or "off" */ |
70,7 → 70,7 |
brkflag = 1; |
} else if (!imatch(p->argv[0], "off")) { |
outputnl("Invalid parameter"); |
return(-1); |
return(CMD_FAIL); |
} |
/* set break accordingly to brkflag */ |
86,5 → 86,5 |
pop ax |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/cd.c |
---|
35,7 → 35,7 |
*/ |
static int cmd_cd(struct cmd_funcparam *p) { |
static enum cmd_result cmd_cd(struct cmd_funcparam *p) { |
char *buffptr = p->BUFFER; |
/* CD /? */ |
51,13 → 51,13 |
outputnl(""); |
outputnl("Type CD drive: to display the current directory in the specified drive."); |
outputnl("Type CD without parameters to display the current drive and directory."); |
return(-1); |
return(CMD_OK); |
} |
/* one argument max */ |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
/* no argument? display current drive and dir ("CWD") */ |
64,7 → 64,7 |
if (p->argc == 0) { |
curpathfordrv(buffptr, 0); |
outputnl(buffptr); |
return(-1); |
return(CMD_OK); |
} |
/* argument can be either a drive (D:) or a path */ |
98,8 → 98,9 |
} |
if (err != 0) { |
outputnl(doserr(err)); |
return(CMD_FAIL); |
} |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/chcp.c |
---|
26,7 → 26,7 |
* chcp |
*/ |
static int cmd_chcp(struct cmd_funcparam *p) { |
static enum cmd_result cmd_chcp(struct cmd_funcparam *p) { |
unsigned short nnn = 0; |
unsigned short errcode = 0; |
38,13 → 38,13 |
outputnl("nnn Specifies a code page number"); |
outputnl(""); |
outputnl("Type CHCP without a parameter to display the active code page number."); |
return(-1); |
return(CMD_OK); |
} |
/* too many parameters */ |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
/* one param? must be numeric in range 1+ */ |
52,7 → 52,7 |
unsigned char nlsfuncflag = 0; |
if (atous(&nnn, p->argv[0]) != 0) { |
outputnl("Invalid code page number"); |
return(-1); |
return(CMD_FAIL); |
} |
_asm { |
/* verify that NLSFUNC is installed */ |
81,6 → 81,7 |
outputnl("NLSFUNC not installed"); |
} else if (errcode != 0) { |
outputnl("Failed to change code page"); |
return(CMD_FAIL); |
} |
} else { /* no parameter given: display active code page */ |
106,8 → 107,9 |
outputnl(p->BUFFER); |
} else { |
outputnl(doserr(errcode)); |
return(CMD_FAIL); |
} |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/cls.c |
---|
26,7 → 26,7 |
* cls |
*/ |
static int cmd_cls(struct cmd_funcparam *p) { |
static enum cmd_result cmd_cls(struct cmd_funcparam *p) { |
unsigned char screenw, screenh; |
const char *ansiesc = "\x1B[2J$"; |
34,7 → 34,7 |
outputnl("Clears the screen"); |
outputnl(""); |
outputnl("CLS"); |
return(-1); |
return(CMD_OK); |
} |
screenw = screen_getwidth(); |
83,5 → 83,5 |
DONE: |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/copy.c |
---|
161,7 → 161,7 |
} |
static int cmd_copy(struct cmd_funcparam *p) { |
static enum cmd_result cmd_copy(struct cmd_funcparam *p) { |
struct copy_setup *setup = (void *)(p->BUFFER); |
unsigned short i; |
unsigned short copiedcount_in = 0, copiedcount_out = 0; /* number of input/output copied files */ |
182,7 → 182,7 |
outputnl("for source (using wildcards or file1+file2+file3 format)."); |
outputnl(""); |
outputnl("NOTE: /A and /B are no-ops (ignored), provided only for compatibility reasons."); |
return(-1); |
return(CMD_OK); |
} |
/* parse cmdline and fill the setup struct accordingly */ |
207,7 → 207,7 |
setup->verifyflag = 1; |
} else { |
outputnl("Invalid switch"); |
return(-1); |
return(CMD_FAIL); |
} |
continue; |
} |
217,7 → 217,7 |
/* a plus cannot appear after destination or before first source */ |
if ((setup->dst[0] != 0) || (setup->src_count == 0)) { |
outputnl("Invalid syntax"); |
return(-1); |
return(CMD_FAIL); |
} |
setup->lastitemwasplus = 1; |
/* a plus may be immediately followed by a filename - if so, emulate |
241,11 → 241,11 |
/* must be a dst then */ |
if (setup->dst[0] != 0) { |
outputnl("Invalid syntax"); |
return(-1); |
return(CMD_FAIL); |
} |
if (file_truename(p->argv[i], setup->dst) != 0) { |
outputnl("Invalid destination"); |
return(-1); |
return(CMD_FAIL); |
} |
setup->dst_asciimode = setup->last_asciimode; |
/* if dst is a directory then append a backslash */ |
267,7 → 267,7 |
/* must have at least one source */ |
if (setup->src_count == 0) { |
outputnl("Required parameter missing"); |
return(-1); |
return(CMD_FAIL); |
} |
/* perform the operation based on setup directives: |
348,7 → 348,7 |
t = cmd_copy_internal(setup->dst, 0, setup->cursrc, 0, appendflag, setup->databuf, setup->databufsz); |
if (t != 0) { |
outputnl(doserr(t)); |
return(-1); |
return(CMD_FAIL); |
} |
copiedcount_in++; |
359,5 → 359,5 |
sprintf(setup->databuf, "%u file(s) copied", copiedcount_out); |
outputnl(setup->databuf); |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/date.c |
---|
130,7 → 130,7 |
} |
static int cmd_date(struct cmd_funcparam *p) { |
static enum cmd_result cmd_date(struct cmd_funcparam *p) { |
struct nls_patterns *nls = (void *)(p->BUFFER); |
char *buff = p->BUFFER + sizeof(*nls); |
unsigned short i; |
144,13 → 144,13 |
outputnl(""); |
outputnl("Type DATE with no parameters to display the current date and a prompt for a"); |
outputnl("new one. Press ENTER to keep the same date."); |
return(-1); |
return(CMD_OK); |
} |
i = nls_getpatterns(nls); |
if (i != 0) { |
outputnl(doserr(i)); |
return(-1); |
return(CMD_FAIL); |
} |
/* display current date if no args */ |
222,5 → 222,5 |
outputnl("Invalid date"); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/del.c |
---|
26,7 → 26,7 |
* del/erase |
*/ |
static int cmd_del(struct cmd_funcparam *p) { |
static enum cmd_result cmd_del(struct cmd_funcparam *p) { |
const char *delspec = NULL; |
unsigned short err = 0; |
unsigned short confirmflag = 0; |
45,12 → 45,12 |
outputnl(""); |
outputnl("[drive:][path]filename Specifies the file(s) to delete."); |
outputnl("/P Prompts for confirmation before deleting each file."); |
return(-1); |
return(CMD_OK); |
} |
if (p->argc == 0) { |
outputnl("Required parameter missing"); |
return(-1); |
return(CMD_FAIL); |
} |
/* scan argv for delspec and possible /p or /v */ |
63,11 → 63,11 |
output("Invalid switch:"); |
output(" "); |
outputnl(p->argv[i]); |
return(-1); |
return(CMD_FAIL); |
} |
} else if (delspec != NULL) { /* otherwise its a delspec */ |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} else { |
delspec = p->argv[i]; |
} |
87,7 → 87,7 |
* confirmation set, ask for a global confirmation */ |
if ((confirmflag == 0) && (imatch(buff + pathlimit, "????????.???"))) { |
outputnl("All files in directory will be deleted!"); |
if (askchoice("Are you sure (Y/N)?", "YN") != 0) return(-1); |
if (askchoice("Are you sure (Y/N)?", "YN") != 0) return(CMD_FAIL); |
} |
for (i = 0;; i = 1) { |
138,5 → 138,6 |
} |
} |
return(-1); |
if (err == 0) return(CMD_OK); |
return(CMD_FAIL); |
} |
/svarcom/trunk/cmd/dir.c |
---|
108,7 → 108,7 |
} |
static int cmd_dir(struct cmd_funcparam *p) { |
static enum cmd_result cmd_dir(struct cmd_funcparam *p) { |
const char *filespecptr = NULL; |
struct DTA *dta = (void *)0x80; /* set DTA to its default location at 80h in PSP */ |
unsigned short i; |
150,7 → 150,7 |
outputnl("/S Displays files in specified directory and all subdirectories"); |
outputnl("/B Uses bare format (no heading information or summary)"); |
outputnl("/L Uses lowercases"); |
return(-1); |
return(CMD_OK); |
} |
i = nls_getpatterns(nls); |
170,7 → 170,7 |
case 'A': |
/* TODO */ |
outputnl("/A NOT IMPLEMENTED YET"); |
return(-1); |
return(CMD_FAIL); |
break; |
case 'b': |
case 'B': |
184,7 → 184,7 |
case 'O': |
/* TODO */ |
outputnl("/O NOT IMPLEMENTED YET"); |
return(-1); |
return(CMD_FAIL); |
break; |
case 'p': |
case 'P': |
195,7 → 195,7 |
case 'S': |
/* TODO */ |
outputnl("/S NOT IMPLEMENTED YET"); |
return(-1); |
return(CMD_FAIL); |
break; |
case 'w': |
case 'W': |
203,12 → 203,12 |
break; |
default: |
outputnl("Invalid switch"); |
return(-1); |
return(CMD_FAIL); |
} |
} else { /* filespec */ |
if (filespecptr != NULL) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
filespecptr = p->argv[i]; |
} |
231,7 → 231,7 |
} |
if (i != 0) { |
outputnl(doserr(i)); |
return(-1); |
return(CMD_FAIL); |
} |
if (format != DIR_OUTPUT_BARE) { |
259,7 → 259,7 |
i = findfirst(dta, p->BUFFER, DOS_ATTR_RO | DOS_ATTR_HID | DOS_ATTR_SYS | DOS_ATTR_DIR | DOS_ATTR_ARC); |
if (i != 0) { |
outputnl(doserr(i)); |
return(-1); |
return(CMD_FAIL); |
} |
wcolcount = 0; /* may be used for columns counting with wide mode */ |
362,5 → 362,5 |
if (flags & DIR_FLAG_PAUSE) dir_pagination(&availrows); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/echo.c |
---|
26,7 → 26,7 |
* echo |
*/ |
static int cmd_echo(struct cmd_funcparam *p) { |
static enum cmd_result cmd_echo(struct cmd_funcparam *p) { |
unsigned short offs = FP_OFF(p->cmdline) + 5; |
unsigned short segm = FP_SEG(p->cmdline); |
38,7 → 38,7 |
outputnl("ECHO [message]"); |
outputnl(""); |
outputnl("Type ECHO without parameters to display the current echo setting."); |
return(-1); |
return(CMD_OK); |
} |
/* ECHO without any parameter: display current state */ |
48,19 → 48,19 |
} else { |
outputnl("ECHO is off"); |
} |
return(-1); |
return(CMD_OK); |
} |
/* ECHO ON */ |
if ((p->argc == 1) && (imatch(p->argv[0], "on"))) { |
p->rmod->flags |= FLAG_ECHOFLAG; |
return(-1); |
return(CMD_OK); |
} |
/* ECHO OFF */ |
if ((p->argc == 1) && (imatch(p->argv[0], "off"))) { |
p->rmod->flags &= ~FLAG_ECHOFLAG; |
return(-1); |
return(CMD_OK); |
} |
/* ECHO MSG (start at cmdline+5 since first 5 are "ECHO" + separator) */ |
95,5 → 95,5 |
pop ax |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/exit.c |
---|
29,7 → 29,7 |
* |
*/ |
static int cmd_exit(struct cmd_funcparam *p) { |
static enum cmd_result cmd_exit(struct cmd_funcparam *p) { |
if (cmd_ishlp(p)) { |
outputnl("EXIT\r\n"); |
outputnl("Quits the COMMAND.COM program (command interpreter)"); |
36,5 → 36,5 |
} else { |
sayonara(p->rmod); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/if.c |
---|
37,7 → 37,7 |
#define JMP_NEXT_ARG(s) while ((*s != ' ') && (*s != 0)) s++; while (*s == ' ') s++; |
static int cmd_if(struct cmd_funcparam *p) { |
static enum cmd_result cmd_if(struct cmd_funcparam *p) { |
unsigned char negflag = 0; |
unsigned short i; |
const char *s = p->cmdline + p->argoffset; |
56,7 → 56,7 |
outputnl("string1==string2 condition: both strings must be equal"); |
outputnl("EXIST filename condition: filename exists"); |
outputnl("command command to carry out if condition is met."); |
return(-1); |
return(CMD_OK); |
} |
/* negation? */ |
80,11 → 80,11 |
if (*s == 0) goto SYNTAX_ERR; |
/* is errorlevel matching? */ |
if (i <= *rmod_exitcode) negflag ^= 1; |
if (negflag) { |
output("EXEC (TO BE IMPLEMENTED): "); |
outputnl(s); |
if (negflag) { /* let's exec command (write it to start of cmdline and exec again) */ |
memmove((void *)(p->cmdline), s, strlen(s) + 1); /* cmdline and s share the same memory! */ |
return(CMD_CHANGED); |
} |
return(-1); |
return(CMD_OK); |
} |
/* TODO IF EXISTS fname */ |
95,5 → 95,5 |
/* invalid syntax */ |
outputnl("Syntax error"); |
return(-1); |
return(CMD_FAIL); |
} |
/svarcom/trunk/cmd/mkdir.c |
---|
26,7 → 26,7 |
* mkdir |
*/ |
static int cmd_mkdir(struct cmd_funcparam *p) { |
static enum cmd_result cmd_mkdir(struct cmd_funcparam *p) { |
const char *dname = p->argv[0]; |
unsigned short err = 0; |
35,22 → 35,22 |
outputnl(""); |
outputnl("MKDIR [drive:]path"); |
outputnl("MD [drive:]path"); |
return(-1); |
return(CMD_OK); |
} |
if (p->argc == 0) { |
outputnl("Required parameter missing"); |
return(-1); |
return(CMD_FAIL); |
} |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
if (p->argv[0][0] == '/') { |
outputnl("Invalid parameter"); |
return(-1); |
return(CMD_FAIL); |
} |
_asm { |
68,7 → 68,10 |
pop ax |
} |
if (err != 0) outputnl(doserr(err)); |
if (err != 0) { |
outputnl(doserr(err)); |
return(CMD_FAIL); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/path.c |
---|
28,7 → 28,7 |
* Displays or sets a search path for executable files. |
*/ |
static int cmd_path(struct cmd_funcparam *p) { |
static enum cmd_result cmd_path(struct cmd_funcparam *p) { |
char *buff = p->BUFFER; |
/* help screen (/?) */ |
42,7 → 42,7 |
"only in the current directory.\r\n" |
"\r\n" |
"Type PATH without parameters to display the current path.\r\n"); |
return(-1); |
return(CMD_OK); |
} |
/* no parameter - display current path */ |
58,13 → 58,13 |
} |
outputnl(buff); |
} |
return(-1); |
return(CMD_FAIL); |
} |
/* more than 1 parameter */ |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
/* IF HERE: THERE IS EXACTLY 1 ARGUMENT (argc == 1) */ |
72,7 → 72,7 |
/* reset the PATH string (PATH ;) */ |
if (imatch(p->argv[0], ";")) { |
env_dropvar(p->env_seg, "PATH"); |
return(-1); |
return(CMD_OK); |
} |
/* otherwise set PATH to whatever is passed on command-line */ |
86,5 → 86,5 |
env_setvar(p->env_seg, buff); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/pause.c |
---|
27,13 → 27,12 |
*/ |
static int cmd_pause(struct cmd_funcparam *p) { |
static enum cmd_result cmd_pause(struct cmd_funcparam *p) { |
if (cmd_ishlp(p)) { |
nls_outputnl(15, 0); |
outputnl("\r\nPAUSE"); |
return(-1); |
} else { |
press_any_key(); |
} |
press_any_key(); |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/prompt.c |
---|
29,19 → 29,19 |
* |
*/ |
static int cmd_prompt(struct cmd_funcparam *p) { |
static enum cmd_result cmd_prompt(struct cmd_funcparam *p) { |
if (cmd_ishlp(p)) { |
outputnl("Changes the DOS command prompt."); |
outputnl(""); |
outputnl("PROMPT [new command prompt specification]"); |
return(-1); |
return(CMD_OK); |
} |
/* no parameter - restore default prompt path */ |
if (p->argc == 0) { |
env_dropvar(p->env_seg, "PROMPT"); |
return(-1); |
return(CMD_OK); |
} |
/* otherwise set PROMPT to whatever is passed on command-line */ |
56,5 → 56,5 |
env_setvar(p->env_seg, buff); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/rem.c |
---|
26,7 → 26,7 |
* rem |
*/ |
static int cmd_rem(struct cmd_funcparam *p) { |
static enum cmd_result cmd_rem(struct cmd_funcparam *p) { |
/* help screen ONLY if /? is the only argument - I do not want to output |
* help for ex. for "REM mouse.com /?" */ |
if ((p->argc == 1) && (imatch(p->argv[0], "/?"))) { |
34,5 → 34,5 |
outputnl(""); |
outputnl("REM [comment]"); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/rename.c |
---|
26,7 → 26,7 |
* rename/ren |
*/ |
static int cmd_rename(struct cmd_funcparam *p) { |
static enum cmd_result cmd_rename(struct cmd_funcparam *p) { |
char *src = p->BUFFER; |
char *dst = p->BUFFER + 256; |
char *buff1 = p->BUFFER + 512; |
42,13 → 42,13 |
outputnl(""); |
outputnl("Note that you cannot specify a new drive or path for your destination file."); |
outputnl("Use MOVE to rename a directory, or to move files from one directory to another."); |
return(-1); |
return(CMD_OK); |
} |
/* I expect exactly two arguments */ |
if (p->argc != 2) { |
outputnl("Invalid syntax"); |
return(-1); |
return(CMD_FAIL); |
} |
/* convert src to truename format */ |
55,7 → 55,7 |
i = file_truename(p->argv[0], src); |
if (i != 0) { |
outputnl(doserr(i)); |
return(-1); |
return(CMD_FAIL); |
} |
/* copy src path to buffers and remember where the filename starts */ |
74,7 → 74,7 |
case '\\': |
case '/': |
outputnl("Invalid destination"); |
return(-1); |
return(CMD_FAIL); |
} |
buff1[fnameoffset + i] = p->argv[1][i]; |
if (buff1[fnameoffset + i] == 0) break; |
84,7 → 84,7 |
i = file_truename(buff1, dst); |
if (i != 0) { |
outputnl(doserr(i)); |
return(-1); |
return(CMD_FAIL); |
} |
/* we're good to go, src and dst should look somehow like that now: |
159,5 → 159,5 |
i = findnext(dta); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/rmdir.c |
---|
26,7 → 26,7 |
* rmdir |
*/ |
static int cmd_rmdir(struct cmd_funcparam *p) { |
static enum cmd_result cmd_rmdir(struct cmd_funcparam *p) { |
const char *dname = p->argv[0]; |
unsigned short err = 0; |
35,22 → 35,22 |
outputnl(""); |
outputnl("RMDIR [drive:]path"); |
outputnl("RD [drive:]path"); |
return(-1); |
return(CMD_OK); |
} |
if (p->argc == 0) { |
outputnl("Required parameter missing"); |
return(-1); |
return(CMD_FAIL); |
} |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
if (p->argv[0][0] == '/') { |
outputnl("Invalid parameter"); |
return(-1); |
return(CMD_FAIL); |
} |
_asm { |
68,7 → 68,10 |
pop ax |
} |
if (err != 0) outputnl(doserr(err)); |
if (err != 0) { |
outputnl(doserr(err)); |
return(CMD_FAIL); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/set.c |
---|
30,7 → 30,7 |
*/ |
static int cmd_set(struct cmd_funcparam *p) { |
static enum cmd_result cmd_set(struct cmd_funcparam *p) { |
char far *env = MK_FP(p->env_seg, 0); |
char *buff = p->BUFFER; |
43,7 → 43,7 |
outputnl("string Specifies a series of characters to assign to the variable"); |
outputnl(""); |
outputnl("Type SET without parameters to display the current environment variables."); |
return(-1); |
return(CMD_OK); |
} |
/* no arguments - display content */ |
86,12 → 86,15 |
/* commit variable to environment */ |
i = env_setvar(p->env_seg, buff); |
if (i == ENV_INVSYNT) goto syntax_err; |
if (i == ENV_NOTENOM) outputnl("Not enough available space within the environment block"); |
if (i == ENV_NOTENOM) { |
outputnl("Not enough available space within the environment block"); |
return(CMD_FAIL); |
} |
} |
return(-1); |
return(CMD_OK); |
syntax_err: |
outputnl("Syntax error"); |
return(-1); |
return(CMD_FAIL); |
} |
/svarcom/trunk/cmd/shift.c |
---|
26,7 → 26,7 |
* shift |
*/ |
static int cmd_shift(struct cmd_funcparam *p) { |
static enum cmd_result cmd_shift(struct cmd_funcparam *p) { |
char far *batargv = p->rmod->batargv; |
char far *nextarg; |
35,11 → 35,11 |
nls_outputnl(16, 1); |
outputnl(""); |
outputnl("SHIFT"); |
return(-1); |
return(CMD_OK); |
} |
/* abort if batargv is empty */ |
if (*batargv == 0) return(-1); |
if (*batargv == 0) return(CMD_OK); |
/* find the next argument in batargv */ |
for (nextarg = batargv + 1; *nextarg != 0; nextarg++); |
48,5 → 48,5 |
/* move down batargv so 2nd argument is at the head now */ |
_fmemmove(batargv, nextarg, sizeof(p->rmod->batargv) - (nextarg - batargv)); |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/time.c |
---|
134,7 → 134,7 |
} |
static int cmd_time(struct cmd_funcparam *p) { |
static enum cmd_result cmd_time(struct cmd_funcparam *p) { |
struct nls_patterns *nls = (void *)(p->BUFFER); |
char *buff = p->BUFFER + sizeof(*nls); |
unsigned short i; |
147,13 → 147,13 |
outputnl(""); |
outputnl("Type TIME with no parameters to display the current time and a prompt for a"); |
outputnl("new one. Press ENTER to keep the same time."); |
return(-1); |
return(CMD_OK); |
} |
i = nls_getpatterns(nls); |
if (i != 0) { |
outputnl(doserr(i)); |
return(-1); |
return(CMD_FAIL); |
} |
/* display current time if no args */ |
225,6 → 225,7 |
if (buff[1] == 0) break; /* empty string = do not change time */ |
if (cmd_time_parse(buff + 2, &ho, &mi, &se, nls) == 0) break; |
outputnl("Invalid time"); |
return(CMD_FAIL); |
} |
if (ho >= 0) { |
249,5 → 250,5 |
} |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/type.c |
---|
26,7 → 26,7 |
* type |
*/ |
static int cmd_type(struct cmd_funcparam *p) { |
static enum cmd_result cmd_type(struct cmd_funcparam *p) { |
char *buff = p->BUFFER; |
const char *fname = p->argv[0]; |
unsigned short err = 0; |
35,17 → 35,17 |
outputnl("Displays the contents of a text file."); |
outputnl(""); |
outputnl("TYPE [drive:][path]filename"); |
return(-1); |
return(CMD_OK); |
} |
if (p->argc == 0) { |
outputnl("Required parameter missing"); |
return(-1); |
return(CMD_FAIL); |
} |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
/* if here then display the file */ |
104,7 → 104,10 |
pop ax |
} |
if (err != 0) outputnl(doserr(err)); |
if (err != 0) { |
outputnl(doserr(err)); |
return(CMD_FAIL); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/ver.c |
---|
29,7 → 29,7 |
#define PVER "2021.0" |
#define COPYRDATE "2021" |
static int cmd_ver(struct cmd_funcparam *p) { |
static enum cmd_result cmd_ver(struct cmd_funcparam *p) { |
char *buff = p->BUFFER; |
unsigned char maj = 0, min = 0; |
41,7 → 41,7 |
#ifdef VERDBG |
outputnl("ver /dbg"); |
#endif |
return(-1); |
return(CMD_OK); |
} |
#ifdef VERDBG |
84,7 → 84,7 |
printf("\r\n"); |
} |
return(-1); |
return(CMD_OK); |
} |
#endif |
97,12 → 97,12 |
outputnl("Program ten dedykuje Milenie i Mojmirowi. Zycze wam, byscie w swoim zyciu"); |
outputnl("potrafili docenic wartosci minionych pokolen, jednoczesnie czerpiac radosc"); |
outputnl("z prostych przyjemnosci dnia codziennego. Lair, jesien 2021."); |
return(-1); |
return(CMD_OK); |
} |
if (p->argc != 0) { |
outputnl("Invalid parameter"); |
return(-1); |
return(CMD_FAIL); |
} |
_asm { |
122,5 → 122,5 |
outputnl(buff); |
outputnl("SvarCOM shell ver " PVER); |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/verify.c |
---|
26,18 → 26,18 |
* verify |
*/ |
static int cmd_verify(struct cmd_funcparam *p) { |
static enum cmd_result cmd_verify(struct cmd_funcparam *p) { |
if (cmd_ishlp(p)) { |
outputnl("Tells DOS whether to verify that files are written correctly to disk."); |
outputnl("\r\nVERIFY [ON | OFF]\r\n"); |
outputnl("Type VERIFY without a parameter to display its current setting."); |
return(-1); |
return(CMD_OK); |
} |
if (p->argc > 1) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
if (p->argc == 0) { |
54,7 → 54,7 |
} else { |
outputnl("VERIFY is on"); |
} |
return(-1); |
return(CMD_OK); |
} |
/* argc == 1*/ |
80,7 → 80,8 |
} |
} else { |
outputnl("Must specify ON or OFF"); |
return(CMD_FAIL); |
} |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd/vol.c |
---|
93,7 → 93,7 |
} |
static int cmd_vol(struct cmd_funcparam *p) { |
static enum cmd_result cmd_vol(struct cmd_funcparam *p) { |
char drv = 0; |
char curdrv = 0; |
unsigned short i; |
102,21 → 102,21 |
outputnl("Displays the disk volume label and serial number, if they exist."); |
outputnl(""); |
outputnl("VOL [drive:]"); |
return(-1); |
return(CMD_OK); |
} |
for (i = 0; i < p->argc; i++) { |
if (p->argv[i][0] == '/') { |
outputnl("Invalid switch"); |
return(-1); |
return(CMD_FAIL); |
} |
if (drv != 0) { |
outputnl("Too many parameters"); |
return(-1); |
return(CMD_FAIL); |
} |
if ((p->argv[i][0] == 0) || (p->argv[i][1] != ':') || (p->argv[i][2] != 0)) { |
outputnl("Invalid parameter format"); |
return(-1); |
return(CMD_FAIL); |
} |
drv = p->argv[i][0]; |
/* convert drive letter to a value 1..x (1=A, 2=B, etc) */ |
141,10 → 141,10 |
drv = curdrv; |
} else if (!isdrivevalid(drv)) { /* is specified drive valid? */ |
outputnl("Invalid drive"); |
return(-1); |
return(CMD_FAIL); |
} |
cmd_vol_internal(drv, p->BUFFER); |
return(-1); |
return(CMD_OK); |
} |
/svarcom/trunk/cmd.c |
---|
40,7 → 40,9 |
#include "rmodinit.h" |
#include "sayonara.h" |
#include "cmd.h" |
struct cmd_funcparam { |
int argc; /* number of arguments */ |
const char *argv[128]; /* pointers to each argument */ |
89,12 → 91,10 |
#include "cmd/ver.c" |
#include "cmd/verify.c" |
#include "cmd.h" |
struct CMD_ID { |
const char *cmd; |
int (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */ |
enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */ |
}; |
const struct CMD_ID INTERNAL_CMDS[] = { |
201,10 → 201,10 |
} |
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ, const struct redir_data *redir) { |
enum cmd_result cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ, const struct redir_data *redir) { |
const struct CMD_ID *cmdptr; |
unsigned short argoffset; |
int cmdres; |
enum cmd_result cmdres; |
struct cmd_funcparam *p = (void *)BUFFER; |
p->BUFFERSZ = BUFFERSZ - sizeof(*p); |
230,19 → 230,20 |
pop dx |
pop ax |
} |
if (curdrive != drive) outputnl(doserr(0x0f)); |
return(-1); |
if (curdrive == drive) return(CMD_OK); |
outputnl(doserr(0x0f)); |
return(CMD_FAIL); |
} |
} |
/* try matching an internal command */ |
cmdptr = cmd_match(cmdline, &argoffset); |
if (cmdptr == NULL) return(-2); /* command is not recognized as internal */ |
if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */ |
/* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */ |
/* apply redirections (if any) */ |
if (redir_apply(redir) != 0) return(-1); |
if (redir_apply(redir) != 0) return(CMD_FAIL); |
/* prepare function parameters and feed it to the cmd handling function */ |
p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv); |
/svarcom/trunk/cmd.h |
---|
27,8 → 27,16 |
#include "rmodinit.h" |
/* what cmd_process may return */ |
enum cmd_result { |
CMD_OK, /* command executed and succeeded */ |
CMD_FAIL, /* command executed and failed */ |
CMD_NOTFOUND, /* no such command (not an internal command) */ |
CMD_CHANGED /* command-line transformed, please reparse it */ |
}; |
/* process internal commands */ |
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ, const struct redir_data *r); |
enum cmd_result cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ, const struct redir_data *r); |
/* 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 |
/svarcom/trunk/command.c |
---|
731,6 → 731,7 |
static char cmdlinebuf[CMDLINE_MAXLEN + 2]; /* 1 extra byte for 0-terminator and another for memguard */ |
static char *cmdline; |
static struct redir_data redirprops; |
static enum cmd_result cmdres; |
rmod = rmod_find(BUFFER_len); |
if (rmod == NULL) { |
847,20 → 848,26 |
redir_parsecmd(&redirprops, cmdline); |
/* try matching (and executing) an internal command */ |
if (cmd_process(rmod, *rmod_envseg, cmdline, BUFFER, sizeof(BUFFER), &redirprops) >= -1) { |
cmdres = cmd_process(rmod, *rmod_envseg, cmdline, BUFFER, sizeof(BUFFER), &redirprops); |
if ((cmdres == CMD_OK) || (cmdres == CMD_FAIL)) { |
/* internal command executed */ |
continue; |
} else if (cmdres == CMD_CHANGED) { /* cmdline changed, needs to be reprocessed */ |
goto EXEC_CMDLINE; |
} else if (cmdres == CMD_NOTFOUND) { |
/* this was not an internal command, try matching an external command */ |
run_as_external(BUFFER, cmdline, *rmod_envseg, rmod, &redirprops); |
/* perhaps this is a newly launched BAT file */ |
if ((rmod->batfile[0] != 0) && (rmod->batnextline == 0)) goto SKIP_NEWLINE; |
/* 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"); |
continue; |
} |
/* if here, then this was not an internal command */ |
run_as_external(BUFFER, cmdline, *rmod_envseg, rmod, &redirprops); |
/* perhaps this is a newly launched BAT file */ |
if ((rmod->batfile[0] != 0) && (rmod->batnextline == 0)) goto SKIP_NEWLINE; |
/* I should never ever land here */ |
outputnl("INTERNAL ERR: INVALID CMDRES"); |
/* 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); |
sayonara(rmod); |
/svarcom/trunk/todo.txt |
---|
7,6 → 7,7 |
=== HIGH PRIORITY ============================================================ |
echo: no need to consider cmdline like a far ptr (it is not) |
pipes redirections |
DIR /A |
ctrl+break handler |