emul-handler: fh_Arg1 should be the only element of struct FileHandle touched during...
[AROS.git] / rom / dos / getprompt.c
blob7c0ab522af93397ba81bc27ca954198eb598529a
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Get the current prompt.
6 Lang: english
7 */
8 #include <aros/debug.h>
10 #include <proto/exec.h>
11 #include <dos/dos.h>
12 #include "dos_intern.h"
13 #include <string.h>
15 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH2(BOOL, GetPrompt,
22 /* SYNOPSIS */
23 AROS_LHA(STRPTR, buf, D1),
24 AROS_LHA(LONG , len, D2),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 98, Dos)
29 /* FUNCTION
30 Copies the prompt from the CLI structure into the buffer. If the
31 buffer is too small the name is truncated, and a failure is returned.
32 If the current process doesn't have a CLI structure, a 0 length string
33 is put into the buffer and a failure is returned.
35 INPUTS
36 buf - Buffer for the prompt.
37 len - Size of the buffer in bytes.
39 RESULT
40 !=0 on success, 0 on failure. IoErr() gives additional information
41 in that case.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 SetPrompt()
52 INTERNALS
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
58 struct Process *me = (struct Process *)FindTask(NULL);
59 struct CommandLineInterface *cli = BADDR(me->pr_CLI);
60 STRPTR cname;
61 ULONG clen;
62 BOOL ret = DOSTRUE;
64 ASSERT_VALID_PROCESS(me);
66 if (cli == NULL)
68 if (len >= 1)
69 buf[0] = '\0';
70 me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE;
71 return DOSFALSE;
74 cname = AROS_BSTR_ADDR(cli->cli_Prompt);
75 clen = (ULONG)AROS_BSTR_strlen(cli->cli_Prompt);
76 if (clen >= (len-1))
78 clen = len-1;
79 me->pr_Result2 = ERROR_LINE_TOO_LONG;
80 ret = DOSFALSE;
82 CopyMem(cname, buf, clen);
83 buf[clen] = '\0';
85 return ret;
86 AROS_LIBFUNC_EXIT
87 } /* GetPrompt */