xref: /netbsd-src/external/gpl2/xcvs/dist/src/version.c (revision 6a493d6bc668897c91594964a732d38505b70cbb)
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 
17 #include "cvs.h"
18 
19 #ifdef CLIENT_SUPPORT
20 #ifdef SERVER_SUPPORT
21 char *config_string = " (client/server)\n";
22 #else
23 char *config_string = " (client)\n";
24 #endif
25 #else
26 #ifdef SERVER_SUPPORT
27 char *config_string = " (server)\n";
28 #else
29 char *config_string = "\n";
30 #endif
31 #endif
32 
33 /* cvsacl patch */
34 static const char aclpatch_string[] =
35     "with CVSACL Patch 1.2.5 (cvsacl.sourceforge.net)\n";
36 
37 static const char *const version_usage[] =
38 {
39     "Usage: %s %s\n",
40     NULL
41 };
42 
43 
44 
45 /*
46  * Output a version string for the client and server.
47  *
48  * This function will output the simple version number (for the '--version'
49  * option) or the version numbers of the client and server (using the 'version'
50  * command).
51  */
52 int
53 version (int argc, char **argv)
54 {
55     int err = 0;
56 
57     if (argc == -1)
58 	usage (version_usage);
59 
60     if (current_parsed_root && current_parsed_root->isremote)
61         (void) fputs ("Client: ", stdout);
62 
63     /* Having the year here is a good idea, so people have
64        some idea of how long ago their version of CVS was
65        released.  */
66     (void) fputs (PACKAGE_STRING, stdout);
67     (void) fputs (config_string, stdout);
68     /* cvsacl patch */
69     (void) fputs (aclpatch_string, stdout);
70 
71 #ifdef CLIENT_SUPPORT
72     if (current_parsed_root && current_parsed_root->isremote)
73     {
74 	(void) fputs ("Server: ", stdout);
75 	start_server ();
76 	if (supported_request ("version"))
77 	    send_to_server ("version\012", 0);
78 	else
79 	{
80 	    send_to_server ("noop\012", 0);
81 	    fputs ("(unknown)\n", stdout);
82 	}
83 	err = get_responses_and_close ();
84     }
85 #endif
86     return err;
87 }
88 
89