xref: /titanic_51/usr/src/lib/libxcurses/src/libc/mks/getsyntx.c (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Dummy version of getsyntx() from C/370.
31  * This version simply uses the external variable VARIANTS, and assigns them
32  * to the variant structure.
33  * This is a dummy routine, that would not actually run on any production
34  * system.
35  *
36  * Copyright 1993 by Mortice Kern Systems Inc.  All rights reserved.
37  *
38  */
39 #ifdef M_RCSID
40 #ifndef lint
41 static char const rcsID[] = "$Header: /rd/src/libc/mks/rcs/getsyntx.c 1.4 1995/04/19 23:04:55 ross Exp $";
42 #endif /* lint */
43 #endif /* M_RCSID */
44 
45 #include <mks.h>
46 #include <variant.h>
47 #include <stdlib.h>
48 
49 struct variant *
50 getsyntx(void)
51 {
52 	static struct variant v;
53 	static char const var[] = "\\][}{^~!#|$@`";
54 	char const *e;
55 
56 	if ((e = __m_getenv("VARIANTS")) == NULL || *e == '\0')
57 		e = var;
58 	else if (strlen(e) != 13) {
59 		m_error("getsyntx: environment variable VARIANTS: must be exactly 13 bytes long");
60 		return NULL;
61 	}
62 	v.backslash = e[0];
63 	v.right_bracket = e[1];
64 	v.left_bracket = e[2];
65 	v.right_brace = e[3];
66 	v.left_brace = e[4];
67 	v.circumflex = e[5];
68 	v.tilde = e[6];
69 	v.exclamation_mark = e[7];
70 	v.number_sign = e[8];
71 	v.vertical_line = e[9];
72 	v.dollar_sign = e[10];
73 	v.commercial_at = e[11];
74 	v.grave_accent = e[12];
75 	return &v;
76 }
77