Blame lib/version-etc.c

Packit 709fb3
/* Print --version and bug-reporting information in a consistent format.
Packit 709fb3
   Copyright (C) 1999-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software: you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3 of the License, or
Packit 709fb3
   (at your option) any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License
Packit 709fb3
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
/* Written by Jim Meyering. */
Packit 709fb3
Packit 709fb3
#include <config.h>
Packit 709fb3
Packit 709fb3
/* Specification.  */
Packit 709fb3
#include "version-etc.h"
Packit 709fb3
Packit 709fb3
#include <stdarg.h>
Packit 709fb3
#include <stdio.h>
Packit 709fb3
#include <stdlib.h>
Packit 709fb3
Packit 709fb3
#if USE_UNLOCKED_IO
Packit 709fb3
# include "unlocked-io.h"
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#include "gettext.h"
Packit 709fb3
#define _(msgid) gettext (msgid)
Packit 709fb3
Packit 709fb3
/* If you use AM_INIT_AUTOMAKE's no-define option,
Packit 709fb3
   PACKAGE is not defined.  Use PACKAGE_TARNAME instead.  */
Packit 709fb3
#if ! defined PACKAGE && defined PACKAGE_TARNAME
Packit 709fb3
# define PACKAGE PACKAGE_TARNAME
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
enum { COPYRIGHT_YEAR = 2017 };
Packit 709fb3
Packit 709fb3
/* The three functions below display the --version information the
Packit 709fb3
   standard way.
Packit 709fb3
Packit 709fb3
   If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
Packit 709fb3
   the program.  The formats are therefore:
Packit 709fb3
Packit 709fb3
   PACKAGE VERSION
Packit 709fb3
Packit 709fb3
   or
Packit 709fb3
Packit 709fb3
   COMMAND_NAME (PACKAGE) VERSION.
Packit 709fb3
Packit 709fb3
   The functions differ in the way they are passed author names. */
Packit 709fb3
Packit 709fb3
/* Display the --version information the standard way.
Packit 709fb3
Packit 709fb3
   Author names are given in the array AUTHORS. N_AUTHORS is the
Packit 709fb3
   number of elements in the array. */
Packit 709fb3
void
Packit 709fb3
version_etc_arn (FILE *stream,
Packit 709fb3
                 const char *command_name, const char *package,
Packit 709fb3
                 const char *version,
Packit 709fb3
                 const char * const * authors, size_t n_authors)
Packit 709fb3
{
Packit 709fb3
  if (command_name)
Packit 709fb3
    fprintf (stream, "%s (%s) %s\n", command_name, package, version);
Packit 709fb3
  else
Packit 709fb3
    fprintf (stream, "%s %s\n", package, version);
Packit 709fb3
Packit 709fb3
#ifdef PACKAGE_PACKAGER
Packit 709fb3
# ifdef PACKAGE_PACKAGER_VERSION
Packit 709fb3
  fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER,
Packit 709fb3
           PACKAGE_PACKAGER_VERSION);
Packit 709fb3
# else
Packit 709fb3
  fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER);
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
  /* TRANSLATORS: Translate "(C)" to the copyright symbol
Packit 709fb3
     (C-in-a-circle), if this symbol is available in the user's
Packit 709fb3
     locale.  Otherwise, do not translate "(C)"; leave it as-is.  */
Packit 709fb3
  fprintf (stream, version_etc_copyright, _("(C)"), COPYRIGHT_YEAR);
Packit 709fb3
Packit 709fb3
  fputs (_("\
Packit 709fb3
\n\
Packit 709fb3
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n\
Packit 709fb3
This is free software: you are free to change and redistribute it.\n\
Packit 709fb3
There is NO WARRANTY, to the extent permitted by law.\n\
Packit 709fb3
\n\
Packit 709fb3
"),
Packit 709fb3
         stream);
Packit 709fb3
Packit 709fb3
  switch (n_authors)
Packit 709fb3
    {
Packit 709fb3
    case 0:
Packit 709fb3
      /* The caller must provide at least one author name.  */
Packit 709fb3
      abort ();
Packit 709fb3
    case 1:
Packit 709fb3
      /* TRANSLATORS: %s denotes an author name.  */
Packit 709fb3
      fprintf (stream, _("Written by %s.\n"), authors[0]);
Packit 709fb3
      break;
Packit 709fb3
    case 2:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.  */
Packit 709fb3
      fprintf (stream, _("Written by %s and %s.\n"), authors[0], authors[1]);
Packit 709fb3
      break;
Packit 709fb3
    case 3:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.  */
Packit 709fb3
      fprintf (stream, _("Written by %s, %s, and %s.\n"),
Packit 709fb3
               authors[0], authors[1], authors[2]);
Packit 709fb3
      break;
Packit 709fb3
    case 4:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"),
Packit 709fb3
               authors[0], authors[1], authors[2], authors[3]);
Packit 709fb3
      break;
Packit 709fb3
    case 5:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"),
Packit 709fb3
               authors[0], authors[1], authors[2], authors[3], authors[4]);
Packit 709fb3
      break;
Packit 709fb3
    case 6:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
Packit 709fb3
               authors[0], authors[1], authors[2], authors[3], authors[4],
Packit 709fb3
               authors[5]);
Packit 709fb3
      break;
Packit 709fb3
    case 7:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
Packit 709fb3
               authors[0], authors[1], authors[2], authors[3], authors[4],
Packit 709fb3
               authors[5], authors[6]);
Packit 709fb3
      break;
Packit 709fb3
    case 8:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("\
Packit 709fb3
Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
Packit 709fb3
                authors[0], authors[1], authors[2], authors[3], authors[4],
Packit 709fb3
                authors[5], authors[6], authors[7]);
Packit 709fb3
      break;
Packit 709fb3
    case 9:
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("\
Packit 709fb3
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
Packit 709fb3
               authors[0], authors[1], authors[2], authors[3], authors[4],
Packit 709fb3
               authors[5], authors[6], authors[7], authors[8]);
Packit 709fb3
      break;
Packit 709fb3
    default:
Packit 709fb3
      /* 10 or more authors.  Use an abbreviation, since the human reader
Packit 709fb3
         will probably not want to read the entire list anyway.  */
Packit 709fb3
      /* TRANSLATORS: Each %s denotes an author name.
Packit 709fb3
         You can use line breaks, estimating that each author name occupies
Packit 709fb3
         ca. 16 screen columns and that a screen line has ca. 80 columns.  */
Packit 709fb3
      fprintf (stream, _("\
Packit 709fb3
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
Packit 709fb3
                authors[0], authors[1], authors[2], authors[3], authors[4],
Packit 709fb3
                authors[5], authors[6], authors[7], authors[8]);
Packit 709fb3
      break;
Packit 709fb3
    }
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
/* Display the --version information the standard way.  See the initial
Packit 709fb3
   comment to this module, for more information.
Packit 709fb3
Packit 709fb3
   Author names are given in the NULL-terminated array AUTHORS. */
Packit 709fb3
void
Packit 709fb3
version_etc_ar (FILE *stream,
Packit 709fb3
                const char *command_name, const char *package,
Packit 709fb3
                const char *version, const char * const * authors)
Packit 709fb3
{
Packit 709fb3
  size_t n_authors;
Packit 709fb3
Packit 709fb3
  for (n_authors = 0; authors[n_authors]; n_authors++)
Packit 709fb3
    ;
Packit 709fb3
  version_etc_arn (stream, command_name, package, version, authors, n_authors);
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
/* Display the --version information the standard way.  See the initial
Packit 709fb3
   comment to this module, for more information.
Packit 709fb3
Packit 709fb3
   Author names are given in the NULL-terminated va_list AUTHORS. */
Packit 709fb3
void
Packit 709fb3
version_etc_va (FILE *stream,
Packit 709fb3
                const char *command_name, const char *package,
Packit 709fb3
                const char *version, va_list authors)
Packit 709fb3
{
Packit 709fb3
  size_t n_authors;
Packit 709fb3
  const char *authtab[10];
Packit 709fb3
Packit 709fb3
  for (n_authors = 0;
Packit 709fb3
       n_authors < 10
Packit 709fb3
         && (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
Packit 709fb3
       n_authors++)
Packit 709fb3
    ;
Packit 709fb3
  version_etc_arn (stream, command_name, package, version,
Packit 709fb3
                   authtab, n_authors);
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
Packit 709fb3
/* Display the --version information the standard way.
Packit 709fb3
Packit 709fb3
   If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
Packit 709fb3
   the program.  The formats are therefore:
Packit 709fb3
Packit 709fb3
   PACKAGE VERSION
Packit 709fb3
Packit 709fb3
   or
Packit 709fb3
Packit 709fb3
   COMMAND_NAME (PACKAGE) VERSION.
Packit 709fb3
Packit 709fb3
   The authors names are passed as separate arguments, with an additional
Packit 709fb3
   NULL argument at the end.  */
Packit 709fb3
void
Packit 709fb3
version_etc (FILE *stream,
Packit 709fb3
             const char *command_name, const char *package,
Packit 709fb3
             const char *version, /* const char *author1, ...*/ ...)
Packit 709fb3
{
Packit 709fb3
  va_list authors;
Packit 709fb3
Packit 709fb3
  va_start (authors, version);
Packit 709fb3
  version_etc_va (stream, command_name, package, version, authors);
Packit 709fb3
  va_end (authors);
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
void
Packit 709fb3
emit_bug_reporting_address (void)
Packit 709fb3
{
Packit 709fb3
  /* TRANSLATORS: The placeholder indicates the bug-reporting address
Packit 709fb3
     for this package.  Please add _another line_ saying
Packit 709fb3
     "Report translation bugs to <...>\n" with the address for translation
Packit 709fb3
     bugs (typically your translation team's web or email address).  */
Packit 709fb3
  printf (_("\nReport bugs to: %s\n"), PACKAGE_BUGREPORT);
Packit 709fb3
#ifdef PACKAGE_PACKAGER_BUG_REPORTS
Packit 709fb3
  printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER,
Packit 709fb3
          PACKAGE_PACKAGER_BUG_REPORTS);
Packit 709fb3
#endif
Packit 709fb3
#ifdef PACKAGE_URL
Packit 709fb3
  printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
Packit 709fb3
#else
Packit 709fb3
  printf (_("%s home page: <http://www.gnu.org/software/%s/>\n"),
Packit 709fb3
          PACKAGE_NAME, PACKAGE);
Packit 709fb3
#endif
Packit 709fb3
  fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
Packit 709fb3
         stdout);
Packit 709fb3
}