home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / patch / patch.zoo / common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-10  |  4.1 KB  |  168 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. #include "config.h"
  18.  
  19. /* shut lint up about the following when return value ignored */
  20.  
  21. #define Signal (void)signal
  22. #define Unlink (void)unlink
  23. #define Lseek (void)lseek
  24. #define Fseek (void)fseek
  25. #define Fstat (void)fstat
  26. #define Pclose (void)pclose
  27. #define Close (void)close
  28. #define Fclose (void)fclose
  29. #define Fflush (void)fflush
  30. #define Sprintf (void)sprintf
  31. #define Mktemp (void)mktemp
  32. #define Strcpy (void)strcpy
  33. #define Strcat (void)strcat
  34.  
  35. #include <stdio.h>
  36. #include <assert.h>
  37. #include <sys/types.h>
  38. #include <sys/stat.h>
  39. #include <ctype.h>
  40. #include <signal.h>
  41.  
  42. /* constants */
  43.  
  44. #define TRUE (1)
  45. #define FALSE (0)
  46.  
  47. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  48. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  49. #define MAXLINELEN 1024
  50. #define BUFFERSIZE 1024
  51. #define SCCSPREFIX "s."
  52. #define GET "get -e %s"
  53. #define RCSSUFFIX ",v"
  54. #define CHECKOUT "co -l %s"
  55.  
  56. #ifdef FLEXFILENAMES
  57. #define ORIGEXT ".orig"
  58. #define REJEXT ".rej"
  59. #else
  60. #define ORIGEXT "~"
  61. #define REJEXT "#"
  62. #endif
  63.  
  64. /* handy definitions */
  65.  
  66. #define Null(t) ((t)0)
  67. #define Nullch Null(char *)
  68. #define Nullfp Null(FILE *)
  69. #define Nulline Null(LINENUM)
  70.  
  71. #define Ctl(ch) ((ch) & 037)
  72.  
  73. #define strNE(s1,s2) (strcmp(s1, s2))
  74. #define strEQ(s1,s2) (!strcmp(s1, s2))
  75. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  76. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  77.  
  78. /* typedefs */
  79.  
  80. typedef char bool;
  81. typedef long LINENUM;            /* must be signed */
  82. typedef unsigned MEM;            /* what to feed malloc */
  83.  
  84. /* globals */
  85.  
  86. EXT int Argc;                /* guess */
  87. EXT char **Argv;
  88. EXT int Argc_last;            /* for restarting plan_b */
  89. EXT char **Argv_last;
  90.  
  91. EXT struct stat filestat;        /* file statistics area */
  92. EXT int filemode INIT(0644);
  93.  
  94. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  95. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  96. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  97.  
  98. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  99. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  100.  
  101. #define MAXFILEC 2
  102. EXT int filec INIT(0);            /* how many file arguments? */
  103. EXT char *filearg[MAXFILEC];
  104. EXT bool ok_to_create_file INIT(FALSE);
  105. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  106.  
  107. EXT char *outname INIT(Nullch);
  108. EXT char rejname[128];
  109.  
  110. EXT char *origext INIT(Nullch);
  111. EXT char *origprae INIT(Nullch);
  112.  
  113. #ifdef TOS
  114. EXT char TMPOUTNAME[] INIT("poXXXXXX");
  115. EXT char TMPINNAME[] INIT("piXXXXXX");    /* might want /usr/tmp here */
  116. EXT char TMPREJNAME[] INIT("prXXXXXX");
  117. EXT char TMPPATNAME[] INIT("ppXXXXXX");
  118. #else
  119. EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
  120. EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX");    /* might want /usr/tmp here */
  121. EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
  122. EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
  123. #endif
  124. EXT bool toutkeep INIT(FALSE);
  125. EXT bool trejkeep INIT(FALSE);
  126.  
  127. EXT LINENUM last_offset INIT(0);
  128. #ifdef DEBUGGING
  129. EXT int debug INIT(0);
  130. #endif
  131. EXT LINENUM maxfuzz INIT(2);
  132. EXT bool force INIT(FALSE);
  133. EXT bool verbose INIT(TRUE);
  134. EXT bool reverse INIT(FALSE);
  135. EXT bool noreverse INIT(FALSE);
  136. EXT bool skip_rest_of_patch INIT(FALSE);
  137. EXT int strippath INIT(957);
  138. EXT bool canonicalize INIT(FALSE);
  139.  
  140. #define CONTEXT_DIFF 1
  141. #define NORMAL_DIFF 2
  142. #define ED_DIFF 3
  143. #define NEW_CONTEXT_DIFF 4
  144. EXT int diff_type INIT(0);
  145.  
  146. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  147. EXT char if_defined[128];        /* #ifdef xyzzy */
  148. EXT char not_defined[128];        /* #ifndef xyzzy */
  149. EXT char else_defined[] INIT("#else\n");/* #else */
  150. EXT char end_defined[128];        /* #endif xyzzy */
  151.  
  152. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  153.  
  154. char *malloc();
  155. char *realloc();
  156. char *strcpy();
  157. char *strcat();
  158. long atol();
  159. long lseek();
  160. char *mktemp();
  161. #ifdef CHARSPRINTF
  162. char *sprintf();
  163. #else
  164. #ifndef __STDC__    /* pick up proto instead */
  165. int sprintf();
  166. #endif
  167. #endif
  168.