summaryrefslogtreecommitdiffstats
path: root/usr.sbin/memcontrol/memcontrol.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1999-07-20 04:33:14 +0000
committermsmith <msmith@FreeBSD.org>1999-07-20 04:33:14 +0000
commit4ec71ddc19200ad2b21ca2c02ea0ea25c3074689 (patch)
tree447d46c32f6877797f5a36d271dcd08b9d34e402 /usr.sbin/memcontrol/memcontrol.c
parentc1740a7c668b438f5027e9d9c522cc524213f0f7 (diff)
downloadFreeBSD-src-4ec71ddc19200ad2b21ca2c02ea0ea25c3074689.zip
FreeBSD-src-4ec71ddc19200ad2b21ca2c02ea0ea25c3074689.tar.gz
Make memcontrol's internal help actually work. No substitute for a real
manpage, but at least now you can get syntax help without resorting to reading the source.
Diffstat (limited to 'usr.sbin/memcontrol/memcontrol.c')
-rw-r--r--usr.sbin/memcontrol/memcontrol.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.sbin/memcontrol/memcontrol.c b/usr.sbin/memcontrol/memcontrol.c
index d52e8af..92f4300 100644
--- a/usr.sbin/memcontrol/memcontrol.c
+++ b/usr.sbin/memcontrol/memcontrol.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: memcontrol.c,v 1.1.1.1 1999/04/07 04:11:14 msmith Exp $
*/
#include <sys/types.h>
@@ -315,11 +315,27 @@ clearfunc(int memfd, int argc, char *argv[])
static void
helpfunc(int memfd, int argc, char *argv[])
{
- help(NULL);
+ help(argv[1]);
}
static void
help(char *what)
{
- errx(1, "help!");
+ int i;
+
+ if (what != NULL) {
+ /* find a function that matches */
+ for (i = 0; functions[i].cmd != NULL; i++)
+ if (!strcmp(what, functions[i].cmd)) {
+ fprintf(stderr, "%s\n", functions[i].desc);
+ return;
+ }
+ fprintf(stderr, "Unknown command '%s'\n", what);
+ }
+
+ /* print general help */
+ fprintf(stderr, "Valid commands are :\n");
+ for (i = 0; functions[i].cmd != NULL; i++)
+ fprintf(stderr, " %s\n", functions[i].cmd);
+ fprintf(stderr, "Use help <command> for command-specific help\n");
}
OpenPOWER on IntegriCloud