1*a2dcb089Ssobrado /* $OpenBSD: main.c,v 1.8 2007/12/30 13:50:43 sobrado Exp $ */
21d588f09Shannken
31d588f09Shannken /*
41d588f09Shannken * Copyright (c) 1996 Juergen Hannken-Illjes
51d588f09Shannken * All rights reserved.
61d588f09Shannken *
71d588f09Shannken * Redistribution and use in source and binary forms, with or without
81d588f09Shannken * modification, are permitted provided that the following conditions
91d588f09Shannken * are met:
101d588f09Shannken * 1. Redistributions of source code must retain the above copyright
111d588f09Shannken * notice, this list of conditions and the following disclaimer.
121d588f09Shannken * 2. Redistributions in binary form must reproduce the above copyright
131d588f09Shannken * notice, this list of conditions and the following disclaimer in the
141d588f09Shannken * documentation and/or other materials provided with the distribution.
151d588f09Shannken * 3. All advertising materials mentioning features or use of this software
161d588f09Shannken * must display the following acknowledgement:
171d588f09Shannken * This product includes software developed for the NetBSD Project
181d588f09Shannken * by Juergen Hannken-Illjes.
191d588f09Shannken * 4. The name of the author may not be used to endorse or promote products
201d588f09Shannken * derived from this software without specific prior written permission.
211d588f09Shannken *
221d588f09Shannken * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231d588f09Shannken * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241d588f09Shannken * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251d588f09Shannken * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261d588f09Shannken * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
271d588f09Shannken * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
281d588f09Shannken * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
291d588f09Shannken * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
301d588f09Shannken * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311d588f09Shannken * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321d588f09Shannken * SUCH DAMAGE.
331d588f09Shannken */
341d588f09Shannken
351d588f09Shannken #include <unistd.h>
361d588f09Shannken #include <stdio.h>
37b1b7cd8fSdavid #include <stdlib.h>
381d588f09Shannken
39c72b5b24Smillert extern void kbd_list(void);
40c72b5b24Smillert extern void kbd_set(char *, int);
411d588f09Shannken
421d588f09Shannken extern char *__progname;
431d588f09Shannken
441d588f09Shannken static void
usage(void)45bc52e260Sderaadt usage(void)
461d588f09Shannken {
47*a2dcb089Ssobrado fprintf(stderr, "usage: %s -l\n", __progname);
48*a2dcb089Ssobrado fprintf(stderr, " %s [-q] name\n", __progname);
491d588f09Shannken exit(1);
501d588f09Shannken }
511d588f09Shannken
524158ce8dSderaadt int
main(int argc,char * argv[])53bc52e260Sderaadt main(int argc, char *argv[])
541d588f09Shannken {
551d588f09Shannken char *optstring = "lq";
561be0d1a8Sderaadt int ch, list_tables = 0, verbose = 1;
571d588f09Shannken
581d588f09Shannken while ((ch = getopt(argc, argv, optstring)) != -1)
591d588f09Shannken switch (ch) {
601d588f09Shannken case 'l':
611d588f09Shannken list_tables = 1;
621d588f09Shannken break;
631d588f09Shannken case 'q':
641d588f09Shannken verbose = 0;
651d588f09Shannken break;
661d588f09Shannken default:
671d588f09Shannken usage();
681d588f09Shannken }
691d588f09Shannken if (argc != optind + list_tables ? 0 : 1)
701d588f09Shannken usage();
711d588f09Shannken
721be0d1a8Sderaadt if (list_tables)
731d588f09Shannken kbd_list();
741be0d1a8Sderaadt else
751d588f09Shannken kbd_set(argv[optind], verbose);
761d588f09Shannken exit(0);
771d588f09Shannken }
78