Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / setprogramname.c
blob8ac339a4cd14b6fbffa57c31c2a811217d436cf5
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Sets the name of the current program.
6 Lang: English
7 */
8 #include <proto/exec.h>
9 #include <proto/dos.h>
10 #include <dos/dos.h>
11 #include <dos/dosextens.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
16 NAME */
18 #include <proto/dos.h>
20 AROS_LH1(BOOL, SetProgramName,
22 /* SYNOPSIS */
23 AROS_LHA(STRPTR, name, D1),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 95, Dos)
28 /* FUNCTION
29 Sets the name for the current program in the CLI structure. If the
30 name doesn't fit the old name is kept and a failure is returned.
31 If the current process doesn't have a CLI structure this function
32 does nothing.
34 INPUTS
35 name -- Name for the current program.
37 RESULT
38 != 0 on success, 0 on failure.
40 NOTES
42 EXAMPLE
44 BUGS
45 Never copies more than 255 bytes.
47 SEE ALSO
48 GetProgramName()
50 INTERNALS
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
55 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
57 return internal_SetProgramName(Cli(), name, DOSBase) ? DOSTRUE : DOSFALSE;
59 AROS_LIBFUNC_EXIT
60 } /* SetProgramName */
63 BOOL internal_SetProgramName(struct CommandLineInterface *cli, STRPTR name,
64 struct DosLibrary *DOSBase)
66 STRPTR s;
67 ULONG namelen;
69 if (cli == NULL)
71 return FALSE;
74 s = name;
76 while(*s++)
79 namelen = s - name - 1;
81 if (namelen > 255)
83 return FALSE;
86 s = AROS_BSTR_ADDR(cli->cli_CommandName);
88 AROS_BSTR_setstrlen(cli->cli_CommandName, namelen);
89 CopyMem((APTR)name, s, namelen);
91 return TRUE;