Subversion Repositories SvarDOS

Rev

Rev 404 | Rev 406 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 404 Rev 405
Line 9... Line 9...
9
#include <string.h>
9
#include <string.h>
10
 
10
 
11
#include "doserr.h"
11
#include "doserr.h"
12
#include "env.h"
12
#include "env.h"
13
#include "helpers.h"
13
#include "helpers.h"
-
 
14
#include "rmodinit.h"
14
 
15
 
15
#define BUFFER_SIZE 2048    /* make sure this is not bigger than the static buffer in command.c */
16
#define BUFFER_SIZE 2048    /* make sure this is not bigger than the static buffer in command.c */
16
 
17
 
17
struct cmd_funcparam {
18
struct cmd_funcparam {
18
  int argc;                 /* number of arguments */
19
  int argc;                 /* number of arguments */
19
  const char *argv[256];    /* pointers to each argument */
20
  const char *argv[256];    /* pointers to each argument */
20
  unsigned short env_seg;   /* segment of environment block */
21
  unsigned short env_seg;   /* segment of environment block */
-
 
22
  unsigned short rmod_seg;  /* segment of the resident module */
21
  unsigned short argoffset; /* offset of cmdline where first argument starts */
23
  unsigned short argoffset; /* offset of cmdline where first argument starts */
22
  const char far *cmdline;  /* original cmdline (terminated by \r) */
24
  const char far *cmdline;  /* original cmdline (terminated by a NULL) */
23
  char BUFFER[BUFFER_SIZE]; /* a buffer for whatever is needed */
25
  char BUFFER[BUFFER_SIZE]; /* a buffer for whatever is needed */
24
};
26
};
25
 
27
 
26
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
28
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
27
static int cmd_ishlp(const struct cmd_funcparam *p) {
29
static int cmd_ishlp(const struct cmd_funcparam *p) {
Line 37... Line 39...
37
#include "cmd/cls.c"
39
#include "cmd/cls.c"
38
#include "cmd/copy.c"
40
#include "cmd/copy.c"
39
#include "cmd/del.c"
41
#include "cmd/del.c"
40
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
42
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
41
#include "cmd/dir.c"
43
#include "cmd/dir.c"
-
 
44
#include "cmd/echo.c"
42
#include "cmd/exit.c"
45
#include "cmd/exit.c"
43
#include "cmd/mkdir.c"
46
#include "cmd/mkdir.c"
44
#include "cmd/path.c"
47
#include "cmd/path.c"
45
#include "cmd/pause.c"
48
#include "cmd/pause.c"
46
#include "cmd/prompt.c"
49
#include "cmd/prompt.c"
Line 68... Line 71...
68
  {"COPY",    cmd_copy},
71
  {"COPY",    cmd_copy},
69
  {"CTTY",    cmd_notimpl},
72
  {"CTTY",    cmd_notimpl},
70
  {"DATE",    cmd_notimpl},
73
  {"DATE",    cmd_notimpl},
71
  {"DEL",     cmd_del},
74
  {"DEL",     cmd_del},
72
  {"DIR",     cmd_dir},
75
  {"DIR",     cmd_dir},
73
  {"ECHO",    cmd_notimpl},
76
  {"ECHO",    cmd_echo},
74
  {"ERASE",   cmd_del},
77
  {"ERASE",   cmd_del},
75
  {"EXIT",    cmd_exit},
78
  {"EXIT",    cmd_exit},
76
  {"LH",      cmd_notimpl},
79
  {"LH",      cmd_notimpl},
77
  {"LOADHIGH",cmd_notimpl},
80
  {"LOADHIGH",cmd_notimpl},
78
  {"MD",      cmd_mkdir},
81
  {"MD",      cmd_mkdir},
Line 153... Line 156...
153
  argvlist[argc] = NULL;
156
  argvlist[argc] = NULL;
154
  return(argc);
157
  return(argc);
155
}
158
}
156
 
159
 
157
 
160
 
158
int cmd_process(unsigned short env_seg, const char far *cmdline, char *BUFFER) {
161
int cmd_process(unsigned short rmod_seg, unsigned short env_seg, const char far *cmdline, char *BUFFER) {
159
  const struct CMD_ID *cmdptr;
162
  const struct CMD_ID *cmdptr;
160
  unsigned short argoffset;
163
  unsigned short argoffset;
161
  struct cmd_funcparam *p = (void *)BUFFER;
164
  struct cmd_funcparam *p = (void *)BUFFER;
162
 
165
 
163
  /* special case: is this a drive change? (like "E:") */
166
  /* special case: is this a drive change? (like "E:") */
Line 194... Line 197...
194
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
197
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
195
 
198
 
196
  /* prepare function parameters and feed it to the cmd handling function */
199
  /* prepare function parameters and feed it to the cmd handling function */
197
  p->argc = cmd_explode(BUFFER + sizeof(*p), cmdline + argoffset, p->argv);
200
  p->argc = cmd_explode(BUFFER + sizeof(*p), cmdline + argoffset, p->argv);
198
  p->env_seg = env_seg;
201
  p->env_seg = env_seg;
-
 
202
  p->rmod_seg = rmod_seg;
199
  p->argoffset = argoffset;
203
  p->argoffset = argoffset;
200
  p->cmdline = cmdline;
204
  p->cmdline = cmdline;
201
 
205
 
202
  return((cmdptr->func_ptr)(p));
206
  return((cmdptr->func_ptr)(p));
203
}
207
}