Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / lib / libast / misc / setuniv.c
1 /* $XConsortium: setuniv.c /main/3 1995/11/01 18:03:52 rswiston $ */
2 /***************************************************************
3 *                                                              *
4 *                      AT&T - PROPRIETARY                      *
5 *                                                              *
6 *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
7 *                    AT&T BELL LABORATORIES                    *
8 *         AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN         *
9 *            ACCORDANCE WITH APPLICABLE AGREEMENTS             *
10 *                                                              *
11 *          Copyright (c) 1994 AT&T Bell Laboratories           *
12 *              Unpublished & Not for Publication               *
13 *                     All Rights Reserved                      *
14 *                                                              *
15 *       The copyright notice above does not evidence any       *
16 *      actual or intended publication of such source code      *
17 *                                                              *
18 *               This software was created by the               *
19 *           Software Engineering Research Department           *
20 *                    AT&T Bell Laboratories                    *
21 *                                                              *
22 *               For further information contact                *
23 *                   advsoft@research.att.com                   *
24 *                 Randy Hackbarth 908-582-5245                 *
25 *                  Dave Belanger 908-582-7427                  *
26 *                                                              *
27 ***************************************************************/
28
29 /* : : generated by proto : : */
30
31 #line 1
32
33 #if !defined(__PROTO__)
34 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
35 #if defined(__cplusplus)
36 #define __MANGLE__      "C"
37 #else
38 #define __MANGLE__
39 #endif
40 #define __STDARG__
41 #define __PROTO__(x)    x
42 #define __OTORP__(x)
43 #define __PARAM__(n,o)  n
44 #if !defined(__STDC__) && !defined(__cplusplus)
45 #if !defined(c_plusplus)
46 #define const
47 #endif
48 #define signed
49 #define void            int
50 #define volatile
51 #define __V_            char
52 #else
53 #define __V_            void
54 #endif
55 #else
56 #define __PROTO__(x)    ()
57 #define __OTORP__(x)    x
58 #define __PARAM__(n,o)  o
59 #define __MANGLE__
60 #define __V_            char
61 #define const
62 #define signed
63 #define void            int
64 #define volatile
65 #endif
66 #if defined(__cplusplus) || defined(c_plusplus)
67 #define __VARARG__      ...
68 #else
69 #define __VARARG__
70 #endif
71 #if defined(__STDARG__)
72 #define __VA_START__(p,a)       va_start(p,a)
73 #else
74 #define __VA_START__(p,a)       va_start(p)
75 #endif
76 #endif
77
78 #line 9
79 #include "univlib.h"
80
81 int
82 setuniv __PARAM__((const char* buf), (buf)) __OTORP__(const char* buf;)
83 #line 13
84 {
85 #if _lib_getuniverse
86         return(setuniverse(buf));
87 #else
88 #ifndef UNIV_MAX
89         char*           p;
90         char            tmp[32];
91
92         sfsprintf(tmp, sizeof(tmp), "%s=%-*.*s", univ_env, UNIV_SIZE - 1, UNIV_SIZE - 1, buf);
93         if ((p = strdup(tmp)) && setenv(p)) return(0);
94         errno = ENOMEM;
95         return(-1);
96 #else
97 #if defined(ATT_UNIV) || defined(U_GET)
98         register int    n;
99
100         for (n = 0; n < UNIV_MAX; n++)
101                 if (streq(buf, univ_name[n]))
102 #if defined(ATT_UNIV)
103                         return(setuniverse(n + 1) >= 0 ? 0 : -1);
104 #else
105                         return(universe(n) >= 0 ? 0 : -1);
106 #endif
107 #endif
108         errno = EINVAL;
109         return(-1);
110 #endif
111 #endif
112 }