Subversion Repositories SvarDOS

Rev

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

Rev Author Line No. Line
982 mateusz.vi 1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
3
 *
4
 * Copyright (C) 2021-2022 Mateusz Viste
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
 
25
/*
26
 * FOR %variable IN (set) DO command [command-parameters]
27
 *
28
 * %variable    a replaceable parameter name
29
 * (set)        a set of one of more files. Wildcards allowed.
30
 * command      the command to carry out for each matched file
31
 * command-parameters   parameters or switches for the specified command
32
 *
33
 * To use FOR in a batch program, use %%variable instead of %variable
34
 *
35
 * the set of files must be surrounded by parenthesis, and may contain one
36
 * or more space-delimited wildcards. Examples:
37
 * (file.txt other.txt)
38
 * (*.exe *.com *.bat)
39
 * (jan*.txt 199201??.txt)
40
 */
41
 
42
/* Implementation notes:
43
 *
44
 * For cannot be nested (no "FOR ... do FOR ..." allowed)
45
 *
46
 * When executed, FOR allocates a "FOR context" to RMOD's memory, this context
47
 * holds the memory state of a FindNext iteration, as well as the command
48
 * to run on each matched file.
49
 *
50
 * This FOR context is looked at by command.c and used to provide a command
51
 * instead of getting the command from interactive cli or BAT file. Repeats
52
 * until the FindNext buffer stops matching files.
53
 *
54
 * This file only provides the help screen of FOR, as well as the FOR-context
55
 * initialization. Actual execution happens within command.c.
56
 */
57
 
58
static enum cmd_result cmd_for(struct cmd_funcparam *p) {
59
 
60
  /* help screen ONLY if /? is the only argument */
61
  if ((p->argc == 1) && (imatch(p->argv[0], "/?"))) {
62
    nls_outputnl(18,0); /* "Runs a specified command for each file in a set of files" */
63
    outputnl("");
64
    nls_outputnl(18,1); /* "FOR %variable IN (set) DO command [parameters]" */
65
    outputnl("");
66
    nls_outputnl(18,2); /* "%variable    a replaceable parameter name" */
67
    nls_outputnl(18,3); /* "(set)        a set of one of more files. Wildcards allowed." */
68
    nls_outputnl(18,4); /* "command      the command to carry out for each matched file" */
69
    nls_outputnl(18,5); /* "parameters   parameters or switches for the specified command" */
70
    outputnl("");
71
    nls_outputnl(18,6); /* "To use FOR in a batch program, use %%variable instead of %variable" */
72
    return(CMD_OK);
73
  }
74
 
75
  outputnl("FOR IS NOT IMPLEMENTED YET");
76
 
77
  return(CMD_OK);
78
}