/* Utility to help print --version output in a consistent format.1Copyright (C) 1999-2004 Free Software Foundation, Inc.23This program is free software; you can redistribute it and/or modify4it under the terms of the GNU General Public License as published by5the Free Software Foundation; either version 2, or (at your option)6any later version.78This program is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.1213You should have received a copy of the GNU General Public License14along with this program; if not, write to the Free Software Foundation,15Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */1617/* Written by Jim Meyering. */1819#if HAVE_CONFIG_H20# include <config.h>21#endif2223/* Specification. */24#include "version-etc.h"2526#include <stdarg.h>27#include <stdio.h>28#include <stdlib.h>29#include "unlocked-io.h"3031#include "gettext.h"32#define _(msgid) gettext (msgid)3334/* Default copyright goes to the FSF. */3536const char* version_etc_copyright =37/* Do *not* mark this string for translation. */38"Copyright (C) 2004 Free Software Foundation, Inc.";394041/* Like version_etc, below, but with the NULL-terminated author list42provided via a variable of type va_list. */43void44version_etc_va (FILE *stream,45const char *command_name, const char *package,46const char *version, va_list authors)47{48unsigned int n_authors;4950/* Count the number of authors. */51{52va_list tmp_authors;5354#ifdef __va_copy55__va_copy (tmp_authors, authors);56#else57tmp_authors = authors;58#endif5960n_authors = 0;61while (va_arg (tmp_authors, const char *) != NULL)62++n_authors;63}6465if (command_name)66fprintf (stream, "%s (%s) %s\n", command_name, package, version);67else68fprintf (stream, "%s %s\n", package, version);6970switch (n_authors)71{72case 0:73/* The caller must provide at least one author name. */74abort ();75case 1:76/* TRANSLATORS: %s denotes an author name. */77vfprintf (stream, _("Written by %s.\n"), authors);78break;79case 2:80/* TRANSLATORS: Each %s denotes an author name. */81vfprintf (stream, _("Written by %s and %s.\n"), authors);82break;83case 3:84/* TRANSLATORS: Each %s denotes an author name. */85vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors);86break;87case 4:88/* TRANSLATORS: Each %s denotes an author name.89You can use line breaks, estimating that each author name occupies90ca. 16 screen columns and that a screen line has ca. 80 columns. */91vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors);92break;93case 5:94/* TRANSLATORS: Each %s denotes an author name.95You can use line breaks, estimating that each author name occupies96ca. 16 screen columns and that a screen line has ca. 80 columns. */97vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors);98break;99case 6:100/* TRANSLATORS: Each %s denotes an author name.101You can use line breaks, estimating that each author name occupies102ca. 16 screen columns and that a screen line has ca. 80 columns. */103vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),104authors);105break;106case 7:107/* TRANSLATORS: Each %s denotes an author name.108You can use line breaks, estimating that each author name occupies109ca. 16 screen columns and that a screen line has ca. 80 columns. */110vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),111authors);112break;113case 8:114/* TRANSLATORS: Each %s denotes an author name.115You can use line breaks, estimating that each author name occupies116ca. 16 screen columns and that a screen line has ca. 80 columns. */117vfprintf (stream, _("\118Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),119authors);120break;121case 9:122/* TRANSLATORS: Each %s denotes an author name.123You can use line breaks, estimating that each author name occupies124ca. 16 screen columns and that a screen line has ca. 80 columns. */125vfprintf (stream, _("\126Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),127authors);128break;129default:130/* 10 or more authors. Use an abbreviation, since the human reader131will probably not want to read the entire list anyway. */132/* TRANSLATORS: Each %s denotes an author name.133You can use line breaks, estimating that each author name occupies134ca. 16 screen columns and that a screen line has ca. 80 columns. */135vfprintf (stream, _("\136Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),137authors);138break;139}140va_end (authors);141putc ('\n', stream);142143fputs (version_etc_copyright, stream);144putc ('\n', stream);145146fputs (_("\147This is free software; see the source for copying conditions. There is NO\n\148warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"),149stream);150}151152153/* Display the --version information the standard way.154155If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of156the program. The formats are therefore:157158PACKAGE VERSION159160or161162COMMAND_NAME (PACKAGE) VERSION.163164The author names are passed as separate arguments, with an additional165NULL argument at the end. */166void167version_etc (FILE *stream,168const char *command_name, const char *package,169const char *version, /* const char *author1, ...*/ ...)170{171va_list authors;172173va_start (authors, version);174version_etc_va (stream, command_name, package, version, authors);175}176177178