Source:NetHack 3.3.0/system.h

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