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. */
9 * All the references to the contents of patchlevel.h have been moved
12 #ifdef SHORT_FILENAMES
15 #include "patchlevel.h"
20 STATIC_DCL
void FDECL(insert_rtoptions
, (winid
,char *,const char *));
22 /* fill buffer with short version (so caller can avoid including date.h) */
27 return strcpy(buf
, VERSION_STRING
);
30 /* fill and return the given buffer with the long nethack version string */
35 Strcpy(buf
, VERSION_ID
);
36 #if defined(BETA) && defined(BETA_INFO)
37 Sprintf(eos(buf
), " %s", BETA_INFO
);
39 #if defined(RUNTIME_PORT_ID)
51 pline("%s", getversionstring(buf
));
55 /* the '#version' command; also a choice for '?' */
61 winid win
= create_nhwindow(NHW_TEXT
);
62 boolean rtadded
= FALSE
;
64 /* instead of using ``display_file(OPTIONS_USED,TRUE)'' we handle
65 the file manually so we can include dynamic version info */
66 putstr(win
, 0, getversionstring(buf
));
68 f
= dlb_fopen(OPTIONS_USED
, "r");
71 Sprintf(buf
, "[Configuration '%s' not available?]", OPTIONS_USED
);
75 * already inserted above:
76 * + outdented program name and version plus build date and time
77 * dat/options; display the contents with lines prefixed by '-'
80 * - indented program name and version
82 * outdented feature header
84 * indented feature list
85 * spread over multiple lines
87 * outdented windowing header
89 * indented windowing choices with
90 * optional second line for default
94 boolean prolog
= TRUE
; /* to skip indented program name */
96 while (dlb_fgets(buf
, BUFSZ
, f
)) {
97 (void) strip_newline(buf
);
98 if (index(buf
, '\t') != 0)
99 (void) tabexpand(buf
);
101 if (*buf
&& *buf
!= ' ') {
102 /* found outdented header; insert a separator since we'll
103 have skipped corresponding blank line inside the file */
107 /* skip blank lines and prolog (progame name plus version) */
112 const char *catchphrase
= ", and basic NetHack features.";
114 pd
= strstri(buf
, catchphrase
);
117 insert_rtoptions(win
, buf
, &catchphrase
[2]);
118 rtadded
= TRUE
; /* only do it once */
124 (void) dlb_fclose(f
);
125 display_nhwindow(win
, FALSE
);
126 destroy_nhwindow(win
);
131 extern const char regex_id
[];
133 static const char *rt_opts
[] = {
134 "pattern matching via", regex_id
,
136 static const char indent
[] = " ";
140 * Some optional stuff is no longer available to makedefs because
141 * it depends which of several object files got linked into the
142 * game image, so we insert those options here.
145 insert_rtoptions(win
, buf
, finalphrase
)
148 const char *finalphrase
;
152 const char *s1
= 0, *s2
= 0, *s3
= 0, *s4
= 0;
154 if ((int) strlen(buf
) >= (BUFSZ
- 1))
158 for (i
= 0; i
< (SIZE(rt_opts
) + 1); i
+= 2) {
159 if (i
< SIZE(rt_opts
)) {
170 l
= (int) strlen(rtbuf
) + (int) strlen(s1
) + (int) strlen(s2
)
171 + (int) strlen(s3
) + (int) strlen(s4
) + 1;
172 if (l
<= (COLNO
- 5) && l
< (BUFSZ
- 1)) {
178 putstr(win
, 0, rtbuf
);
179 if (i
>= SIZE(rt_opts
))
181 l
= (int) strlen(indent
) + (int) strlen(s1
) + (int) strlen(s2
)
182 + (int) strlen(s3
) + (int) strlen(s4
) + 1;
183 if (l
<= (COLNO
- 5) && l
< (BUFSZ
- 1)) {
184 Strcpy(rtbuf
, indent
);
194 putstr(win
, 0, rtbuf
);
203 return (boolean
) (filetime
< BUILD_TIME
);
208 check_version(version_data
, filename
, complain
)
209 struct version_info
*version_data
;
210 const char *filename
;
214 #ifdef VERSION_COMPATIBILITY
215 version_data
->incarnation
< VERSION_COMPATIBILITY
216 || version_data
->incarnation
> VERSION_NUMBER
218 version_data
->incarnation
!= VERSION_NUMBER
222 pline("Version mismatch for file \"%s\".", filename
);
225 #ifndef IGNORED_FEATURES
226 version_data
->feature_set
!= VERSION_FEATURES
228 (version_data
->feature_set
& ~IGNORED_FEATURES
)
229 != (VERSION_FEATURES
& ~IGNORED_FEATURES
)
231 || version_data
->entity_count
!= VERSION_SANITY1
232 || version_data
->struct_sizes1
!= VERSION_SANITY2
233 || version_data
->struct_sizes2
!= VERSION_SANITY3
) {
235 pline("Configuration incompatibility for file \"%s\".", filename
);
241 /* this used to be based on file date and somewhat OS-dependant,
242 but now examines the initial part of the file's contents */
249 struct version_info vers_info
;
250 boolean verbose
= name
? TRUE
: FALSE
;
252 rlen
= read(fd
, (genericptr_t
) &vers_info
, sizeof vers_info
);
253 minit(); /* ZEROCOMP */
256 pline("File \"%s\" is empty?", name
);
261 if (!check_version(&vers_info
, name
, verbose
)) {
273 static const struct version_info version_data
= {
274 VERSION_NUMBER
, VERSION_FEATURES
,
275 VERSION_SANITY1
, VERSION_SANITY2
, VERSION_SANITY3
279 /* bwrite() before bufon() uses plain write() */
280 bwrite(fd
, (genericptr_t
) &version_data
,
281 (unsigned) (sizeof version_data
));
287 const char amiga_version_string
[] = AMIGA_VERSION_STRING
;
291 get_feature_notice_ver(str
)
295 int ver_maj
, ver_min
, patch
;
301 str
= strcpy(buf
, str
);
310 } else if (index("0123456789", *str
) != 0) {
317 ver_maj
= atoi(istr
[0]);
318 ver_min
= atoi(istr
[1]);
319 patch
= atoi(istr
[2]);
320 return FEATURE_NOTICE_VER(ver_maj
, ver_min
, patch
);
321 /* macro from hack.h */
325 get_current_feature_ver()
327 return FEATURE_NOTICE_VER(VERSION_MAJOR
, VERSION_MINOR
, PATCHLEVEL
);
332 copyright_banner_line(indx
)
335 #ifdef COPYRIGHT_BANNER_A
337 return COPYRIGHT_BANNER_A
;
339 #ifdef COPYRIGHT_BANNER_B
341 return COPYRIGHT_BANNER_B
;
343 #ifdef COPYRIGHT_BANNER_C
345 return COPYRIGHT_BANNER_C
;
347 #ifdef COPYRIGHT_BANNER_D
349 return COPYRIGHT_BANNER_D
;