Subversion Repositories SvarDOS

Rev

Rev 989 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
421 mateuszvis 1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
3
 *
989 mateusz.vi 4
 * Copyright (C) 2021-2022 Mateusz Viste
421 mateuszvis 5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
23
 */
24
 
386 mateuszvis 25
/*
26
 * verify
27
 */
28
 
533 mateuszvis 29
static enum cmd_result cmd_verify(struct cmd_funcparam *p) {
386 mateuszvis 30
 
387 mateuszvis 31
  if (cmd_ishlp(p)) {
989 mateusz.vi 32
    nls_outputnl(19,0); /* "Tells DOS whether to verify that files are written correctly to disk." */
33
    outputnl("");
34
    outputnl("VERIFY [ON | OFF]");
35
    outputnl("");
36
    nls_outputnl(19,1); /* "Type VERIFY without a parameter to display its current setting." */
533 mateuszvis 37
    return(CMD_OK);
386 mateuszvis 38
  }
39
 
40
  if (p->argc > 1) {
989 mateusz.vi 41
    nls_outputnl(0,4); /* "Too many parameters" */
533 mateuszvis 42
    return(CMD_FAIL);
386 mateuszvis 43
  }
44
 
45
  if (p->argc == 0) {
46
    unsigned char verstate = 0;
47
    _asm {
48
      push ax
49
      mov ah, 0x54   /* Get VERIFY status */
50
      int 0x21       /* AL == 0 (off) or AL == 1 (on) */
51
      mov [verstate], al
52
      pop ax
53
    }
54
    if (verstate == 0) {
989 mateusz.vi 55
      nls_outputnl(19,2); /* "VERIFY is off" */
386 mateuszvis 56
    } else {
989 mateusz.vi 57
      nls_outputnl(19,3); /* "VERIFY is on" */
386 mateuszvis 58
    }
533 mateuszvis 59
    return(CMD_OK);
386 mateuszvis 60
  }
61
 
62
  /* argc == 1*/
63
  if (imatch(p->argv[0], "on")) {
64
    _asm {
65
      push ax
66
      push dx
67
      mov ax, 0x2e01  /* set verify ON */
68
      xor dl, dl      /* apparently required by MS-DOS 2.x */
69
      int 0x21
70
      pop dx
71
      pop ax
72
    }
73
  } else if (imatch(p->argv[0], "off")) {
74
    _asm {
75
      push ax
76
      push dx
77
      mov ax, 0x2e00  /* set verify OFF */
78
      xor dl, dl      /* apparently required by MS-DOS 2.x */
79
      int 0x21
80
      pop dx
81
      pop ax
82
    }
83
  } else {
989 mateusz.vi 84
    nls_outputnl(19,4); /* "Must specify ON or OFF" */
533 mateuszvis 85
    return(CMD_FAIL);
386 mateuszvis 86
  }
87
 
533 mateuszvis 88
  return(CMD_OK);
386 mateuszvis 89
}