1 /* NetHack 3.6 version.c $NHDT-Date: 1524693365 2018/04/25 21:56:05 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.49 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Michael Allison, 2018. */
4 /* NetHack may be freely redistributed. See license for details. */
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2018 */
9 /* JNetHack may be freely redistributed. See license for details. */
15 * All the references to the contents of patchlevel.h have been moved
18 #ifdef SHORT_FILENAMES
20 #include "../japanese/jpatchle.h"
22 #include "patchlevel.h"
23 #include "../japanese/jpatchlevel.h"
26 #if defined(NETHACK_GIT_SHA)
27 const char * NetHack_git_sha = NETHACK_GIT_SHA;
29 #if defined(NETHACK_GIT_BRANCH)
30 const char * NetHack_git_branch = NETHACK_GIT_BRANCH;
33 STATIC_DCL void FDECL(insert_rtoption, (char *));
35 /* fill buffer with short version (so caller can avoid including date.h) */
40 return strcpy(buf, VERSION_STRING);
43 /* fill and return the given buffer with the long nethack version string */
48 boolean details = FALSE;
50 Strcpy(buf, VERSION_ID);
51 #if defined(RUNTIME_PORT_ID) || \
52 defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH)
57 #if defined(RUNTIME_PORT_ID) || defined(NETHACK_GIT_SHA) || defined(NETHACK_GIT_BRANCH)
60 #if defined(RUNTIME_PORT_ID)
62 char *tmp = (char *)0;
65 Sprintf(eos(buf), " (");
66 #if defined(RUNTIME_PORT_ID)
67 tmp = get_port_id(tmpbuf);
69 Sprintf(eos(buf), "%s%s", c++ ? "," : "", tmp);
71 #if defined(NETHACK_GIT_SHA)
73 Sprintf(eos(buf), "%s%s", c++ ? "," : "", NetHack_git_sha);
75 #if defined(NETHACK_GIT_BRANCH)
77 if (NetHack_git_branch)
78 Sprintf(eos(buf), "%sbranch:%s", c++ ? "," : "", NetHack_git_branch);
81 Sprintf(eos(buf), ")");
92 pline("%s", getversionstring(buf));
94 pline("%s", JVERSION_ID);
99 /* the '#version' command; also a choice for '?' */
105 winid win = create_nhwindow(NHW_TEXT);
107 /* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
108 the file manually so we can include dynamic version info */
109 putstr(win, 0, getversionstring(buf));
111 f = dlb_fopen(OPTIONS_USED, "r");
114 Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED);
118 * already inserted above:
119 * + outdented program name and version plus build date and time
120 * dat/options; display contents with lines prefixed by '-' deleted:
122 * - indented program name and version
124 * outdented feature header
126 * indented feature list
127 * spread over multiple lines
129 * outdented windowing header
131 * indented windowing choices with
132 * optional second line for default
136 boolean prolog = TRUE; /* to skip indented program name */
138 while (dlb_fgets(buf, BUFSZ, f)) {
139 (void) strip_newline(buf);
140 if (index(buf, '\t') != 0)
141 (void) tabexpand(buf);
143 if (*buf && *buf != ' ') {
144 /* found outdented header; insert a separator since we'll
145 have skipped corresponding blank line inside the file */
149 /* skip blank lines and prolog (progame name plus version) */
154 insert_rtoption(buf);
159 (void) dlb_fclose(f);
160 display_nhwindow(win, FALSE);
161 destroy_nhwindow(win);
166 void early_version_info(pastebuf)
169 char buf[BUFSZ], buf2[BUFSZ];
170 char *tmp = getversionstring(buf);
172 /* this is early enough that we have to do
173 our own line-splitting */
175 tmp = strstri(buf," (");
176 if (tmp) *tmp++ = '\0';
179 Sprintf(buf2, "%s\n", buf);
180 if (tmp) Sprintf(eos(buf2), "%s\n", tmp);
181 raw_printf("%s", buf2);
184 #ifdef RUNTIME_PASTEBUF_SUPPORT
186 * Call a platform/port-specific routine to insert the
187 * version information into a paste buffer. Useful for
188 * easy inclusion in bug reports.
190 port_insert_pastebuf(buf2);
192 raw_printf("%s", "Paste buffer copy is not available.\n");
197 extern const char regex_id[];
200 * makedefs should put the first token into dat/options; we'll substitute
201 * the second value for it. The token must contain at least one colon
202 * so that we can spot it, and should not contain spaces so that makedefs
203 * won't split it across lines. Ideally the length should be close to
204 * that of the substituted value since we don't do phrase-splitting/line-
205 * wrapping when displaying it.
207 static struct rt_opt {
208 const char *token, *value;
210 { ":PATMATCH:", regex_id },
215 * Some optional stuff is no longer available to makedefs because
216 * it depends which of several object files got linked into the
217 * game image, so we insert those options here.
225 for (i = 0; i < SIZE(rt_opts); ++i) {
226 if (strstri(buf, rt_opts[i].token))
227 (void) strsubst(buf, rt_opts[i].token, rt_opts[i].value);
228 /* we don't break out of the loop after a match; there might be
229 other matches on the same line */
238 /* BUILD_TIME is constant but might have L suffix rather than UL;
239 'filetime' is historically signed but ought to have been unsigned */
240 return (boolean) ((unsigned long) filetime < (unsigned long) BUILD_TIME);
245 check_version(version_data, filename, complain)
246 struct version_info *version_data;
247 const char *filename;
251 #ifdef VERSION_COMPATIBILITY
252 version_data->incarnation < VERSION_COMPATIBILITY
253 || version_data->incarnation > VERSION_NUMBER
255 version_data->incarnation != VERSION_NUMBER
259 pline("Version mismatch for file \"%s\".", filename);
262 #ifndef IGNORED_FEATURES
263 version_data->feature_set != VERSION_FEATURES
265 (version_data->feature_set & ~IGNORED_FEATURES)
266 != (VERSION_FEATURES & ~IGNORED_FEATURES)
268 || version_data->entity_count != VERSION_SANITY1
269 || version_data->struct_sizes1 != VERSION_SANITY2
270 || version_data->struct_sizes2 != VERSION_SANITY3) {
272 pline("Configuration incompatibility for file \"%s\".", filename);
278 /* this used to be based on file date and somewhat OS-dependant,
279 but now examines the initial part of the file's contents */
286 struct version_info vers_info;
287 boolean verbose = name ? TRUE : FALSE;
289 rlen = read(fd, (genericptr_t) &vers_info, sizeof vers_info);
290 minit(); /* ZEROCOMP */
293 pline("File \"%s\" is empty?", name);
298 if (!check_version(&vers_info, name, verbose)) {
310 static const struct version_info version_data = {
311 VERSION_NUMBER, VERSION_FEATURES,
312 VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3
316 /* bwrite() before bufon() uses plain write() */
317 bwrite(fd, (genericptr_t) &version_data,
318 (unsigned) (sizeof version_data));
324 const char amiga_version_string[] = AMIGA_VERSION_STRING;
328 get_feature_notice_ver(str)
332 int ver_maj, ver_min, patch;
338 str = strcpy(buf, str);
347 } else if (index("0123456789", *str) != 0) {
354 ver_maj = atoi(istr[0]);
355 ver_min = atoi(istr[1]);
356 patch = atoi(istr[2]);
357 return FEATURE_NOTICE_VER(ver_maj, ver_min, patch);
358 /* macro from hack.h */
362 get_current_feature_ver()
364 return FEATURE_NOTICE_VER(VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL);
369 copyright_banner_line(indx)
372 #ifdef COPYRIGHT_BANNER_A
374 return COPYRIGHT_BANNER_A;
376 #ifdef COPYRIGHT_BANNER_B
378 return COPYRIGHT_BANNER_B;
380 #ifdef COPYRIGHT_BANNER_C
382 return COPYRIGHT_BANNER_C;
384 #ifdef COPYRIGHT_BANNER_D
386 return COPYRIGHT_BANNER_D;