home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / sharutils-4.1-src.tgz / tar.out / fsf / sharutils / system.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  4KB  |  194 lines

  1. /* Shared definitions for GNU shar utilities.
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.   
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.   
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.   
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. #ifdef HAVE_CONFIG_H
  20. # include <config.h>
  21. #endif
  22.  
  23. /* AIX requires this to be the first thing in the file.  */
  24. #if defined (_AIX) && !defined (__GNUC__)
  25.  #pragma alloca
  26. #endif
  27.  
  28. #ifdef    __GNUC__
  29. # undef    alloca
  30. # define alloca(n) __builtin_alloca (n)
  31. #else
  32. # ifdef HAVE_ALLOCA_H
  33. #  include <alloca.h>
  34. # else
  35. #  ifndef _AIX
  36. extern char *alloca ();
  37. #  endif
  38. # endif
  39. #endif
  40.  
  41. #if __STDC__
  42. # define voidstar void *
  43. #else
  44. # define voidstar char *
  45. #endif
  46.  
  47. #ifdef PROTOTYPES
  48. # define _(Args) Args
  49. #else
  50. # define _(Args) ()
  51. #endif
  52.  
  53. #ifdef STDC_HEADERS
  54. # include <stdlib.h>
  55. #else
  56. char *getenv ();
  57. #endif
  58.  
  59. /* Some systems do not define EXIT_*, even with STDC_HEADERS.  */
  60. #ifndef EXIT_SUCCESS
  61. # define EXIT_SUCCESS 0
  62. #endif
  63. #ifndef EXIT_FAILURE
  64. # define EXIT_FAILURE 1
  65. #endif
  66.  
  67. #if STDC_HEADERS || HAVE_STRING_H
  68. # include <string.h>
  69. # if !STDC_HEADERS && HAVE_MEMORY_H
  70. #  include <memory.h>
  71. # endif
  72. #else
  73. # include <strings.h>
  74. #endif
  75. #if !HAVE_MEMCPY
  76. # ifndef memcpy
  77. #  define memcpy(D, S, N) bcopy ((S), (D), (N))
  78. # endif
  79. #endif
  80. #if !HAVE_STRCHR
  81. # ifndef strchr
  82. #  define strchr index
  83. # endif
  84. #endif
  85.  
  86. /* Other header files.  */
  87.  
  88. #include <stdio.h>
  89.  
  90. #include <errno.h>
  91. #ifndef errno
  92. extern int errno;
  93. #endif
  94.  
  95. #include <sys/types.h>
  96.  
  97. #ifdef HAVE_SYS_WAIT_H
  98. # include <sys/wait.h>
  99. #endif
  100.  
  101. /* Get definitions for the file permission bits.  */
  102.  
  103. #include <sys/stat.h>
  104.  
  105. #ifdef STAT_MACROS_BROKEN
  106. # undef S_ISDIR
  107. # undef S_ISREG
  108. #endif
  109.  
  110. #ifndef S_IFMT
  111. # define S_IFMT 0170000
  112. #endif
  113. #if !defined(S_ISDIR) && defined(S_IFDIR)
  114. # define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
  115. #endif
  116. #if !defined(S_ISREG) && defined(S_IFREG)
  117. # define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG)
  118. #endif
  119.  
  120. #ifndef S_IRWXU
  121. # define S_IRWXU 0700
  122. #endif
  123. #ifndef S_IRUSR
  124. # define S_IRUSR 0400
  125. #endif
  126. #ifndef S_IWUSR
  127. # define S_IWUSR 0200
  128. #endif
  129. #ifndef S_IXUSR
  130. # define S_IXUSR 0100
  131. #endif
  132.  
  133. #ifndef S_IRWXG
  134. # define S_IRWXG 0070
  135. #endif
  136. #ifndef S_IRGRP
  137. # define S_IRGRP 0040
  138. #endif
  139. #ifndef S_IWGRP
  140. # define S_IWGRP 0020
  141. #endif
  142. #ifndef S_IXGRP
  143. # define S_IXGRP 0010
  144. #endif
  145.  
  146. #ifndef S_IRWXO
  147. # define S_IRWXO 0007
  148. #endif
  149. #ifndef S_IROTH
  150. # define S_IROTH 0004
  151. #endif
  152. #ifndef S_IWOTH
  153. # define S_IWOTH 0002
  154. #endif
  155. #ifndef S_IXOTH
  156. # define S_IXOTH 0001
  157. #endif
  158.  
  159. /* System functions.  Even if we usually avoid declaring them, we cannot
  160.    avoid them all.  */
  161.  
  162. #ifdef HAVE_UNISTD_H
  163. # include <unistd.h>
  164. #endif
  165.  
  166. FILE *fdopen ();
  167. long ftell ();
  168. FILE *popen ();
  169.  
  170. /* GNU small library functions.  */
  171.  
  172. #if HAVE_BASENAME
  173. char *basename ();
  174. #else
  175. char *basename _((const char *));
  176. #endif
  177. void error _((int, int, const char *, ...));
  178. char *xgetcwd _((void));
  179. voidstar xmalloc _((size_t));
  180. voidstar xrealloc _((voidstar, size_t));
  181. char *xstrdup _((const char *));
  182.  
  183. /* Global functions of the shar package.  */
  184.  
  185. void copy_file_encoded _((FILE *, FILE *));
  186. char *get_submitter _((char *));
  187.  
  188. /* Debugging the memory allocator.  */
  189.  
  190. #ifdef WITH_DMALLOC
  191. # define MALLOC_FUNC_CHECK
  192. # include <dmalloc.h>
  193. #endif
  194.