Subversion Repositories SvarDOS

Rev

Rev 538 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 538 Rev 989
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 Mateusz Viste
4
 * Copyright (C) 2021-2022 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 29... Line 29...
29
static enum cmd_result 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
    nls_outputnl(11,0); /* "Displays or sets the active code page number" */
35
    outputnl("");
35
    outputnl("");
36
    outputnl("CHCP [nnn]");
36
    nls_outputnl(11,1); /* "CHCP [nnn]" */
37
    outputnl("");
37
    outputnl("");
38
    outputnl("nnn  Specifies a code page number");
38
    nls_outputnl(11,2); /* "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
    nls_outputnl(11,3); /* "Type CHCP without a parameter to display the active code page number." */
41
    return(CMD_OK);
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
    nls_outputnl(0,4); /* "Too many parameters" */
47
    return(CMD_FAIL);
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
      nls_outputnl(11,4); /* "Invalid code page number" */
55
      return(CMD_FAIL);
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
Line 76... Line 76...
76
 
76
 
77
      pop bx
77
      pop bx
78
      pop ax
78
      pop ax
79
    }
79
    }
80
    if (nlsfuncflag == 0) {
80
    if (nlsfuncflag == 0) {
81
      outputnl("NLSFUNC not installed");
81
      nls_outputnl(11,5); /* "NLSFUNC not installed" */
82
    } else if (errcode != 0) {
82
    } else if (errcode != 0) {
83
      outputnl("Failed to change code page");
83
      nls_outputnl(11,6); /* "Failed to change code page" */
84
      return(CMD_FAIL);
84
      return(CMD_FAIL);
85
    }
85
    }
86
 
86
 
87
  } else { /* no parameter given: display active code page */
87
  } else { /* no parameter given: display active code page */
88
 
88
 
Line 101... Line 101...
101
      pop dx
101
      pop dx
102
      pop bx
102
      pop bx
103
      pop ax
103
      pop ax
104
    }
104
    }
105
    if (errcode == 0) {
105
    if (errcode == 0) {
-
 
106
      nls_output(11,7); /* Active code page: */
-
 
107
      output(" ");
106
      sprintf(p->BUFFER, "Active code page: %d", nnn);
108
      sprintf(p->BUFFER, "%u", nnn);
107
      outputnl(p->BUFFER);
109
      outputnl(p->BUFFER);
108
    } else {
110
    } else {
109
      nls_outputnl_doserr(errcode);
111
      nls_outputnl_doserr(errcode);
110
      return(CMD_FAIL);
112
      return(CMD_FAIL);
111
    }
113
    }