xref: /openbsd/gnu/usr.bin/cvs/src/version.c.in (revision 4bdff4be)
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
15char *version_string = "Concurrent Versions System (CVS) @VERSION@";
16
17#ifdef CLIENT_SUPPORT
18#ifdef SERVER_SUPPORT
19char *config_string = " (client/server)\n";
20#else
21char *config_string = " (client)\n";
22#endif
23#else
24#ifdef SERVER_SUPPORT
25char *config_string = " (server)\n";
26#else
27char *config_string = "\n";
28#endif
29#endif
30
31
32
33static const char *const version_usage[] =
34{
35    "Usage: %s %s\n",
36    NULL
37};
38
39
40
41/*
42 * Output a version string for the client and server.
43 *
44 * This function will output the simple version number (for the '--version'
45 * option) or the version numbers of the client and server (using the 'version'
46 * command).
47 */
48int
49version (argc, argv)
50    int argc;
51    char **argv;
52{
53    int err = 0;
54
55    if (argc == -1)
56	usage (version_usage);
57
58#ifdef CLIENT_SUPPORT
59    if (current_parsed_root && current_parsed_root->isremote)
60        (void) fputs ("Client: ", stdout);
61#endif
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 (version_string, stdout);
67    (void) fputs (config_string, stdout);
68
69#ifdef CLIENT_SUPPORT
70    if (current_parsed_root && current_parsed_root->isremote)
71    {
72	(void) fputs ("Server: ", stdout);
73	start_server ();
74	if (supported_request ("version"))
75	    send_to_server ("version\012", 0);
76	else
77	{
78	    send_to_server ("noop\012", 0);
79	    fputs ("(unknown)\n", stdout);
80	}
81	err = get_responses_and_close ();
82    }
83#endif
84    return err;
85}
86
87