Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / dos / setprogramname.c
blobd948d63af9d16cb0859d4a258434b0a4ae2af436
1 /*
2 Copyright © 1995-2008, 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(CONST_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
56 return internal_SetProgramName(Cli(), name, DOSBase) ? DOSTRUE : DOSFALSE;
58 AROS_LIBFUNC_EXIT
59 } /* SetProgramName */
62 BOOL internal_SetProgramName(struct CommandLineInterface *cli,
63 CONST_STRPTR name, struct DosLibrary *DOSBase)
65 CONST_STRPTR s;
66 STRPTR bs;
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 bs = AROS_BSTR_ADDR(cli->cli_CommandName);
88 AROS_BSTR_setstrlen(cli->cli_CommandName, namelen);
89 CopyMem((APTR)name, bs, namelen);
91 return TRUE;