home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia: Special Games / INFESPGAMES.mdf / os2 / spl / src / general.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  1.6 KB  |  60 lines

  1. /* general.hpp:  Headers for general interest routines
  2.  
  3.     Copyright (C) 1993, 1994 John-Marc Chandonia
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #ifndef _GENERAL_HPP
  21. #define _GENERAL_HPP
  22.  
  23. /* error handlers */
  24. void fatal(char *fmt, ...);
  25. void error(char *fmt, ...);
  26. void warning(char *fmt, ...);
  27.  
  28. /* memory allocation */
  29. void *chkcalloc(size_t nitems, size_t size);
  30.  
  31. /* string functions for unix system */
  32. char *upstr(char *str);
  33. char *lowstr(char *str);
  34.  
  35. // fgets a string without the trailing cr or lf
  36. void fgets_no_cr(char *, int, FILE *);
  37.  
  38. /* general stuff */
  39. typedef enum boolean {false,true} boolean;
  40. #define forever while (true)
  41.  
  42. #ifndef max
  43. #define max(x,y) ((x)>(y)?(x):(y))
  44. #endif
  45.  
  46. #ifndef min
  47. #define min(x,y) ((x)<(y)?(x):(y))
  48. #endif
  49.  
  50. #ifndef sqr
  51. #define sqr(x) ((x)*(x))
  52. #endif
  53.  
  54. #ifndef abs
  55. #define abs(x) ((x)>0.0 ? (x) : 0.0-(x))
  56. #endif
  57.  
  58. #endif
  59.  
  60.