Subversion Repositories SvarDOS

Rev

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

Rev 490 Rev 491
Line 128... Line 128...
128
}
128
}
129
 
129
 
130
 
130
 
131
/* parses command line the hard way (directly from PSP) */
131
/* parses command line the hard way (directly from PSP) */
132
static void parse_argv(struct config *cfg) {
132
static void parse_argv(struct config *cfg) {
133
  unsigned short i;
-
 
134
  const unsigned char *cmdlinelen = (unsigned char *)0x80;
133
  const unsigned char *cmdlinelen = (void *)0x80;
135
  char *cmdline = (char *)0x81;
134
  char *cmdline = (void *)0x81;
136
 
135
 
137
  memset(cfg, 0, sizeof(*cfg));
136
  memset(cfg, 0, sizeof(*cfg));
138
 
137
 
139
  /* set a NULL terminator on cmdline */
138
  /* set a NULL terminator on cmdline */
140
  cmdline[*cmdlinelen] = 0;
139
  cmdline[*cmdlinelen] = 0;
141
 
140
 
142
  for (i = 0;;) {
141
  while (*cmdline != 0) {
143
 
142
 
144
    /* skip over any leading spaces */
143
    /* skip over any leading spaces */
145
    for (;; i++) {
144
    if (*cmdline == ' ') {
146
      if (cmdline[i] == 0) return;
145
      cmdline++;
147
      if (cmdline[i] != ' ') break;
146
      continue;
148
    }
147
    }
149
 
148
 
150
    if (cmdline[i] != '/') {
149
    if (*cmdline != '/') {
151
      output("Invalid parameter: ");
150
      output("Invalid parameter: ");
152
      outputnl(cmdline + i);
151
      outputnl(cmdline);
153
      /* exit(1); */
-
 
154
    } else {
-
 
155
      i++;        /* skip the slash */
-
 
156
      switch (cmdline[i]) {
-
 
157
        case 'c': /* /C = execute command and quit */
-
 
158
        case 'C':
-
 
159
          cfg->flags |= FLAG_EXEC_AND_QUIT;
-
 
160
          /* FALLTHRU */
-
 
161
        case 'k': /* /K = execute command and keep running */
-
 
162
        case 'K':
-
 
163
          cfg->execcmd = cmdline + i + 1;
-
 
164
          return;
-
 
165
 
-
 
166
        case 'e': /* preset the initial size of the environment block */
-
 
167
        case 'E':
-
 
168
          i++;
-
 
169
          if (cmdline[i] == ':') i++; /* could be /E:size */
-
 
170
          atous(&(cfg->envsiz), cmdline + i);
-
 
171
          if (cfg->envsiz < 64) cfg->envsiz = 0;
-
 
172
          break;
-
 
173
 
-
 
174
        case 'p': /* permanent shell (can't exit + run autoexec.bat) */
-
 
175
        case 'P':
-
 
176
          cfg->flags |= FLAG_PERMANENT;
-
 
177
          break;
-
 
178
 
-
 
179
        case '?':
-
 
180
          outputnl("Starts the SvarCOM command interpreter");
-
 
181
          outputnl("");
-
 
182
          outputnl("COMMAND /E:nnn [/[C|K] command]");
-
 
183
          outputnl("");
-
 
184
          outputnl("/E:nnn     Sets the environment size to nnn bytes");
-
 
185
          outputnl("/P         Makes the new command interpreter permanent (can't exit)");
-
 
186
          outputnl("/C         Executes the specified command and returns");
-
 
187
          outputnl("/K         Executes the specified command and continues running");
-
 
188
          exit(1);
-
 
189
          break;
-
 
190
 
-
 
191
        default:
-
 
192
          output("Invalid switch:");
-
 
193
          output(" ");
-
 
194
          outputnl(cmdline + i);
152
      goto SKIP_TO_NEXT_ARG;
195
          exit(1);
-
 
196
          break;
-
 
197
      }
-
 
198
    }
153
    }
199
 
154
 
-
 
155
    /* got a slash */
-
 
156
    cmdline++;  /* skip the slash */
-
 
157
    switch (*cmdline) {
-
 
158
      case 'c': /* /C = execute command and quit */
-
 
159
      case 'C':
-
 
160
        cfg->flags |= FLAG_EXEC_AND_QUIT;
-
 
161
        /* FALLTHRU */
-
 
162
      case 'k': /* /K = execute command and keep running */
-
 
163
      case 'K':
-
 
164
        cfg->execcmd = cmdline + 1;
-
 
165
        return;
-
 
166
 
200
    /* move to next argument or quit processing if end of cmdline */
167
      case 'e': /* preset the initial size of the environment block */
-
 
168
      case 'E':
-
 
169
        cmdline++;
201
    for (i++; (cmdline[i] != 0) && (cmdline[i] != ' ') && (cmdline[i] != '/'); i++);
170
        if (*cmdline == ':') cmdline++; /* could be /E:size */
-
 
171
        atous(&(cfg->envsiz), cmdline);
-
 
172
        if (cfg->envsiz < 64) cfg->envsiz = 0;
-
 
173
        break;
-
 
174
 
-
 
175
      case 'p': /* permanent shell (can't exit + run autoexec.bat) */
-
 
176
      case 'P':
-
 
177
        cfg->flags |= FLAG_PERMANENT;
-
 
178
        break;
-
 
179
 
-
 
180
      case '?':
-
 
181
        outputnl("Starts the SvarCOM command interpreter");
-
 
182
        outputnl("");
-
 
183
        outputnl("COMMAND /E:nnn [/[C|K] command]");
-
 
184
        outputnl("");
-
 
185
        outputnl("/E:nnn     Sets the environment size to nnn bytes");
-
 
186
        outputnl("/P         Makes the new command interpreter permanent (can't exit)");
-
 
187
        outputnl("/C         Executes the specified command and returns");
-
 
188
        outputnl("/K         Executes the specified command and continues running");
-
 
189
        exit(1);
-
 
190
        break;
-
 
191
 
-
 
192
      default:
-
 
193
        output("Invalid switch:");
-
 
194
        output(" ");
-
 
195
        outputnl(cmdline);
-
 
196
        break;
-
 
197
    }
202
 
198
 
-
 
199
    /* move to next argument or quit processing if end of cmdline */
-
 
200
    SKIP_TO_NEXT_ARG:
-
 
201
    while ((*cmdline != 0) && (*cmdline != ' ') && (*cmdline != '/')) cmdline++;
203
  }
202
  }
204
}
203
}
205
 
204
 
206
 
205
 
207
/* builds the prompt string and displays it. buff is filled with a zero-terminated copy of the prompt. */
206
/* builds the prompt string and displays it. buff is filled with a zero-terminated copy of the prompt. */