Blame gnu/version-etc.c

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