2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Prompts the user for an input. Possible inputs are y for yes
26 and n or Return for no. Selecting y sets the return code to 5.
30 PROMPT -- the string is displayed in the window
48 ******************************************************************************/
52 #include <proto/exec.h>
53 #include <proto/dos.h>
55 #include <proto/utility.h>
57 #include <aros/shcommands.h>
59 static int stripwhites(char * buffer
);
60 static char * skipwhites(char * buffer
);
63 AROS_SHA(STRPTR
, ,PROMPT
,/A
,NULL
))
69 int error
= RETURN_OK
;
71 struct UtilityBase
*UtilityBase
=
72 (struct UtilityBase
*)OpenLibrary("utility.library", 37);
82 Printf("%s ", SHArg(PROMPT
));
85 if (FGets(Input(), buffer
, 100) == (STRPTR
)buffer
)
90 tmpbuf
= skipwhites(buffer
);
91 tmplen
= stripwhites(tmpbuf
);
99 if (Strnicmp(tmpbuf
, "y", 1) == 0)
104 else if (Strnicmp(tmpbuf
, "n", 1) == 0)
109 else if (tmplen
== 2)
111 if (Strnicmp(tmpbuf
, "no", 2) == 0)
116 else if (tmplen
== 3)
118 if (Strnicmp(tmpbuf
, "yes", 3) == 0)
131 CloseLibrary((struct Library
*)UtilityBase
);
138 static int stripwhites(char * buffer
)
141 len
= strlen(buffer
);
144 (buffer
[len
- 1] == ' ' ||
145 buffer
[len
- 1] == '\t' ||
146 buffer
[len
- 1] == '\n'))
155 static char *skipwhites(char *buffer
)
157 while (buffer
[0] == ' ' || buffer
[0] == '\t')