Source:NetHack 3.2.0/version.c

From NetHackWiki
(Redirected from NetHack 3.2.0/version.c)
Jump to navigation Jump to search

Below is the full text to version.c from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/version.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1.    /*	SCCS Id: @(#)version.c	3.2	95/09/10	*/
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #include "hack.h"
6.    #include "date.h"
7.    #ifdef SHORT_FILENAMES
8.    #include "patchlev.h"
9.    #else
10.   #include "patchlevel.h"
11.   #endif
12.   
13.   int
14.   doversion()
15.   {
16.   #ifdef BETA
17.   # ifndef PORT_SUB_ID
18.   	pline("%s NetHack Beta Version %d.%d.%d-%d - last build %s.",
19.   # else
20.   	pline("%s NetHack %s Beta Version %d.%d.%d-%d - last build %s.",
21.   # endif
22.   #else
23.   # ifndef PORT_SUB_ID
24.   	pline("%s NetHack Version %d.%d.%d - last build %s.",
25.   # else
26.   	pline("%s NetHack %s Version %d.%d.%d - last build %s.",
27.   # endif
28.   #endif
29.   #ifndef PORT_SUB_ID
30.   		PORT_ID, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
31.   #else
32.   		PORT_ID, PORT_SUB_ID, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
33.   #endif
34.   #ifdef BETA
35.   		EDITLEVEL,
36.   #endif
37.   		BUILD_DATE);	/* from date.h, generated by 'makedefs' */
38.   	return 0;
39.   }
40.   
41.   int
42.   doextversion()
43.   {
44.   	display_file(OPTIONS_USED, TRUE);
45.   	return 0;
46.   }
47.   
48.   #ifdef MICRO
49.   boolean
50.   comp_times(filetime)
51.   long filetime;
52.   {
53.   	return((boolean)(filetime < BUILD_TIME));
54.   }
55.   #endif
56.   
57.   boolean
58.   check_version(version_info, filename, complain)
59.   long *version_info;
60.   const char *filename;
61.   boolean complain;
62.   {
63.   	if (
64.   #ifdef VERSION_COMPATIBILITY
65.   	    version_info[0] < VERSION_COMPATIBILITY ||
66.   	    version_info[0] > VERSION_NUMBER
67.   #else
68.   	    version_info[0] != VERSION_NUMBER
69.   #endif
70.   	  ) {
71.   	    if (complain)
72.   		pline("Version mismatch for file \"%s\".", filename);
73.   	    return FALSE;
74.   	} else if (version_info[1] != VERSION_FEATURES ||
75.   		   version_info[2] != VERSION_SANITY) {
76.   	    if (complain)
77.   		pline("Configuration incompatability for file \"%s\".",
78.   		      filename);
79.   	    return FALSE;
80.   	}
81.   	return TRUE;
82.   }
83.   
84.   /* this used to be based on file date and somewhat OS-dependant,
85.      but now examines the initial part of the file's contents */
86.   boolean
87.   uptodate(fd, name)
88.   int fd;
89.   const char *name;
90.   {
91.   	long vers_info[3];
92.   	boolean verbose = name ? TRUE : FALSE;
93.   
94.   	(void) read(fd, (genericptr_t) vers_info, sizeof vers_info);
95.   	minit();	/* ZEROCOMP */
96.   	if (!check_version(vers_info, name, verbose)) {
97.   		if (verbose) wait_synch();
98.   		return FALSE;
99.   	}
100.  	return TRUE;
101.  }
102.  
103.  void
104.  store_version(fd)
105.  int fd;
106.  {
107.  	static long version_info[3] = {
108.  			VERSION_NUMBER, VERSION_FEATURES, VERSION_SANITY
109.  	};
110.  
111.  	bufoff(fd);
112.  	/* bwrite() before bufon() uses plain write() */
113.  	bwrite(fd, (genericptr_t)version_info, (unsigned)(sizeof version_info));
114.  	bufon(fd);
115.  	return;
116.  }
117.  
118.  #ifdef AMIGA
119.  const char amiga_version_string[] = AMIGA_VERSION_STRING;
120.  #endif
121.  
122.  /*version.c*/