2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Skip commands in a script file until a certain label (declared with
26 Lab) or an EndSkip command is reached.
30 LABEL -- The label to skip to.
32 BACK -- Specify this if the label appears before the Skip statement
51 14.01.2000 SDuvan implemented
53 ******************************************************************************/
55 #include <proto/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>
65 AROS_SHA(STRPTR
, , LABEL
, , NULL
),
66 AROS_SHA(BOOL
, , BACK
, /S
, FALSE
))
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");
86 SelectInput(cli
->cli_CurrentInput
);
91 Seek(Input(), 0, OFFSET_BEGINNING
);
96 status
= ReadItem(buffer
, sizeof(buffer
), NULL
);
98 if (status
== ITEM_ERROR
)
103 if (status
== ITEM_NOTHING
)
105 if(FGetC(Input()) == ENDSTREAMCH
)
109 switch (FindArg("LAB,ENDSKIP", buffer
))
112 if (SHArg(LABEL
) != NULL
)
114 ReadItem(buffer
, sizeof(buffer
), NULL
);
116 if (FindArg(SHArg(LABEL
), buffer
) == 0)
129 /* Skip to the next line */
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");