155714Skris/* apps/version.c */
255714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
355714Skris * All rights reserved.
455714Skris *
555714Skris * This package is an SSL implementation written
655714Skris * by Eric Young (eay@cryptsoft.com).
755714Skris * The implementation was written so as to conform with Netscapes SSL.
8280297Sjkim *
955714Skris * This library is free for commercial and non-commercial use as long as
1055714Skris * the following conditions are aheared to.  The following conditions
1155714Skris * apply to all code found in this distribution, be it the RC4, RSA,
1255714Skris * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1355714Skris * included with this distribution is covered by the same copyright terms
1455714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15280297Sjkim *
1655714Skris * Copyright remains Eric Young's, and as such any Copyright notices in
1755714Skris * the code are not to be removed.
1855714Skris * If this package is used in a product, Eric Young should be given attribution
1955714Skris * as the author of the parts of the library used.
2055714Skris * This can be in the form of a textual message at program startup or
2155714Skris * in documentation (online or textual) provided with the package.
22280297Sjkim *
2355714Skris * Redistribution and use in source and binary forms, with or without
2455714Skris * modification, are permitted provided that the following conditions
2555714Skris * are met:
2655714Skris * 1. Redistributions of source code must retain the copyright
2755714Skris *    notice, this list of conditions and the following disclaimer.
2855714Skris * 2. Redistributions in binary form must reproduce the above copyright
2955714Skris *    notice, this list of conditions and the following disclaimer in the
3055714Skris *    documentation and/or other materials provided with the distribution.
3155714Skris * 3. All advertising materials mentioning features or use of this software
3255714Skris *    must display the following acknowledgement:
3355714Skris *    "This product includes cryptographic software written by
3455714Skris *     Eric Young (eay@cryptsoft.com)"
3555714Skris *    The word 'cryptographic' can be left out if the rouines from the library
3655714Skris *    being used are not cryptographic related :-).
37280297Sjkim * 4. If you include any Windows specific code (or a derivative thereof) from
3855714Skris *    the apps directory (application code) you must include an acknowledgement:
3955714Skris *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40280297Sjkim *
4155714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4455714Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5155714Skris * SUCH DAMAGE.
52280297Sjkim *
5355714Skris * The licence and distribution terms for any publically available version or
5455714Skris * derivative of this code cannot be changed.  i.e. this code cannot simply be
5555714Skris * copied and put under another distribution licence
5655714Skris * [including the GNU Public Licence.]
5755714Skris */
58109998Smarkm/* ====================================================================
59109998Smarkm * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
60109998Smarkm *
61109998Smarkm * Redistribution and use in source and binary forms, with or without
62109998Smarkm * modification, are permitted provided that the following conditions
63109998Smarkm * are met:
64109998Smarkm *
65109998Smarkm * 1. Redistributions of source code must retain the above copyright
66280297Sjkim *    notice, this list of conditions and the following disclaimer.
67109998Smarkm *
68109998Smarkm * 2. Redistributions in binary form must reproduce the above copyright
69109998Smarkm *    notice, this list of conditions and the following disclaimer in
70109998Smarkm *    the documentation and/or other materials provided with the
71109998Smarkm *    distribution.
72109998Smarkm *
73109998Smarkm * 3. All advertising materials mentioning features or use of this
74109998Smarkm *    software must display the following acknowledgment:
75109998Smarkm *    "This product includes software developed by the OpenSSL Project
76109998Smarkm *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77109998Smarkm *
78109998Smarkm * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79109998Smarkm *    endorse or promote products derived from this software without
80109998Smarkm *    prior written permission. For written permission, please contact
81109998Smarkm *    openssl-core@openssl.org.
82109998Smarkm *
83109998Smarkm * 5. Products derived from this software may not be called "OpenSSL"
84109998Smarkm *    nor may "OpenSSL" appear in their names without prior written
85109998Smarkm *    permission of the OpenSSL Project.
86109998Smarkm *
87109998Smarkm * 6. Redistributions of any form whatsoever must retain the following
88109998Smarkm *    acknowledgment:
89109998Smarkm *    "This product includes software developed by the OpenSSL Project
90109998Smarkm *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91109998Smarkm *
92109998Smarkm * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93109998Smarkm * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95109998Smarkm * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
96109998Smarkm * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97109998Smarkm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98109998Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99109998Smarkm * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101109998Smarkm * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102109998Smarkm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103109998Smarkm * OF THE POSSIBILITY OF SUCH DAMAGE.
104109998Smarkm * ====================================================================
105109998Smarkm *
106109998Smarkm * This product includes cryptographic software written by Eric Young
107109998Smarkm * (eay@cryptsoft.com).  This product includes software written by Tim
108109998Smarkm * Hudson (tjh@cryptsoft.com).
109109998Smarkm *
110109998Smarkm */
11155714Skris
11255714Skris#include <stdio.h>
11355714Skris#include <stdlib.h>
11455714Skris#include <string.h>
11555714Skris#include "apps.h"
11655714Skris#include <openssl/evp.h>
11755714Skris#include <openssl/crypto.h>
118160814Ssimon#include <openssl/bn.h>
119109998Smarkm#ifndef OPENSSL_NO_MD2
120109998Smarkm# include <openssl/md2.h>
121109998Smarkm#endif
122109998Smarkm#ifndef OPENSSL_NO_RC4
123109998Smarkm# include <openssl/rc4.h>
124109998Smarkm#endif
125109998Smarkm#ifndef OPENSSL_NO_DES
126109998Smarkm# include <openssl/des.h>
127109998Smarkm#endif
128109998Smarkm#ifndef OPENSSL_NO_IDEA
129109998Smarkm# include <openssl/idea.h>
130109998Smarkm#endif
131109998Smarkm#ifndef OPENSSL_NO_BF
132109998Smarkm# include <openssl/blowfish.h>
133109998Smarkm#endif
13455714Skris
13555714Skris#undef PROG
136280297Sjkim#define PROG    version_main
13755714Skris
13859191Skrisint MAIN(int, char **);
13959191Skris
14055714Skrisint MAIN(int argc, char **argv)
141280297Sjkim{
142280297Sjkim    int i, ret = 0;
143280297Sjkim    int cflags = 0, version = 0, date = 0, options = 0, platform = 0, dir = 0;
14455714Skris
145280297Sjkim    apps_startup();
14655714Skris
147280297Sjkim    if (bio_err == NULL)
148280297Sjkim        if ((bio_err = BIO_new(BIO_s_file())) != NULL)
149280297Sjkim            BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
15055714Skris
151280297Sjkim    if (argc == 1)
152280297Sjkim        version = 1;
153280297Sjkim    for (i = 1; i < argc; i++) {
154280297Sjkim        if (strcmp(argv[i], "-v") == 0)
155280297Sjkim            version = 1;
156280297Sjkim        else if (strcmp(argv[i], "-b") == 0)
157280297Sjkim            date = 1;
158280297Sjkim        else if (strcmp(argv[i], "-f") == 0)
159280297Sjkim            cflags = 1;
160280297Sjkim        else if (strcmp(argv[i], "-o") == 0)
161280297Sjkim            options = 1;
162280297Sjkim        else if (strcmp(argv[i], "-p") == 0)
163280297Sjkim            platform = 1;
164280297Sjkim        else if (strcmp(argv[i], "-d") == 0)
165280297Sjkim            dir = 1;
166280297Sjkim        else if (strcmp(argv[i], "-a") == 0)
167280297Sjkim            date = version = cflags = options = platform = dir = 1;
168280297Sjkim        else {
169280297Sjkim            BIO_printf(bio_err, "usage:version -[avbofpd]\n");
170280297Sjkim            ret = 1;
171280297Sjkim            goto end;
172280297Sjkim        }
173280297Sjkim    }
17455714Skris
175280297Sjkim    if (version) {
176280297Sjkim        if (SSLeay() == SSLEAY_VERSION_NUMBER) {
177280297Sjkim            printf("%s\n", SSLeay_version(SSLEAY_VERSION));
178280297Sjkim        } else {
179280297Sjkim            printf("%s (Library: %s)\n",
180280297Sjkim                   OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
181280297Sjkim        }
182280297Sjkim    }
183280297Sjkim    if (date)
184280297Sjkim        printf("%s\n", SSLeay_version(SSLEAY_BUILT_ON));
185280297Sjkim    if (platform)
186280297Sjkim        printf("%s\n", SSLeay_version(SSLEAY_PLATFORM));
187280297Sjkim    if (options) {
188280297Sjkim        printf("options:  ");
189280297Sjkim        printf("%s ", BN_options());
190109998Smarkm#ifndef OPENSSL_NO_MD2
191280297Sjkim        printf("%s ", MD2_options());
19255714Skris#endif
193109998Smarkm#ifndef OPENSSL_NO_RC4
194280297Sjkim        printf("%s ", RC4_options());
19555714Skris#endif
196109998Smarkm#ifndef OPENSSL_NO_DES
197280297Sjkim        printf("%s ", DES_options());
19855714Skris#endif
199109998Smarkm#ifndef OPENSSL_NO_IDEA
200280297Sjkim        printf("%s ", idea_options());
20155714Skris#endif
202109998Smarkm#ifndef OPENSSL_NO_BF
203280297Sjkim        printf("%s ", BF_options());
20455714Skris#endif
205280297Sjkim        printf("\n");
206280297Sjkim    }
207280297Sjkim    if (cflags)
208280297Sjkim        printf("%s\n", SSLeay_version(SSLEAY_CFLAGS));
209280297Sjkim    if (dir)
210280297Sjkim        printf("%s\n", SSLeay_version(SSLEAY_DIR));
211280297Sjkim end:
212280297Sjkim    apps_shutdown();
213280297Sjkim    OPENSSL_EXIT(ret);
214280297Sjkim}
215