r9263@lvps87-230-33-50: verhaegs | 2008-10-04 23:31:42 +0200
[AROS.git] / workbench / c / AddBuffers.c
blob3f368fa433260175be3bf7197a6fa912f5758260
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
22 Sys:C
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 <stdio.h>
57 #include <proto/dos.h>
58 #include <dos/dos.h>
61 const TEXT version[] = "$VER: AddBuffers 41.1 (18.2.1997)\n";
63 #define ARG_TEMPLATE "DRIVE/A,BUFFERS/N"
65 enum
67 ARG_DRIVE = 0,
68 ARG_BUFFERS,
69 NOOFARGS
73 int __nocommandline = 1;
75 int main(void)
77 IPTR args[NOOFARGS] = { (IPTR)NULL, (IPTR)0 };
78 struct RDArgs *rda;
80 int result;
81 int error = RETURN_OK;
82 ULONG buffers = 0;
84 rda = ReadArgs(ARG_TEMPLATE, args, NULL);
86 if (rda != NULL)
88 STRPTR drive = (STRPTR)args[ARG_DRIVE];
89 ULONG *bufsptr = (ULONG *)args[ARG_BUFFERS];
91 if (bufsptr != NULL)
93 buffers = *bufsptr;
96 result = AddBuffers(drive, buffers);
98 if (result == -1)
100 Printf("%s has %ld buffers\n", drive, IoErr());
102 else if (result > 0)
104 Printf("%s has %ld buffers\n", drive, (LONG)result);
106 else
108 PrintFault(IoErr(), "AddBuffers");
109 error = RETURN_FAIL;
112 FreeArgs(rda);
114 else
116 PrintFault(IoErr(), "AddBuffers");
117 error = RETURN_FAIL;
120 return error;