std.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* This file contains code for X-CHESS.
  2. Copyright (C) 1986 Free Software Foundation, Inc.
  3. This file is part of X-CHESS.
  4. X-CHESS is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the X-CHESS General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. X-CHESS, but only under the conditions described in the
  12. X-CHESS General Public License. A copy of this license is
  13. supposed to have been given to you along with X-CHESS so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:18:32 $
  18. * $Source: /users/faustus/xchess/RCS/std.h,v $
  19. * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
  20. *
  21. * Standard definitions.
  22. */
  23. #define UNIX
  24. #define BSD
  25. #ifndef FILE
  26. #include <stdio.h>
  27. #endif
  28. #ifndef isalpha
  29. #include <ctype.h>
  30. #endif
  31. #ifndef HUGE
  32. #include <math.h>
  33. #endif
  34. #include <strings.h>
  35. typedef int bool;
  36. #define false 0
  37. #define true 1
  38. /* Externs defined in std.c */
  39. extern char *tmalloc();
  40. extern char *trealloc();
  41. extern char *copy();
  42. extern char *datestring();
  43. extern char *getusername();
  44. extern char *gethome();
  45. extern char *gettok();
  46. extern char *tildexpand();
  47. extern void fatal();
  48. extern void setenv();
  49. extern void appendc();
  50. extern int scannum();
  51. extern int seconds();
  52. extern bool prefix();
  53. extern bool ciprefix();
  54. extern bool cieq();
  55. extern bool substring();
  56. /* Externs from libc */
  57. extern char *getenv();
  58. extern int errno;
  59. extern char *sys_errlist[];
  60. /* Should use BSIZE instead of BUFSIZ... */
  61. #define BSIZE 512
  62. /* Some standard macros. */
  63. #define eq(a,b) (!strcmp((a), (b)))
  64. #define isalphanum(c) (isalpha(c) || isdigit(c))
  65. #define alloc(strname) ((struct strname *) tmalloc(sizeof(struct strname)))
  66. #define tfree(ptr) { if (ptr) free((char *) ptr); ptr = 0; }
  67. #define hexnum(c) ((((c) >= '0') && ((c) <= '9')) ? ((c) - '0') : ((((c) >= \
  68. 'a') && ((c) <= 'f')) ? ((c) - 'a' + 10) : ((((c) >= 'A') && \
  69. ((c) <= 'F')) ? ((c) - 'A' + 10) : 0)))
  70. #ifndef BSD
  71. #define random rand
  72. #define srandom srand
  73. #endif BSD
  74. #ifdef VMS
  75. #define EXIT_NORMAL 1
  76. #define EXIT_BAD 0
  77. #else VMS
  78. #define EXIT_NORMAL 0
  79. #define EXIT_BAD 1
  80. #endif VMS