diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/chio/Makefile | 4 | ||||
-rw-r--r-- | bin/chio/chio.1 | 4 | ||||
-rw-r--r-- | bin/chio/chio.c | 35 |
3 files changed, 27 insertions, 16 deletions
diff --git a/bin/chio/Makefile b/bin/chio/Makefile index 7f56f9e..f5d2d78 100644 --- a/bin/chio/Makefile +++ b/bin/chio/Makefile @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.2 1997/09/12 15:00:06 jkh Exp $ +# $Id: Makefile,v 1.3 1998/09/15 07:48:51 gibbs Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -CFLAGS+=-I${.CURDIR}/../../sys +CFLAGS+=-I${.CURDIR}/../../sys -W -Wall PROG= chio SRCS= chio.c diff --git a/bin/chio/chio.1 b/bin/chio/chio.1 index 27fee8d..344b587 100644 --- a/bin/chio/chio.1 +++ b/bin/chio/chio.1 @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: chio.1,v 1.7 1998/09/15 07:48:51 gibbs Exp $ +.\" $Id: chio.1,v 1.8 1998/11/30 23:05:38 billf Exp $ .\" .Dd May 14, 1998 .Dt CHIO 1 @@ -135,7 +135,7 @@ respectively. .Pp Note that not all medium changers support the .Ic exchange -operation; The changer must have multiple free pickers or emulate +operation; the changer must have multiple free pickers or emulate multiple free pickers with transient storage. .It Xo Nm position .Ar <to ET> <to EU> diff --git a/bin/chio/chio.c b/bin/chio/chio.c index fb82fe6..3601649 100644 --- a/bin/chio/chio.c +++ b/bin/chio/chio.c @@ -77,23 +77,23 @@ static int do_voltag(char *, int, char **); /* Valid changer element types. */ const struct element_type elements[] = { + { "drive", CHET_DT }, { "picker", CHET_MT }, - { "slot", CHET_ST }, { "portal", CHET_IE }, - { "drive", CHET_DT }, + { "slot", CHET_ST }, { NULL, 0 }, }; /* Valid commands. */ const struct changer_command commands[] = { - { "move", do_move }, { "exchange", do_exchange }, - { "position", do_position }, - { "params", do_params }, { "getpicker", do_getpicker }, + { "ielem", do_ielem }, + { "move", do_move }, + { "params", do_params }, + { "position", do_position }, { "setpicker", do_setpicker }, { "status", do_status }, - { "ielem", do_ielem }, { "voltag", do_voltag }, { NULL, 0 }, }; @@ -147,6 +147,14 @@ main(int argc, char *argv[]) for (i = 0; commands[i].cc_name != NULL; ++i) if (strcmp(*argv, commands[i].cc_name) == 0) break; + if (commands[i].cc_name == NULL) { + /* look for abbreviation */ + for (i = 0; commands[i].cc_name != NULL; ++i) + if (strncmp(*argv, commands[i].cc_name, + strlen(*argv)) == 0) + break; + } + if (commands[i].cc_name == NULL) errx(1, "unknown command: %s", *argv); @@ -881,7 +889,9 @@ bits_to_string(int v, const char *cp) np++; if ((v & (1 << (f - 1))) == 0) continue; - bp += sprintf(bp, "%c%.*s", sep, (int)(long)(np - cp), cp); + (void) snprintf(bp, sizeof(buf) - (bp - &buf[0]), + "%c%.*s", sep, (int)(long)(np - cp), cp); + bp += strlen(bp); sep = ','; } if (sep != '<') @@ -900,11 +910,12 @@ cleanup() static void usage() { + int i; - (void) fprintf(stderr, "usage: %s command arg1 arg2 ...\n", __progname); - (void) fprintf(stderr, "Examples:\n"); - (void) fprintf(stderr, "\tchio -f /dev/ch0 move slot 1 drive 0\n"); - (void) fprintf(stderr, "\tchio ielem\n"); - (void) fprintf(stderr, "\tchio -f /dev/ch1 status\n"); + (void) fprintf(stderr, "usage: %s [-f device] command [-<flags>] [args ...]\n", __progname); + (void) fprintf(stderr, "commands:"); + for (i = 0; commands[i].cc_name; i++) + (void) fprintf(stderr, " %s", commands[i].cc_name); + (void) fprintf(stderr, "\n"); exit(1); } |