Blame lib/version-etc.c

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