Source:NetHack 3.1.0/system.h

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

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

1.   /*	SCCS Id: @(#)system.h 3.1	92/12/11	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #ifndef SYSTEM_H 6.   #define SYSTEM_H 7.    8.    #ifndef __GO32__  /* djgpp compiler for msdos */ 9.    10.   #define E extern 11.   12.   /* some old  may not define off_t and size_t; if your system is  13. * one of these, define them by hand below 14.   */  15.   #if (defined(VMS) && !defined(__GNUC__)) || defined(MAC) 16.  # include   17. #else 18.  # ifndef AMIGA 19.  #  include   20. # endif 21.  #endif 22.   23.   #if (defined(MICRO) && !defined(TOS)) || defined(ANCIENT_VAXC) 24.  # if !defined(_SIZE_T) && !defined(__size_t) /* __size_t for CSet/2 */ 25.  #  define _SIZE_T 26.  #  if !((defined(MSDOS) || defined(OS2)) && defined(_SIZE_T_DEFINED)) /* MSC 5.1 */ 27.  typedef unsigned int	size_t; 28.  #  endif 29.  # endif 30.  #endif	/* MICRO && !TOS */ 31.   32.   #if defined(__TURBOC__) || defined(MAC) 33.  #include 	/* time_t is not in  */ 34.  #endif 35.  #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC)) 36.  /* The Ultrix v3.0  seems to be very wrong. */ 37.   # define time_t long 38.  #endif 39.   40.   #if defined(ULTRIX) || defined(VMS) 41.  # define off_t long 42.  #endif 43.  #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__) 44.  typedef long	off_t; 45.  #endif 46.   47.   #endif /* __GO32__ */ 48.   49.   /* You may want to change this to fit your system, as this is almost 50.   * impossible to get right automatically. 51.   * This is the type of signal handling functions. 52.   */  53.   #if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(MSDOS) || defined(__DECC) 54.  # define SIG_RET_TYPE void (*) 55.  #endif 56.  #ifndef SIG_RET_TYPE 57.  # if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4) 58.  	/* SVR3 is defined automatically by some systems */ 59.  #  define SIG_RET_TYPE void (*) 60.  # endif 61.  #endif 62.  #ifndef SIG_RET_TYPE	/* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */ 63.  # define SIG_RET_TYPE int (*) 64.  #endif 65.   66.   #ifndef __GO32__ 67.   68.   #if defined(BSD) || defined(ULTRIX) || defined(RANDOM) 69.  E long NDECL(random); 70.  # if !defined(SUNOS4) || defined(RANDOM) 71.  E void FDECL(srandom, (unsigned int)); 72.  # else 73.  E int FDECL(srandom, (unsigned int)); 74.  # endif 75.  #else 76.  E long lrand48; 77.  E void srand48; 78.  #endif /* BSD || ULTRIX || RANDOM */ 79.   80.   #if !defined(BSD) || defined(ultrix) 81.  			/* real BSD wants all these to return int */ 82.  # ifndef MICRO 83.  E void FDECL(exit, (int)); 84.  # endif /* MICRO */ 85.  /* If flex thinks that we're not __STDC__ it declares free to return 86.     int and we die. We must use __STDC__ instead of NHSTDC because 87.     the former is naturally what flex tests for. */ 88.   # if defined(__STDC__) || !defined(FLEX_SCANNER) 89.  #  ifndef OS2_CSET2 90.  E void FDECL(free, (genericptr_t)); 91.  #  endif 92.  # endif 93.  #ifndef	__SASC_60 94.  # if defined(AMIGA) && !defined(AZTEC_50) 95.  E int FDECL(perror, (const char *)); 96.  # else 97.  #  if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 98.  E void FDECL(perror, (const char *)); 99.  #  endif 100. # endif 101. #endif 102. #endif 103. #ifdef POSIX_TYPES 104. E void FDECL(qsort, (genericptr_t,size_t,size_t, 105. 		     int(*)(const genericptr,const genericptr))); 106. #else 107. # if defined(BSD) || defined(ULTRIX) || defined(__TURBOC__) 108. E  int qsort; 109. # else 110. #  if !defined(LATTICE) && !defined(AZTEC_50) 111. E   void FDECL(qsort, (genericptr_t,size_t,size_t, 112. 		       int(*)(const genericptr,const genericptr))); 113. #  endif 114. # endif 115. #endif 116.  117.  #ifndef AZTEC_50	/* Already defined in include files */ 118.  119.  #ifdef ULTRIX 120. # ifdef ULTRIX_PROTO 121. E int FDECL(lseek, (int,off_t,int)); 122. # else 123. E long FDECL(lseek, (int,off_t,int)); 124. # endif 125.   /* Ultrix 3.0 man page mistakenly says it returns an int. */ 126.  E int FDECL(write, (int,char *,int)); 127. E int FDECL(link, (const char *, const char*)); 128. #else 129. E long FDECL(lseek, (int,long,int)); 130. # ifdef POSIX_TYPES 131. E int FDECL(write, (int, const void *,unsigned)); 132. # else 133. E int FDECL(write, (int,genericptr_t,unsigned)); 134. # endif 135. #endif /* ULTRIX */ 136. #ifndef	__SASC_60 137. # ifdef OS2_CSET2	/* IBM CSet/2 */ 138. E int FDECL(unlink, (char *)); 139. # else 140. E int FDECL(unlink, (const char *)); 141. # endif 142. #endif 143.  144.  #if defined(MICRO) || defined (MAC) 145. E int FDECL(close, (int)); 146. E int FDECL(read, (int,genericptr_t,unsigned int)); 147. #ifndef	__SASC_60 148. # ifdef MAC 149. E int FDECL(open, (const char *,int)); 150. # else 151. E int FDECL(open, (const char *,int,...)); 152. # endif /* MAC */ 153. #endif 154. E int FDECL(dup2, (int, int)); 155. E int FDECL(setmode, (int,int)); 156. E int NDECL(kbhit); 157. #ifndef	__SASC_60 158. E int FDECL(chdir, (char *)); 159. E char *FDECL(getcwd, (char *,int)); 160. #endif 161. #else 162. # if defined(ULTRIX) 163. E int FDECL(close, (int)); 164. # endif 165. #endif 166.  167.  #ifdef ULTRIX 168. E int FDECL(atoi, (const char *)); 169. E int FDECL(chdir, (const char *)); 170. # ifndef ULTRIX_CC20 171. E int FDECL(chmod, (const char *,int)); 172. E mode_t FDECL(umask, (int)); 173. # endif 174. E int FDECL(read, (int,genericptr_t,unsigned)); 175. /* these aren't quite right, but this saves including lots of system files */ 176. E int FDECL(stty, (int,genericptr_t)); 177. E int FDECL(gtty, (int,genericptr_t)); 178. E int FDECL(ioctl, (int, int, char*)); 179. E int FDECL(isatty, (int));	/* 1==yes, 0==no, -1==error */ 180. #include   181. # ifdef ULTRIX_PROTO 182. E int NDECL(fork); 183. # else 184. E long NDECL(fork); 185. # endif 186. #endif 187.  188.  #ifdef VMS 189. # ifndef abs 190. E int FDECL(abs, (int)); 191. # endif 192. E int FDECL(atexit, (void (*)(void))); 193. E int FDECL(atoi, (const char *)); 194. E int FDECL(chdir, (const char *)); 195. E int FDECL(chmod, (const char *,int)); 196. E int FDECL(chown, (const char *,unsigned,unsigned)); 197. # ifndef __DECC /* incompatible prototype hidden in  */ 198. E int FDECL(umask, (int)); 199. # endif 200. /* #include  */ 201. E int FDECL(close, (int)); 202. E int VDECL(creat, (const char *,unsigned,...)); 203. E int FDECL(delete, (const char *)); 204. E int FDECL(fstat, ( /*_ int, stat_t * _*/ )); 205. E int FDECL(isatty, (int));	/* 1==yes, 0==no, -1==error */ 206. E int FDECL(read, (int,genericptr_t,unsigned)); 207. E int VDECL(open, (const char *,int,unsigned,...)); 208. E int FDECL(rename, (const char *,const char *)); 209. E int FDECL(stat, ( /*_ const char *,stat_t * _*/ )); 210. #endif 211.  212.  #endif  /* AZTEC_50 */ 213.  214.  #ifdef TOS 215. E int FDECL(creat, (const char *, int)); 216. #endif 217.  218.  /* both old & new versions of Ultrix want these, but real BSD does not */ 219. #ifdef ultrix 220. E void abort; 221. E void bcopy; 222. # ifdef ULTRIX 223. E int FDECL(system, (const char *)); 224. #  ifndef _UNISTD_H_ 225. E int FDECL(execl, (const char *, ...)); 226. #  endif 227. # endif 228. #endif 229. #ifdef MICRO 230. E void NDECL(abort); 231. E void FDECL(_exit, (int)); 232. E int FDECL(system, (const char *)); 233. #endif 234. #ifdef HPUX 235. E long NDECL(fork); 236. #endif 237.  238.  #if defined(SYSV) || defined(VMS) || defined(MAC) || defined(SUNOS4) 239. # if defined(NHSTDC) || defined(POSIX_TYPES) || (defined(VMS) && !defined(ANCIENT_VAXC)) 240. #  if !(defined(SUNOS4) && defined(__STDC__))	/* Solaris unbundled cc (acc) */ 241. E int FDECL(memcmp, (const void *,const void *,size_t)); 242. E void *FDECL(memcpy, (void *, const void *, size_t)); 243. E void *FDECL(memset, (void *, int, size_t)); 244. #  endif 245. # else 246. E int memcmp; 247. E char *memcpy, *memset; 248. # endif 249. #endif 250.  251.  #ifdef HPUX 252. E int FDECL(memcmp, (char *,char *,int)); 253. E void *FDECL(memcpy, (char *,char *,int)); 254. E void *FDECL(memset, (char*,int,int)); 255. #endif 256.  257.  #if defined(MICRO) && !defined(LATTICE) 258. # if defined(TOS) && defined(__GNUC__) 259. E int FDECL(memcmp, (const void *,const void *,size_t)); 260. E void *FDECL(memcpy, (void *,const void *,size_t)); 261. E void *FDECL(memset, (void *,int,size_t)); 262. # else 263. #  if defined(AZTEC_50) || defined(NHSTDC) 264. E int  FDECL(memcmp, (const void *, const void *, size_t)); 265. E void *FDECL(memcpy, (void *, const void *, size_t)); 266. E void *FDECL(memset, (void *, int, size_t)); 267. #  else 268. E int FDECL(memcmp, (char *,char *,unsigned int)); 269. E char *FDECL(memcpy, (char *,char *,unsigned int)); 270. E char *FDECL(memset, (char*,int,int)); 271. #  endif /* AZTEC_50 || NHSTDC */ 272. # endif /* TOS */ 273. #endif /* MICRO */ 274.  275.  #if defined(BSD) && defined(ultrix)	/* i.e., old versions of Ultrix */ 276. E void sleep; 277. #endif 278. #if defined(ULTRIX) || defined(SYSV) 279. E unsigned sleep; 280. #endif 281. #if defined(HPUX) 282. E unsigned int FDECL(sleep, (unsigned int)); 283. #endif 284. #ifdef VMS 285. E int FDECL(sleep, (unsigned)); 286. #endif 287.  288.  E char *FDECL(getenv, (const char *)); 289. E char *getlogin; 290. #ifdef HPUX 291. E long NDECL(getuid); 292. E long NDECL(getgid); 293. E long NDECL(getpid); 294. #else 295. # ifdef POSIX_TYPES 296. E pid_t NDECL(getpid); 297. E uid_t NDECL(getuid); 298. E gid_t NDECL(getgid); 299. # else 300. E int NDECL(getpid); 301. # endif 302. # ifdef VMS 303. E int NDECL(getppid); 304. E unsigned NDECL(getuid); 305. E unsigned NDECL(getgid); 306. # endif 307. # if defined(ULTRIX) && !defined(_UNISTD_H_) 308. E unsigned NDECL(getuid); 309. E unsigned NDECL(getgid); 310. E int FDECL(setgid, (int)); 311. E int FDECL(setuid, (int)); 312. # endif 313. #endif 314.  315.  /*# string(s).h #*/ 316. #ifndef _XtIntrinsic_h	/*  #includes  */ 317.  318.  #if defined(ULTRIX) && defined(__GNUC__) 319. #include   320. #else 321. E char	*FDECL(strcpy, (char *,const char *)); 322. E char	*FDECL(strncpy, (char *,const char *,size_t)); 323. E char	*FDECL(strcat, (char *,const char *)); 324. E char	*FDECL(strncat, (char *,const char *,size_t)); 325. E char	*FDECL(strpbrk, (const char *,const char *)); 326.  327.  # if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) || defined(HPUX) 328. E char	*FDECL(strchr, (const char *,int)); 329. E char	*FDECL(strrchr, (const char *,int)); 330. # else /* BSD */ 331. E char	*FDECL(index, (const char *,int)); 332. E char	*FDECL(rindex, (const char *,int)); 333. # endif 334.  335.  E int	FDECL(strcmp, (const char *,const char *)); 336. E int	FDECL(strncmp, (const char *,const char *,size_t)); 337. # if defined(MICRO) || defined(MAC) || defined(VMS) || defined(POSIX_TYPES) 338. E size_t FDECL(strlen, (const char *)); 339. # else 340. # ifdef HPUX 341. E unsigned int	FDECL(strlen, (char *)); 342. #  else 343. #   if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 344. E int	FDECL(strlen, (const char *)); 345. #   endif 346. #  endif /* HPUX */ 347. # endif /* MICRO */ 348. #endif /* ULTRIX */ 349.  350.  #endif	/* !_XtIntrinsic_h_ */ 351.  352.  #if defined(ULTRIX) && defined(__GNUC__) 353. E char	*FDECL(index, (const char *,int)); 354. E char	*FDECL(rindex, (const char *,int)); 355. #endif 356.  357.  /* Old varieties of BSD have char *sprintf. 358.  * Newer varieties of BSD have int sprintf but allow for the old char *. 359.  * Several varieties of SYSV and PC systems also have int sprintf. 360.  * If your system doesn't agree with this breakdown, you may want to change 361.  * this declaration, especially if your machine treats the types differently. 362.  * If your system defines sprintf, et al, in stdio.h, add to the initial 363.  * #if. 364.  */  365.  #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || (defined(SUNOS4) && defined(__STDC__)) 366. #define SPRINTF_PROTO 367. #endif 368. #if defined(TOS) || defined(AZTEC_50) || defined(sgi) || defined(__GNUC__) 369. 	/* problem with prototype mismatches */ 370. #define SPRINTF_PROTO 371. #endif 372.  373.  #ifndef SPRINTF_PROTO 374. # ifdef POSIX_TYPES 375. E  int FDECL(sprintf, (char *,const char *,...)); 376. # else 377. #  if defined(BSD) && !defined(DGUX) && !defined(NeXT) 378. #   define OLD_SPRINTF 379. E   char *sprintf; 380. #  else 381. E   int FDECL(sprintf, (char *,const char *,...)); 382. #  endif 383. # endif 384. #endif 385. #ifdef SPRINTF_PROTO 386. # undef SPRINTF_PROTO 387. #endif 388.  389.  #ifndef	__SASC_60 390. #ifdef NEED_VARARGS 391. # if defined(USE_STDARG) || defined(USE_VARARGS) 392. #  if !defined(SVR4) && !defined(apollo) 393. #   if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 394. #    if !(defined(SUNOS4) && defined(__STDC__))	/* Solaris unbundled cc (acc) */ 395. E int FDECL(vsprintf, (char *, const char *, va_list)); 396. E int FDECL(vfprintf, (FILE *, const char *, va_list)); 397. E int FDECL(vprintf, (const char *, va_list)); 398. #    endif 399. #   endif 400. #  endif 401. # else 402. #  define vprintf	printf 403. #  define vfprintf	fprintf 404. #  define vsprintf	sprintf 405. # endif 406. #endif /* NEED_VARARGS */ 407. #endif 408.  409.  #endif /* __GO32__ */ 410.  411.  #define Sprintf	(void) sprintf 412. #define Strcat	(void) strcat 413. #define Strcpy	(void) strcpy 414.  415.  #ifdef NEED_VARARGS 416. # define Vprintf (void) vprintf 417. # define Vfprintf (void) vfprintf 418. # define Vsprintf (void) vsprintf 419. #endif 420.  421.  #ifndef __GO32__ 422.  423.  #ifdef MICRO 424. E int FDECL(tgetent, (const char *,const char *)); 425. E int FDECL(tgetnum, (const char *)); 426. E int FDECL(tgetflag, (const char *)); 427. E char *FDECL(tgetstr, (const char *,char **)); 428. E char *FDECL(tgoto, (const char *,int,int)); 429. E void FDECL(tputs, (const char *,int,int (*))); 430. #else 431. E int FDECL(tgetent, (char *,const char *)); 432. E int FDECL(tgetnum, (char *)); 433. E int FDECL(tgetflag, (char *)); 434. E char *FDECL(tgetstr, (char *,char **)); 435. E char *FDECL(tgoto, (char *,int,int)); 436. E void FDECL(tputs, (const char *,int,int (*))); 437. #endif 438.  439.  #ifdef ALLOC_C 440. E genericptr_t FDECL(malloc, (size_t)); 441. #endif 442.  443.  /* time functions */ 444.  445.  # ifndef LATTICE 446. #  if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 447. E struct tm *FDECL(localtime, (const time_t *)); 448. #  endif 449. # endif 450.  451.  # if defined(ULTRIX) || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) 452. E time_t FDECL(time, (time_t *)); 453. # else 454. E long FDECL(time, (time_t *)); 455. # endif /* ULTRIX */ 456.  457.  #ifdef VMS 458. 	/* used in makedefs.c, but missing from gcc-vms's  */ 459. E char *FDECL(ctime, (const time_t *)); 460. #endif 461.  462.   463.  #ifdef MICRO 464. # ifdef abs 465. # undef abs 466. # endif 467. E int FDECL(abs, (int)); 468. E int FDECL(atoi, (const char *)); 469. #endif 470.  471.  #undef E  472. 473. #endif /* __GO32__ */ 474.  475.  #endif /* SYSTEM_H */