Try to handle "function declaration isn't a prototype" warnings.
[gnutls.git] / gl / version-etc.c
blob1ae82c4179d86ba61376e08aaf9a2eb390226836
1 /* Utility to help print --version output in a consistent format.
2 Copyright (C) 1999-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Jim Meyering. */
20 #include <config.h>
22 /* Specification. */
23 #include "version-etc.h"
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
29 #if USE_UNLOCKED_IO
30 # include "unlocked-io.h"
31 #endif
33 #include "gettext.h"
34 #define _(msgid) gettext (msgid)
36 enum { COPYRIGHT_YEAR = 2007 };
38 /* Like version_etc, below, but with the NULL-terminated author list
39 provided via a variable of type va_list. */
40 void
41 version_etc_va (FILE *stream,
42 const char *command_name, const char *package,
43 const char *version, va_list authors)
45 size_t n_authors;
47 /* Count the number of authors. */
49 va_list tmp_authors;
51 va_copy (tmp_authors, authors);
53 n_authors = 0;
54 while (va_arg (tmp_authors, const char *) != NULL)
55 ++n_authors;
58 if (command_name)
59 fprintf (stream, "%s (%s) %s\n", command_name, package, version);
60 else
61 fprintf (stream, "%s %s\n", package, version);
63 /* TRANSLATORS: Translate "(C)" to the copyright symbol
64 (C-in-a-circle), if this symbol is available in the user's
65 locale. Otherwise, do not translate "(C)"; leave it as-is. */
66 fprintf (stream, version_etc_copyright, _("(C)"), COPYRIGHT_YEAR);
68 fputs (_("\
69 \n\
70 License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n\
71 This is free software: you are free to change and redistribute it.\n\
72 There is NO WARRANTY, to the extent permitted by law.\n\
73 \n\
74 "),
75 stream);
77 switch (n_authors)
79 case 0:
80 /* The caller must provide at least one author name. */
81 abort ();
82 case 1:
83 /* TRANSLATORS: %s denotes an author name. */
84 vfprintf (stream, _("Written by %s.\n"), authors);
85 break;
86 case 2:
87 /* TRANSLATORS: Each %s denotes an author name. */
88 vfprintf (stream, _("Written by %s and %s.\n"), authors);
89 break;
90 case 3:
91 /* TRANSLATORS: Each %s denotes an author name. */
92 vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors);
93 break;
94 case 4:
95 /* TRANSLATORS: Each %s denotes an author name.
96 You can use line breaks, estimating that each author name occupies
97 ca. 16 screen columns and that a screen line has ca. 80 columns. */
98 vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors);
99 break;
100 case 5:
101 /* TRANSLATORS: Each %s denotes an author name.
102 You can use line breaks, estimating that each author name occupies
103 ca. 16 screen columns and that a screen line has ca. 80 columns. */
104 vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors);
105 break;
106 case 6:
107 /* TRANSLATORS: Each %s denotes an author name.
108 You can use line breaks, estimating that each author name occupies
109 ca. 16 screen columns and that a screen line has ca. 80 columns. */
110 vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
111 authors);
112 break;
113 case 7:
114 /* TRANSLATORS: Each %s denotes an author name.
115 You can use line breaks, estimating that each author name occupies
116 ca. 16 screen columns and that a screen line has ca. 80 columns. */
117 vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
118 authors);
119 break;
120 case 8:
121 /* TRANSLATORS: Each %s denotes an author name.
122 You can use line breaks, estimating that each author name occupies
123 ca. 16 screen columns and that a screen line has ca. 80 columns. */
124 vfprintf (stream, _("\
125 Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
126 authors);
127 break;
128 case 9:
129 /* TRANSLATORS: Each %s denotes an author name.
130 You can use line breaks, estimating that each author name occupies
131 ca. 16 screen columns and that a screen line has ca. 80 columns. */
132 vfprintf (stream, _("\
133 Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
134 authors);
135 break;
136 default:
137 /* 10 or more authors. Use an abbreviation, since the human reader
138 will probably not want to read the entire list anyway. */
139 /* TRANSLATORS: Each %s denotes an author name.
140 You can use line breaks, estimating that each author name occupies
141 ca. 16 screen columns and that a screen line has ca. 80 columns. */
142 vfprintf (stream, _("\
143 Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
144 authors);
145 break;
147 va_end (authors);
151 /* Display the --version information the standard way.
153 If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
154 the program. The formats are therefore:
156 PACKAGE VERSION
160 COMMAND_NAME (PACKAGE) VERSION.
162 The author names are passed as separate arguments, with an additional
163 NULL argument at the end. */
164 void
165 version_etc (FILE *stream,
166 const char *command_name, const char *package,
167 const char *version, /* const char *author1, ...*/ ...)
169 va_list authors;
171 va_start (authors, version);
172 version_etc_va (stream, command_name, package, version, authors);