VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1l/apps/vms_decc_init.c@ 93560

最後變更 在這個檔案從93560是 91772,由 vboxsync 提交於 3 年 前

openssl-1.1.1l: Applied and adjusted our OpenSSL changes to 1.1.1l. bugref:10126

檔案大小: 6.4 KB
 
1/*
2 * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (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
8 */
9
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
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 * ----------------------------------------------------------------------
22 */
23
24# include <stdio.h>
25# include <stdlib.h>
26# include <unixlib.h>
27
28# include "apps.h"
29
30/* Global storage. */
31
32/* Flag to sense if decc_init() was called. */
33
34int decc_init_done = -1;
35
36/* Structure to hold a DECC$* feature name and its desired value. */
37
38typedef struct {
39 char *name;
40 int value;
41} decc_feat_t;
42
43/*
44 * Array of DECC$* feature names and their desired values. Note:
45 * DECC$ARGV_PARSE_STYLE is the urgent one.
46 */
47
48decc_feat_t decc_feat_array[] = {
49 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
50 {"DECC$ARGV_PARSE_STYLE", 1},
51
52 /* Preserve case for file names on ODS5 disks. */
53 {"DECC$EFS_CASE_PRESERVE", 1},
54
55 /*
56 * Enable multiple dots (and most characters) in ODS5 file names, while
57 * preserving VMS-ness of ";version".
58 */
59 {"DECC$EFS_CHARSET", 1},
60
61 /* List terminator. */
62 {(char *)NULL, 0}
63};
64
65
66char **copy_argv(int *argc, char *argv[])
67{
68 /*-
69 * The note below is for historical purpose. On VMS now we always
70 * copy argv "safely."
71 *
72 * 2011-03-22 SMS.
73 * If we have 32-bit pointers everywhere, then we're safe, and
74 * we bypass this mess, as on non-VMS systems.
75 * Problem 1: Compaq/HP C before V7.3 always used 32-bit
76 * pointers for argv[].
77 * Fix 1: For a 32-bit argv[], when we're using 64-bit pointers
78 * everywhere else, we always allocate and use a 64-bit
79 * duplicate of argv[].
80 * Problem 2: Compaq/HP C V7.3 (Alpha, IA64) before ECO1 failed
81 * to NULL-terminate a 64-bit argv[]. (As this was written, the
82 * compiler ECO was available only on IA64.)
83 * Fix 2: Unless advised not to (VMS_TRUST_ARGV), we test a
84 * 64-bit argv[argc] for NULL, and, if necessary, use a
85 * (properly) NULL-terminated (64-bit) duplicate of argv[].
86 * The same code is used in either case to duplicate argv[].
87 * Some of these decisions could be handled in preprocessing,
88 * but the code tends to get even uglier, and the penalty for
89 * deciding at compile- or run-time is tiny.
90 */
91
92 int i, count = *argc;
93 char **newargv = app_malloc(sizeof(*newargv) * (count + 1), "argv copy");
94
95 for (i = 0; i < count; i++)
96 newargv[i] = argv[i];
97 newargv[i] = NULL;
98 *argc = i;
99 return newargv;
100}
101
102/* LIB$INITIALIZE initialization function. */
103
104static void decc_init(void)
105{
106 char *openssl_debug_decc_init;
107 int verbose = 0;
108 int feat_index;
109 int feat_value;
110 int feat_value_max;
111 int feat_value_min;
112 int i;
113 int sts;
114
115 /* Get debug option. */
116 openssl_debug_decc_init = getenv("OPENSSL_DEBUG_DECC_INIT");
117 if (openssl_debug_decc_init != NULL) {
118 verbose = strtol(openssl_debug_decc_init, NULL, 10);
119 if (verbose <= 0) {
120 verbose = 1;
121 }
122 }
123
124 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
125 decc_init_done = 1;
126
127 /* Loop through all items in the decc_feat_array[]. */
128
129 for (i = 0; decc_feat_array[i].name != NULL; i++) {
130 /* Get the feature index. */
131 feat_index = decc$feature_get_index(decc_feat_array[i].name);
132 if (feat_index >= 0) {
133 /* Valid item. Collect its properties. */
134 feat_value = decc$feature_get_value(feat_index, 1);
135 feat_value_min = decc$feature_get_value(feat_index, 2);
136 feat_value_max = decc$feature_get_value(feat_index, 3);
137
138 /* Check the validity of our desired value. */
139 if ((decc_feat_array[i].value >= feat_value_min) &&
140 (decc_feat_array[i].value <= feat_value_max)) {
141 /* Valid value. Set it if necessary. */
142 if (feat_value != decc_feat_array[i].value) {
143 sts = decc$feature_set_value(feat_index,
144 1, decc_feat_array[i].value);
145
146 if (verbose > 1) {
147 fprintf(stderr, " %s = %d, sts = %d.\n",
148 decc_feat_array[i].name,
149 decc_feat_array[i].value, sts);
150 }
151 }
152 } else {
153 /* Invalid DECC feature value. */
154 fprintf(stderr,
155 " INVALID DECC$FEATURE VALUE, %d: %d <= %s <= %d.\n",
156 feat_value,
157 feat_value_min, decc_feat_array[i].name,
158 feat_value_max);
159 }
160 } else {
161 /* Invalid DECC feature name. */
162 fprintf(stderr,
163 " UNKNOWN DECC$FEATURE: %s.\n", decc_feat_array[i].name);
164 }
165 }
166
167 if (verbose > 0) {
168 fprintf(stderr, " DECC_INIT complete.\n");
169 }
170}
171
172/* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
173
174# pragma nostandard
175
176/*
177 * Establish the LIB$INITIALIZE PSECTs, with proper alignment and other
178 * attributes. Note that "nopic" is significant only on VAX.
179 */
180# pragma extern_model save
181
182# if __INITIAL_POINTER_SIZE == 64
183# define PSECT_ALIGN 3
184# else
185# define PSECT_ALIGN 2
186# endif
187
188# pragma extern_model strict_refdef "LIB$INITIALIZ" PSECT_ALIGN, nopic, nowrt
189const int spare[8] = { 0 };
190
191# pragma extern_model strict_refdef "LIB$INITIALIZE" PSECT_ALIGN, nopic, nowrt
192void (*const x_decc_init) () = decc_init;
193
194# pragma extern_model restore
195
196/* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
197
198# pragma extern_model save
199
200int LIB$INITIALIZE(void);
201
202# pragma extern_model strict_refdef
203int dmy_lib$initialize = (int)LIB$INITIALIZE;
204
205# pragma extern_model restore
206
207# pragma standard
208
209#else /* def USE_DECC_INIT */
210
211/* Dummy code to avoid a %CC-W-EMPTYFILE complaint. */
212int decc_init_dummy(void);
213
214#endif /* def USE_DECC_INIT */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette