155682Smarkm/* 2102644Snectar * Copyright (C) 1986-2005 The Free Software Foundation, Inc. 355682Smarkm * 455682Smarkm * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, 555682Smarkm * and others. 655682Smarkm * 755682Smarkm * Portions Copyright (C) 1994 david d `zoo' zuhn 855682Smarkm * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk 955682Smarkm * Portions Copyright (C) 1989-1992, Brian Berliner 1055682Smarkm * 1155682Smarkm * You may distribute under the terms of the GNU General Public License as 1255682Smarkm * specified in the README file that comes with this CVS source distribution. 1355682Smarkm * 1455682Smarkm * version.c - the CVS version number 1555682Smarkm */ 1655682Smarkm 1755682Smarkm#include "cvs.h" 1855682Smarkm 1955682Smarkm#ifdef CLIENT_SUPPORT 2055682Smarkm#ifdef SERVER_SUPPORT 2155682Smarkmchar *config_string = " (client/server)\n"; 2255682Smarkm#else 2355682Smarkmchar *config_string = " (client)\n"; 2455682Smarkm#endif 2555682Smarkm#else 2655682Smarkm#ifdef SERVER_SUPPORT 2755682Smarkmchar *config_string = " (server)\n"; 2855682Smarkm#else 2955682Smarkmchar *config_string = "\n"; 3055682Smarkm#endif 3155682Smarkm#endif 3255682Smarkm 3355682Smarkm 3455682Smarkm 35102644Snectarstatic const char *const version_usage[] = 3655682Smarkm{ 37120945Snectar "Usage: %s %s\n", 3855682Smarkm NULL 3972445Sassar}; 4072445Sassar 41120945Snectar 42120945Snectar 4355682Smarkm/* 4455682Smarkm * Output a version string for the client and server. 4555682Smarkm * 4655682Smarkm * This function will output the simple version number (for the '--version' 4755682Smarkm * option) or the version numbers of the client and server (using the 'version' 4855682Smarkm * command). 4955682Smarkm */ 5055682Smarkmint 5155682Smarkmversion (argc, argv) 5255682Smarkm int argc; 5355682Smarkm char **argv; 5472445Sassar{ 5555682Smarkm int err = 0; 5655682Smarkm 5755682Smarkm if (argc == -1) 5855682Smarkm usage (version_usage); 5955682Smarkm 6055682Smarkm if (current_parsed_root && current_parsed_root->isremote) 6155682Smarkm (void) fputs ("Client: ", stdout); 6255682Smarkm 6355682Smarkm /* Having the year here is a good idea, so people have 6455682Smarkm some idea of how long ago their version of CVS was 6555682Smarkm released. */ 6655682Smarkm (void) fputs (PACKAGE_STRING, stdout); 6755682Smarkm (void) fputs (config_string, stdout); 6855682Smarkm 6955682Smarkm#ifdef CLIENT_SUPPORT 7055682Smarkm if (current_parsed_root && current_parsed_root->isremote) 7190926Snectar { 7255682Smarkm (void) fputs ("Server: ", stdout); 7355682Smarkm start_server (); 7472445Sassar if (supported_request ("version")) 7572445Sassar send_to_server ("version\012", 0); 7655682Smarkm else 7755682Smarkm { 7855682Smarkm send_to_server ("noop\012", 0); 7955682Smarkm fputs ("(unknown)\n", stdout); 8055682Smarkm } 8155682Smarkm err = get_responses_and_close (); 8255682Smarkm } 8355682Smarkm#endif 8455682Smarkm return err; 8555682Smarkm} 8655682Smarkm 8755682Smarkm