diff options
author | phk <phk@FreeBSD.org> | 1995-03-04 20:36:46 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-03-04 20:36:46 +0000 |
commit | 504389ec944dd6925d07e290d3aa2f23ccb14153 (patch) | |
tree | eb133f95e766e4312715d846edc4955ce5ea5367 /usr.sbin/ctm | |
parent | de3bb318cf8eb29945d2b01a7963a6a71cbca3af (diff) | |
download | FreeBSD-src-504389ec944dd6925d07e290d3aa2f23ccb14153.zip FreeBSD-src-504389ec944dd6925d07e290d3aa2f23ccb14153.tar.gz |
Look at the .ctm_status file and ignores all patches already applied.
Reviewed by: phk
Submitted by: J Wunsch <j@uriah.heep.sax.de>
Diffstat (limited to 'usr.sbin/ctm')
-rw-r--r-- | usr.sbin/ctm/ctm/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/ctm/ctm/ctm.c | 24 | ||||
-rw-r--r-- | usr.sbin/ctm/ctm/ctm.h | 5 | ||||
-rw-r--r-- | usr.sbin/ctm/ctm/ctm_pass1.c | 15 |
4 files changed, 37 insertions, 13 deletions
diff --git a/usr.sbin/ctm/ctm/Makefile b/usr.sbin/ctm/ctm/Makefile index 7c01d35..3d77453 100644 --- a/usr.sbin/ctm/ctm/Makefile +++ b/usr.sbin/ctm/ctm/Makefile @@ -6,7 +6,7 @@ # this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp # ---------------------------------------------------------------------------- # -# $Id: Makefile,v 1.5 1994/09/22 02:49:15 phk Exp $ +# $Id: Makefile,v 1.6 1994/10/24 20:09:18 phk Exp $ # PROG= ctm @@ -18,5 +18,7 @@ DPADD+= ${LIBMD} NOMAN= 1 CFLAGS+= -Wall -g -.include "../../Makefile.inc" +.if exists(${.CURDIR}/../../Makefile.inc) +.include "${.CURDIR}/../../Makefile.inc" +.endif .include <bsd.prog.mk> diff --git a/usr.sbin/ctm/ctm/ctm.c b/usr.sbin/ctm/ctm/ctm.c index 38b3306..b1790a5 100644 --- a/usr.sbin/ctm/ctm/ctm.c +++ b/usr.sbin/ctm/ctm/ctm.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ctm.c,v 1.6 1994/11/26 08:57:40 phk Exp $ + * $Id: ctm.c,v 1.7 1994/12/01 21:05:28 phk Exp $ * * This is the client program of 'CTM'. It will apply a CTM-patch to a * collection of files. @@ -35,7 +35,9 @@ #define EXTERN /* */ #include "ctm.h" -extern int Proc(char *); +#define CTM_STATUS ".ctm_status" + +extern int Proc(char *, unsigned applied); int main(int argc, char **argv) @@ -44,6 +46,8 @@ main(int argc, char **argv) int c; extern int optopt,optind; extern char * optarg; + FILE *statfile; + unsigned applied = 0; Verbose = 1; Paranoid = 1; @@ -81,11 +85,19 @@ main(int argc, char **argv) argc -= optind; argv += optind; + if((statfile = fopen(CTM_STATUS, "r")) == NULL) + fprintf(stderr, "Warning: " CTM_STATUS " not found.\n"); + else { + fscanf(statfile, "%*s %u", &applied); + fclose(statfile); + } + if(!argc) - stat |= Proc("-"); + stat |= Proc("-", applied); while(argc-- && stat == Exit_Done) { - stat |= Proc(*argv++); + stat |= Proc(*argv++, applied); + stat &= ~Exit_Version; } if(stat == Exit_Done) @@ -97,7 +109,7 @@ main(int argc, char **argv) } int -Proc(char *filename) +Proc(char *filename, unsigned applied) { FILE *f; int i; @@ -152,7 +164,7 @@ Proc(char *filename) if(!p) rewind(f); - if((i=Pass1(f))) + if((i=Pass1(f, applied))) return i; if(!p) { diff --git a/usr.sbin/ctm/ctm/ctm.h b/usr.sbin/ctm/ctm/ctm.h index 0812f0f..eb4b4ba 100644 --- a/usr.sbin/ctm/ctm/ctm.h +++ b/usr.sbin/ctm/ctm/ctm.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ctm.h,v 1.4 1994/09/22 02:49:16 phk Exp $ + * $Id: ctm.h,v 1.5 1994/10/24 20:09:21 phk Exp $ * */ @@ -106,6 +106,7 @@ EXTERN int CheckIt; #define Exit_Forcible 16 #define Exit_Mess 32 #define Exit_Done 64 +#define Exit_Version 128 char * String(char *s); void Fatal_(int ln, char *fn, char *kind); @@ -124,7 +125,7 @@ u_char * Fdata(FILE *fd, int u_chars, MD5_CTX *ctx); #define GETBYTECNT(p,q) if(0 >((p)= Fbytecnt(fd,&ctx,(q)))) return BADREAD #define GETDATA(p,q) if(!((p) = Fdata(fd,(q),&ctx))) return BADREAD -int Pass1(FILE *fd); +int Pass1(FILE *fd, unsigned applied); int Pass2(FILE *fd); int Pass3(FILE *fd); diff --git a/usr.sbin/ctm/ctm/ctm_pass1.c b/usr.sbin/ctm/ctm/ctm_pass1.c index 7ef3cb9..3f9dcf7 100644 --- a/usr.sbin/ctm/ctm/ctm_pass1.c +++ b/usr.sbin/ctm/ctm/ctm_pass1.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ctm_pass1.c,v 1.6 1995/02/04 19:20:47 phk Exp $ + * $Id: ctm_pass1.c,v 1.7 1995/02/25 05:02:18 phk Exp $ * */ @@ -18,7 +18,7 @@ */ int -Pass1(FILE *fd) +Pass1(FILE *fd, unsigned applied) { u_char *p,*q; MD5_CTX ctx; @@ -26,7 +26,8 @@ Pass1(FILE *fd) u_char *md5=0,*trash=0; struct CTM_Syntax *sp; int slashwarn=0; - + unsigned current; + if(Verbose>3) printf("Pass1 -- Checking integrity of incoming CTM-patch\n"); MD5Init (&ctx); @@ -52,6 +53,14 @@ Pass1(FILE *fd) GETFIELDCOPY(TimeStamp,' '); /* <TimeStamp> */ GETFIELDCOPY(Prefix,'\n'); /* <Prefix> */ + sscanf(Nbr, "%u", ¤t); + if(current <= applied) { + if(Verbose) + fprintf(stderr,"Delta number %u is already applied; ignoring.\n", + current); + return Exit_Version; + } + for(;;) { if(md5) {Free(md5), md5 = 0;} if(trash) {Free(trash), trash = 0;} |