use m4_normalize on the output strings to remove trailing spaces/tabs and consolidate...
[AROS.git] / workbench / c / shellcommands / Stack.c
blob270037bdd4fe7a514ddda91e6ac096ff4e1c46cd
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Stack CLI command
6 Lang: English
7 */
9 /**************************************************************************
11 NAME
12 Stack
14 FORMAT
15 Stack [[SIZE] (stack size)]
17 SYNOPSIS
18 SIZE/N
20 LOCATION
23 FUNCTION
24 Stack sets the default stack size of the current Shell. This is the
25 stack size of the commands run from the Shell. If you use Stack
26 without arguments, the current stack size will be written out.
28 EXAMPLE
30 HISTORY
32 1.1.2000 SDuvan implemented (yes, celebration is over -- time for
33 some hard work again -- but I might change to
34 everyday clothes first...)
36 **************************************************************************/
38 #include <exec/types.h>
39 #include <dos/dosextens.h>
40 #include <dos/rdargs.h>
41 #include <proto/dos.h>
43 #include <aros/shcommands.h>
45 #define MINIMUM_STACK_SIZE 2048 /* This is a wild guess and depends on
46 (among other things) how much stack
47 space AROS functions need. */
49 AROS_SH1(Stack, 41.1,
50 AROS_SHA(LONG *, , SIZE,/N,NULL))
52 AROS_SHCOMMAND_INIT
54 int retval = RETURN_OK;
55 struct CommandLineInterface *cli = Cli();
58 /* We must be a Shell to do this operation */
59 if (cli == NULL)
61 return RETURN_FAIL;
64 /* Write out current stack size */
65 if (SHArg(SIZE) == NULL)
67 LONG currentstack = cli->cli_DefaultStack * CLI_DEFAULTSTACK_UNIT;
69 Printf("Current stack size is %ld bytes\n", currentstack);
71 /* Set new stack size */
72 else
74 LONG newSize = *SHArg(SIZE);
76 if (newSize > MINIMUM_STACK_SIZE)
78 cli->cli_DefaultStack = (newSize + CLI_DEFAULTSTACK_UNIT - 1) / CLI_DEFAULTSTACK_UNIT;
80 else
82 PutStr("Requested size is too small.\n");
83 retval = RETURN_ERROR;
87 return retval;
89 AROS_SHCOMMAND_EXIT