Difference between revisions of "Source:NetHack 3.4.3/src/version.c"
Jump to navigation
Jump to search
m (add headers) |
Kernigh bot (talk | contribs) m (Version.c moved to Source:Version.c: Robot: moved page) |
(No difference)
|
Revision as of 15:29, 4 March 2008
Below is the full text to src/version.c from NetHack 3.4.3. To link to a particular line, write [[version.c#line123]], for example.
Contents
Top of file
1. /* SCCS Id: @(#)version.c 3.4 2003/12/06 */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4.
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.
5. #include "hack.h" 6. #include "date.h" 7. /* 8. * All the references to the contents of patchlevel.h have been moved 9. * into makedefs.... 10. */ 11. #ifdef SHORT_FILENAMES 12. #include "patchlev.h" 13. #else 14. #include "patchlevel.h" 15. #endif 16. 17. /* #define BETA_INFO "" */ /* "[ beta n]" */ 18.
version_string
19. /* fill buffer with short version (so caller can avoid including date.h) */ 20. char * 21. version_string(buf) 22. char *buf; 23. { 24. return strcpy(buf, VERSION_STRING); 25. } 26.
getversionstring
27. /* fill and return the given buffer with the long nethack version string */ 28. char * 29. getversionstring(buf) 30. char *buf; 31. { 32. Strcpy(buf, VERSION_ID); 33. #if defined(BETA) && defined(BETA_INFO) 34. Sprintf(eos(buf), " %s", BETA_INFO); 35. #endif 36. #if defined(RUNTIME_PORT_ID) 37. append_port_id(buf); 38. #endif 39. return buf; 40. } 41.
doversion
42. int 43. doversion() 44. { 45. char buf[BUFSZ]; 46. 47. pline("%s", getversionstring(buf)); 48. return 0; 49. } 50.
doextversion
51. int 52. doextversion() 53. { 54. display_file(OPTIONS_USED, TRUE); 55. return 0; 56. } 57. 58. #ifdef MICRO
comp_times
59. boolean 60. comp_times(filetime) 61. long filetime; 62. { 63. return((boolean)(filetime < BUILD_TIME)); 64. } 65. #endif 66.
check_version
67. boolean 68. check_version(version_data, filename, complain) 69. struct version_info *version_data; 70. const char *filename; 71. boolean complain; 72. { 73. if ( 74. #ifdef VERSION_COMPATIBILITY 75. version_data->incarnation < VERSION_COMPATIBILITY || 76. version_data->incarnation > VERSION_NUMBER 77. #else 78. version_data->incarnation != VERSION_NUMBER 79. #endif 80. ) { 81. if (complain) 82. pline("Version mismatch for file \"%s\".", filename); 83. return FALSE; 84. } else if ( 85. #ifndef IGNORED_FEATURES 86. version_data->feature_set != VERSION_FEATURES || 87. #else 88. (version_data->feature_set & ~IGNORED_FEATURES) != 89. (VERSION_FEATURES & ~IGNORED_FEATURES) || 90. #endif 91. version_data->entity_count != VERSION_SANITY1 || 92. version_data->struct_sizes != VERSION_SANITY2) { 93. if (complain) 94. pline("Configuration incompatibility for file \"%s\".", 95. filename); 96. return FALSE; 97. } 98. return TRUE; 99. } 100.
uptodate
101. /* this used to be based on file date and somewhat OS-dependant, 102. but now examines the initial part of the file's contents */ 103. boolean 104. uptodate(fd, name) 105. int fd; 106. const char *name; 107. { 108. int rlen; 109. struct version_info vers_info; 110. boolean verbose = name ? TRUE : FALSE; 111. 112. rlen = read(fd, (genericptr_t) &vers_info, sizeof vers_info); 113. minit(); /* ZEROCOMP */ 114. if (rlen == 0) { 115. if (verbose) { 116. pline("File \"%s\" is empty?", name); 117. wait_synch(); 118. } 119. return FALSE; 120. } 121. if (!check_version(&vers_info, name, verbose)) { 122. if (verbose) wait_synch(); 123. return FALSE; 124. } 125. return TRUE; 126. } 127.
store_version
128. void 129. store_version(fd) 130. int fd; 131. { 132. const static struct version_info version_data = { 133. VERSION_NUMBER, VERSION_FEATURES, 134. VERSION_SANITY1, VERSION_SANITY2 135. }; 136. 137. bufoff(fd); 138. /* bwrite() before bufon() uses plain write() */ 139. bwrite(fd,(genericptr_t)&version_data,(unsigned)(sizeof version_data)); 140. bufon(fd); 141. return; 142. } 143. 144. #ifdef AMIGA 145. const char amiga_version_string[] = AMIGA_VERSION_STRING; 146. #endif 147.
get_feature_notice_ver
148. unsigned long 149. get_feature_notice_ver(str) 150. char *str; 151. { 152. char buf[BUFSZ]; 153. int ver_maj, ver_min, patch; 154. char *istr[3]; 155. int j = 0; 156. 157. if (!str) return 0L; 158. str = strcpy(buf, str); 159. istr[j] = str; 160. while (*str) { 161. if (*str == '.') { 162. *str++ = '\0'; 163. j++; 164. istr[j] = str; 165. if (j == 2) break; 166. } else if (index("0123456789", *str) != 0) { 167. str++; 168. } else 169. return 0L; 170. } 171. if (j != 2) return 0L; 172. ver_maj = atoi(istr[0]); 173. ver_min = atoi(istr[1]); 174. patch = atoi(istr[2]); 175. return FEATURE_NOTICE_VER(ver_maj,ver_min,patch); 176. /* macro from hack.h */ 177. } 178.
get_current_feature_ver
179. unsigned long 180. get_current_feature_ver() 181. { 182. return FEATURE_NOTICE_VER(VERSION_MAJOR,VERSION_MINOR,PATCHLEVEL); 183. } 184. 185. /*version.c*/