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