]>
Commit | Line | Data |
---|---|---|
7e1b7485 | 1 | /* |
846e33c7 | 2 | * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. |
7e1b7485 | 3 | * |
dffa7520 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
846e33c7 RS |
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 | |
7e1b7485 RS |
8 | */ |
9 | ||
537c9823 RL |
10 | #if defined( __VMS) && !defined( OPENSSL_NO_DECC_INIT) && \ |
11 | defined( __DECC) && !defined( __VAX) && (__CRTL_VER >= 70301000) | |
12 | # define USE_DECC_INIT 1 | |
13 | #endif | |
14 | ||
15 | #ifdef USE_DECC_INIT | |
16 | ||
7e1b7485 RS |
17 | /* |
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 | * ---------------------------------------------------------------------- | |
537c9823 RL |
22 | */ |
23 | ||
0f113f3e MC |
24 | # include <stdio.h> |
25 | # include <stdlib.h> | |
26 | # include <unixlib.h> | |
537c9823 RL |
27 | |
28 | /* Global storage. */ | |
29 | ||
30 | /* Flag to sense if decc_init() was called. */ | |
31 | ||
32 | int decc_init_done = -1; | |
33 | ||
537c9823 RL |
34 | /* Structure to hold a DECC$* feature name and its desired value. */ |
35 | ||
0f113f3e | 36 | typedef struct { |
537c9823 RL |
37 | char *name; |
38 | int value; | |
39 | } decc_feat_t; | |
40 | ||
0f113f3e MC |
41 | /* |
42 | * Array of DECC$* feature names and their desired values. Note: | |
43 | * DECC$ARGV_PARSE_STYLE is the urgent one. | |
537c9823 RL |
44 | */ |
45 | ||
0f113f3e MC |
46 | decc_feat_t decc_feat_array[] = { |
47 | /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */ | |
48 | {"DECC$ARGV_PARSE_STYLE", 1}, | |
537c9823 | 49 | |
0f113f3e MC |
50 | /* Preserve case for file names on ODS5 disks. */ |
51 | {"DECC$EFS_CASE_PRESERVE", 1}, | |
537c9823 | 52 | |
0f113f3e MC |
53 | /* |
54 | * Enable multiple dots (and most characters) in ODS5 file names, while | |
55 | * preserving VMS-ness of ";version". | |
56 | */ | |
57 | {"DECC$EFS_CHARSET", 1}, | |
537c9823 | 58 | |
0f113f3e MC |
59 | /* List terminator. */ |
60 | {(char *)NULL, 0} | |
537c9823 RL |
61 | }; |
62 | ||
087ca80a | 63 | |
537c9823 RL |
64 | /* LIB$INITIALIZE initialization function. */ |
65 | ||
0f113f3e | 66 | static void decc_init(void) |
537c9823 RL |
67 | { |
68 | char *openssl_debug_decc_init; | |
69 | int verbose = 0; | |
70 | int feat_index; | |
71 | int feat_value; | |
72 | int feat_value_max; | |
73 | int feat_value_min; | |
74 | int i; | |
75 | int sts; | |
76 | ||
77 | /* Get debug option. */ | |
0f113f3e MC |
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); | |
81 | if (verbose <= 0) { | |
537c9823 RL |
82 | verbose = 1; |
83 | } | |
84 | } | |
85 | ||
86 | /* Set the global flag to indicate that LIB$INITIALIZE worked. */ | |
87 | decc_init_done = 1; | |
88 | ||
89 | /* Loop through all items in the decc_feat_array[]. */ | |
90 | ||
0f113f3e | 91 | for (i = 0; decc_feat_array[i].name != NULL; i++) { |
537c9823 | 92 | /* Get the feature index. */ |
0f113f3e MC |
93 | feat_index = decc$feature_get_index(decc_feat_array[i].name); |
94 | if (feat_index >= 0) { | |
537c9823 | 95 | /* Valid item. Collect its properties. */ |
0f113f3e MC |
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); | |
537c9823 RL |
99 | |
100 | /* Check the validity of our desired value. */ | |
0f113f3e MC |
101 | if ((decc_feat_array[i].value >= feat_value_min) && |
102 | (decc_feat_array[i].value <= feat_value_max)) { | |
537c9823 | 103 | /* Valid value. Set it if necessary. */ |
0f113f3e MC |
104 | if (feat_value != decc_feat_array[i].value) { |
105 | sts = decc$feature_set_value(feat_index, | |
106 | 1, decc_feat_array[i].value); | |
107 | ||
108 | if (verbose > 1) { | |
109 | fprintf(stderr, " %s = %d, sts = %d.\n", | |
110 | decc_feat_array[i].name, | |
111 | decc_feat_array[i].value, sts); | |
112 | } | |
537c9823 | 113 | } |
0f113f3e | 114 | } else { |
537c9823 | 115 | /* Invalid DECC feature value. */ |
0f113f3e MC |
116 | fprintf(stderr, |
117 | " INVALID DECC$FEATURE VALUE, %d: %d <= %s <= %d.\n", | |
118 | feat_value, | |
119 | feat_value_min, decc_feat_array[i].name, | |
120 | feat_value_max); | |
537c9823 | 121 | } |
0f113f3e | 122 | } else { |
537c9823 | 123 | /* Invalid DECC feature name. */ |
0f113f3e MC |
124 | fprintf(stderr, |
125 | " UNKNOWN DECC$FEATURE: %s.\n", decc_feat_array[i].name); | |
537c9823 RL |
126 | } |
127 | } | |
128 | ||
0f113f3e MC |
129 | if (verbose > 0) { |
130 | fprintf(stderr, " DECC_INIT complete.\n"); | |
537c9823 RL |
131 | } |
132 | } | |
133 | ||
134 | /* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */ | |
135 | ||
0f113f3e | 136 | # pragma nostandard |
537c9823 | 137 | |
0f113f3e MC |
138 | /* |
139 | * Establish the LIB$INITIALIZE PSECTs, with proper alignment and other | |
140 | * attributes. Note that "nopic" is significant only on VAX. | |
537c9823 | 141 | */ |
0f113f3e | 142 | # pragma extern_model save |
537c9823 | 143 | |
0f113f3e MC |
144 | # if __INITIAL_POINTER_SIZE == 64 |
145 | # define PSECT_ALIGN 3 | |
146 | # else | |
147 | # define PSECT_ALIGN 2 | |
148 | # endif | |
537c9823 | 149 | |
0f113f3e MC |
150 | # pragma extern_model strict_refdef "LIB$INITIALIZ" PSECT_ALIGN, nopic, nowrt |
151 | const int spare[8] = { 0 }; | |
537c9823 | 152 | |
0f113f3e MC |
153 | # pragma extern_model strict_refdef "LIB$INITIALIZE" PSECT_ALIGN, nopic, nowrt |
154 | void (*const x_decc_init) () = decc_init; | |
537c9823 | 155 | |
0f113f3e | 156 | # pragma extern_model restore |
537c9823 RL |
157 | |
158 | /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */ | |
159 | ||
0f113f3e | 160 | # pragma extern_model save |
537c9823 | 161 | |
0f113f3e | 162 | int LIB$INITIALIZE(void); |
537c9823 | 163 | |
0f113f3e MC |
164 | # pragma extern_model strict_refdef |
165 | int dmy_lib$initialize = (int)LIB$INITIALIZE; | |
537c9823 | 166 | |
0f113f3e | 167 | # pragma extern_model restore |
537c9823 | 168 | |
0f113f3e | 169 | # pragma standard |
537c9823 | 170 | |
0f113f3e | 171 | #else /* def USE_DECC_INIT */ |
537c9823 RL |
172 | |
173 | /* Dummy code to avoid a %CC-W-EMPTYFILE complaint. */ | |
0f113f3e | 174 | int decc_init_dummy(void); |
537c9823 | 175 | |
0f113f3e | 176 | #endif /* def USE_DECC_INIT */ |