Annotation of 43BSDTahoe/new/patch/common.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.