home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / fingercl.zip / general.h < prev    next >
C/C++ Source or Header  |  1997-08-29  |  2KB  |  63 lines

  1. /* general.h -- Generally useful macros and defines. */
  2.  
  3. /* Copyright (C) 1988, 1990, 1992 Free Software Foundation, Inc.
  4.  
  5.    This file is part of GNU Finger.
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 2, or (at your option)
  10.    any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program; if not, write to the Free Software
  19.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #if !defined (_GENERAL_H_)
  22. #define _GENERAL_H_
  23.  
  24. /* An 8-bit byte. */
  25. #ifndef byte
  26. #define byte unsigned char
  27. #endif
  28.  
  29. /* So I can say (Function *)foo; */
  30. typedef int Function ();
  31.  
  32. /* Like malloc () and realloc (), but abort if out of memory. */
  33. void *xmalloc (), *xrealloc ();
  34.  
  35. /* Wrapper for gethostname() */
  36. char *xgethostname (), *getservhost(), *getforwardhost();
  37.  
  38. /* Macro returns non-zero if C is a Tab, Space or Newline. */
  39. #define whitespace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r')
  40.  
  41. /* Macro returns non-zero if C is a digit character. */
  42. #define digit(c) ((c) >= '0' && (c) <= '9')
  43.  
  44. #define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
  45. #define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
  46. #define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
  47.  
  48. #ifndef to_upper
  49. #define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
  50. #define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
  51. #endif
  52.  
  53. #define label_character(c) \
  54.   (whitespace (c) || pure_alphabetic (c) || index ("-_,/", (c)))
  55.  
  56. #ifndef savestring
  57. #define savestring(s) (char *)strcpy ((char *) xmalloc (1 + strlen (s)), (s))
  58. #endif
  59.  
  60. #include <config.h>
  61.  
  62. #endif /* _GENERAL_H_ */
  63.