Subversion Repositories SvarDOS

Rev

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

Rev 426 Rev 533
Line 24... Line 24...
24
 
24
 
25
/*
25
/*
26
 * chcp
26
 * chcp
27
 */
27
 */
28
 
28
 
29
static int cmd_chcp(struct cmd_funcparam *p) {
29
static enum cmd_result cmd_chcp(struct cmd_funcparam *p) {
30
  unsigned short nnn = 0;
30
  unsigned short nnn = 0;
31
  unsigned short errcode = 0;
31
  unsigned short errcode = 0;
32
 
32
 
33
  if (cmd_ishlp(p)) {
33
  if (cmd_ishlp(p)) {
34
    outputnl("Displays or sets the active code page number");
34
    outputnl("Displays or sets the active code page number");
Line 36... Line 36...
36
    outputnl("CHCP [nnn]");
36
    outputnl("CHCP [nnn]");
37
    outputnl("");
37
    outputnl("");
38
    outputnl("nnn  Specifies a code page number");
38
    outputnl("nnn  Specifies a code page number");
39
    outputnl("");
39
    outputnl("");
40
    outputnl("Type CHCP without a parameter to display the active code page number.");
40
    outputnl("Type CHCP without a parameter to display the active code page number.");
41
    return(-1);
41
    return(CMD_OK);
42
  }
42
  }
43
 
43
 
44
  /* too many parameters */
44
  /* too many parameters */
45
  if (p->argc > 1) {
45
  if (p->argc > 1) {
46
    outputnl("Too many parameters");
46
    outputnl("Too many parameters");
47
    return(-1);
47
    return(CMD_FAIL);
48
  }
48
  }
49
 
49
 
50
  /* one param? must be numeric in range 1+ */
50
  /* one param? must be numeric in range 1+ */
51
  if (p->argc == 1) {
51
  if (p->argc == 1) {
52
    unsigned char nlsfuncflag = 0;
52
    unsigned char nlsfuncflag = 0;
53
    if (atous(&nnn, p->argv[0]) != 0) {
53
    if (atous(&nnn, p->argv[0]) != 0) {
54
      outputnl("Invalid code page number");
54
      outputnl("Invalid code page number");
55
      return(-1);
55
      return(CMD_FAIL);
56
    }
56
    }
57
    _asm {
57
    _asm {
58
      /* verify that NLSFUNC is installed */
58
      /* verify that NLSFUNC is installed */
59
      push ax
59
      push ax
60
      push bx
60
      push bx
Line 79... Line 79...
79
    }
79
    }
80
    if (nlsfuncflag == 0) {
80
    if (nlsfuncflag == 0) {
81
      outputnl("NLSFUNC not installed");
81
      outputnl("NLSFUNC not installed");
82
    } else if (errcode != 0) {
82
    } else if (errcode != 0) {
83
      outputnl("Failed to change code page");
83
      outputnl("Failed to change code page");
-
 
84
      return(CMD_FAIL);
84
    }
85
    }
85
 
86
 
86
  } else { /* no parameter given: display active code page */
87
  } else { /* no parameter given: display active code page */
87
 
88
 
88
    _asm {
89
    _asm {
Line 104... Line 105...
104
    if (errcode == 0) {
105
    if (errcode == 0) {
105
      sprintf(p->BUFFER, "Active code page: %d", nnn);
106
      sprintf(p->BUFFER, "Active code page: %d", nnn);
106
      outputnl(p->BUFFER);
107
      outputnl(p->BUFFER);
107
    } else {
108
    } else {
108
      outputnl(doserr(errcode));
109
      outputnl(doserr(errcode));
-
 
110
      return(CMD_FAIL);
109
    }
111
    }
110
  }
112
  }
111
 
113
 
112
  return(-1);
114
  return(CMD_OK);
113
}
115
}