1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (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#include "internal/cryptlib.h"
11
12#include "buildinf.h"
13
14unsigned long OpenSSL_version_num(void)
15{
16 return OPENSSL_VERSION_NUMBER;
17}
18
19unsigned int OPENSSL_version_major(void)
20{
21 return OPENSSL_VERSION_MAJOR;
22}
23
24unsigned int OPENSSL_version_minor(void)
25{
26 return OPENSSL_VERSION_MINOR;
27}
28
29unsigned int OPENSSL_version_patch(void)
30{
31 return OPENSSL_VERSION_PATCH;
32}
33
34const char *OPENSSL_version_pre_release(void)
35{
36 return OPENSSL_VERSION_PRE_RELEASE;
37}
38
39const char *OPENSSL_version_build_metadata(void)
40{
41 return OPENSSL_VERSION_BUILD_METADATA;
42}
43
44extern char ossl_cpu_info_str[];
45
46const char *OpenSSL_version(int t)
47{
48 switch (t) {
49 case OPENSSL_VERSION:
50 return OPENSSL_VERSION_TEXT;
51 case OPENSSL_VERSION_STRING:
52 return OPENSSL_VERSION_STR;
53 case OPENSSL_FULL_VERSION_STRING:
54 return OPENSSL_FULL_VERSION_STR;
55 case OPENSSL_BUILT_ON:
56 return DATE;
57 case OPENSSL_CFLAGS:
58 return compiler_flags;
59 case OPENSSL_PLATFORM:
60 return PLATFORM;
61 case OPENSSL_DIR:
62#ifdef OPENSSLDIR
63 return "OPENSSLDIR: \"" OPENSSLDIR "\"";
64#else
65 return "OPENSSLDIR: N/A";
66#endif
67 case OPENSSL_ENGINES_DIR:
68#ifdef ENGINESDIR
69 return "ENGINESDIR: \"" ENGINESDIR "\"";
70#else
71 return "ENGINESDIR: N/A";
72#endif
73 case OPENSSL_MODULES_DIR:
74#ifdef MODULESDIR
75 return "MODULESDIR: \"" MODULESDIR "\"";
76#else
77 return "MODULESDIR: N/A";
78#endif
79 case OPENSSL_CPU_INFO:
80 if (OPENSSL_info(OPENSSL_INFO_CPU_SETTINGS) != NULL)
81 return ossl_cpu_info_str;
82 else
83 return "CPUINFO: N/A";
84 }
85 return "not available";
86}
87