Home | History | Annotate | Line # | Download | only in menuc
      1  1.11  mbalmer /*	$NetBSD: main.c,v 1.11 2012/03/06 16:55:18 mbalmer Exp $	*/
      2   1.1     phil 
      3   1.1     phil /*
      4   1.1     phil  * Copyright 1997 Piermont Information Systems Inc.
      5   1.1     phil  * All rights reserved.
      6   1.1     phil  *
      7   1.1     phil  * Written by Philip A. Nelson for Piermont Information Systems Inc.
      8   1.1     phil  *
      9   1.1     phil  * Redistribution and use in source and binary forms, with or without
     10   1.1     phil  * modification, are permitted provided that the following conditions
     11   1.1     phil  * are met:
     12   1.1     phil  * 1. Redistributions of source code must retain the above copyright
     13   1.1     phil  *    notice, this list of conditions and the following disclaimer.
     14   1.1     phil  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1     phil  *    notice, this list of conditions and the following disclaimer in the
     16   1.1     phil  *    documentation and/or other materials provided with the distribution.
     17  1.11  mbalmer  * 3. The name of Piermont Information Systems Inc. may not be used to endorse
     18   1.1     phil  *    or promote products derived from this software without specific prior
     19   1.1     phil  *    written permission.
     20   1.1     phil  *
     21   1.1     phil  * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
     22   1.1     phil  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23   1.1     phil  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24   1.1     phil  * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
     25   1.1     phil  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26   1.1     phil  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27   1.1     phil  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28   1.1     phil  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29   1.1     phil  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30   1.1     phil  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31   1.1     phil  * THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1     phil  *
     33   1.1     phil  */
     34   1.1     phil 
     35   1.1     phil /* main.c - main program for menu compiler. */
     36   1.8      agc 
     37  1.10      jmc #if HAVE_NBTOOL_CONFIG_H
     38  1.10      jmc #include "nbtool_config.h"
     39  1.10      jmc #endif
     40  1.10      jmc 
     41   1.8      agc #include <sys/cdefs.h>
     42   1.8      agc 
     43   1.9    lukem #if defined(__RCSID) && !defined(lint)
     44  1.11  mbalmer __RCSID("$NetBSD: main.c,v 1.11 2012/03/06 16:55:18 mbalmer Exp $");
     45   1.8      agc #endif
     46   1.8      agc 
     47   1.1     phil 
     48   1.1     phil #include <stdio.h>
     49   1.7     matt #include <stdlib.h>
     50   1.4    perry #include <unistd.h>
     51   1.1     phil 
     52   1.1     phil #define MAIN
     53   1.1     phil #include "defs.h"
     54   1.1     phil 
     55   1.1     phil /* Local prototypes */
     56  1.11  mbalmer __dead void usage(void);
     57   1.1     phil 
     58   1.1     phil int
     59  1.11  mbalmer main(int argc, char **argv)
     60   1.1     phil {
     61   1.1     phil 	int ch;
     62   1.1     phil 
     63   1.1     phil 	/* Process the arguments. */
     64  1.11  mbalmer 	while ((ch = getopt(argc, argv, "o:")) != -1 ) {
     65   1.1     phil 		switch (ch) {
     66   1.1     phil 		case 'o': /* output file name */
     67   1.1     phil 			out_name = optarg;
     68   1.1     phil 			break;
     69   1.1     phil 		default:
     70  1.11  mbalmer 			usage();
     71   1.1     phil 		}
     72   1.1     phil 	}
     73   1.1     phil 
     74  1.11  mbalmer 	if (optind != argc - 1)
     75  1.11  mbalmer 		usage();
     76   1.1     phil 
     77   1.1     phil 	src_name = argv[optind];
     78   1.1     phil 
     79  1.11  mbalmer 	yyin = fopen(src_name, "r");
     80   1.1     phil 	if (yyin == NULL) {
     81  1.11  mbalmer 		(void)fprintf(stderr, "%s: could not open %s.\n", prog_name,
     82  1.11  mbalmer 		    src_name);
     83  1.11  mbalmer 		exit(1);
     84   1.1     phil 	}
     85   1.1     phil 
     86   1.1     phil 	/* The default menu */
     87   1.1     phil 	default_menu.info = &default_info;
     88   1.1     phil 	default_info.title = "\"\"";
     89   1.5      cgd 	default_info.helpstr = NULL;
     90   1.5      cgd 	default_info.exitstr = NULL;
     91   1.1     phil 	default_info.mopt = 0;
     92   1.6      cgd 	default_info.x = -1;
     93   1.1     phil 	default_info.y = 0;
     94   1.1     phil 	default_info.h = 0;
     95   1.1     phil 	default_info.w = 0;
     96   1.1     phil 	default_info.numopt = 0;
     97   1.1     phil 	default_info.optns = NULL;
     98   1.1     phil 	default_info.postact.code = NULL;
     99   1.1     phil 	default_info.postact.endwin = FALSE;
    100   1.1     phil 	default_info.exitact.code = NULL;
    101   1.1     phil 	default_info.exitact.endwin = FALSE;
    102   1.1     phil 
    103   1.1     phil 	/* Do the parse */
    104  1.11  mbalmer 	(void)yyparse();
    105   1.1     phil 
    106  1.11  mbalmer 	return had_errors ? 1 : 0;
    107   1.1     phil }
    108   1.1     phil 
    109   1.1     phil 
    110  1.11  mbalmer __dead void
    111  1.11  mbalmer usage(void)
    112   1.1     phil {
    113  1.11  mbalmer 	(void)fprintf (stderr, "%s [-o name] file\n", getprogname());
    114  1.11  mbalmer 	exit(1);
    115   1.1     phil }
    116