Look at the .ctm_status file and ignores all patches already applied.

Reviewed by:	phk
Submitted by:	J Wunsch <j@uriah.heep.sax.de>
This commit is contained in:
phk 1995-03-04 20:36:46 +00:00
parent b5fa7eeb6c
commit e8089e5175
4 changed files with 37 additions and 13 deletions

View File

@ -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>

View File

@ -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) {

View File

@ -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);

View File

@ -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", &current);
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;}