xref: /openbsd-src/usr.bin/cvs/version.c (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1 /*	$OpenBSD: version.c,v 1.25 2007/05/02 16:26:50 xsa Exp $	*/
2 /*
3  * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
4  * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include "cvs.h"
20 #include "remote.h"
21 
22 struct cvs_cmd cvs_cmd_version = {
23 	CVS_OP_VERSION, 0, "version",
24 	{ "ve", "ver" },
25 	"Show current CVS version(s)",
26 	"",
27 	"",
28 	NULL,
29 	cvs_version
30 };
31 
32 int
33 cvs_version(int argc, char **argv)
34 {
35 	if (argc > 1)
36 		fatal("version does not take any extra arguments");
37 
38 	if (current_cvsroot != NULL &&
39 	    current_cvsroot->cr_method != CVS_METHOD_LOCAL)
40 		cvs_printf("Client: ");
41 
42 	cvs_printf("%s\n", CVS_VERSION);
43 
44 	if (current_cvsroot != NULL &&
45 	    current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
46 		cvs_client_connect_to_server();
47 		cvs_client_send_request("version");
48 		/* XXX: better way to handle server response? */
49 		cvs_printf("Server: ");
50 		cvs_client_get_responses();
51 	}
52 
53 	return (0);
54 }
55