home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / patch-2.1-src.tgz / tar.out / fsf / patch / common.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  5KB  |  191 lines

  1. /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
  2.  *
  3.  * $Log:    common.h,v $
  4.  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  5.  * patch12: sprintf was declared wrong
  6.  * 
  7.  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
  8.  * patch10: support for shorter extensions.
  9.  * 
  10.  * Revision 2.0  86/09/17  15:36:39  lwall
  11.  * Baseline for netwide release.
  12.  * 
  13.  */
  14.  
  15. #define DEBUGGING
  16.  
  17. #define VOIDUSED 7
  18. #include "config.h"
  19.  
  20. /* shut lint up about the following when return value ignored */
  21.  
  22. #define Signal (void)signal
  23. #define Unlink (void)unlink
  24. #define Lseek (void)lseek
  25. #define Fseek (void)fseek
  26. #define Fstat (void)fstat
  27. #define Pclose (void)pclose
  28. #define Close (void)close
  29. #define Fclose (void)fclose
  30. #define Fflush (void)fflush
  31. #define Sprintf (void)sprintf
  32. #define Mktemp (void)mktemp
  33. #define Strcpy (void)strcpy
  34. #define Strcat (void)strcat
  35.  
  36. /* NeXT declares malloc and realloc incompatibly from us in some of
  37.    these files.  Temporarily redefine them to prevent errors.  */
  38. #define malloc system_malloc
  39. #define realloc system_realloc
  40. #include <stdio.h>
  41. #include <assert.h>
  42. #include <sys/types.h>
  43. #include <sys/stat.h>
  44. #include <ctype.h>
  45. #include <signal.h>
  46. #undef malloc
  47. #undef realloc
  48.  
  49. /* constants */
  50.  
  51. /* AIX predefines these.  */
  52. #ifdef TRUE
  53. #undef TRUE
  54. #endif
  55. #ifdef FALSE
  56. #undef FALSE
  57. #endif
  58. #define TRUE (1)
  59. #define FALSE (0)
  60.  
  61. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  62. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  63. #define MAXLINELEN 1024
  64. #define BUFFERSIZE 1024
  65.  
  66. #define SCCSPREFIX "s."
  67. #define GET "get %s"
  68. #define GET_LOCKED "get -e %s"
  69. #define SCCSDIFF "get -p %s | diff - %s >/dev/null"
  70.  
  71. #define RCSSUFFIX ",v"
  72. #define CHECKOUT "co %s"
  73. #define CHECKOUT_LOCKED "co -l %s"
  74. #define RCSDIFF "rcsdiff %s > /dev/null"
  75.  
  76. /* handy definitions */
  77.  
  78. #define Null(t) ((t)0)
  79. #define Nullch Null(char *)
  80. #define Nullfp Null(FILE *)
  81. #define Nulline Null(LINENUM)
  82.  
  83. #define Ctl(ch) ((ch) & 037)
  84.  
  85. #define strNE(s1,s2) (strcmp(s1, s2))
  86. #define strEQ(s1,s2) (!strcmp(s1, s2))
  87. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  88. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  89.  
  90. /* typedefs */
  91.  
  92. typedef char bool;
  93. typedef long LINENUM;            /* must be signed */
  94. typedef unsigned MEM;            /* what to feed malloc */
  95.  
  96. /* globals */
  97.  
  98. EXT int Argc;                /* guess */
  99. EXT char **Argv;
  100. EXT int optind_last;            /* for restarting plan_b */
  101.  
  102. EXT struct stat filestat;        /* file statistics area */
  103. EXT int filemode INIT(0644);
  104.  
  105. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  106. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  107. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  108.  
  109. EXT int myuid;                /* cache getuid return value */
  110.  
  111. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  112. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  113.  
  114. #define MAXFILEC 2
  115. EXT int filec INIT(0);            /* how many file arguments? */
  116. EXT char *filearg[MAXFILEC];
  117. EXT bool ok_to_create_file INIT(FALSE);
  118. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  119.  
  120. EXT char *outname INIT(Nullch);
  121. EXT char rejname[128];
  122.  
  123. EXT char *origprae INIT(Nullch);
  124.  
  125. EXT char *TMPOUTNAME;
  126. EXT char *TMPINNAME;
  127. EXT char *TMPREJNAME;
  128. EXT char *TMPPATNAME;
  129. EXT bool toutkeep INIT(FALSE);
  130. EXT bool trejkeep INIT(FALSE);
  131.  
  132. EXT LINENUM last_offset INIT(0);
  133. #ifdef DEBUGGING
  134. EXT int debug INIT(0);
  135. #endif
  136. EXT LINENUM maxfuzz INIT(2);
  137. EXT bool force INIT(FALSE);
  138. EXT bool batch INIT(FALSE);
  139. EXT bool verbose INIT(TRUE);
  140. EXT bool reverse INIT(FALSE);
  141. EXT bool noreverse INIT(FALSE);
  142. EXT bool skip_rest_of_patch INIT(FALSE);
  143. EXT int strippath INIT(957);
  144. EXT bool canonicalize INIT(FALSE);
  145.  
  146. #define CONTEXT_DIFF 1
  147. #define NORMAL_DIFF 2
  148. #define ED_DIFF 3
  149. #define NEW_CONTEXT_DIFF 4
  150. #define UNI_DIFF 5
  151. EXT int diff_type INIT(0);
  152.  
  153. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  154. EXT char if_defined[128];        /* #ifdef xyzzy */
  155. EXT char not_defined[128];        /* #ifndef xyzzy */
  156. EXT char else_defined[] INIT("#else\n");/* #else */
  157. EXT char end_defined[128];        /* #endif xyzzy */
  158.  
  159. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  160.  
  161. #include <errno.h>
  162. #ifdef STDC_HEADERS
  163. #include <stdlib.h>
  164. #include <string.h>
  165. #else
  166. extern int errno;
  167. FILE *popen();
  168. char *malloc();
  169. char *realloc();
  170. long atol();
  171. char *getenv();
  172. char *strcpy();
  173. char *strcat();
  174. #endif
  175. char *mktemp();
  176. #ifdef HAVE_UNISTD_H
  177. #include <unistd.h>
  178. #else
  179. long lseek();
  180. #endif
  181. #if defined(_POSIX_VERSION) || defined(HAVE_FCNTL_H)
  182. #include <fcntl.h>
  183. #endif
  184.  
  185. #if !defined(S_ISDIR) && defined(S_IFDIR)
  186. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  187. #endif
  188. #if !defined(S_ISREG) && defined(S_IFREG)
  189. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  190. #endif
  191.