2a0dcf944591a75d882494f15ed2ad51277e1889
[openssl.git] / crypto / cversion.c
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
14 #if !OPENSSL_API_3
15 unsigned long OpenSSL_version_num(void)
16 {
17     return OPENSSL_VERSION_NUMBER;
18 }
19 #endif
20
21 unsigned int OPENSSL_version_major(void)
22 {
23     return OPENSSL_VERSION_MAJOR;
24 }
25
26 unsigned int OPENSSL_version_minor(void)
27 {
28     return OPENSSL_VERSION_MINOR;
29 }
30
31 unsigned int OPENSSL_version_patch(void)
32 {
33     return OPENSSL_VERSION_PATCH;
34 }
35
36 const char *OPENSSL_version_pre_release(void)
37 {
38     return OPENSSL_VERSION_PRE_RELEASE_STR;
39 }
40
41 const char *OPENSSL_version_build_metadata(void)
42 {
43     return OPENSSL_VERSION_BUILD_METADATA_STR;
44 }
45
46 extern char ossl_cpu_info_str[];
47
48 const char *OpenSSL_version(int t)
49 {
50     switch (t) {
51     case OPENSSL_VERSION:
52         return OPENSSL_VERSION_TEXT;
53     case OPENSSL_VERSION_STRING:
54         return OPENSSL_VERSION_STR;
55     case OPENSSL_FULL_VERSION_STRING:
56         return OPENSSL_FULL_VERSION_STR;
57     case OPENSSL_BUILT_ON:
58         return DATE;
59     case OPENSSL_CFLAGS:
60         return compiler_flags;
61     case OPENSSL_PLATFORM:
62         return PLATFORM;
63     case OPENSSL_DIR:
64 #ifdef OPENSSLDIR
65         return "OPENSSLDIR: \"" OPENSSLDIR "\"";
66 #else
67         return "OPENSSLDIR: N/A";
68 #endif
69     case OPENSSL_ENGINES_DIR:
70 #ifdef ENGINESDIR
71         return "ENGINESDIR: \"" ENGINESDIR "\"";
72 #else
73         return "ENGINESDIR: N/A";
74 #endif
75     case OPENSSL_MODULES_DIR:
76 #ifdef MODULESDIR
77         return "MODULESDIR: \"" MODULESDIR "\"";
78 #else
79         return "MODULESDIR: N/A";
80 #endif
81     case OPENSSL_CPU_INFO:
82         if (OPENSSL_info(OPENSSL_INFO_CPU_SETTINGS) != NULL)
83             return ossl_cpu_info_str;
84         else
85             return "CPUINFO: N/A";
86     }
87     return "not available";
88 }