New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / c / shellcommands / Skip.c
blob68ef9a2a84200575395a8119d5cbd7ff204fc5a6
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /******************************************************************************
11 NAME
13 Skip
15 SYNOPSIS
17 LABEL, BACK/S
19 LOCATION
21 Workbench:C
23 FUNCTION
25 Skip commands in a script file until a certain label (declared with
26 Lab) or an EndSkip command is reached.
28 INPUTS
30 LABEL -- The label to skip to.
32 BACK -- Specify this if the label appears before the Skip statement
33 in the script file.
35 RESULT
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 Lab, EndSkip
47 INTERNALS
49 HISTORY
51 14.01.2000 SDuvan implemented
53 ******************************************************************************/
55 #include <proto/dos.h>
56 #include <dos/dos.h>
57 #include <dos/dosextens.h>
58 #include <dos/rdargs.h>
59 #include <dos_commanderrors.h>
60 #include <dos/stdio.h>
62 #include <aros/shcommands.h>
64 AROS_SH2(Skip, 41.1,
65 AROS_SHA(STRPTR, , LABEL, , NULL),
66 AROS_SHA(BOOL, , BACK, /S, FALSE))
68 AROS_SHCOMMAND_INIT
70 struct CommandLineInterface *cli = Cli();
71 BOOL labelFound = FALSE;
74 if(cli == NULL || cli->cli_CurrentInput == cli->cli_StandardInput)
76 PrintFault(ERROR_SCRIPT_ONLY, "Skip");
78 return RETURN_FAIL;
82 char buffer[256];
83 LONG status;
84 BOOL quit = FALSE;
86 SelectInput(cli->cli_CurrentInput);
88 if (SHArg(BACK))
90 Flush(Input());
91 Seek(Input(), 0, OFFSET_BEGINNING);
94 while (!quit)
96 status = ReadItem(buffer, sizeof(buffer), NULL);
98 if (status == ITEM_ERROR)
100 break;
103 if (status == ITEM_NOTHING)
105 if(FGetC(Input()) == ENDSTREAMCH)
106 break;
109 switch (FindArg("LAB,ENDSKIP", buffer))
111 case 0:
112 if (SHArg(LABEL) != NULL)
114 ReadItem(buffer, sizeof(buffer), NULL);
116 if (FindArg(SHArg(LABEL), buffer) == 0)
118 quit = TRUE;
119 labelFound = TRUE;
122 break;
124 case 1:
125 quit = TRUE;
126 break;
129 /* Skip to the next line */
131 char a;
135 a = FGetC(Input());
136 } while (a != '\n' && a != ENDSTREAMCH);
141 if (!labelFound && SHArg(LABEL) != NULL)
143 SetIoErr(ERROR_OBJECT_NOT_FOUND);
144 PrintFault(ERROR_OBJECT_NOT_FOUND, "Skip");
146 return RETURN_FAIL;
149 return RETURN_OK;
151 AROS_SHCOMMAND_EXIT