1 #if defined( __VMS) && !defined( OPENSSL_NO_DECC_INIT) && \
2 defined( __DECC) && !defined( __VAX) && (__CRTL_VER >= 70301000)
3 # define USE_DECC_INIT 1
11 *----------------------------------------------------------------------
15 * On non-VAX systems, uses LIB$INITIALIZE to set a collection of C
16 * RTL features without using the DECC$* logical name method.
18 *----------------------------------------------------------------------
28 /* Flag to sense if decc_init() was called. */
30 int decc_init_done = -1;
33 /* Structure to hold a DECC$* feature name and its desired value. */
42 /* Array of DECC$* feature names and their desired values.
43 * Note: DECC$ARGV_PARSE_STYLE is the urgent one.
46 decc_feat_t decc_feat_array[] =
48 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
49 { "DECC$ARGV_PARSE_STYLE", 1 },
51 /* Preserve case for file names on ODS5 disks. */
52 { "DECC$EFS_CASE_PRESERVE", 1 },
54 /* Enable multiple dots (and most characters) in ODS5 file names,
55 * while 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)
81 verbose = strtol( openssl_debug_decc_init, NULL, 10);
88 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
91 /* Loop through all items in the decc_feat_array[]. */
93 for (i = 0; decc_feat_array[ i].name != NULL; i++)
95 /* Get the feature index. */
96 feat_index = decc$feature_get_index( decc_feat_array[ i].name);
99 /* Valid item. Collect its properties. */
100 feat_value = decc$feature_get_value( feat_index, 1);
101 feat_value_min = decc$feature_get_value( feat_index, 2);
102 feat_value_max = decc$feature_get_value( feat_index, 3);
104 /* Check the validity of our desired value. */
105 if ((decc_feat_array[ i].value >= feat_value_min) &&
106 (decc_feat_array[ i].value <= feat_value_max))
108 /* Valid value. Set it if necessary. */
109 if (feat_value != decc_feat_array[ i].value)
111 sts = decc$feature_set_value( feat_index,
113 decc_feat_array[ i].value);
117 fprintf( stderr, " %s = %d, sts = %d.\n",
118 decc_feat_array[ i].name,
119 decc_feat_array[ i].value,
126 /* Invalid DECC feature value. */
128 " INVALID DECC$FEATURE VALUE, %d: %d <= %s <= %d.\n",
130 feat_value_min, decc_feat_array[ i].name, feat_value_max);
135 /* Invalid DECC feature name. */
137 " UNKNOWN DECC$FEATURE: %s.\n", decc_feat_array[ i].name);
143 fprintf( stderr, " DECC_INIT complete.\n");
147 /* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
151 /* Establish the LIB$INITIALIZE PSECTs, with proper alignment and
152 * other attributes. Note that "nopic" is significant only on VAX.
154 #pragma extern_model save
156 #if __INITIAL_POINTER_SIZE == 64
157 # define PSECT_ALIGN 3
159 # define PSECT_ALIGN 2
162 #pragma extern_model strict_refdef "LIB$INITIALIZ" PSECT_ALIGN, nopic, nowrt
163 const int spare[ 8] = { 0 };
165 #pragma extern_model strict_refdef "LIB$INITIALIZE" PSECT_ALIGN, nopic, nowrt
166 void (*const x_decc_init)() = decc_init;
168 #pragma extern_model restore
170 /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
172 #pragma extern_model save
174 int LIB$INITIALIZE( void);
176 #pragma extern_model strict_refdef
177 int dmy_lib$initialize = (int) LIB$INITIALIZE;
179 #pragma extern_model restore
183 #else /* def USE_DECC_INIT */
185 /* Dummy code to avoid a %CC-W-EMPTYFILE complaint. */
186 int decc_init_dummy( void);
188 #endif /* def USE_DECC_INIT */