open-src/app/cmap_compact/sun-src/cmc.c
author X gate hg captive account <xhg@xserver.us.oracle.com>
Wed, 19 Aug 2015 13:48:41 -0700
changeset 1484 bc8922b8e1d2
parent 1233 1134c9fd2fe6
permissions -rw-r--r--
Added tag s11u3_30 for changeset 221e9d9cc9cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
     1
/*
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
     2
*
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
     3
* Copyright (c) 1990, 2011, Oracle and/or its affiliates. All rights reserved.
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
     4
*
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
     5
* Permission is hereby granted, free of charge, to any person obtaining a
919
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
     6
* copy of this software and associated documentation files (the "Software"),
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
     7
* to deal in the Software without restriction, including without limitation
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
     8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
     9
* and/or sell copies of the Software, and to permit persons to whom the
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    10
* Software is furnished to do so, subject to the following conditions:
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    11
*
919
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    12
* The above copyright notice and this permission notice (including the next
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    13
* paragraph) shall be included in all copies or substantial portions of the
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    14
* Software.
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    15
*
919
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    19
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
425233ae7236 6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents: 907
diff changeset
    22
* DEALINGS IN THE SOFTWARE.
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    23
*
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    24
*/
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    25
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    26
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    27
#include <stdio.h>
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    28
#include <stdarg.h>
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    29
#include <string.h>
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    30
#include "cmc.h"
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    31
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    32
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    33
/*
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    34
** Options and Arguments
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    35
*/
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    36
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    37
char	*display_name 	= NULL;		/* -display */
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    38
int	warn_flag	= 0;		/* -warn */
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    39
char	*basename_arg 	= NULL;		/* optional argument */
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    40
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    41
char *program;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    42
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    43
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    44
void
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    45
fatal_error (const char *format, ...)
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    46
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    47
{
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    48
	va_list args;
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    49
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    50
	va_start(args, format);
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    51
	(void) fprintf(stderr, "%s: error: ", program);
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    52
	(void) vfprintf(stderr, format, args);
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    53
	(void) fprintf(stderr, "\n");
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    54
	va_end(args);
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    55
	exit(1);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    56
}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    57
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    58
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    59
void
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    60
warning (const char *format, ...)
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    61
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    62
{
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    63
	va_list args;
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    64
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    65
	va_start(args, format);
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    66
	(void) fprintf(stderr, "Warning: ");
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    67
	(void) vfprintf(stderr, format, args);
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    68
	(void) fprintf(stderr, "\n");
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    69
	va_end(args);
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    70
	exit(1);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    71
}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    72
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    73
static void
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    74
usage ()
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    75
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    76
{
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    77
	/* Note: optional filename arg explicitly not documented */
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    78
	fprintf(stderr, "usage: %s <op> [-display name] [-warn]\n", program);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    79
	fprintf(stderr, "<op> = save | init | discard | dealloc | show | NeWSinit\n");
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    80
	exit(1);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    81
}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    82
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    83
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    84
/* 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    85
** Parse arguments 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    86
*/
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    87
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    88
void
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    89
process_arguments (argv)
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    90
char	**argv;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    91
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    92
{
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    93
	register char	**a;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    94
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    95
	for (a = argv; *a; a++) {
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    96
		if (**a == '-') {
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    97
			if        (!strcmp(*a, "-warn")) {
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
    98
			    warn_flag = 1;
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
    99
			} else if (!strcmp(*a, "-display")) {
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   100
			    if (*++a)
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   101
				display_name = *a;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   102
			    else {
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   103
				fprintf(stderr, "error: -display needs an argument\n");
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   104
				usage();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   105
			    }
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   106
			} else {
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   107
				fprintf(stderr, "error: unrecognized option '%s'\n", *a);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   108
				usage();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   109
			}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   110
	        } else {
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
   111
		    if (basename_arg) {
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   112
			fprintf(stderr, "error: unrecognized argument '%s'\n", *a);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   113
			usage();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   114
		    } else
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
   115
			basename_arg = *a;
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   116
		}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   117
	}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   118
}
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   119
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   120
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   121
/*ARGSUSED*/
1233
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
   122
int
1134c9fd2fe6 7125797 Fix crufty code complaints uncovered by xorg-macros new tougher defaults
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents: 943
diff changeset
   123
main (int argc, char **argv)
550
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   124
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   125
{
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   126
	void	(*op)();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   127
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   128
	/* Initialize error handling */
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   129
	program = argv[0];
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   130
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   131
	/* determine operation */
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   132
	if (argc <= 1)
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   133
		usage();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   134
	++argv;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   135
	if      (!strcmp("save", *argv)) 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   136
		op = cmc_save;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   137
	else if (!strcmp("init", *argv)) 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   138
		op = cmc_init;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   139
	else if (!strcmp("show", *argv)) 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   140
		op = cmc_show;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   141
	else if (!strcmp("discard", *argv)) 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   142
		op = cmc_discard;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   143
	else if (!strcmp("dealloc", *argv)) 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   144
		op = cmc_dealloc;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   145
	else if (!strcmp("NeWSinit", *argv)) 
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   146
		op = cmc_NeWSinit;
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   147
	else
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   148
		usage();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   149
	
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   150
	/* parse rest of arguments */
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   151
	process_arguments(++argv);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   152
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   153
	/* invoke operation */
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   154
	op();
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   155
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   156
	exit(0);
3b62053c3b77 6730028 Moving /usr/openwin/lib/mkcookie to /usr/X11/lib
Sam Lau <Sam.Lau@Sun.COM>
parents:
diff changeset
   157
}