New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / dos / getprogramname.c
blob1fba8ff5df6b6e2025ef4bbc5238034accc47c69
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Get the name of the current program.
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include <dos/dos.h>
10 #include "dos_intern.h"
11 #include <string.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH2(BOOL, GetProgramName,
20 /* SYNOPSIS */
21 AROS_LHA(STRPTR, buf, D1),
22 AROS_LHA(LONG , len, D2),
24 /* LOCATION */
25 struct DosLibrary *, DOSBase, 96, Dos)
27 /* FUNCTION
28 Copies the name of the current program from the CLI structure
29 into the buffer. If the buffer is too small the name is truncated,
30 and a failure is returned. If the current process doesn't have
31 a CLI structure, a 0 length string is put into the buffer and a
32 failure is returned.
34 INPUTS
35 buf - Buffer for the name.
36 len - Size of the buffer in bytes.
38 RESULT
39 !=0 on success, 0 on failure. IoErr() gives additional information
40 in that case.
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 SetProgramName()
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
56 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
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 if (cli == NULL)
66 *buf = '\0';
67 me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE;
68 return DOSFALSE;
71 cname = AROS_BSTR_ADDR(cli->cli_CommandName);
72 clen = (ULONG)AROS_BSTR_strlen(cli->cli_CommandName);
73 if (clen >= (len-1))
75 clen = len-1;
76 me->pr_Result2 = ERROR_LINE_TOO_LONG;
77 ret = DOSFALSE;
79 CopyMem(cname, buf, clen);
80 buf[clen] = '\0';
82 return ret;
83 AROS_LIBFUNC_EXIT
84 } /* GetProgramName */