Fixed out-by-one error in previous commit.
[AROS.git] / workbench / c / AddBuffers.c
blob1294b5c064f2ba56ba94ed623c6ede2ff62cd9b5
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: AddBuffers CLI command
6 Lang: English
7 */
10 /******************************************************************************
12 NAME
14 AddBuffers (drive) [(N)]
16 SYNOPSIS
18 DRIVE/A, BUFFERS/N
20 LOCATION
24 FUNCTION
26 Add buffers to the list of available buffers for a specific
27 drive. Adding buffers speeds disk access but has the drawback
28 of using up system memory (512 bytes per buffer). Specifying
29 a negative number subtracts buffers from the drive.
30 If only the DRIVE argument is specified, the number of
31 buffers for that drive are displayed without changing the buffer
32 allocation.
34 INPUTS
36 DRIVE -- the drive to alter the buffer allocation of
37 BUFFERS -- the number of buffers to add (or subtract in case of
38 a negative number) to a drive.
40 RESULT
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 HISTORY
54 ******************************************************************************/
56 #include <proto/dos.h>
57 #include <dos/dos.h>
60 const TEXT version[] = "$VER: AddBuffers 41.1 (18.2.1997)\n";
62 #define ARG_TEMPLATE "DRIVE/A,BUFFERS/N"
64 enum
66 ARG_DRIVE = 0,
67 ARG_BUFFERS,
68 NOOFARGS
72 int __nocommandline = 1;
74 int main(void)
76 IPTR args[NOOFARGS] = { (IPTR)NULL, (IPTR)0 };
77 struct RDArgs *rda;
79 int result;
80 int error = RETURN_OK;
81 ULONG buffers = 0;
83 rda = ReadArgs(ARG_TEMPLATE, args, NULL);
85 if (rda != NULL)
87 STRPTR drive = (STRPTR)args[ARG_DRIVE];
88 ULONG *bufsptr = (ULONG *)args[ARG_BUFFERS];
90 if (bufsptr != NULL)
92 buffers = *bufsptr;
95 result = AddBuffers(drive, buffers);
97 if (result == -1)
99 Printf("%s has %ld buffers\n", drive, IoErr());
101 else if (result > 0)
103 Printf("%s has %ld buffers\n", drive, (LONG)result);
105 else
107 PrintFault(IoErr(), "AddBuffers");
108 error = RETURN_FAIL;
111 FreeArgs(rda);
113 else
115 PrintFault(IoErr(), "AddBuffers");
116 error = RETURN_FAIL;
119 return error;