11e72d8d2Sderaadt /*
21e72d8d2Sderaadt * Copyright (c) 1994 david d `zoo' zuhn
31e72d8d2Sderaadt * Copyright (c) 1994 Free Software Foundation, Inc.
41e72d8d2Sderaadt * Copyright (c) 1992, Brian Berliner and Jeff Polk
51e72d8d2Sderaadt * Copyright (c) 1989-1992, Brian Berliner
61e72d8d2Sderaadt *
71e72d8d2Sderaadt * You may distribute under the terms of the GNU General Public License as
81e72d8d2Sderaadt * specified in the README file that comes with this CVS source distribution.
91e72d8d2Sderaadt *
101e72d8d2Sderaadt * version.c - the CVS version number
111e72d8d2Sderaadt */
121e72d8d2Sderaadt
131e72d8d2Sderaadt #include "cvs.h"
141e72d8d2Sderaadt
15*43c1707eStholo char *version_string = "Concurrent Versions System (CVS) 1.11.1p1";
161e72d8d2Sderaadt
171e72d8d2Sderaadt #ifdef CLIENT_SUPPORT
181e72d8d2Sderaadt #ifdef SERVER_SUPPORT
191e72d8d2Sderaadt char *config_string = " (client/server)\n";
201e72d8d2Sderaadt #else
211e72d8d2Sderaadt char *config_string = " (client)\n";
221e72d8d2Sderaadt #endif
231e72d8d2Sderaadt #else
241e72d8d2Sderaadt #ifdef SERVER_SUPPORT
251e72d8d2Sderaadt char *config_string = " (server)\n";
261e72d8d2Sderaadt #else
271e72d8d2Sderaadt char *config_string = "\n";
281e72d8d2Sderaadt #endif
291e72d8d2Sderaadt #endif
30e77048c1Stholo
31*43c1707eStholo
32*43c1707eStholo
33e77048c1Stholo static const char *const version_usage[] =
34e77048c1Stholo {
35e77048c1Stholo "Usage: %s %s\n",
36e77048c1Stholo NULL
37e77048c1Stholo };
38e77048c1Stholo
39*43c1707eStholo
40*43c1707eStholo
41*43c1707eStholo /*
42*43c1707eStholo * Output a version string for the client and server.
43*43c1707eStholo *
44*43c1707eStholo * This function will output the simple version number (for the '--version'
45*43c1707eStholo * option) or the version numbers of the client and server (using the 'version'
46*43c1707eStholo * command).
47*43c1707eStholo */
48e77048c1Stholo int
version(argc,argv)49e77048c1Stholo version (argc, argv)
50e77048c1Stholo int argc;
51e77048c1Stholo char **argv;
52e77048c1Stholo {
53e77048c1Stholo int err = 0;
54e77048c1Stholo
55e77048c1Stholo if (argc == -1)
56e77048c1Stholo usage (version_usage);
57e77048c1Stholo
58e77048c1Stholo #ifdef CLIENT_SUPPORT
59*43c1707eStholo if (current_parsed_root && current_parsed_root->isremote)
60e77048c1Stholo (void) fputs ("Client: ", stdout);
61e77048c1Stholo #endif
62e77048c1Stholo
63e77048c1Stholo /* Having the year here is a good idea, so people have
64e77048c1Stholo some idea of how long ago their version of CVS was
65e77048c1Stholo released. */
66e77048c1Stholo (void) fputs (version_string, stdout);
67e77048c1Stholo (void) fputs (config_string, stdout);
68e77048c1Stholo
69e77048c1Stholo #ifdef CLIENT_SUPPORT
70*43c1707eStholo if (current_parsed_root && current_parsed_root->isremote)
71e77048c1Stholo {
72e77048c1Stholo (void) fputs ("Server: ", stdout);
73e77048c1Stholo start_server ();
74e77048c1Stholo if (supported_request ("version"))
75e77048c1Stholo send_to_server ("version\012", 0);
76e77048c1Stholo else
77e77048c1Stholo {
78e77048c1Stholo send_to_server ("noop\012", 0);
79e77048c1Stholo fputs ("(unknown)\n", stdout);
80e77048c1Stholo }
81e77048c1Stholo err = get_responses_and_close ();
82e77048c1Stholo }
83e77048c1Stholo #endif
84e77048c1Stholo return err;
85e77048c1Stholo }
86e77048c1Stholo
87