xref: /netbsd-src/external/gpl2/xcvs/dist/src/version.c (revision 5a6c14c844c4c665da5632061aebde7bb2cb5766)
1a7c91847Schristos /*
2a7c91847Schristos  * Copyright (C) 1986-2005 The Free Software Foundation, Inc.
3a7c91847Schristos  *
4a7c91847Schristos  * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>,
5a7c91847Schristos  *                                  and others.
6a7c91847Schristos  *
7a7c91847Schristos  * Portions Copyright (C) 1994 david d `zoo' zuhn
8a7c91847Schristos  * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk
9a7c91847Schristos  * Portions Copyright (C) 1989-1992, Brian Berliner
10a7c91847Schristos  *
11a7c91847Schristos  * You may distribute under the terms of the GNU General Public License as
12a7c91847Schristos  * specified in the README file that comes with this  CVS source distribution.
13a7c91847Schristos  *
14a7c91847Schristos  * version.c - the CVS version number
15a7c91847Schristos  */
16*5a6c14c8Schristos #include <sys/cdefs.h>
17*5a6c14c8Schristos __RCSID("$NetBSD: version.c,v 1.3 2016/05/17 14:00:09 christos Exp $");
18a7c91847Schristos 
19a7c91847Schristos #include "cvs.h"
20a7c91847Schristos 
21a7c91847Schristos #ifdef CLIENT_SUPPORT
22a7c91847Schristos #ifdef SERVER_SUPPORT
23a7c91847Schristos char *config_string = " (client/server)\n";
24a7c91847Schristos #else
25a7c91847Schristos char *config_string = " (client)\n";
26a7c91847Schristos #endif
27a7c91847Schristos #else
28a7c91847Schristos #ifdef SERVER_SUPPORT
29a7c91847Schristos char *config_string = " (server)\n";
30a7c91847Schristos #else
31a7c91847Schristos char *config_string = "\n";
32a7c91847Schristos #endif
33a7c91847Schristos #endif
34a7c91847Schristos 
354872c424Schristos /* cvsacl patch */
364872c424Schristos static const char aclpatch_string[] =
374872c424Schristos     "with CVSACL Patch 1.2.5 (cvsacl.sourceforge.net)\n";
38a7c91847Schristos 
39a7c91847Schristos static const char *const version_usage[] =
40a7c91847Schristos {
41a7c91847Schristos     "Usage: %s %s\n",
42a7c91847Schristos     NULL
43a7c91847Schristos };
44a7c91847Schristos 
45a7c91847Schristos 
46a7c91847Schristos 
47a7c91847Schristos /*
48a7c91847Schristos  * Output a version string for the client and server.
49a7c91847Schristos  *
50a7c91847Schristos  * This function will output the simple version number (for the '--version'
51a7c91847Schristos  * option) or the version numbers of the client and server (using the 'version'
52a7c91847Schristos  * command).
53a7c91847Schristos  */
54a7c91847Schristos int
version(int argc,char ** argv)55a7c91847Schristos version (int argc, char **argv)
56a7c91847Schristos {
57a7c91847Schristos     int err = 0;
58a7c91847Schristos 
59a7c91847Schristos     if (argc == -1)
60a7c91847Schristos 	usage (version_usage);
61a7c91847Schristos 
62a7c91847Schristos     if (current_parsed_root && current_parsed_root->isremote)
63a7c91847Schristos         (void) fputs ("Client: ", stdout);
64a7c91847Schristos 
65a7c91847Schristos     /* Having the year here is a good idea, so people have
66a7c91847Schristos        some idea of how long ago their version of CVS was
67a7c91847Schristos        released.  */
68a7c91847Schristos     (void) fputs (PACKAGE_STRING, stdout);
69a7c91847Schristos     (void) fputs (config_string, stdout);
704872c424Schristos     /* cvsacl patch */
714872c424Schristos     (void) fputs (aclpatch_string, stdout);
72a7c91847Schristos 
73a7c91847Schristos #ifdef CLIENT_SUPPORT
74a7c91847Schristos     if (current_parsed_root && current_parsed_root->isremote)
75a7c91847Schristos     {
76a7c91847Schristos 	(void) fputs ("Server: ", stdout);
77a7c91847Schristos 	start_server ();
78a7c91847Schristos 	if (supported_request ("version"))
79a7c91847Schristos 	    send_to_server ("version\012", 0);
80a7c91847Schristos 	else
81a7c91847Schristos 	{
82a7c91847Schristos 	    send_to_server ("noop\012", 0);
83a7c91847Schristos 	    fputs ("(unknown)\n", stdout);
84a7c91847Schristos 	}
85a7c91847Schristos 	err = get_responses_and_close ();
86a7c91847Schristos     }
87a7c91847Schristos #endif
88a7c91847Schristos     return err;
89a7c91847Schristos }
90a7c91847Schristos 
91