/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1995-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> *
* *
***********************************************************************/
#include "vdelhdr.h"
/* Apply the transformation source->target to reconstruct target
** This code is designed to work even if the local machine has
** word size smaller than that of the machine where the delta
** was computed. A requirement is that "long" on the local
** machine must be large enough to hold source and target sizes.
** It is also assumed that if an array is given, the size of
** that array in bytes must be storable in an "int". This is
** used in various cast from "long" to "int".
**
** Written by Kiem-Phong Vo, kpv@research.att.com, 5/20/94
*/
/* structure for update table */
typedef struct _utable_s
long n_src;
long n_tar;
} Utable_t;
#if __STD_C
#else
#endif
{
return -1;
else /* non-local ADD size */
return -1;
return -1;
}
return -1;
/* copy data from the delta stream to target */
for(;;)
{ if(!tar)
n = (int)size;
return -1;
if(r != n)
return -1;
}
else
{ n = (int)size;
return -1;
}
t += n;
if((size -= n) <= 0)
break;
}
goto do_copy;
}
}
else
else
return -1;
return -1;
}
return -1;
return -1;
else
return -1;
/* else k_type == K_SELF */
}
return -1;
if(src)
{ n = (int)size;
if(tar)
}
else
if(r != n)
return -1;
}
t += n;
}
else
}
else
}
for(;;)
{ if(tar)
{ n = (int)size;
}
else
if((long)n > size)
n = (int)size;
if(r != n)
return -1;
}
if(r != n)
return -1;
t += n;
if((size -= n) <= 0)
break;
copy += n;
}
}
}
else /* copy from target data */
return -1;
for(;;) /* allow for copying overlapped data */
{ reg long s, a;
s = size;
if(tar)
t += n;
goto next;
}
a = copy;
for(;;)
n = (int)s;
if(r != n)
return -1;
if(r != n)
return -1;
t += n;
if((s -= n) <= 0)
break;
a += n;
}
break;
}
}
}
}
return 0;
}
#if __STD_C
#else
#endif
{
reg int n, r;
return -1;
return -1;
/* initialize I/O buffer */
/* check magic header */
/* VD_MAGIC is the preferred binary magic */
/* VD_MAGIC_OLD is the deprecated ascii magic */
n = sizeof(VD_MAGIC) - 1;
return -1;
for(r = 0; r < n; ++r)
for (r = 0; r < n; ++r)
#if _PACKAGE_ast
#else
return -1;
#endif
break;
}
/* get true target size */
return -1;
n_tar = t;
/* get true source size */
return -1;
else if(t > 0)
return -1;
return -1;
}
n_src = t;
/* get window size */
return -1;
/* if we have space, it'll be faster to unfold */
if(n > n_tar)
n = n_tar;
if(n_src <= 0)
n = 0;
}
else
if(n > n_src)
n = n_src;
}
for(t = 0; t < n_tar; )
if(n_src <= 0) /* data compression */
if(t == 0)
else
if(tar)
}
else
if(r != n)
goto done;
}
}
}
}
else /* data differencing */
{ if(t < n_src)
p = 0;
else p = t;
if(src)
if(r != n)
goto done;
}
}
/* else use last window */
}
if(tar)
goto done;
goto done;
}
}
done:
return t;
}