Subversion Repositories SvarDOS

Rev

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

Rev 1713 Rev 1714
Line 1... Line 1...
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-2023 Mateusz Viste
4
 * Copyright (C) 2021-2024 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,
Line 119... Line 119...
119
}
119
}
120
 
120
 
121
 
121
 
122
/* parses command line the hard way (directly from PSP) */
122
/* parses command line the hard way (directly from PSP) */
123
static void parse_argv(struct config *cfg) {
123
static void parse_argv(struct config *cfg) {
124
  const unsigned char *cmdlinelen = (void *)0x80;
-
 
125
  char *cmdline = (void *)0x81;
124
  char *cmdline = (void *)0x81;
126
 
125
 
127
  memset(cfg, 0, sizeof(*cfg));
126
  memset(cfg, 0, sizeof(*cfg));
128
 
127
 
129
  /* set a NULL terminator on cmdline */
-
 
130
  cmdline[*cmdlinelen] = 0;
-
 
131
 
-
 
132
  while (*cmdline != 0) {
128
  while (*cmdline != 0x0d) {
133
 
129
 
134
    /* skip over any leading spaces */
130
    /* skip over any leading spaces */
135
    if (*cmdline == ' ') {
131
    if (*cmdline == ' ') {
136
      cmdline++;
132
      cmdline++;
137
      continue;
133
      continue;
Line 153... Line 149...
153
        /* FALLTHRU */
149
        /* FALLTHRU */
154
      case 'k': /* /K = execute command and keep running */
150
      case 'k': /* /K = execute command and keep running */
155
      case 'K':
151
      case 'K':
156
        cmdline++;
152
        cmdline++;
157
        cfg->execcmd = cmdline;
153
        cfg->execcmd = cmdline;
158
        return; /* further arguments are for the executed program, not for me */
154
        goto DONE; /* further arguments are for the executed program, not for me */
159
 
155
 
160
      case 'y': /* /Y = execute batch file step-by-step (with /P, /K or /C) */
156
      case 'y': /* /Y = execute batch file step-by-step (with /P, /K or /C) */
161
      case 'Y':
157
      case 'Y':
162
        cfg->flags |= FLAG_STEPBYSTEP;
158
        cfg->flags |= FLAG_STEPBYSTEP;
163
        break;
159
        break;
Line 201... Line 197...
201
        break;
197
        break;
202
    }
198
    }
203
 
199
 
204
    /* move to next argument or quit processing if end of cmdline */
200
    /* move to next argument or quit processing if end of cmdline */
205
    SKIP_TO_NEXT_ARG:
201
    SKIP_TO_NEXT_ARG:
206
    while ((*cmdline != 0) && (*cmdline != ' ') && (*cmdline != '/')) cmdline++;
202
    while ((*cmdline != 0x0d) && (*cmdline != ' ') && (*cmdline != '/')) cmdline++;
207
  }
203
  }
-
 
204
 
-
 
205
  DONE:
-
 
206
 
-
 
207
  /* set a nul terminator on cmdline (expected later in the code) */
-
 
208
  while (*cmdline != 0x0d) cmdline++;
-
 
209
  *cmdline = 0;
208
}
210
}
209
 
211
 
210
 
212
 
211
/* builds the prompt string and displays it. buff is filled with a zero-terminated copy of the prompt. */
213
/* builds the prompt string and displays it. buff is filled with a zero-terminated copy of the prompt. */
212
static void build_and_display_prompt(char *buff, unsigned short envseg) {
214
static void build_and_display_prompt(char *buff, unsigned short envseg) {