Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / dos / getprogramname.c
blob6b3438ca731c8925201499fade8ade974e65fcf8
1 /*
2 Copyright © 1995-2007, 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
57 struct Process *me = (struct Process *)FindTask(NULL);
58 struct CommandLineInterface *cli = BADDR(me->pr_CLI);
59 STRPTR cname;
60 ULONG clen;
61 BOOL ret = DOSTRUE;
63 if (cli == NULL)
65 *buf = '\0';
66 me->pr_Result2 = ERROR_OBJECT_WRONG_TYPE;
67 return DOSFALSE;
70 cname = AROS_BSTR_ADDR(cli->cli_CommandName);
71 clen = (ULONG)AROS_BSTR_strlen(cli->cli_CommandName);
72 if (clen >= (len-1))
74 clen = len-1;
75 me->pr_Result2 = ERROR_LINE_TOO_LONG;
76 ret = DOSFALSE;
78 CopyMem(cname, buf, clen);
79 buf[clen] = '\0';
81 return ret;
82 AROS_LIBFUNC_EXIT
83 } /* GetProgramName */