xref: /illumos-gate/usr/src/lib/libxcurses/src/libc/mks/getsyntx.c (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 /*
28  * Dummy version of getsyntx() from C/370.
29  * This version simply uses the external variable VARIANTS, and assigns them
30  * to the variant structure.
31  * This is a dummy routine, that would not actually run on any production
32  * system.
33  *
34  * Copyright 1993 by Mortice Kern Systems Inc.  All rights reserved.
35  *
36  */
37 #ifdef M_RCSID
38 #ifndef lint
39 static char const rcsID[] = "$Header: /rd/src/libc/mks/rcs/getsyntx.c 1.4 1995/04/19 23:04:55 ross Exp $";
40 #endif /* lint */
41 #endif /* M_RCSID */
42 
43 #include <mks.h>
44 #include <variant.h>
45 #include <stdlib.h>
46 
47 struct variant *
getsyntx(void)48 getsyntx(void)
49 {
50 	static struct variant v;
51 	static char const var[] = "\\][}{^~!#|$@`";
52 	char const *e;
53 
54 	if ((e = __m_getenv("VARIANTS")) == NULL || *e == '\0')
55 		e = var;
56 	else if (strlen(e) != 13) {
57 		m_error("getsyntx: environment variable VARIANTS: must be exactly 13 bytes long");
58 		return NULL;
59 	}
60 	v.backslash = e[0];
61 	v.right_bracket = e[1];
62 	v.left_bracket = e[2];
63 	v.right_brace = e[3];
64 	v.left_brace = e[4];
65 	v.circumflex = e[5];
66 	v.tilde = e[6];
67 	v.exclamation_mark = e[7];
68 	v.number_sign = e[8];
69 	v.vertical_line = e[9];
70 	v.dollar_sign = e[10];
71 	v.commercial_at = e[11];
72 	v.grave_accent = e[12];
73 	return &v;
74 }
75