1*5cd43bc6Smbalmer /* $NetBSD: main.c,v 1.11 2012/03/06 16:55:18 mbalmer Exp $ */
295f3bf39Sphil
395f3bf39Sphil /*
495f3bf39Sphil * Copyright 1997 Piermont Information Systems Inc.
595f3bf39Sphil * All rights reserved.
695f3bf39Sphil *
795f3bf39Sphil * Written by Philip A. Nelson for Piermont Information Systems Inc.
895f3bf39Sphil *
995f3bf39Sphil * Redistribution and use in source and binary forms, with or without
1095f3bf39Sphil * modification, are permitted provided that the following conditions
1195f3bf39Sphil * are met:
1295f3bf39Sphil * 1. Redistributions of source code must retain the above copyright
1395f3bf39Sphil * notice, this list of conditions and the following disclaimer.
1495f3bf39Sphil * 2. Redistributions in binary form must reproduce the above copyright
1595f3bf39Sphil * notice, this list of conditions and the following disclaimer in the
1695f3bf39Sphil * documentation and/or other materials provided with the distribution.
17*5cd43bc6Smbalmer * 3. The name of Piermont Information Systems Inc. may not be used to endorse
1895f3bf39Sphil * or promote products derived from this software without specific prior
1995f3bf39Sphil * written permission.
2095f3bf39Sphil *
2195f3bf39Sphil * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
2295f3bf39Sphil * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2395f3bf39Sphil * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2495f3bf39Sphil * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
2595f3bf39Sphil * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2695f3bf39Sphil * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2795f3bf39Sphil * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2895f3bf39Sphil * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2995f3bf39Sphil * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3095f3bf39Sphil * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3195f3bf39Sphil * THE POSSIBILITY OF SUCH DAMAGE.
3295f3bf39Sphil *
3395f3bf39Sphil */
3495f3bf39Sphil
3595f3bf39Sphil /* main.c - main program for menu compiler. */
3695f3bf39Sphil
37b2f78261Sjmc #if HAVE_NBTOOL_CONFIG_H
38b2f78261Sjmc #include "nbtool_config.h"
39b2f78261Sjmc #endif
40b2f78261Sjmc
41a8d6388eSagc #include <sys/cdefs.h>
42a8d6388eSagc
43abcf838dSlukem #if defined(__RCSID) && !defined(lint)
44*5cd43bc6Smbalmer __RCSID("$NetBSD: main.c,v 1.11 2012/03/06 16:55:18 mbalmer Exp $");
45a8d6388eSagc #endif
46a8d6388eSagc
47a8d6388eSagc
4895f3bf39Sphil #include <stdio.h>
49fcd0fb11Smatt #include <stdlib.h>
50cb66b175Sperry #include <unistd.h>
5195f3bf39Sphil
5295f3bf39Sphil #define MAIN
5395f3bf39Sphil #include "defs.h"
5495f3bf39Sphil
5595f3bf39Sphil /* Local prototypes */
56*5cd43bc6Smbalmer __dead void usage(void);
5795f3bf39Sphil
5895f3bf39Sphil int
main(int argc,char ** argv)5995f3bf39Sphil main(int argc, char **argv)
6095f3bf39Sphil {
6195f3bf39Sphil int ch;
6295f3bf39Sphil
6395f3bf39Sphil /* Process the arguments. */
641519255eSlukem while ((ch = getopt(argc, argv, "o:")) != -1 ) {
6595f3bf39Sphil switch (ch) {
6695f3bf39Sphil case 'o': /* output file name */
6795f3bf39Sphil out_name = optarg;
6895f3bf39Sphil break;
6995f3bf39Sphil default:
70*5cd43bc6Smbalmer usage();
7195f3bf39Sphil }
7295f3bf39Sphil }
7395f3bf39Sphil
7495f3bf39Sphil if (optind != argc - 1)
75*5cd43bc6Smbalmer usage();
7695f3bf39Sphil
7795f3bf39Sphil src_name = argv[optind];
7895f3bf39Sphil
7995f3bf39Sphil yyin = fopen(src_name, "r");
8095f3bf39Sphil if (yyin == NULL) {
81*5cd43bc6Smbalmer (void)fprintf(stderr, "%s: could not open %s.\n", prog_name,
82*5cd43bc6Smbalmer src_name);
8395f3bf39Sphil exit(1);
8495f3bf39Sphil }
8595f3bf39Sphil
8695f3bf39Sphil /* The default menu */
8795f3bf39Sphil default_menu.info = &default_info;
8895f3bf39Sphil default_info.title = "\"\"";
89b12d2926Scgd default_info.helpstr = NULL;
90b12d2926Scgd default_info.exitstr = NULL;
9195f3bf39Sphil default_info.mopt = 0;
928c3bc73eScgd default_info.x = -1;
9395f3bf39Sphil default_info.y = 0;
9495f3bf39Sphil default_info.h = 0;
9595f3bf39Sphil default_info.w = 0;
9695f3bf39Sphil default_info.numopt = 0;
9795f3bf39Sphil default_info.optns = NULL;
9895f3bf39Sphil default_info.postact.code = NULL;
9995f3bf39Sphil default_info.postact.endwin = FALSE;
10095f3bf39Sphil default_info.exitact.code = NULL;
10195f3bf39Sphil default_info.exitact.endwin = FALSE;
10295f3bf39Sphil
10395f3bf39Sphil /* Do the parse */
10495f3bf39Sphil (void)yyparse();
10595f3bf39Sphil
106*5cd43bc6Smbalmer return had_errors ? 1 : 0;
10795f3bf39Sphil }
10895f3bf39Sphil
10995f3bf39Sphil
110*5cd43bc6Smbalmer __dead void
usage(void)111*5cd43bc6Smbalmer usage(void)
11295f3bf39Sphil {
113*5cd43bc6Smbalmer (void)fprintf (stderr, "%s [-o name] file\n", getprogname());
11495f3bf39Sphil exit(1);
11595f3bf39Sphil }
116