1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "tool_setup.h"
26 #if defined(__DECC) && !defined(__VAX) && \
27 defined(__CRTL_VER) && (__CRTL_VER >= 70301000)
31 #define ENABLE_CURLX_PRINTF
34 #include "curlmsg_vms.h"
37 #include "memdebug.h" /* keep this as LAST include */
39 void decc$__posix_exit(int __status);
40 void decc$exit(int __status);
42 static int vms_shell = -1;
44 /* VMS has a DCL shell and and also has Unix shells ported to it.
45 * When curl is running under a Unix shell, we want it to be as much
46 * like Unix as possible.
48 int is_vms_shell(void)
52 /* Have we checked the shell yet? */
56 shell = getenv("SHELL");
58 /* No shell, means DCL */
64 /* Have to make sure some one did not set shell to DCL */
65 if(strcmp(shell, "DCL") == 0) {
75 * VMS has two exit() routines. When running under a Unix style shell, then
76 * Unix style and the __posix_exit() routine is used.
78 * When running under the DCL shell, then the VMS encoded codes and decc$exit()
81 * We can not use exit() or return a code from main() because the actual
82 * routine called depends on both the compiler version, compile options, and
83 * feature macro settings, and one of the exit routines is hidden at compile
86 * Since we want Curl to work properly under the VMS DCL shell and Unix
87 * shells under VMS, this routine should compile correctly regardless of
91 void vms_special_exit(int code, int vms_show)
95 /* The Posix exit mode is only available after VMS 7.0 */
96 #if __CRTL_VER >= 70000000
97 if(is_vms_shell() == 0) {
98 decc$__posix_exit(code);
102 if(code > CURL_LAST) { /* If CURL_LAST exceeded then */
103 vms_code = CURL_LAST; /* curlmsg.h is out of sync. */
106 vms_code = vms_cond[code] | vms_show;
111 #if defined(__DECC) && !defined(__VAX) && \
112 defined(__CRTL_VER) && (__CRTL_VER >= 70301000)
119 * On non-VAX systems, use LIB$INITIALIZE to set a collection of C
120 * RTL features without using the DECC$* logical name method, nor
121 * requiring the user to define the corresponding logical names.
124 /* Structure to hold a DECC$* feature name and its desired value. */
130 /* Array of DECC$* feature names and their desired values. */
131 static decc_feat_t decc_feat_array[] = {
132 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
133 { "DECC$ARGV_PARSE_STYLE", 1 },
134 /* Preserve case for file names on ODS5 disks. */
135 { "DECC$EFS_CASE_PRESERVE", 1 },
136 /* Enable multiple dots (and most characters) in ODS5 file names,
137 while preserving VMS-ness of ";version". */
138 { "DECC$EFS_CHARSET", 1 },
139 /* List terminator. */
143 /* Flag to sense if decc_init() was called. */
144 static int decc_init_done = -1;
146 /* LIB$INITIALIZE initialization function. */
147 static void decc_init(void)
156 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
159 /* Loop through all items in the decc_feat_array[]. */
160 for(i = 0; decc_feat_array[i].name != NULL; i++) {
162 /* Get the feature index. */
163 feat_index = decc$feature_get_index( decc_feat_array[i].name);
165 if(feat_index >= 0) {
166 /* Valid item. Collect its properties. */
167 feat_value = decc$feature_get_value( feat_index, 1);
168 feat_value_min = decc$feature_get_value( feat_index, 2);
169 feat_value_max = decc$feature_get_value( feat_index, 3);
171 if((decc_feat_array[i].value >= feat_value_min) &&
172 (decc_feat_array[i].value <= feat_value_max)) {
173 /* Valid value. Set it if necessary. */
174 if(feat_value != decc_feat_array[i].value) {
175 sts = decc$feature_set_value( feat_index, 1,
176 decc_feat_array[i].value);
180 /* Invalid DECC feature value. */
181 printf(" INVALID DECC FEATURE VALUE, %d: %d <= %s <= %d.\n",
183 feat_value_min, decc_feat_array[i].name, feat_value_max);
187 /* Invalid DECC feature name. */
188 printf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name);
194 /* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
198 /* Establish the LIB$INITIALIZE PSECTs, with proper alignment and
199 other attributes. Note that "nopic" is significant only on VAX. */
200 #pragma extern_model save
201 #pragma extern_model strict_refdef "LIB$INITIALIZ" 2, nopic, nowrt
202 const int spare[8] = {0};
203 #pragma extern_model strict_refdef "LIB$INITIALIZE" 2, nopic, nowrt
204 void (*const x_decc_init)() = decc_init;
205 #pragma extern_model restore
207 /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
208 #pragma extern_model save
209 int LIB$INITIALIZE(void);
210 #pragma extern_model strict_refdef
211 int dmy_lib$initialize = (int) LIB$INITIALIZE;
212 #pragma extern_model restore
216 #endif /* __DECC && !__VAX && __CRTL_VER && __CRTL_VER >= 70301000 */