/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include "update.h"
/*
** Reconstruct a target file from a source file and a delta file.
** The delta file contain block move instructions computed by delta().
**
** Written by Kiem-Phong Vo, 5/20/88
*/
/* buffers for delta and target files */
/* read a byte from delta file */
static int delgetc(void)
{
{
register int n;
return -1;
}
return (int)(*Dnext++);
}
/* read a long value from delta file */
static long delgetl(register int n)
{
register long lv;
lv = 0;
for(; n > 0; --n)
{
register int v;
if((v = delgetc()) < 0)
return -1;
}
return lv;
}
/* transfer a number of bytes from a file to the target file */
{
while(n > 0)
{
register int r;
if(tarflush() < 0)
return -1;
return -1;
Tnext += r;
n -= r;
}
return 0;
}
/* transfer a number of bytes from a memory area to the target file */
{
while(n > 0)
{
register int r;
if(tarflush() < 0)
return -1;
Tnext += r;
addr += r;
n -= r;
}
return 0;
}
/* transfer a number of bytes from delta to target */
static int deltransfer(long n)
{
register int d;
/* transfer what's already in core */
{
register int w = n <= d ? n : d;
if(tarflush() < 0)
return -1;
/* copy from the delta buffer */
Dnext += w;
Tnext += w;
n -= w;
}
return n > 0 ? filetransfer(Dfd,n) : 0;
}
int
{
register int i;
/* start buffering system for delta file */
/* read the file sizes */
return -1;
return -1;
/* make data area for target file */
/* read in source file if possible to avoid lseek */
{
return -1;
}
while((i = delgetc()) >= 0)
{
return -1;
switch(i&DELTA_TYPE)
{
default :
return -1;
case DELTA_TYPE :
/* sync delta file pointer */
/* flush output buffer */
if(tarflush() < 0)
return -1;
/* free space used */
if(src)
if(tar)
return 0;
case DELTA_MOVE :
return -1;
if(src)
{
return -1;
}
else
{
return -1;
return -1;
}
break;
case DELTA_ADD :
if(deltransfer(size) < 0)
return -1;
break;
}
}
/* should never get here */
return -1;
}