Subversion Repositories SvarDOS

Rev

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

Rev 501 Rev 508
Line 164... Line 164...
164
 
164
 
165
  return(NULL); /* command is not recognized as internal */
165
  return(NULL); /* command is not recognized as internal */
166
}
166
}
167
 
167
 
168
 
168
 
169
/* explodes a command into an array of arguments where last arg is NULL
169
/* explodes a command into an array of arguments where last arg is NULL.
-
 
170
 * if argvlist is not NULL, it will be filled with pointers that point to buff
-
 
171
 * locations. buff is filled with all the arguments, each argument being
-
 
172
 * zero-separated. buff is terminated with an empty argument to mark the end
-
 
173
 * of arguments.
170
 * returns number of args */
174
 * returns number of args */
171
static unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
175
unsigned short cmd_explode(char *buff, const char far *s, char const **argvlist) {
172
  int si = 0, argc = 0, i = 0;
176
  int si = 0, argc = 0, i = 0;
173
  for (;;) {
177
  for (;;) {
174
    /* skip to next non-space character */
178
    /* skip to next non-space character */
175
    while (s[si] == ' ') si++;
179
    while (s[si] == ' ') si++;
176
    /* end of string? */
180
    /* end of string? */
177
    if (s[si] == 0) break;
181
    if (s[si] == 0) break;
178
    /* set argv ptr */
182
    /* set argv ptr */
179
    argvlist[argc++] = buff + i;
183
    if (argvlist) argvlist[argc] = buff + i;
-
 
184
    argc++;
180
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
185
    /* find next arg delimiter (spc, null, slash or plus) while copying arg to local buffer */
181
    do {
186
    do {
182
      buff[i++] = s[si++];
187
      buff[i++] = s[si++];
183
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
188
    } while (s[si] != ' ' && s[si] != 0 && s[si] != '/' && s[si] != '+');
184
    buff[i++] = 0;
189
    buff[i++] = 0;
185
    /* is this end of string? */
190
    /* is this end of string? */
186
    if (s[si] == 0) break;
191
    if (s[si] == 0) break;
187
  }
192
  }
-
 
193
  buff[i] = 0; /* terminate with one extra zero to tell "this is the end of list" */
188
  argvlist[argc] = NULL;
194
  if (argvlist) argvlist[argc] = NULL;
189
  return(argc);
195
  return(argc);
190
}
196
}
191
 
197
 
192
 
198
 
193
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ) {
199
int cmd_process(struct rmod_props far *rmod, unsigned short env_seg, const char *cmdline, void *BUFFER, unsigned short BUFFERSZ) {