/contrib/cvs/src/version.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 86 lines · 48 code · 13 blank · 25 comment · 7 complexity · 1e7d0a7ce05ceabaa15871df0f3c5b7d MD5 · raw file

  1. /*
  2. * Copyright (C) 1986-2005 The Free Software Foundation, Inc.
  3. *
  4. * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>,
  5. * and others.
  6. *
  7. * Portions Copyright (C) 1994 david d `zoo' zuhn
  8. * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk
  9. * Portions Copyright (C) 1989-1992, Brian Berliner
  10. *
  11. * You may distribute under the terms of the GNU General Public License as
  12. * specified in the README file that comes with this CVS source distribution.
  13. *
  14. * version.c - the CVS version number
  15. */
  16. #include "cvs.h"
  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. static const char *const version_usage[] =
  31. {
  32. "Usage: %s %s\n",
  33. NULL
  34. };
  35. /*
  36. * Output a version string for the client and server.
  37. *
  38. * This function will output the simple version number (for the '--version'
  39. * option) or the version numbers of the client and server (using the 'version'
  40. * command).
  41. */
  42. int
  43. version (argc, argv)
  44. int argc;
  45. char **argv;
  46. {
  47. int err = 0;
  48. if (argc == -1)
  49. usage (version_usage);
  50. if (current_parsed_root && current_parsed_root->isremote)
  51. (void) fputs ("Client: ", stdout);
  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 (PACKAGE_STRING, stdout);
  56. (void) fputs (config_string, stdout);
  57. #ifdef CLIENT_SUPPORT
  58. if (current_parsed_root && current_parsed_root->isremote)
  59. {
  60. (void) fputs ("Server: ", stdout);
  61. start_server ();
  62. if (supported_request ("version"))
  63. send_to_server ("version\012", 0);
  64. else
  65. {
  66. send_to_server ("noop\012", 0);
  67. fputs ("(unknown)\n", stdout);
  68. }
  69. err = get_responses_and_close ();
  70. }
  71. #endif
  72. return err;
  73. }