Path: blob/main/external/curl/packages/vms/report_openssl_version.c
2066 views
/* File: report_openssl_version.c1*2* This file dynamically loads the OpenSSL shared image to report the3* version string.4*5* It will optionally place that version string in a DCL symbol.6*7* Usage: report_openssl_version <shared_image> [<dcl_symbol>]8*9* Copyright (C) John Malmberg10*11* Permission to use, copy, modify, and/or distribute this software for any12* purpose with or without fee is hereby granted, provided that the above13* copyright notice and this permission notice appear in all copies.14*15* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES16* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF17* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR18* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES19* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN20* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT21* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.22*23* SPDX-License-Identifier: ISC24*25*/2627#include <dlfcn.h>28#include <openssl/opensslv.h>29#include <openssl/crypto.h>3031#include <string.h>32#include <descrip.h>33#include <libclidef.h>34#include <stsdef.h>35#include <errno.h>3637unsigned long LIB$SET_SYMBOL(38const struct dsc$descriptor_s * symbol,39const struct dsc$descriptor_s * value,40const unsigned long *table_type);4142int main(int argc, char **argv)43{44void *libptr;45const char * (*ssl_version)(int t);46const char *version;4748if(argc < 1) {49puts("report_openssl_version filename");50return 1;51}5253libptr = dlopen(argv[1], 0);5455ssl_version = (const char * (*)(int))dlsym(libptr, "SSLeay_version");56if(!ssl_version) {57ssl_version = (const char * (*)(int))dlsym(libptr, "ssleay_version");58if(!ssl_version) {59ssl_version = (const char * (*)(int))dlsym(libptr, "SSLEAY_VERSION");60}61}6263dlclose(libptr);6465if(!ssl_version) {66puts("Unable to lookup version of OpenSSL");67return 1;68}6970version = ssl_version(SSLEAY_VERSION);7172puts(version);7374/* Was a symbol argument given? */75if(argc > 1) {76int status;77struct dsc$descriptor_s symbol_dsc;78struct dsc$descriptor_s value_dsc;79const unsigned long table_type = LIB$K_CLI_LOCAL_SYM;8081symbol_dsc.dsc$a_pointer = argv[2];82symbol_dsc.dsc$w_length = strlen(argv[2]);83symbol_dsc.dsc$b_dtype = DSC$K_DTYPE_T;84symbol_dsc.dsc$b_class = DSC$K_CLASS_S;8586value_dsc.dsc$a_pointer = (char *)version; /* Cast ok */87value_dsc.dsc$w_length = strlen(version);88value_dsc.dsc$b_dtype = DSC$K_DTYPE_T;89value_dsc.dsc$b_class = DSC$K_CLASS_S;9091status = LIB$SET_SYMBOL(&symbol_dsc, &value_dsc, &table_type);92if(!$VMS_STATUS_SUCCESS(status)) {93return status;94}95}9697return 0;98}99100101