added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / dos / setprogramname.c
blob6583f9629e9858f73746117dee0b85999d447ccf
1 /*
2 Copyright © 1995-2007, 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
56 return internal_SetProgramName(Cli(), name, DOSBase) ? DOSTRUE : DOSFALSE;
58 AROS_LIBFUNC_EXIT
59 } /* SetProgramName */
62 BOOL internal_SetProgramName(struct CommandLineInterface *cli, STRPTR name,
63 struct DosLibrary *DOSBase)
65 STRPTR s;
66 ULONG namelen;
68 if (cli == NULL)
70 return FALSE;
73 s = name;
75 while(*s++)
78 namelen = s - name - 1;
80 if (namelen > 255)
82 return FALSE;
85 s = AROS_BSTR_ADDR(cli->cli_CommandName);
87 AROS_BSTR_setstrlen(cli->cli_CommandName, namelen);
88 CopyMem((APTR)name, s, namelen);
90 return TRUE;