1 /* File: report_openssl_version.c
5 * This file dynamically loads the openssl shared image to report the
8 * It will optionally place that version string in a DCL symbol.
10 * Usage: report_openssl_version <shared_image> [<dcl_symbol>]
12 * Copyright 2013, John Malmberg
14 * Permission to use, copy, modify, and/or distribute this software for any
15 * purpose with or without fee is hereby granted, provided that the above
16 * copyright notice and this permission notice appear in all copies.
18 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
19 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
21 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
24 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 #include <openssl/opensslv.h>
30 #include <openssl/crypto.h>
34 #include <libclidef.h>
38 unsigned long LIB$SET_SYMBOL(
39 const struct dsc$descriptor_s * symbol,
40 const struct dsc$descriptor_s * value,
41 const unsigned long * table_type);
43 int main(int argc, char ** argv) {
47 const char * (*ssl_version)(int t);
51 puts("report_openssl_version filename");
55 libptr = dlopen(argv[1], 0);
57 ssl_version = (const char * (*)(int))dlsym(libptr, "SSLeay_version");
58 if ((void *)ssl_version == NULL) {
59 ssl_version = (const char * (*)(int))dlsym(libptr, "ssleay_version");
60 if ((void *)ssl_version == NULL) {
61 ssl_version = (const char * (*)(int))dlsym(libptr, "SSLEAY_VERSION");
67 if ((void *)ssl_version == NULL) {
68 puts("Unable to lookup version of OpenSSL");
72 version = ssl_version(SSLEAY_VERSION);
76 /* Was a symbol argument given? */
79 struct dsc$descriptor_s symbol_dsc;
80 struct dsc$descriptor_s value_dsc;
81 const unsigned long table_type = LIB$K_CLI_LOCAL_SYM;
83 symbol_dsc.dsc$a_pointer = argv[2];
84 symbol_dsc.dsc$w_length = strlen(argv[2]);
85 symbol_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
86 symbol_dsc.dsc$b_class = DSC$K_CLASS_S;
88 value_dsc.dsc$a_pointer = (char *)version; /* Cast ok */
89 value_dsc.dsc$w_length = strlen(version);
90 value_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
91 value_dsc.dsc$b_class = DSC$K_CLASS_S;
93 status = LIB$SET_SYMBOL(&symbol_dsc, &value_dsc, &table_type);
94 if (!$VMS_STATUS_SUCCESS(status)) {