1 /* NetHack 3.6 version.c $NHDT-Date: 1449328116 2015/12/05 15:08:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.41 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */
8 /* JNetHack may be freely redistributed. See license for details. */
14 * All the references to the contents of patchlevel.h have been moved
17 #ifdef SHORT_FILENAMES
19 #include "../japanese/jpatchle.h"
21 #include "patchlevel.h"
22 #include "../japanese/jpatchlevel.h"
27 STATIC_DCL void FDECL(insert_rtoptions, (winid,char *,const char *));
29 /* fill buffer with short version (so caller can avoid including date.h) */
34 return strcpy(buf, VERSION_STRING);
37 /* fill and return the given buffer with the long nethack version string */
42 Strcpy(buf, VERSION_ID);
43 #if defined(BETA) && defined(BETA_INFO)
44 Sprintf(eos(buf), " %s", BETA_INFO);
46 #if defined(RUNTIME_PORT_ID)
58 pline("%s", getversionstring(buf));
60 pline("%s", JVERSION_ID);
65 /* the '#version' command; also a choice for '?' */
70 char *cr, *pd, buf[BUFSZ];
71 winid win = create_nhwindow(NHW_TEXT);
72 boolean rtadded = FALSE;
74 /* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
75 the file manually so we can include dynamic version info */
76 putstr(win, 0, getversionstring(buf));
78 f = dlb_fopen(OPTIONS_USED, "r");
81 Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED);
85 * already inserted above:
86 * + outdented program name and version plus build date and time
87 * dat/options; display the contents with lines prefixed by '-'
90 * - indented program name and version
92 * outdented feature header
94 * indented feature list
95 * spread over multiple lines
97 * outdented windowing header
99 * indented windowing choices with
100 * optional second line for default
104 boolean prolog = TRUE; /* to skip indented program name */
106 while (dlb_fgets(buf, BUFSZ, f)) {
107 if ((cr = index(buf, '\n')) != 0)
109 if ((cr = index(buf, '\r')) != 0)
111 if (index(buf, '\t') != 0)
112 (void) tabexpand(buf);
114 if (*buf && *buf != ' ') {
115 /* found outdented header; insert a separator since we'll
116 have skipped corresponding blank line inside the file */
120 /* skip blank lines and prolog (progame name plus version) */
125 const char *catchphrase = ", and basic NetHack features.";
127 pd = strstri(buf, catchphrase);
130 insert_rtoptions(win, buf, &catchphrase[2]);
131 rtadded = TRUE; /* only do it once */
137 (void) dlb_fclose(f);
138 display_nhwindow(win, FALSE);
139 destroy_nhwindow(win);
144 extern const char regex_id[];
146 static const char *rt_opts[] = {
147 "pattern matching via", regex_id,
149 static const char indent[] = " ";
153 * Some optional stuff is no longer available to makedefs because
154 * it depends which of several object files got linked into the
155 * game image, so we insert those options here.
158 insert_rtoptions(win, buf, finalphrase)
161 const char *finalphrase;
165 const char *s1 = 0, *s2 = 0, *s3 = 0, *s4 = 0;
167 if ((int) strlen(buf) >= (BUFSZ - 1))
171 for (i = 0; i < (SIZE(rt_opts) + 1); i += 2) {
172 if (i < SIZE(rt_opts)) {
183 l = (int) strlen(rtbuf) + (int) strlen(s1) + (int) strlen(s2)
184 + (int) strlen(s3) + (int) strlen(s4) + 1;
185 if (l <= (COLNO - 5) && l < (BUFSZ - 1)) {
191 putstr(win, 0, rtbuf);
192 if (i >= SIZE(rt_opts))
194 l = (int) strlen(indent) + (int) strlen(s1) + (int) strlen(s2)
195 + (int) strlen(s3) + (int) strlen(s4) + 1;
196 if (l <= (COLNO - 5) && l < (BUFSZ - 1)) {
197 Strcpy(rtbuf, indent);
207 putstr(win, 0, rtbuf);
216 return (boolean) (filetime < BUILD_TIME);
221 check_version(version_data, filename, complain)
222 struct version_info *version_data;
223 const char *filename;
227 #ifdef VERSION_COMPATIBILITY
228 version_data->incarnation < VERSION_COMPATIBILITY
229 || version_data->incarnation > VERSION_NUMBER
231 version_data->incarnation != VERSION_NUMBER
235 pline("Version mismatch for file \"%s\".", filename);
238 #ifndef IGNORED_FEATURES
239 version_data->feature_set != VERSION_FEATURES
241 (version_data->feature_set & ~IGNORED_FEATURES)
242 != (VERSION_FEATURES & ~IGNORED_FEATURES)
244 || version_data->entity_count != VERSION_SANITY1
245 || version_data->struct_sizes1 != VERSION_SANITY2
246 || version_data->struct_sizes2 != VERSION_SANITY3) {
248 pline("Configuration incompatibility for file \"%s\".", filename);
254 /* this used to be based on file date and somewhat OS-dependant,
255 but now examines the initial part of the file's contents */
262 struct version_info vers_info;
263 boolean verbose = name ? TRUE : FALSE;
265 rlen = read(fd, (genericptr_t) &vers_info, sizeof vers_info);
266 minit(); /* ZEROCOMP */
269 pline("File \"%s\" is empty?", name);
274 if (!check_version(&vers_info, name, verbose)) {
286 static const struct version_info version_data = {
287 VERSION_NUMBER, VERSION_FEATURES,
288 VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3
292 /* bwrite() before bufon() uses plain write() */
293 bwrite(fd, (genericptr_t) &version_data,
294 (unsigned) (sizeof version_data));
300 const char amiga_version_string[] = AMIGA_VERSION_STRING;
304 get_feature_notice_ver(str)
308 int ver_maj, ver_min, patch;
314 str = strcpy(buf, str);
323 } else if (index("0123456789", *str) != 0) {
330 ver_maj = atoi(istr[0]);
331 ver_min = atoi(istr[1]);
332 patch = atoi(istr[2]);
333 return FEATURE_NOTICE_VER(ver_maj, ver_min, patch);
334 /* macro from hack.h */
338 get_current_feature_ver()
340 return FEATURE_NOTICE_VER(VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL);
345 copyright_banner_line(indx)
348 #ifdef COPYRIGHT_BANNER_A
350 return COPYRIGHT_BANNER_A;
352 #ifdef COPYRIGHT_BANNER_B
354 return COPYRIGHT_BANNER_B;
356 #ifdef COPYRIGHT_BANNER_C
358 return COPYRIGHT_BANNER_C;
360 #ifdef COPYRIGHT_BANNER_D
362 return COPYRIGHT_BANNER_D;