version.c revision 59191
120253Sjoerg/* apps/version.c */
220302Sjoerg/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
320302Sjoerg * All rights reserved.
420253Sjoerg *
520253Sjoerg * This package is an SSL implementation written
620253Sjoerg * by Eric Young (eay@cryptsoft.com).
720253Sjoerg * The implementation was written so as to conform with Netscapes SSL.
820253Sjoerg *
920302Sjoerg * This library is free for commercial and non-commercial use as long as
1020253Sjoerg * the following conditions are aheared to.  The following conditions
1120253Sjoerg * apply to all code found in this distribution, be it the RC4, RSA,
1220253Sjoerg * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1320253Sjoerg * included with this distribution is covered by the same copyright terms
1420302Sjoerg * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1520253Sjoerg *
1620253Sjoerg * Copyright remains Eric Young's, and as such any Copyright notices in
1720302Sjoerg * the code are not to be removed.
1820253Sjoerg * If this package is used in a product, Eric Young should be given attribution
1920253Sjoerg * as the author of the parts of the library used.
2020253Sjoerg * This can be in the form of a textual message at program startup or
2120253Sjoerg * in documentation (online or textual) provided with the package.
2220253Sjoerg *
2320253Sjoerg * Redistribution and use in source and binary forms, with or without
2420253Sjoerg * modification, are permitted provided that the following conditions
2520253Sjoerg * are met:
2620253Sjoerg * 1. Redistributions of source code must retain the copyright
2730259Scharnier *    notice, this list of conditions and the following disclaimer.
2830259Scharnier * 2. Redistributions in binary form must reproduce the above copyright
2950479Speter *    notice, this list of conditions and the following disclaimer in the
3030259Scharnier *    documentation and/or other materials provided with the distribution.
3130259Scharnier * 3. All advertising materials mentioning features or use of this software
3220253Sjoerg *    must display the following acknowledgement:
3330259Scharnier *    "This product includes cryptographic software written by
34286196Sbapt *     Eric Young (eay@cryptsoft.com)"
35286150Sbapt *    The word 'cryptographic' can be left out if the rouines from the library
36286196Sbapt *    being used are not cryptographic related :-).
37286196Sbapt * 4. If you include any Windows specific code (or a derivative thereof) from
38286196Sbapt *    the apps directory (application code) you must include an acknowledgement:
3920253Sjoerg *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4030259Scharnier *
4120253Sjoerg * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4220253Sjoerg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4320253Sjoerg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4420253Sjoerg * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45176474Sscf * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46285411Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47286196Sbapt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48286196Sbapt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4920253Sjoerg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50285136Sbapt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51286196Sbapt * SUCH DAMAGE.
52285136Sbapt *
53285136Sbapt * The licence and distribution terms for any publically available version or
54285136Sbapt * derivative of this code cannot be changed.  i.e. this code cannot simply be
55285136Sbapt * copied and put under another distribution licence
56285136Sbapt * [including the GNU Public Licence.]
57285136Sbapt */
58286196Sbapt
59286196Sbapt#include <stdio.h>
60286196Sbapt#include <stdlib.h>
61286196Sbapt#include <string.h>
62285136Sbapt#include "apps.h"
63285136Sbapt#include <openssl/evp.h>
64285136Sbapt#include <openssl/crypto.h>
65285136Sbapt
66286196Sbapt#undef PROG
67285136Sbapt#define PROG	version_main
68285136Sbapt
69285136Sbaptint MAIN(int, char **);
70286196Sbapt
71285136Sbaptint MAIN(int argc, char **argv)
72285136Sbapt	{
73285136Sbapt	int i,ret=0;
74285136Sbapt	int cflags=0,version=0,date=0,options=0,platform=0;
75286196Sbapt
76285136Sbapt	apps_startup();
77286196Sbapt
78285136Sbapt	if (bio_err == NULL)
79285136Sbapt		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
80285136Sbapt			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
81285136Sbapt
82285136Sbapt	if (argc == 1) version=1;
83285136Sbapt	for (i=1; i<argc; i++)
84285136Sbapt		{
85285136Sbapt		if (strcmp(argv[i],"-v") == 0)
86285136Sbapt			version=1;
87285136Sbapt		else if (strcmp(argv[i],"-b") == 0)
88285136Sbapt			date=1;
89286196Sbapt		else if (strcmp(argv[i],"-f") == 0)
90285136Sbapt			cflags=1;
91285136Sbapt		else if (strcmp(argv[i],"-o") == 0)
92285136Sbapt			options=1;
93285136Sbapt		else if (strcmp(argv[i],"-p") == 0)
94285136Sbapt			platform=1;
95285136Sbapt		else if (strcmp(argv[i],"-a") == 0)
96285136Sbapt			date=version=cflags=options=platform=1;
9720253Sjoerg		else
98285395Sbapt			{
99285395Sbapt			BIO_printf(bio_err,"usage:version -[avbofp]\n");
100285395Sbapt			ret=1;
101285395Sbapt			goto end;
102285395Sbapt			}
103285395Sbapt		}
104286150Sbapt
105285395Sbapt	if (version) printf("%s\n",SSLeay_version(SSLEAY_VERSION));
106285395Sbapt	if (date)    printf("%s\n",SSLeay_version(SSLEAY_BUILT_ON));
107285395Sbapt	if (platform) printf("%s\n",SSLeay_version(SSLEAY_PLATFORM));
108285395Sbapt	if (options)
109286196Sbapt		{
110286196Sbapt		printf("options:  ");
111285398Sbapt		printf("%s ",BN_options());
112286196Sbapt#ifndef NO_MD2
113285398Sbapt		printf("%s ",MD2_options());
114286196Sbapt#endif
115286196Sbapt#ifndef NO_RC4
116285398Sbapt		printf("%s ",RC4_options());
117285398Sbapt#endif
118286196Sbapt#ifndef NO_DES
119286196Sbapt		printf("%s ",des_options());
120285401Sbapt#endif
121286196Sbapt#ifndef NO_IDEA
122285401Sbapt		printf("%s ",idea_options());
123285401Sbapt#endif
124286196Sbapt#ifndef NO_BF
125285401Sbapt		printf("%s ",BF_options());
126285401Sbapt#endif
127176474Sscf		printf("\n");
128176474Sscf		}
129176474Sscf	if (cflags)  printf("%s\n",SSLeay_version(SSLEAY_CFLAGS));
130176474Sscfend:
131176474Sscf	EXIT(ret);
132176474Sscf	}
133176474Sscf