Change one-line summary to reflect that shred does
[coreutils.git] / lib / version-etc.c
blob95b7e40d15fa5cbb92a10c3e5c076ace1e563362
1 /* Utility to help print --version output in a consistent format.
2 Copyright (C) 1999-2005 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /* Written by Jim Meyering. */
20 #if HAVE_CONFIG_H
21 # include <config.h>
22 #endif
24 /* Specification. */
25 #include "version-etc.h"
27 #include <stdarg.h>
28 #include <stdio.h>
29 #include <stdlib.h>
31 #if USE_UNLOCKED_IO
32 # include "unlocked-io.h"
33 #endif
35 #include "gettext.h"
36 #define _(msgid) gettext (msgid)
38 /* Default copyright goes to the FSF. */
40 const char* version_etc_copyright =
41 /* Do *not* mark this string for translation. */
42 "Copyright (C) 2005 Free Software Foundation, Inc.";
45 /* Like version_etc, below, but with the NULL-terminated author list
46 provided via a variable of type va_list. */
47 void
48 version_etc_va (FILE *stream,
49 const char *command_name, const char *package,
50 const char *version, va_list authors)
52 size_t n_authors;
54 /* Count the number of authors. */
56 va_list tmp_authors;
58 #ifdef __va_copy
59 __va_copy (tmp_authors, authors);
60 #else
61 tmp_authors = authors;
62 #endif
64 n_authors = 0;
65 while (va_arg (tmp_authors, const char *) != NULL)
66 ++n_authors;
69 if (command_name)
70 fprintf (stream, "%s (%s) %s\n", command_name, package, version);
71 else
72 fprintf (stream, "%s %s\n", package, version);
74 switch (n_authors)
76 case 0:
77 /* The caller must provide at least one author name. */
78 abort ();
79 case 1:
80 /* TRANSLATORS: %s denotes an author name. */
81 vfprintf (stream, _("Written by %s.\n"), authors);
82 break;
83 case 2:
84 /* TRANSLATORS: Each %s denotes an author name. */
85 vfprintf (stream, _("Written by %s and %s.\n"), authors);
86 break;
87 case 3:
88 /* TRANSLATORS: Each %s denotes an author name. */
89 vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors);
90 break;
91 case 4:
92 /* TRANSLATORS: Each %s denotes an author name.
93 You can use line breaks, estimating that each author name occupies
94 ca. 16 screen columns and that a screen line has ca. 80 columns. */
95 vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors);
96 break;
97 case 5:
98 /* TRANSLATORS: Each %s denotes an author name.
99 You can use line breaks, estimating that each author name occupies
100 ca. 16 screen columns and that a screen line has ca. 80 columns. */
101 vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors);
102 break;
103 case 6:
104 /* TRANSLATORS: Each %s denotes an author name.
105 You can use line breaks, estimating that each author name occupies
106 ca. 16 screen columns and that a screen line has ca. 80 columns. */
107 vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
108 authors);
109 break;
110 case 7:
111 /* TRANSLATORS: Each %s denotes an author name.
112 You can use line breaks, estimating that each author name occupies
113 ca. 16 screen columns and that a screen line has ca. 80 columns. */
114 vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
115 authors);
116 break;
117 case 8:
118 /* TRANSLATORS: Each %s denotes an author name.
119 You can use line breaks, estimating that each author name occupies
120 ca. 16 screen columns and that a screen line has ca. 80 columns. */
121 vfprintf (stream, _("\
122 Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
123 authors);
124 break;
125 case 9:
126 /* TRANSLATORS: Each %s denotes an author name.
127 You can use line breaks, estimating that each author name occupies
128 ca. 16 screen columns and that a screen line has ca. 80 columns. */
129 vfprintf (stream, _("\
130 Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
131 authors);
132 break;
133 default:
134 /* 10 or more authors. Use an abbreviation, since the human reader
135 will probably not want to read the entire list anyway. */
136 /* TRANSLATORS: Each %s denotes an author name.
137 You can use line breaks, estimating that each author name occupies
138 ca. 16 screen columns and that a screen line has ca. 80 columns. */
139 vfprintf (stream, _("\
140 Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
141 authors);
142 break;
144 va_end (authors);
145 putc ('\n', stream);
147 fputs (version_etc_copyright, stream);
148 putc ('\n', stream);
150 fputs (_("\
151 This is free software; see the source for copying conditions. There is NO\n\
152 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"),
153 stream);
157 /* Display the --version information the standard way.
159 If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
160 the program. The formats are therefore:
162 PACKAGE VERSION
166 COMMAND_NAME (PACKAGE) VERSION.
168 The author names are passed as separate arguments, with an additional
169 NULL argument at the end. */
170 void
171 version_etc (FILE *stream,
172 const char *command_name, const char *package,
173 const char *version, /* const char *author1, ...*/ ...)
175 va_list authors;
177 va_start (authors, version);
178 version_etc_va (stream, command_name, package, version, authors);