Subversion Repositories SvarDOS

Rev

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

Rev 361 Rev 364
Line 5... Line 5...
5
 * varname can also contain spaces
5
 * varname can also contain spaces
6
 */
6
 */
7
 
7
 
8
#include "env.h"
8
#include "env.h"
9
 
9
 
10
 
-
 
11
static int cmd_set(int argc, char const **argv, unsigned short env_seg, const char far *cmdline) {
10
static int cmd_set(const struct cmd_funcparam *p) {
12
  char far *env = MK_FP(env_seg, 0);
11
  char far *env = MK_FP(p->env_seg, 0);
13
  char buff[256];
12
  char buff[256];
14
  int i;
13
  int i;
15
  /* no arguments - display content */
14
  /* no arguments - display content */
16
  if (argc == 1) {
15
  if (p->argc == 0) {
17
    while (*env != 0) {
16
    while (*env != 0) {
18
      /* copy string to local buff for display */
17
      /* copy string to local buff for display */
19
      for (i = 0;; i++) {
18
      for (i = 0;; i++) {
20
        buff[i] = *env;
19
        buff[i] = *env;
21
        env++;
20
        env++;
22
        if (buff[i] == 0) break;
21
        if (buff[i] == 0) break;
23
      }
22
      }
24
      puts(buff);
23
      puts(buff);
25
    }
24
    }
26
  } else if ((argc == 2) && (imatch(argv[1], "/?"))) {
25
  } else if ((p->argc == 1) && (imatch(p->argv[0], "/?"))) {
27
    puts("TODO: help screen"); /* TODO */
26
    puts("TODO: help screen"); /* TODO */
28
  } else { /* set variable (do not rely on argv, SET has its own rules...) */
27
  } else { /* set variable (do not rely on argv, SET has its own rules...) */
29
    const char far *ptr;
28
    const char far *ptr;
30
    char buff[256];
29
    char buff[256];
31
    unsigned short i;
30
    unsigned short i;
32
    /* locate the first space */
31
    /* locate the first space */
33
    for (ptr = cmdline; *ptr != ' '; ptr++);
32
    for (ptr = p->cmdline; *ptr != ' '; ptr++);
34
    /* now locate the first non-space: that's where the variable name begins */
33
    /* now locate the first non-space: that's where the variable name begins */
35
    for (; *ptr == ' '; ptr++);
34
    for (; *ptr == ' '; ptr++);
36
    /* copy variable to buff and switch it upercase */
35
    /* copy variable to buff and switch it upercase */
37
    i = 0;
36
    i = 0;
38
    for (; *ptr != '='; ptr++) {
37
    for (; *ptr != '='; ptr++) {
Line 50... Line 49...
50
 
49
 
51
    /* terminate buff */
50
    /* terminate buff */
52
    buff[i] = 0;
51
    buff[i] = 0;
53
 
52
 
54
    /* commit variable to environment */
53
    /* commit variable to environment */
55
    i = env_setvar(env_seg, buff);
54
    i = env_setvar(p->env_seg, buff);
56
    if (i == ENV_INVSYNT) goto syntax_err;
55
    if (i == ENV_INVSYNT) goto syntax_err;
57
    if (i == ENV_NOTENOM) puts("Not enough available space within the environment block");
56
    if (i == ENV_NOTENOM) puts("Not enough available space within the environment block");
58
  }
57
  }
59
  return(-1);
58
  return(-1);
60
 
59