2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/digiio.h>
36 #include <sys/ioctl.h>
40 usage(const char *prog)
42 fprintf(stderr, "Usage: %s [-d debug] [-ir] device...\n", prog);
47 main(int argc, char **argv)
49 char namedata[256], *name = namedata;
51 enum digi_model model;
52 int ch, debug, fd, i, res;
53 int dflag, iflag, rflag;
55 if ((prog = strrchr(argv[0], '/')) == NULL)
60 dflag = iflag = rflag = 0;
61 while ((ch = getopt(argc, argv, "d:ir")) != -1)
81 for (i = optind; i < argc; i++) {
82 if ((fd = open(argv[i], O_RDONLY)) == -1) {
83 fprintf(stderr, "%s: %s: open: %s\n", prog, argv[i],
89 if (dflag && ioctl(fd, DIGIIO_DEBUG, &debug) != 0) {
90 fprintf(stderr, "%s: %s: debug: %s\n",
91 prog, argv[i], strerror(errno));
96 if (ioctl(fd, DIGIIO_MODEL, &model) != 0) {
97 fprintf(stderr, "%s: %s: model: %s\n",
98 prog, argv[i], strerror(errno));
100 } else if (ioctl(fd, DIGIIO_IDENT, &name) != 0) {
101 fprintf(stderr, "%s: %s: ident: %s\n",
102 prog, argv[i], strerror(errno));
105 printf("%s: %s (type %d)\n",
106 argv[i], name, (int)model);
109 if (rflag && ioctl(fd, DIGIIO_REINIT) != 0) {
110 fprintf(stderr, "%s: %s: reinit: %s\n",
111 prog, argv[i], strerror(errno));