Put pciehci.device in DEVS:USBHardware, like the other host-controller
[AROS.git] / workbench / c / shellcommands / Else.c
blob58c1f427c5a7c4719177fbe478d9ccf4d82ecdbe
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME
13 Else
15 SYNOPSIS
17 LOCATION
21 FUNCTION
23 Separate the 'true' and 'false' blocks of an If statement. The block
24 following an Else command is executed if the condition in the previous
25 If statement was false.
27 INPUTS
29 RESULT
31 NOTES
33 EXAMPLE
35 If EXISTS Sys:Devs
36 Copy random.device Sys:Devs/
37 Else
38 Echo "Cannot find Sys:Devs"
39 EndIf
41 BUGS
43 SEE ALSO
45 If, EndIf
47 INTERNALS
49 HISTORY
51 12.01.2000 SDuvan implemented
53 ******************************************************************************/
55 #include <dos/dos.h>
56 #include <dos/dosextens.h>
57 #include <dos/rdargs.h>
58 #include <dos/stdio.h>
59 #include <proto/dos.h>
60 #include "dos_commanderrors.h"
62 #include <aros/shcommands.h>
64 AROS_SH0(Else,41.1)
66 AROS_SHCOMMAND_INIT
68 struct CommandLineInterface *cli = Cli();
71 if ((cli != NULL) && (cli->cli_CurrentInput != cli->cli_StandardInput))
73 BOOL found = FALSE;
74 int level = 1;
75 char buffer[256];
76 int a = 0;
78 SelectInput(cli->cli_CurrentInput);
80 while (!found)
82 LONG status;
83 int temp;
85 status = ReadItem(buffer, sizeof(buffer), NULL);
87 if (status == ITEM_ERROR)
88 break;
90 if (status == ITEM_NOTHING)
92 if (a == ENDSTREAMCH)
93 break;
94 else
95 goto next;
98 switch ((temp = FindArg("IF,ENDIF", buffer)))
100 case 0:
101 level++;
102 break;
104 case 1:
105 level--;
107 if (level == 0)
109 found = TRUE;
112 break;
115 next:
116 /* Take care of long and empty lines */
119 a = FGetC(Input());
120 } while(a != '\n' && a != ENDSTREAMCH);
124 if (!found)
126 PrintFault(ERROR_NO_MATCHING_ELSEENDIF, "Else");
128 return RETURN_FAIL;
131 else
133 PrintFault(ERROR_SCRIPT_ONLY, "Else");
135 return RETURN_ERROR;
138 return RETURN_OK;
140 AROS_SHCOMMAND_EXIT