2 * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #if defined( __VMS) && !defined( OPENSSL_NO_DECC_INIT) && \
11 defined( __DECC) && !defined( __VAX) && (__CRTL_VER >= 70301000)
12 # define USE_DECC_INIT 1
18 * ----------------------------------------------------------------------
19 * decc_init() On non-VAX systems, uses LIB$INITIALIZE to set a collection
20 * of C RTL features without using the DECC$* logical name method.
21 * ----------------------------------------------------------------------
30 /* Flag to sense if decc_init() was called. */
32 int decc_init_done
= -1;
34 /* Structure to hold a DECC$* feature name and its desired value. */
42 * Array of DECC$* feature names and their desired values. Note:
43 * DECC$ARGV_PARSE_STYLE is the urgent one.
46 decc_feat_t decc_feat_array
[] = {
47 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
48 {"DECC$ARGV_PARSE_STYLE", 1},
50 /* Preserve case for file names on ODS5 disks. */
51 {"DECC$EFS_CASE_PRESERVE", 1},
54 * Enable multiple dots (and most characters) in ODS5 file names, while
55 * preserving VMS-ness of ";version".
57 {"DECC$EFS_CHARSET", 1},
59 /* List terminator. */
64 /* LIB$INITIALIZE initialization function. */
66 static void decc_init(void)
68 char *openssl_debug_decc_init
;
77 /* Get debug option. */
78 openssl_debug_decc_init
= getenv("OPENSSL_DEBUG_DECC_INIT");
79 if (openssl_debug_decc_init
!= NULL
) {
80 verbose
= strtol(openssl_debug_decc_init
, NULL
, 10);
86 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
89 /* Loop through all items in the decc_feat_array[]. */
91 for (i
= 0; decc_feat_array
[i
].name
!= NULL
; i
++) {
92 /* Get the feature index. */
93 feat_index
= decc$
feature_get_index(decc_feat_array
[i
].name
);
94 if (feat_index
>= 0) {
95 /* Valid item. Collect its properties. */
96 feat_value
= decc$
feature_get_value(feat_index
, 1);
97 feat_value_min
= decc$
feature_get_value(feat_index
, 2);
98 feat_value_max
= decc$
feature_get_value(feat_index
, 3);
100 /* Check the validity of our desired value. */
101 if ((decc_feat_array
[i
].value
>= feat_value_min
) &&
102 (decc_feat_array
[i
].value
<= feat_value_max
)) {
103 /* Valid value. Set it if necessary. */
104 if (feat_value
!= decc_feat_array
[i
].value
) {
105 sts
= decc$
feature_set_value(feat_index
,
106 1, decc_feat_array
[i
].value
);
109 fprintf(stderr
, " %s = %d, sts = %d.\n",
110 decc_feat_array
[i
].name
,
111 decc_feat_array
[i
].value
, sts
);
115 /* Invalid DECC feature value. */
117 " INVALID DECC$FEATURE VALUE, %d: %d <= %s <= %d.\n",
119 feat_value_min
, decc_feat_array
[i
].name
,
123 /* Invalid DECC feature name. */
125 " UNKNOWN DECC$FEATURE: %s.\n", decc_feat_array
[i
].name
);
130 fprintf(stderr
, " DECC_INIT complete.\n");
134 /* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
139 * Establish the LIB$INITIALIZE PSECTs, with proper alignment and other
140 * attributes. Note that "nopic" is significant only on VAX.
142 # pragma extern_model save
144 # if __INITIAL_POINTER_SIZE == 64
145 # define PSECT_ALIGN 3
147 # define PSECT_ALIGN 2
150 # pragma extern_model strict_refdef "LIB$INITIALIZ" PSECT_ALIGN, nopic, nowrt
151 const int spare
[8] = { 0 };
153 # pragma extern_model strict_refdef "LIB$INITIALIZE" PSECT_ALIGN, nopic, nowrt
154 void (*const x_decc_init
) () = decc_init
;
156 # pragma extern_model restore
158 /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
160 # pragma extern_model save
162 int LIB$
INITIALIZE(void);
164 # pragma extern_model strict_refdef
165 int dmy_lib$initialize
= (int)LIB$INITIALIZE
;
167 # pragma extern_model restore
171 #else /* def USE_DECC_INIT */
173 /* Dummy code to avoid a %CC-W-EMPTYFILE complaint. */
174 int decc_init_dummy(void);
176 #endif /* def USE_DECC_INIT */