Source:NetHack 3.4.0/system.h

Below is the full text to system.h from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.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.4	2001/12/07	*/ 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.    #if !defined(__cplusplus) && !defined(__GO32__) 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.  #   if !(defined(__GNUC__) && defined(AMIGA)) 28.  typedef unsigned int	size_t; 29.  #   endif 30.  #  endif 31.  # endif 32.  #endif	/* MICRO && !TOS */ 33.   34.   #if defined(__TURBOC__) || defined(MAC) 35.  #include 	/* time_t is not in  */ 36.  #endif 37.  #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC)) 38.  /* The Ultrix v3.0  seems to be very wrong. */ 39.   # define time_t long 40.  #endif 41.   42.   #if defined(ULTRIX) || defined(VMS) 43.  # define off_t long 44.  #endif 45.  #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__) 46.  typedef long	off_t; 47.  #endif 48.   49.   #endif /* !__cplusplus && !__GO32__ */ 50.   51.   /* You may want to change this to fit your system, as this is almost 52.   * impossible to get right automatically. 53.   * This is the type of signal handling functions. 54.   */  55.   #if !defined(OS2) && (defined(_MSC_VER) || defined(__TURBOC__) || defined(__SC__) || defined(WIN32)) 56.  # define SIG_RET_TYPE void (__cdecl *)(int) 57.  #endif 58.  #ifndef SIG_RET_TYPE 59.  # if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC) 60.  #  define SIG_RET_TYPE void (*) 61.  # endif 62.  #endif 63.  #ifndef SIG_RET_TYPE 64.  # if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4) 65.  	/* SVR3 is defined automatically by some systems */ 66.  #  define SIG_RET_TYPE void (*) 67.  # endif 68.  #endif 69.  #ifndef SIG_RET_TYPE	/* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */ 70.  # define SIG_RET_TYPE int (*) 71.  #endif 72.   73.   #if !defined(__cplusplus) && !defined(__GO32__) 74.   75.   #if defined(BSD) || defined(ULTRIX) || defined(RANDOM) 76.  # ifdef random 77.  # undef random 78.  # endif 79.  # if !defined(__SC__) && !defined(LINUX) 80.  E  long NDECL(random); 81.  # endif 82.  # if !defined(SUNOS4) || defined(RANDOM) 83.  E void FDECL(srandom, (unsigned int)); 84.  # else 85.  #  if !defined(bsdi) && !defined(__FreeBSD__) 86.  E int FDECL(srandom, (unsigned int)); 87.  #  endif 88.  # endif 89.  #else 90.  E long lrand48; 91.  E void srand48; 92.  #endif /* BSD || ULTRIX || RANDOM */ 93.   94.   #if !defined(BSD) || defined(ultrix) 95.  			/* real BSD wants all these to return int */ 96.  # ifndef MICRO 97.  E void FDECL(exit, (int)); 98.  # endif /* MICRO */ 99.  /* compensate for some CSet/2 bogosities */ 100. # if defined(OS2_CSET2) && defined(OS2_CSET2_VER_2) 101. #  define open	  _open 102. #  define close   _close 103. #  define read	  _read 104. #  define write   _write 105. #  define lseek   _lseek 106. #  define chdir   _chdir 107. #  define getcwd  _getcwd 108. #  define setmode _setmode 109. # endif /* OS2_CSET2 && OS2_CSET2_VER_2 */ 110. /* If flex thinks that we're not __STDC__ it declares free to return 111.    int and we die. We must use __STDC__ instead of NHSTDC because 112.    the former is naturally what flex tests for. */ 113.  # if defined(__STDC__) || !defined(FLEX_SCANNER) 114. #  ifndef OS2_CSET2 115. #   ifndef MONITOR_HEAP 116. E void FDECL(free, (genericptr_t)); 117. #   endif 118. #  endif 119. # endif 120. #if !defined(__SASC_60) && !defined(_DCC) && !defined(__SC__) 121. # if defined(AMIGA) && !defined(AZTEC_50) && !defined(__GNUC__) 122. E int FDECL(perror, (const char *)); 123. # else 124. #  if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 125. E void FDECL(perror, (const char *)); 126. #  endif 127. # endif 128. #endif 129. #endif 130. #ifndef NeXT 131. #ifdef POSIX_TYPES 132. E void FDECL(qsort, (genericptr_t,size_t,size_t, 133. 		     int(*)(const genericptr,const genericptr))); 134. #else 135. # if defined(BSD) || defined(ULTRIX) 136. E  int qsort; 137. # else 138. #  if !defined(LATTICE) && !defined(AZTEC_50) 139. E   void FDECL(qsort, (genericptr_t,size_t,size_t, 140. 		       int(*)(const genericptr,const genericptr))); 141. #  endif 142. # endif 143. #endif 144. #endif /* NeXT */ 145.  146.  #ifndef __SASC_60 147. #if !defined(AZTEC_50) && !defined(__GNUC__) 148. /* may already be defined */ 149.  150.  # ifdef ULTRIX 151. #  ifdef ULTRIX_PROTO 152. E int FDECL(lseek, (int,off_t,int)); 153. #  else 154. E long FDECL(lseek, (int,off_t,int)); 155. #  endif 156.   /* Ultrix 3.0 man page mistakenly says it returns an int. */ 157.  E int FDECL(write, (int,char *,int)); 158. E int FDECL(link, (const char *, const char*)); 159. # else 160. # ifndef bsdi 161. E long FDECL(lseek, (int,long,int)); 162. # endif 163. #  if defined(POSIX_TYPES) || defined(__TURBOC__) 164. #   ifndef bsdi 165. E int FDECL(write, (int, const void *,unsigned)); 166. #   endif 167. #  else 168. #   ifndef __MWERKS__	/* metrowerks defines write via universal headers */ 169. E int FDECL(write, (int,genericptr_t,unsigned)); 170. #   endif 171. #  endif 172. # endif /* ULTRIX */ 173.  174.  # ifdef OS2_CSET2	/* IBM CSet/2 */ 175. #  ifdef OS2_CSET2_VER_1 176. E int FDECL(unlink, (char *)); 177. #  else 178. E int FDECL(unlink, (const char *)); /* prototype is ok in ver >= 2 */ 179. #  endif 180. # else 181. #  ifndef __SC__ 182. E int FDECL(unlink, (const char *)); 183. #  endif 184. # endif 185.  186.  #endif /* AZTEC_50 && __GNUC__ */ 187.  188.  #ifdef MAC 189. #ifndef __CONDITIONALMACROS__	/* universal headers */ 190. E int FDECL(close, (int));		/* unistd.h */ 191. E int FDECL(read, (int, char *, int));	/* unistd.h */ 192. E int FDECL(chdir, (const char *));	/* unistd.h */ 193. E char *FDECL(getcwd, (char *,int));	/* unistd.h */ 194. #endif 195.  196.  E int FDECL(open, (const char *,int)); 197. #endif 198.  199.  #if defined(MICRO) 200. E int FDECL(close, (int)); 201. #ifndef __EMX__ 202. E int FDECL(read, (int,genericptr_t,unsigned int)); 203. #endif 204. E int FDECL(open, (const char *,int,...)); 205. E int FDECL(dup2, (int, int)); 206. E int FDECL(setmode, (int,int)); 207. E int NDECL(kbhit); 208. # if !defined(_DCC) 209. #  if defined(__TURBOC__) 210. E int FDECL(chdir, (const char *)); 211. #  else 212. #   ifndef __EMX__ 213. E int FDECL(chdir, (char *)); 214. #   endif 215. #  endif 216. #  ifndef __EMX__ 217. E char *FDECL(getcwd, (char *,int)); 218. #  endif 219. # endif /* !_DCC */ 220. #endif 221.  222.  #ifdef ULTRIX 223. E int FDECL(close, (int)); 224. E int FDECL(atoi, (const char *)); 225. E int FDECL(chdir, (const char *)); 226. # if !defined(ULTRIX_CC20) && !defined(__GNUC__) 227. E int FDECL(chmod, (const char *,int)); 228. E mode_t FDECL(umask, (int)); 229. # endif 230. E int FDECL(read, (int,genericptr_t,unsigned)); 231. /* these aren't quite right, but this saves including lots of system files */ 232. E int FDECL(stty, (int,genericptr_t)); 233. E int FDECL(gtty, (int,genericptr_t)); 234. E int FDECL(ioctl, (int, int, char*)); 235. E int FDECL(isatty, (int));	/* 1==yes, 0==no, -1==error */ 236. #include   237. # if defined(ULTRIX_PROTO) || defined(__GNUC__) 238. E int NDECL(fork); 239. # else 240. E long NDECL(fork); 241. # endif 242. #endif /* ULTRIX */ 243.  244.  #ifdef VMS 245. # ifndef abs 246. E int FDECL(abs, (int)); 247. # endif 248. E int FDECL(atexit, (void (*)(void))); 249. E int FDECL(atoi, (const char *)); 250. E int FDECL(chdir, (const char *)); 251. E int FDECL(chown, (const char *,unsigned,unsigned)); 252. # ifdef __DECC_VER 253. E int FDECL(chmod, (const char *,mode_t)); 254. E mode_t FDECL(umask, (mode_t)); 255. # else 256. E int FDECL(chmod, (const char *,int)); 257. E int FDECL(umask, (int)); 258. # endif 259. /* #include  */ 260. E int FDECL(close, (int)); 261. E int VDECL(creat, (const char *,unsigned,...)); 262. E int FDECL(delete, (const char *)); 263. E int FDECL(fstat, ( /*_ int, stat_t * _*/ )); 264. E int FDECL(isatty, (int));	/* 1==yes, 0==no, -1==error */ 265. E long FDECL(lseek, (int,long,int)); 266. E int VDECL(open, (const char *,int,unsigned,...)); 267. E int FDECL(read, (int,genericptr_t,unsigned)); 268. E int FDECL(rename, (const char *,const char *)); 269. E int FDECL(stat, ( /*_ const char *,stat_t * _*/ )); 270. E int FDECL(write, (int,const genericptr,unsigned)); 271. #endif 272.  273.  #endif	/* __SASC_60 */ 274.  275.  /* both old & new versions of Ultrix want these, but real BSD does not */ 276. #ifdef ultrix 277. E void abort; 278. E void bcopy; 279. # ifdef ULTRIX 280. E int FDECL(system, (const char *)); 281. #  ifndef _UNISTD_H_ 282. E int FDECL(execl, (const char *, ...)); 283. #  endif 284. # endif 285. #endif 286. #ifdef MICRO 287. E void NDECL(abort); 288. E void FDECL(_exit, (int)); 289. E int FDECL(system, (const char *)); 290. #endif 291. #if defined(HPUX) && !defined(_POSIX_SOURCE) 292. E long NDECL(fork); 293. #endif 294.  295.  #ifdef POSIX_TYPES 296. /* The POSIX string.h is required to define all the mem* and str* functions */ 297. #include   298. #else 299. #if defined(SYSV) || defined(VMS) || defined(MAC) || defined(SUNOS4) 300. # if defined(NHSTDC) || (defined(VMS) && !defined(ANCIENT_VAXC)) 301. #  if !defined(_AIX32) && !(defined(SUNOS4) && defined(__STDC__)) 302. 				/* Solaris unbundled cc (acc) */ 303. E int FDECL(memcmp, (const void *,const void *,size_t)); 304. E void *FDECL(memcpy, (void *, const void *, size_t)); 305. E void *FDECL(memset, (void *, int, size_t)); 306. #  endif 307. # else 308. #  ifndef memcmp	/* some systems seem to macro these back to b* */ 309. E int memcmp; 310. #  endif 311. #  ifndef memcpy 312. E char *memcpy; 313. #  endif 314. #  ifndef memset 315. E char *memset; 316. #  endif 317. # endif 318. #else 319. # ifdef HPUX 320. E int FDECL(memcmp, (char *,char *,int)); 321. E void *FDECL(memcpy, (char *,char *,int)); 322. E void *FDECL(memset, (char*,int,int)); 323. # endif 324. #endif 325. #endif /* POSIX_TYPES */ 326.  327.  #if defined(MICRO) && !defined(LATTICE) 328. # if defined(TOS) && defined(__GNUC__) 329. E int FDECL(memcmp, (const void *,const void *,size_t)); 330. E void *FDECL(memcpy, (void *,const void *,size_t)); 331. E void *FDECL(memset, (void *,int,size_t)); 332. # else 333. #  if defined(AZTEC_50) || defined(NHSTDC) || defined(WIN32) 334. E int  FDECL(memcmp, (const void *, const void *, size_t)); 335. E void *FDECL(memcpy, (void *, const void *, size_t)); 336. E void *FDECL(memset, (void *, int, size_t)); 337. #  else 338. E int FDECL(memcmp, (char *,char *,unsigned int)); 339. E char *FDECL(memcpy, (char *,char *,unsigned int)); 340. E char *FDECL(memset, (char*,int,int)); 341. #  endif /* AZTEC_50 || NHSTDC */ 342. # endif /* TOS */ 343. #endif /* MICRO */ 344.  345.  #if defined(BSD) && defined(ultrix)	/* i.e., old versions of Ultrix */ 346. E void sleep; 347. #endif 348. #if defined(ULTRIX) || defined(SYSV) 349. E unsigned sleep; 350. #endif 351. #if defined(HPUX) 352. E unsigned int FDECL(sleep, (unsigned int)); 353. #endif 354. #ifdef VMS 355. E int FDECL(sleep, (unsigned)); 356. #endif 357.  358.  E char *FDECL(getenv, (const char *)); 359. E char *getlogin; 360. #if defined(HPUX) && !defined(_POSIX_SOURCE) 361. E long NDECL(getuid); 362. E long NDECL(getgid); 363. E long NDECL(getpid); 364. #else 365. # ifdef POSIX_TYPES 366. E pid_t NDECL(getpid); 367. E uid_t NDECL(getuid); 368. E gid_t NDECL(getgid); 369. #  ifdef VMS 370. E pid_t NDECL(getppid); 371. #  endif 372. # else	/*!POSIX_TYPES*/ 373. #  ifndef getpid		/* Borland C defines getpid as a macro */ 374. E int NDECL(getpid); 375. #  endif 376. #  ifdef VMS 377. E int NDECL(getppid); 378. E unsigned NDECL(getuid); 379. E unsigned NDECL(getgid); 380. #  endif 381. #  if defined(ULTRIX) && !defined(_UNISTD_H_) 382. E unsigned NDECL(getuid); 383. E unsigned NDECL(getgid); 384. E int FDECL(setgid, (int)); 385. E int FDECL(setuid, (int)); 386. #  endif 387. # endif	/*?POSIX_TYPES*/ 388. #endif	/*?(HPUX && !_POSIX_SOURCE)*/ 389.  390.  /* add more architectures as needed */ 391. #if defined(HPUX) 392. #define seteuid(x) setreuid(-1, (x)); 393. #endif 394.  395.  /*# string(s).h #*/ 396. #if !defined(_XtIntrinsic_h) && !defined(POSIX_TYPES) 397. /*  #includes ; so does defining POSIX_TYPES */ 398.  399.  #if (defined(ULTRIX) || defined(NeXT)) && defined(__GNUC__) 400. #include   401. #else 402. E char	*FDECL(strcpy, (char *,const char *)); 403. E char	*FDECL(strncpy, (char *,const char *,size_t)); 404. E char	*FDECL(strcat, (char *,const char *)); 405. E char	*FDECL(strncat, (char *,const char *,size_t)); 406. E char	*FDECL(strpbrk, (const char *,const char *)); 407.  408.  # if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) || defined(HPUX) 409. E char	*FDECL(strchr, (const char *,int)); 410. E char	*FDECL(strrchr, (const char *,int)); 411. # else /* BSD */ 412. E char	*FDECL(index, (const char *,int)); 413. E char	*FDECL(rindex, (const char *,int)); 414. # endif 415.  416.  E int	FDECL(strcmp, (const char *,const char *)); 417. E int	FDECL(strncmp, (const char *,const char *,size_t)); 418. # if defined(MICRO) || defined(MAC) || defined(VMS) 419. E size_t FDECL(strlen, (const char *)); 420. # else 421. # ifdef HPUX 422. E unsigned int	FDECL(strlen, (char *)); 423. #  else 424. #   if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 425. E int	FDECL(strlen, (const char *)); 426. #   endif 427. #  endif /* HPUX */ 428. # endif /* MICRO */ 429. #endif /* ULTRIX */ 430.  431.  #endif	/* !_XtIntrinsic_h_ && !POSIX_TYPES */ 432.  433.  #if defined(ULTRIX) && defined(__GNUC__) 434. E char	*FDECL(index, (const char *,int)); 435. E char	*FDECL(rindex, (const char *,int)); 436. #endif 437.  438.  /* Old varieties of BSD have char *sprintf. 439.  * Newer varieties of BSD have int sprintf but allow for the old char *. 440.  * Several varieties of SYSV and PC systems also have int sprintf. 441.  * If your system doesn't agree with this breakdown, you may want to change 442.  * this declaration, especially if your machine treats the types differently. 443.  * If your system defines sprintf, et al, in stdio.h, add to the initial 444.  * #if. 445.  */  446.  #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32) 447. #define SPRINTF_PROTO 448. #endif 449. #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32) 450. #define SPRINTF_PROTO 451. #endif 452. #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__) 453. 	/* problem with prototype mismatches */ 454. #define SPRINTF_PROTO 455. #endif 456. #if defined(__MWERKS__) || defined(__SC__) 457. 	/* Metrowerks already has a prototype for sprintf */ 458. # define SPRINTF_PROTO 459. #endif 460.  461.  #ifndef SPRINTF_PROTO 462. # if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD) 463. E  int FDECL(sprintf, (char *,const char *,...)); 464. # else 465. #  define OLD_SPRINTF 466. E  char *sprintf; 467. # endif 468. #endif 469. #ifdef SPRINTF_PROTO 470. # undef SPRINTF_PROTO 471. #endif 472.  473.  #ifndef __SASC_60 474. #ifdef NEED_VARARGS 475. # if defined(USE_STDARG) || defined(USE_VARARGS) 476. #  if !defined(SVR4) && !defined(apollo) 477. #   if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 478. #    if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */ 479. E int FDECL(vsprintf, (char *, const char *, va_list)); 480. E int FDECL(vfprintf, (FILE *, const char *, va_list)); 481. E int FDECL(vprintf, (const char *, va_list)); 482. #    endif 483. #   endif 484. #  endif 485. # else 486. #  define vprintf	printf 487. #  define vfprintf	fprintf 488. #  define vsprintf	sprintf 489. # endif 490. #endif /* NEED_VARARGS */ 491. #endif 492.  493.   494.  #ifdef MICRO 495. E int FDECL(tgetent, (const char *,const char *)); 496. E void FDECL(tputs, (const char *,int,int (*))); 497. E int FDECL(tgetnum, (const char *)); 498. E int FDECL(tgetflag, (const char *)); 499. E char *FDECL(tgetstr, (const char *,char **)); 500. E char *FDECL(tgoto, (const char *,int,int)); 501. #else 502. # if ! (defined(HPUX) && defined(_POSIX_SOURCE)) 503. E int FDECL(tgetent, (char *,const char *)); 504. E void FDECL(tputs, (const char *,int,int (*))); 505. # endif 506. E int FDECL(tgetnum, (const char *)); 507. E int FDECL(tgetflag, (const char *)); 508. E char *FDECL(tgetstr, (const char *,char **)); 509. E char *FDECL(tgoto, (const char *,int,int)); 510. #endif 511.  512.  #ifdef ALLOC_C 513. E genericptr_t FDECL(malloc, (size_t)); 514. #endif 515.  516.  /* time functions */ 517.  518.  # ifndef LATTICE 519. #  if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 520. E struct tm *FDECL(localtime, (const time_t *)); 521. #  endif 522. # endif 523.  524.  # if defined(ULTRIX) || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) || (defined(HPUX) && defined(_POSIX_SOURCE)) 525. E time_t FDECL(time, (time_t *)); 526. # else 527. E long FDECL(time, (time_t *)); 528. # endif /* ULTRIX */ 529.  530.  #ifdef VMS 531. 	/* used in makedefs.c, but missing from gcc-vms's  */ 532. E char *FDECL(ctime, (const time_t *)); 533. #endif 534.  535.   536.  #ifdef MICRO 537. # ifdef abs 538. # undef abs 539. # endif 540. E int FDECL(abs, (int)); 541. # ifdef atoi 542. # undef atoi 543. # endif 544. E int FDECL(atoi, (const char *)); 545. #endif 546.  547.  #undef E  548. 549. #endif /*  !__cplusplus && !__GO32__ */ 550.  551.  #endif /* SYSTEM_H */