home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c017 / 14.ddi / PATCH12.ZIP / COMMON.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-02  |  4.4 KB  |  179 lines

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