File: version.c

package info (click to toggle)
slrn 1.0.3+dfsg-3
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 6,412 kB
  • sloc: ansic: 39,852; sh: 3,777; perl: 467; makefile: 229; sed: 24
file content (246 lines) | stat: -rw-r--r-- 5,781 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
 This file is part of SLRN.

 Copyright (c) 1994, 1999, 2007-2016 John E. Davis <jed@jedsoft.org>
 Copyright (c) 2001-2006 Thomas Schultz <tststs@gmx.de>

 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the Free
 Software Foundation; either version 2 of the License, or (at your option)
 any later version.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "slrnfeat.h"

#include <stdio.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif

#ifdef HAVE_SYS_UTSNAME_H
# include <sys/utsname.h>
#endif

#include <slang.h>
#include "jdmacros.h"
#include "version.h"
#include "util.h"
#include "server.h"
#include "group.h"
#include "art.h"
#include "snprintf.h"

char *Slrn_Version_String = SLRN_VERSION_STRING;
int Slrn_Version = SLRN_VERSION;

typedef struct
{
   char *name;
   int value;
}
Compile_Option_Type;

static Compile_Option_Type Backend_Options [] =
{
   {"nntp",			SLRN_HAS_NNTP_SUPPORT},
   {"slrnpull",			SLRN_HAS_PULL_SUPPORT},
   {"spool",			SLRN_HAS_SPOOL_SUPPORT},
   {NULL, 0}
};

static Compile_Option_Type External_Lib_Options [] =
{
   {"canlock",			SLRN_HAS_CANLOCK},
   {"inews",			SLRN_HAS_INEWS_SUPPORT},
   {"ssl",			SLTCP_HAS_SSL_SUPPORT},
   {"uudeview",    		SLRN_HAS_UUDEVIEW},
#ifdef HAVE_ICONV
   {"iconv",			1},
#else
   {"iconv",			0},
#endif
   {NULL, 0}
};

static Compile_Option_Type Feature_Options [] =
{
   {"decoding",			SLRN_HAS_DECODE},
   {"emphasized_text",		SLRN_HAS_EMPHASIZED_TEXT},
   {"end_of_thread",		SLRN_HAS_END_OF_THREAD},
   {"fake_refs",   		SLRN_HAS_FAKE_REFS},
   {"gen_msgid",   		SLRN_HAS_GEN_MSGID},
   {"grouplens",   		SLRN_HAS_GROUPLENS},
   {"msgid_cache", 		SLRN_HAS_MSGID_CACHE},
   {"piping",	     		SLRN_HAS_PIPING},
   {"rnlock",	     		SLRN_HAS_RNLOCK},
   {"spoilers",    		SLRN_HAS_SPOILERS},
   {"strict_from",		SLRN_HAS_STRICT_FROM},
   {NULL, 0}
};

static void print_options (FILE *fp, Compile_Option_Type *opts, char *title)
{
   unsigned int len;

   (void) fprintf (fp, " %s:", title);
   len = strlen (title);
   while (opts->name != NULL)
     {
	unsigned int dlen = strlen (opts->name) + 2;

   	len += dlen;
	if (len >= 80)
	  {
	     (void) fputs ("\n   ", fp);
	     len = dlen + 3;
	  }
	(void) fprintf (fp, " %c%s", (opts->value ? '+' : '-'), opts->name);
	opts++;
     }
   (void) fputc ('\n', fp);
}

static void show_compile_time_options (FILE *fp)
{
   (void) fprintf (fp, "%s:\n", _("COMPILE TIME OPTIONS"));
   print_options (fp, Backend_Options, _("Backends"));
   print_options (fp, External_Lib_Options, _("External programs / libs"));
   print_options (fp, Feature_Options, _("Features"));
   (void) fprintf (fp, _(" Using %d bit integers for article numbers.\n"),
		   8*(int)sizeof(NNTP_Artnum_Type));
}

void slrn_show_version (FILE *fp) /*{{{*/
{
   char *os;

   os = slrn_get_os_name ();

   fprintf (fp, "slrn %s\n", Slrn_Version_String);
   if (*Slrn_Version_String == 'p')
     fprintf (fp, _("\t* Note: This version is a developer preview.\n"));
   fprintf (fp, _("S-Lang Library Version: %s\n"), SLang_Version_String);
   if (SLANG_VERSION != SLang_Version)
     {
	fprintf (fp, _("\t* Note: This program was compiled against version %s.\n"),
		 SLANG_VERSION_STRING);
     }
/* #if defined(__DATE__) && defined(__TIME__) */
/*    fprintf (fp, _("Compiled on: %s %s\n"), __DATE__, __TIME__); */
/* #endif */
   fprintf (fp, _("Operating System: %s\n"), os);

   (void) fputs ("\n", fp);
   show_compile_time_options (fp);

   (void) fputs ("\n", fp);
   fprintf (fp, _("DEFAULTS:\n Default server object:     %s\n"),
	    slrn_map_object_id_to_name (0, SLRN_DEFAULT_SERVER_OBJ));

   fprintf (fp, _(" Default posting mechanism: %s\n"),
	    slrn_map_object_id_to_name (1, SLRN_DEFAULT_POST_OBJ));
}

/*}}}*/

#ifdef REAL_UNIX_SYSTEM
static char *get_unix_system_name (void)
{
# ifdef HAVE_UNAME
   static struct utsname u;

   if (-1 != uname (&u))
     return u.sysname;
# endif
   return "Unix";
}
#endif				       /* Unix */

#ifdef VMS
static char *get_vms_system_name (void)
{
# ifdef MULTINET
   return "VMS/Multinet";
# else
#  ifdef UXC
   return "VMS/UCX";
#  else
#   ifdef NETLIB
   return "VMS/Netlib";
#   else
   return "VMS";
#   endif
#  endif
# endif
}
#endif				       /* VMS */

#ifdef __os2__
static char *get_os2_system_name (void)
{
   return "OS/2";
}
#endif

#ifdef AMIGA
static char *get_amiga_system_name (void)
{
   return "Amiga";
}
#endif

#if defined(__WIN32__)
static char *get_win32_system_name (void)
{
   return "Win32";
}
#endif

#if defined(__BEOS__)
static char *get_beos_system_name (void)
{
   return "BeOS";
}
#endif

char *slrn_get_os_name (void)
{
#ifdef REAL_UNIX_SYSTEM
   return get_unix_system_name ();
#else
# ifdef VMS
   return get_vms_system_name ();
# else
#  ifdef __os2__
   return get_os2_system_name ();
#  else
#   ifdef AMIGA
   return get_amiga_system_name ();
#   else
#    if defined(__WIN32__)
   return get_win32_system_name ();
#    else
#     if defined(__BEOS__)
   return get_beos_system_name ();
#     else
   return "Unknown";
#     endif			       /* BEOS */
#    endif			       /* WIN32 */
#   endif			       /* AMIGA */
#  endif			       /* OS/2 */
# endif				       /* VMS */
#endif				       /* UNIX */
}