report_openssl_version.c
Go to the documentation of this file.
00001 /* File: report_openssl_version.c
00002  *
00003  * $Id$
00004  *
00005  * This file dynamically loads the openssl shared image to report the
00006  * version string.
00007  *
00008  * It will optionally place that version string in a DCL symbol.
00009  *
00010  * Usage:  report_openssl_version <shared_image> [<dcl_symbol>]
00011  *
00012  * Copyright 2013, John Malmberg
00013  *
00014  * Permission to use, copy, modify, and/or distribute this software for any
00015  * purpose with or without fee is hereby granted, provided that the above
00016  * copyright notice and this permission notice appear in all copies.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00019  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00020  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00021  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00022  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00023  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00024  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00025  *
00026  */
00027 
00028 #include <dlfcn.h>
00029 #include <openssl/opensslv.h>
00030 #include <openssl/crypto.h>
00031 
00032 #include <string.h>
00033 #include <descrip.h>
00034 #include <libclidef.h>
00035 #include <stsdef.h>
00036 #include <errno.h>
00037 
00038 unsigned long LIB$SET_SYMBOL(
00039     const struct dsc$descriptor_s * symbol,
00040     const struct dsc$descriptor_s * value,
00041     const unsigned long * table_type);
00042 
00043 int main(int argc, char ** argv) {
00044 
00045 
00046 void * libptr;
00047 const char * (*ssl_version)(int t);
00048 const char * version;
00049 
00050    if (argc < 1) {
00051        puts("report_openssl_version filename");
00052        exit(1);
00053    }
00054 
00055    libptr = dlopen(argv[1], 0);
00056 
00057    ssl_version = (const char * (*)(int))dlsym(libptr, "SSLeay_version");
00058    if ((void *)ssl_version == NULL) {
00059       ssl_version = (const char * (*)(int))dlsym(libptr, "ssleay_version");
00060       if ((void *)ssl_version == NULL) {
00061          ssl_version = (const char * (*)(int))dlsym(libptr, "SSLEAY_VERSION");
00062       }
00063    }
00064 
00065    dlclose(libptr);
00066 
00067    if ((void *)ssl_version == NULL) {
00068       puts("Unable to lookup version of OpenSSL");
00069       exit(1);
00070    }
00071 
00072    version = ssl_version(SSLEAY_VERSION);
00073 
00074    puts(version);
00075 
00076    /* Was a symbol argument given? */
00077    if (argc > 1) {
00078       int status;
00079       struct dsc$descriptor_s symbol_dsc;
00080       struct dsc$descriptor_s value_dsc;
00081       const unsigned long table_type = LIB$K_CLI_LOCAL_SYM;
00082 
00083       symbol_dsc.dsc$a_pointer = argv[2];
00084       symbol_dsc.dsc$w_length = strlen(argv[2]);
00085       symbol_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
00086       symbol_dsc.dsc$b_class = DSC$K_CLASS_S;
00087 
00088       value_dsc.dsc$a_pointer = (char *)version; /* Cast ok */
00089       value_dsc.dsc$w_length = strlen(version);
00090       value_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
00091       value_dsc.dsc$b_class = DSC$K_CLASS_S;
00092 
00093       status = LIB$SET_SYMBOL(&symbol_dsc, &value_dsc, &table_type);
00094       if (!$VMS_STATUS_SUCCESS(status)) {
00095          exit(status);
00096       }
00097    }
00098 
00099    exit(0);
00100 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06