From 4412ca091e6379def8bc836163c6b580df76619c Mon Sep 17 00:00:00 2001 From: crunchy Date: Wed, 23 Apr 2003 08:34:01 +0000 Subject: start restructuring --- mpiosh/global.c | 4 ++-- mpiosh/readline.c | 25 ++++++++++++++++++++++++- mpiosh/readline.h | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'mpiosh') diff --git a/mpiosh/global.c b/mpiosh/global.c index 0047627..e1215f1 100644 --- a/mpiosh/global.c +++ b/mpiosh/global.c @@ -2,7 +2,7 @@ * * Author: Andreas Buesching * - * $Id: global.c,v 1.11 2003/04/19 23:58:02 germeier Exp $ + * $Id: global.c,v 1.12 2003/04/23 08:34:15 crunchy Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -125,7 +125,7 @@ struct mpiosh_cmd_t commands[] = { mpiosh_cmd_health, NULL }, { "id3", NULL, "[]", " enable/disable ID3 rewriting support", - mpiosh_cmd_id3, NULL }, + mpiosh_cmd_id3, mpiosh_readline_comp_onoff }, { "id3_format", NULL, "[]", " define/show the format line for ID3 rewriting", mpiosh_cmd_id3_format, NULL }, diff --git a/mpiosh/readline.c b/mpiosh/readline.c index d10209b..afc78c0 100644 --- a/mpiosh/readline.c +++ b/mpiosh/readline.c @@ -2,7 +2,7 @@ * * Author: Andreas Büsching * - * $Id: readline.c,v 1.6 2003/04/06 23:09:20 germeier Exp $ + * $Id: readline.c,v 1.7 2003/04/23 08:34:16 crunchy Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -38,6 +38,29 @@ mpiosh_readline_init(void) rl_event_hook = mpiosh_readline_cancel; } +char * +mpiosh_readline_comp_onoff(const char *text, int state) +{ + static const char * states[] = { "on", "off", NULL }; + static const char ** st = states; + const char * ret = NULL; + + if (state == 0) { + st = states; + } + + while (*st) { + if (!strncmp(text, *st, strlen(text))) { + ret = *st; + st++; + break; + } + st++; + } + + return (ret ? strdup(ret) : NULL); +} + char * mpiosh_readline_comp_cmd(const char *text, int state) { diff --git a/mpiosh/readline.h b/mpiosh/readline.h index f4deb13..a0bb08a 100644 --- a/mpiosh/readline.h +++ b/mpiosh/readline.h @@ -2,7 +2,7 @@ * * Author: Andreas Büsching * - * $Id: readline.h,v 1.2 2002/10/18 08:39:23 crunchy Exp $ + * $Id: readline.h,v 1.3 2003/04/23 08:34:16 crunchy Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -38,6 +38,7 @@ void mpiosh_readline_pipe(void); int mpiosh_readline_cancel(void); char *mpiosh_readline_comp_cmd(const char *text, int state); +char *mpiosh_readline_comp_onoff(const char *text, int state); char *mpiosh_readline_comp_mpio_file(const char *text, int state); char *mpiosh_readline_comp_config(const char *text, int state); -- cgit v1.2.3