xref: /openbsd-src/gnu/usr.bin/cvs/src/version.c (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*
2  * Copyright (c) 1994 david d `zoo' zuhn
3  * Copyright (c) 1994 Free Software Foundation, Inc.
4  * Copyright (c) 1992, Brian Berliner and Jeff Polk
5  * Copyright (c) 1989-1992, Brian Berliner
6  *
7  * You may distribute under the terms of the GNU General Public License as
8  * specified in the README file that comes with this  CVS source distribution.
9  *
10  * version.c - the CVS version number
11  */
12 
13 #include "cvs.h"
14 
15 char *version_string = "Concurrent Versions System (CVS) 1.11";
16 
17 #ifdef CLIENT_SUPPORT
18 #ifdef SERVER_SUPPORT
19 char *config_string = " (client/server)\n";
20 #else
21 char *config_string = " (client)\n";
22 #endif
23 #else
24 #ifdef SERVER_SUPPORT
25 char *config_string = " (server)\n";
26 #else
27 char *config_string = "\n";
28 #endif
29 #endif
30 
31 static const char *const version_usage[] =
32 {
33     "Usage: %s %s\n",
34     NULL
35 };
36 
37 int
38 version (argc, argv)
39     int argc;
40     char **argv;
41 {
42     int err = 0;
43 
44     if (argc == -1)
45 	usage (version_usage);
46 
47 #ifdef CLIENT_SUPPORT
48     if (client_active)
49         (void) fputs ("Client: ", stdout);
50 #endif
51 
52     /* Having the year here is a good idea, so people have
53        some idea of how long ago their version of CVS was
54        released.  */
55     (void) fputs (version_string, stdout);
56     (void) fputs (config_string, stdout);
57 
58 #ifdef CLIENT_SUPPORT
59     if (client_active)
60     {
61 	(void) fputs ("Server: ", stdout);
62 	start_server ();
63 	if (supported_request ("version"))
64 	    send_to_server ("version\012", 0);
65 	else
66 	{
67 	    send_to_server ("noop\012", 0);
68 	    fputs ("(unknown)\n", stdout);
69 	}
70 	err = get_responses_and_close ();
71     }
72 #endif
73     return err;
74 }
75 
76