1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2009, 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 ***************************************************************************/
24 #include <curl/curl.h>
26 #define ENABLE_CURLX_PRINTF
29 #include "os-specific.h"
31 #if defined(CURLDEBUG) && defined(CURLTOOLDEBUG)
32 # include "memdebug.h"
37 #include "curlmsg_vms.h"
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.
126 /* Structure to hold a DECC$* feature name and its desired value. */
132 /* Array of DECC$* feature names and their desired values. */
133 static decc_feat_t decc_feat_array[] = {
134 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
135 { "DECC$ARGV_PARSE_STYLE", 1 },
136 /* Preserve case for file names on ODS5 disks. */
137 { "DECC$EFS_CASE_PRESERVE", 1 },
138 /* Enable multiple dots (and most characters) in ODS5 file names,
139 while preserving VMS-ness of ";version". */
140 { "DECC$EFS_CHARSET", 1 },
141 /* List terminator. */
145 /* Flag to sense if decc_init() was called. */
146 static int decc_init_done = -1;
148 /* LIB$INITIALIZE initialization function. */
149 static void decc_init(void)
158 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
161 /* Loop through all items in the decc_feat_array[]. */
162 for(i = 0; decc_feat_array[i].name != NULL; i++) {
164 /* Get the feature index. */
165 feat_index = decc$feature_get_index( decc_feat_array[i].name);
167 if(feat_index >= 0) {
168 /* Valid item. Collect its properties. */
169 feat_value = decc$feature_get_value( feat_index, 1);
170 feat_value_min = decc$feature_get_value( feat_index, 2);
171 feat_value_max = decc$feature_get_value( feat_index, 3);
173 if((decc_feat_array[i].value >= feat_value_min) &&
174 (decc_feat_array[i].value <= feat_value_max)) {
175 /* Valid value. Set it if necessary. */
176 if(feat_value != decc_feat_array[i].value) {
177 sts = decc$feature_set_value( feat_index, 1,
178 decc_feat_array[i].value);
182 /* Invalid DECC feature value. */
183 printf(" INVALID DECC FEATURE VALUE, %d: %d <= %s <= %d.\n",
185 feat_value_min, decc_feat_array[i].name, feat_value_max);
189 /* Invalid DECC feature name. */
190 printf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name);
196 /* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
200 /* Establish the LIB$INITIALIZE PSECTs, with proper alignment and
201 other attributes. Note that "nopic" is significant only on VAX. */
202 #pragma extern_model save
203 #pragma extern_model strict_refdef "LIB$INITIALIZ" 2, nopic, nowrt
204 const int spare[8] = {0};
205 #pragma extern_model strict_refdef "LIB$INITIALIZE" 2, nopic, nowrt
206 void (*const x_decc_init)() = decc_init;
207 #pragma extern_model restore
209 /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
210 #pragma extern_model save
211 int LIB$INITIALIZE(void);
212 #pragma extern_model strict_refdef
213 int dmy_lib$initialize = (int) LIB$INITIALIZE;
214 #pragma extern_model restore
218 #endif /* __DECC && !__VAX && __CRTL_VER && __CRTL_VER >= 70301000 */