Subversion Repositories SvarDOS

Rev

Rev 576 | Rev 962 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 576 Rev 957
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021-2022 Mateusz Viste
4
 * Copyright (C) 2021-2022 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
12
 *
13
 * The above copyright notice and this permission notice shall be included in
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
14
 * all copies or substantial portions of the Software.
15
 *
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
22
 * DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
/* entry point for internal commands
25
/* entry point for internal commands, it matches internal commands and
26
 * matches internal commands and executes them
26
 * executes them.
-
 
27
 *
27
 * returns -1 or exit code if processed
28
 * returns one of the following values:
-
 
29
 *   CMD_OK               command executed successfully
-
 
30
 *   CMD_FAIL             command ended in error
-
 
31
 *   CMD_CHANGED          command-line has been modified (used by IF)
-
 
32
 *   CMD_CHANGED_BY_CALL  command-line has been modified by CALL
28
 * returns -2 if command unrecognized
33
 *   CMD_NOTFOUND         command unrecognized
29
 */
34
 */
30
 
35
 
31
#include <i86.h>
36
#include <i86.h>
32
#include <stdio.h>
37
#include <stdio.h>
33
#include <stdlib.h>
38
#include <stdlib.h>
34
#include <string.h>
39
#include <string.h>
35
 
40
 
36
#include "env.h"
41
#include "env.h"
37
#include "helpers.h"
42
#include "helpers.h"
38
#include "redir.h"
43
#include "redir.h"
39
#include "rmodinit.h"
44
#include "rmodinit.h"
40
#include "sayonara.h"
45
#include "sayonara.h"
41
 
46
 
42
#include "cmd.h"
47
#include "cmd.h"
43
 
48
 
44
 
49
 
45
struct cmd_funcparam {
50
struct cmd_funcparam {
46
  int argc;                 /* number of arguments */
51
  int argc;                 /* number of arguments */
47
  const char *argv[128];    /* pointers to each argument */
52
  const char *argv[128];    /* pointers to each argument */
48
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
53
  char argvbuf[256];        /* buffer that hold data pointed out by argv[] */
49
  unsigned short env_seg;   /* segment of environment block */
54
  unsigned short env_seg;   /* segment of environment block */
50
  struct rmod_props far *rmod; /* rmod settings */
55
  struct rmod_props far *rmod; /* rmod settings */
51
  unsigned short argoffset; /* offset of cmdline where first argument starts */
56
  unsigned short argoffset; /* offset of cmdline where first argument starts */
52
  const char *cmdline;      /* original cmdline (terminated by a NULL) */
57
  const char *cmdline;      /* original cmdline (terminated by a NULL) */
53
  unsigned short BUFFERSZ;  /* avail space in BUFFER */
58
  unsigned short BUFFERSZ;  /* avail space in BUFFER */
54
  char BUFFER[1];           /* a buffer for whatever is needed (must be last) */
59
  char BUFFER[1];           /* a buffer for whatever is needed (must be last) */
55
};
60
};
56
 
61
 
57
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
62
/* scans argv for the presence of a "/?" parameter. returns 1 if found, 0 otherwise */
58
static int cmd_ishlp(const struct cmd_funcparam *p) {
63
static int cmd_ishlp(const struct cmd_funcparam *p) {
59
  int i;
64
  int i;
60
  for (i = 0; i < p->argc; i++) {
65
  for (i = 0; i < p->argc; i++) {
61
    if ((p->argv[i][0] == '/') && (p->argv[i][1] == '?')) return(1);
66
    if ((p->argv[i][0] == '/') && (p->argv[i][1] == '?')) return(1);
62
  }
67
  }
63
  return(0);
68
  return(0);
64
}
69
}
65
 
70
 
66
#include "cmd/_notimpl.c"
71
#include "cmd/_notimpl.c"
67
#include "cmd/break.c"
72
#include "cmd/break.c"
-
 
73
#include "cmd/call.c"
68
#include "cmd/cd.c"
74
#include "cmd/cd.c"
69
#include "cmd/chcp.c"
75
#include "cmd/chcp.c"
70
#include "cmd/cls.c"
76
#include "cmd/cls.c"
71
#include "cmd/copy.c"
77
#include "cmd/copy.c"
72
#include "cmd/date.c"
78
#include "cmd/date.c"
73
#include "cmd/del.c"
79
#include "cmd/del.c"
74
#include "cmd/if.c"
80
#include "cmd/if.c"
75
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
81
#include "cmd/vol.c"     /* must be included before dir.c due to dependency */
76
#include "cmd/dir.c"
82
#include "cmd/dir.c"
77
#include "cmd/echo.c"
83
#include "cmd/echo.c"
78
#include "cmd/exit.c"
84
#include "cmd/exit.c"
79
#include "cmd/ln.c"
85
#include "cmd/ln.c"
80
#include "cmd/mkdir.c"
86
#include "cmd/mkdir.c"
81
#include "cmd/path.c"
87
#include "cmd/path.c"
82
#include "cmd/pause.c"
88
#include "cmd/pause.c"
83
#include "cmd/prompt.c"
89
#include "cmd/prompt.c"
84
#include "cmd/rem.c"
90
#include "cmd/rem.c"
85
#include "cmd/rename.c"
91
#include "cmd/rename.c"
86
#include "cmd/rmdir.c"
92
#include "cmd/rmdir.c"
87
#include "cmd/set.c"
93
#include "cmd/set.c"
88
#include "cmd/shift.c"
94
#include "cmd/shift.c"
89
#include "cmd/time.c"
95
#include "cmd/time.c"
90
#include "cmd/type.c"
96
#include "cmd/type.c"
91
#include "cmd/ver.c"
97
#include "cmd/ver.c"
92
#include "cmd/verify.c"
98
#include "cmd/verify.c"
93
 
99
 
94
 
100
 
95
struct CMD_ID {
101
struct CMD_ID {
96
  const char *cmd;
102
  const char *cmd;
97
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
103
  enum cmd_result (*func_ptr)(struct cmd_funcparam *); /* pointer to handling function */
98
};
104
};
99
 
105
 
100
const struct CMD_ID INTERNAL_CMDS[] = {
106
const struct CMD_ID INTERNAL_CMDS[] = {
101
  {"BREAK",   cmd_break},
107
  {"BREAK",   cmd_break},
-
 
108
  {"CALL",    cmd_call},
102
  {"CD",      cmd_cd},
109
  {"CD",      cmd_cd},
103
  {"CHCP",    cmd_chcp},
110
  {"CHCP",    cmd_chcp},
104
  {"CHDIR",   cmd_cd},
111
  {"CHDIR",   cmd_cd},
105
  {"CLS",     cmd_cls},
112
  {"CLS",     cmd_cls},
106
  {"COPY",    cmd_copy},
113
  {"COPY",    cmd_copy},
107
  {"CTTY",    cmd_notimpl},
114
  {"CTTY",    cmd_notimpl},
108
  {"DATE",    cmd_date},
115
  {"DATE",    cmd_date},
109
  {"DEL",     cmd_del},
116
  {"DEL",     cmd_del},
110
  {"DIR",     cmd_dir},
117
  {"DIR",     cmd_dir},
111
  {"ECHO",    cmd_echo},
118
  {"ECHO",    cmd_echo},
112
  {"ERASE",   cmd_del},
119
  {"ERASE",   cmd_del},
113
  {"EXIT",    cmd_exit},
120
  {"EXIT",    cmd_exit},
114
  {"IF",      cmd_if},
121
  {"IF",      cmd_if},
115
  {"LH",      cmd_notimpl},
122
  {"LH",      cmd_notimpl},
116
  {"LN",      cmd_ln},
123
  {"LN",      cmd_ln},
117
  {"LOADHIGH",cmd_notimpl},
124
  {"LOADHIGH",cmd_notimpl},
118
  {"MD",      cmd_mkdir},
125
  {"MD",      cmd_mkdir},
119
  {"MKDIR",   cmd_mkdir},
126
  {"MKDIR",   cmd_mkdir},
120
  {"PAUSE",   cmd_pause},
127
  {"PAUSE",   cmd_pause},
121
  {"PATH",    cmd_path},
128
  {"PATH",    cmd_path},
122
  {"PROMPT",  cmd_prompt},
129
  {"PROMPT",  cmd_prompt},
123
  {"RD",      cmd_rmdir},
130
  {"RD",      cmd_rmdir},
124
  {"REM",     cmd_rem},
131
  {"REM",     cmd_rem},
125
  {"REN",     cmd_rename},
132
  {"REN",     cmd_rename},
126
  {"RENAME",  cmd_rename},
133
  {"RENAME",  cmd_rename},
127
  {"RMDIR",   cmd_rmdir},
134
  {"RMDIR",   cmd_rmdir},
128
  {"SET",     cmd_set},
135
  {"SET",     cmd_set},
129
  {"SHIFT",   cmd_shift},
136
  {"SHIFT",   cmd_shift},
130
  {"TIME",    cmd_time},
137
  {"TIME",    cmd_time},
131
  {"TYPE",    cmd_type},
138
  {"TYPE",    cmd_type},
132
  {"VER",     cmd_ver},
139
  {"VER",     cmd_ver},
133
  {"VERIFY",  cmd_verify},
140
  {"VERIFY",  cmd_verify},
134
  {"VOL",     cmd_vol},
141
  {"VOL",     cmd_vol},
135
  {NULL,      NULL}
142
  {NULL,      NULL}
136
};
143
};
137
 
144
 
138
 
145
 
139
/* NULL if cmdline is not matching an internal command, otherwise returns a
146
/* NULL if cmdline is not matching an internal command, otherwise returns a
140
 * pointer to a CMD_ID struct */
147
 * pointer to a CMD_ID struct */
141
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
148
static const struct CMD_ID *cmd_match(const char *cmdline, unsigned short *argoffset) {
142
  unsigned short i;
149
  unsigned short i;
143
  char buff[10];
150
  char buff[10];
144
 
151
 
145
  /* copy command to buffer, until space, NULL, tab, return, dot, slash or backslash */
152
  /* copy command to buffer, until space, NULL, tab, return, dot, slash or backslash */
146
  for (i = 0; i < 9; i++) {
153
  for (i = 0; i < 9; i++) {
147
    if (cmdline[i] == ' ') break;
154
    if (cmdline[i] == ' ') break;
148
    if (cmdline[i] == 0) break;
155
    if (cmdline[i] == 0) break;
149
    if (cmdline[i] == '\t') break;
156
    if (cmdline[i] == '\t') break;
150
    if (cmdline[i] == '\r') break;
157
    if (cmdline[i] == '\r') break;
151
    if (cmdline[i] == '.') break;
158
    if (cmdline[i] == '.') break;
152
    if (cmdline[i] == '/') break;
159
    if (cmdline[i] == '/') break;
153
    if (cmdline[i] == '\\') break;
160
    if (cmdline[i] == '\\') break;
154
    buff[i] = cmdline[i];
161
    buff[i] = cmdline[i];
155
  }
162
  }
156
  buff[i] = 0;
163
  buff[i] = 0;
157
 
164
 
158
  /* advance to nearest non-space to find where arguments start */
165
  /* advance to nearest non-space to find where arguments start */
159
  while (cmdline[i] == ' ') i++;
166
  while (cmdline[i] == ' ') i++;
160
  *argoffset = i;
167
  *argoffset = i;
161
 
168
 
162
  /* try matching an internal command */
169
  /* try matching an internal command */
163
  for (i = 0; INTERNAL_CMDS[i].cmd != NULL; i++) {
170
  for (i = 0; INTERNAL_CMDS[i].cmd != NULL; i++) {
164
    /*printf("imatch(%s,%s)\r\n", buff, INTERNAL_CMDS[i].cmd); */
171
    /*printf("imatch(%s,%s)\r\n", buff, INTERNAL_CMDS[i].cmd); */
165
    if (imatch(buff, INTERNAL_CMDS[i].cmd)) {
172
    if (imatch(buff, INTERNAL_CMDS[i].cmd)) {
166
      /*printf("match cmd i=%u (buff=%s)\r\n", i, buff);*/
173
      /*printf("match cmd i=%u (buff=%s)\r\n", i, buff);*/
167
      return(&(INTERNAL_CMDS[i]));
174
      return(&(INTERNAL_CMDS[i]));
168
    }
175
    }
169
  }
176
  }
170
 
177
 
171
  return(NULL); /* command is not recognized as internal */
178
  return(NULL); /* command is not recognized as internal */
172
}
179
}
173
 
180
 
174
 
181
 
175
/* explodes a command into an array of arguments where last arg is NULL.
182
/* explodes a command into an array of arguments where last arg is NULL.
176
 * if argvlist is not NULL, it will be filled with pointers that point to buff
183
 * if argvlist is not NULL, it will be filled with pointers that point to buff
177
 * locations. buff is filled with all the arguments, each argument being
184
 * locations. buff is filled with all the arguments, each argument being
178
 * zero-separated. buff is terminated with an empty argument to mark the end
185
 * zero-separated. buff is terminated with an empty argument to mark the end
179
 * of arguments.
186
 * of arguments.
180
 * returns number of args */
187
 * returns number of args */
181
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
188
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
182
  int si = 0, argc = 0, i = 0;
189
  int si = 0, argc = 0, i = 0;
183
  for (;;) {
190
  for (;;) {
184
    /* skip to next non-space character */
191
    /* skip to next non-space character */
185
    while (s[si] == ' ') si++;
192
    while (s[si] == ' ') si++;
186
    /* end of string? */
193
    /* end of string? */
187
    if (s[si] == 0) break;
194
    if (s[si] == 0) break;
188
    /* set argv ptr */
195
    /* set argv ptr */
189
    if (argvlist) argvlist[argc] = buff + i;
196
    if (argvlist) argvlist[argc] = buff + i;
190
    argc++;
197
    argc++;
191
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
198
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
192
    do {
199
    do {
193
      buff[i++] = s[si++];
200
      buff[i++] = s[si++];
194
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
201
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
195
    buff[i++] = 0;
202
    buff[i++] = 0;
196
    /* is this end of string? */
203
    /* is this end of string? */
197
    if (s[si] == 0) break;
204
    if (s[si] == 0) break;
198
  }
205
  }
199
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
206
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
200
  if (argvlist) argvlist[argc] = NULL;
207
  if (argvlist) argvlist[argc] = NULL;
201
  return(argc);
208
  return(argc);
202
}
209
}
203
 
210
 
204
 
211
 
205
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, unsigned char delstdin) {
212
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, unsigned char delstdin) {
206
  const struct CMD_ID *cmdptr;
213
  const struct CMD_ID *cmdptr;
207
  unsigned short argoffset;
214
  unsigned short argoffset;
208
  enum cmd_result cmdres;
215
  enum cmd_result cmdres;
209
  struct cmd_funcparam *p = (void *)BUFFER;
216
  struct cmd_funcparam *p = (void *)BUFFER;
210
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
217
  p->BUFFERSZ = BUFFERSZ - sizeof(*p);
211
 
218
 
212
  /* special case: is this a drive change? (like "E:") */
219
  /* special case: is this a drive change? (like "E:") */
213
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
220
  if ((cmdline[0] != 0) && (cmdline[1] == ':') && ((cmdline[2] == ' ') || (cmdline[2] == 0))) {
214
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
221
    if (((cmdline[0] >= 'a') && (cmdline[0] <= 'z')) || ((cmdline[0] >= 'A') && (cmdline[0] <= 'Z'))) {
215
      unsigned char drive = cmdline[0];
222
      unsigned char drive = cmdline[0];
216
      unsigned char curdrive = 0;
223
      unsigned char curdrive = 0;
217
      if (drive >= 'a') {
224
      if (drive >= 'a') {
218
        drive -= 'a';
225
        drive -= 'a';
219
      } else {
226
      } else {
220
        drive -= 'A';
227
        drive -= 'A';
221
      }
228
      }
222
      _asm {
229
      _asm {
223
        push ax
230
        push ax
224
        push dx
231
        push dx
225
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
232
        mov ah, 0x0e     /* DOS 1+ - SELECT DEFAULT DRIVE */
226
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
233
        mov dl, drive    /* DL = new default drive (00h = A:, 01h = B:, etc) */
227
        int 0x21
234
        int 0x21
228
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
235
        mov ah, 0x19     /* DOS 1+ - GET CURRENT DRIVE */
229
        int 0x21
236
        int 0x21
230
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
237
        mov curdrive, al /* cur drive (0=A, 1=B, etc) */
231
        pop dx
238
        pop dx
232
        pop ax
239
        pop ax
233
      }
240
      }
234
      if (curdrive == drive) return(CMD_OK);
241
      if (curdrive == drive) return(CMD_OK);
235
      nls_outputnl_doserr(0x0f);
242
      nls_outputnl_doserr(0x0f);
236
      return(CMD_FAIL);
243
      return(CMD_FAIL);
237
    }
244
    }
238
  }
245
  }
239
 
246
 
240
  /* try matching an internal command */
247
  /* try matching an internal command */
241
  cmdptr = cmd_match(cmdline, &argoffset);
248
  cmdptr = cmd_match(cmdline, &argoffset);
242
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
249
  if (cmdptr == NULL) return(CMD_NOTFOUND); /* command is not recognized as internal */
243
 
250
 
244
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
251
  /* printf("recognized internal command: '%s', tail of command at offset %u\r\n", cmdptr->cmd, argoffset); */
245
 
252
 
246
  /* apply redirections (if any) */
253
  /* apply redirections (if any) */
247
  if (redir_apply(redir) != 0) return(CMD_FAIL);
254
  if (redir_apply(redir) != 0) return(CMD_FAIL);
248
 
255
 
249
  /* prepare function parameters and feed it to the cmd handling function */
256
  /* prepare function parameters and feed it to the cmd handling function */
250
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
257
  p->argc = cmd_explode(p->argvbuf, cmdline + argoffset, p->argv);
251
  p->env_seg = env_seg;
258
  p->env_seg = env_seg;
252
  p->rmod = rmod;
259
  p->rmod = rmod;
253
  p->argoffset = argoffset;
260
  p->argoffset = argoffset;
254
  p->cmdline = cmdline;
261
  p->cmdline = cmdline;
255
 
262
 
256
  cmdres = (cmdptr->func_ptr)(p);
263
  cmdres = (cmdptr->func_ptr)(p);
257
 
264
 
258
  /* cancel redirections */
265
  /* cancel redirections */
259
  redir_revert();
266
  redir_revert();
260
 
267
 
261
  /* delete stdin temporary file */
268
  /* delete stdin temporary file */
262
  if (delstdin) {
269
  if (delstdin) {
263
    const char *fname = redir->stdinfile;
270
    const char *fname = redir->stdinfile;
264
    unsigned short doserr = 0;
271
    unsigned short doserr = 0;
265
    _asm {
272
    _asm {
266
      push ax
273
      push ax
267
      push dx
274
      push dx
268
      mov ah, 0x41  /* delete a file */
275
      mov ah, 0x41  /* delete a file */
269
      mov dx, fname /* DS:DX - filename to delete */
276
      mov dx, fname /* DS:DX - filename to delete */
270
      int 0x21
277
      int 0x21
271
      jnc DONE
278
      jnc DONE
272
      mov doserr, ax
279
      mov doserr, ax
273
      DONE:
280
      DONE:
274
      pop dx
281
      pop dx
275
      pop ax
282
      pop ax
276
    }
283
    }
277
    if (doserr) {
284
    if (doserr) {
278
      output(fname);
285
      output(fname);
279
      output(": ");
286
      output(": ");
280
      nls_outputnl_doserr(doserr);
287
      nls_outputnl_doserr(doserr);
281
    }
288
    }
282
  }
289
  }
283
 
290
 
284
  return(cmdres);
291
  return(cmdres);
285
}
292
}
286
 
293