home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / patch212.zip / common.h next >
C/C++ Source or Header  |  1991-02-18  |  4KB  |  169 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. #include <io.h>
  42. #include <fcntl.h>
  43.  
  44. /* constants */
  45.  
  46. #define TRUE (1)
  47. #define FALSE (0)
  48.  
  49. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  50. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  51. #define MAXLINELEN 1024
  52. #define BUFFERSIZE 1024
  53. #define SCCSPREFIX "s."
  54. #define GET "get -e %s"
  55. #define RCSSUFFIX ",v"
  56. #define CHECKOUT "co -l %s"
  57.  
  58. #ifdef FLEXFILENAMES
  59. #define ORIGEXT ".orig"
  60. #define REJEXT ".rej"
  61. #else
  62. #define ORIGEXT "~"
  63. #define REJEXT "#"
  64. #endif
  65.  
  66. /* handy definitions */
  67.  
  68. #define Null(t) ((t)0)
  69. #define Nullch Null(char *)
  70. #define Nullfp Null(FILE *)
  71. #define Nulline Null(LINENUM)
  72.  
  73. #define Ctl(ch) ((ch) & 037)
  74.  
  75. #define strNE(s1,s2) (strcmp(s1, s2))
  76. #define strEQ(s1,s2) (!strcmp(s1, s2))
  77. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  78. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  79.  
  80. /* typedefs */
  81.  
  82. typedef char bool;
  83. typedef long LINENUM;            /* must be signed */
  84. typedef unsigned MEM;            /* what to feed malloc */
  85.  
  86. /* globals */
  87.  
  88. EXT int Argc;                /* guess */
  89. EXT char **Argv;
  90. EXT int Argc_last;            /* for restarting plan_b */
  91. EXT char **Argv_last;
  92.  
  93. EXT struct stat filestat;        /* file statistics area */
  94. EXT int filemode INIT(0644);
  95.  
  96. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  97. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  98. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  99.  
  100. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  101. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  102.  
  103. #define MAXFILEC 2
  104. EXT int filec INIT(0);            /* how many file arguments? */
  105. EXT char *filearg[MAXFILEC];
  106. EXT bool ok_to_create_file INIT(FALSE);
  107. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  108.  
  109. EXT char *outname INIT(Nullch);
  110. EXT char rejname[128];
  111.  
  112. EXT char *origext INIT(Nullch);
  113. EXT char *origprae INIT(Nullch);
  114.  
  115. EXT char *TMPOUTNAME;
  116. EXT char *TMPINNAME;
  117. EXT char *TMPREJNAME;
  118. EXT char *TMPPATNAME;
  119.  
  120. EXT bool toutkeep INIT(FALSE);
  121. EXT bool trejkeep INIT(FALSE);
  122.  
  123. EXT LINENUM last_offset INIT(0);
  124. #ifdef DEBUGGING
  125. EXT int debug INIT(0);
  126. #endif
  127. EXT LINENUM maxfuzz INIT(2);
  128. EXT bool force INIT(FALSE);
  129. EXT bool verbose INIT(TRUE);
  130. EXT bool reverse INIT(FALSE);
  131. EXT bool noreverse INIT(FALSE);
  132. EXT bool skip_rest_of_patch INIT(FALSE);
  133. EXT int strippath INIT(957);
  134. EXT bool canonicalize INIT(FALSE);
  135.  
  136. #define CONTEXT_DIFF 1
  137. #define NORMAL_DIFF 2
  138. #define ED_DIFF 3
  139. #define NEW_CONTEXT_DIFF 4
  140. #define UNI_DIFF 5
  141. EXT int diff_type INIT(0);
  142.  
  143. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  144. EXT char if_defined[128];        /* #ifdef xyzzy */
  145. EXT char not_defined[128];        /* #ifndef xyzzy */
  146. EXT char else_defined[] INIT("#else\n");/* #else */
  147. EXT char end_defined[128];        /* #endif xyzzy */
  148.  
  149. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  150.  
  151. void *malloc();
  152. void *realloc();
  153. char *strcpy();
  154. char *strcat();
  155. long atol();
  156. long lseek();
  157. char *mktemp();
  158.  
  159. #ifdef MSDOS
  160. #undef stderr
  161. FILE *stderr;
  162. #endif
  163. #ifdef CHARSPRINTF
  164. char *sprintf();
  165. #else
  166. int sprintf();
  167. #endif
  168. char *getenv();
  169.