Subversion Repositories SvarDOS

Rev

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

Rev 532 Rev 533
Line 38... Line 38...
38
#include "helpers.h"
38
#include "helpers.h"
39
#include "redir.h"
39
#include "redir.h"
40
#include "rmodinit.h"
40
#include "rmodinit.h"
41
#include "sayonara.h"
41
#include "sayonara.h"
42
 
42
 
-
 
43
#include "cmd.h"
-
 
44
 
43
 
45
 
44
struct cmd_funcparam {
46
struct cmd_funcparam {
45
  int argc;                 /* number of arguments */
47
  int argc;                 /* number of arguments */
46
  const char *argv[128];    /* pointers to each argument */
48
  const char *argv[128];    /* pointers to each argument */
47
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
49
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
Line 87... Line 89...
87
#include "cmd/time.c"
89
#include "cmd/time.c"
88
#include "cmd/type.c"
90
#include "cmd/type.c"
89
#include "cmd/ver.c"
91
#include "cmd/ver.c"
90
#include "cmd/verify.c"
92
#include "cmd/verify.c"
91
 
93
 
92
#include "cmd.h"
-
 
93
 
-
 
94
 
94
 
95
struct CMD_ID {
95
struct CMD_ID {
96
  const char *cmd;
96
  const char *cmd;
97
  int (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
97
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
98
};
98
};
99
 
99
 
100
const struct CMD_ID INTERNAL_CMDS[] = {
100
const struct CMD_ID INTERNAL_CMDS[] = {
101
  {"BREAK",   cmd_break},
101
  {"BREAK",   cmd_break},
102
  {"CD",      cmd_cd},
102
  {"CD",      cmd_cd},
Line 199... Line 199...
199
  if (argvlist) argvlist[argc] = NULL;
199
  if (argvlist) argvlist[argc] = NULL;
200
  return(argc);
200
  return(argc);
201
}
201
}
202
 
202
 
203
 
203
 
204
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) {
204
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) {
205
  const struct CMD_ID *cmdptr;
205
  const struct CMD_ID *cmdptr;
206
  unsigned short argoffset;
206
  unsigned short argoffset;
207
  int cmdres;
207
  enum cmd_result cmdres;
208
  struct cmd_funcparam *p = (void *)BUFFER;
208
  struct cmd_funcparam *p = (void *)BUFFER;
209
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
209
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
210
 
210
 
211
  /* special case: is this a drive change? (like "E:") */
211
  /* special case: is this a drive change? (like "E:") */
212
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
212
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
Line 228... Line 228...
228
        int 0x21
228
        int 0x21
229
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
229
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
230
        pop dx
230
        pop dx
231
        pop ax
231
        pop ax
232
      }
232
      }
233
      if (curdrive != drive) outputnl(doserr(0x0f));
233
      if (curdrive == drive) return(CMD_OK);
-
 
234
      outputnl(doserr(0x0f));
234
      return(-1);
235
      return(CMD_FAIL);
235
    }
236
    }
236
  }
237
  }
237
 
238
 
238
  /* try matching an internal command */
239
  /* try matching an internal command */
239
  cmdptr = cmd_match(cmdline, &argoffset);
240
  cmdptr = cmd_match(cmdline, &argoffset);
240
  if (cmdptr == NULL) return(-2); /* command is not recognized as internal */
241
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
241
 
242
 
242
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
243
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
243
 
244
 
244
  /* apply redirections (if any) */
245
  /* apply redirections (if any) */
245
  if (redir_apply(redir) != 0) return(-1);
246
  if (redir_apply(redir) != 0) return(CMD_FAIL);
246
 
247
 
247
  /* prepare function parameters and feed it to the cmd handling function */
248
  /* prepare function parameters and feed it to the cmd handling function */
248
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
249
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
249
  p->env_seg = env_seg;
250
  p->env_seg = env_seg;
250
  p->rmod = rmod;
251
  p->rmod = rmod;