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