Functions4U: Added BSDiff/BSPatch

git-svn-id: svn://ultimatepp.org/upp/trunk@1851 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2009-12-29 06:20:50 +00:00
parent a085713350
commit de2d1b68d4
23 changed files with 1290 additions and 12 deletions

View file

@ -1222,3 +1222,6 @@ Value GetVARIANT(VARIANT &result)
}
#endif

View file

@ -382,5 +382,8 @@ inline void DoEvents() {
}
*/
String BsGetLastError();
bool BSPatch(String oldfile, String newfile, String patchfile);
bool BSDiff(String oldfile, String newfile, String patchfile);
#endif

View file

@ -35,3 +35,66 @@ esES("No es posible borrar")
T_("There was a problem in the copy")
esES("Hubo un problema al copiar")
// bsdiff.cpp
T_("File %s does not exist")
esES("Fichero %s no existe")
T_("Patch file is empty")
esES("Fichero de parche est\303\241 vacio")
T_("Error opening %s")
esES("Error abriendo %s")
T_("Not enough memory")
esES("Memoria insuficiente")
T_("fwrite(%s)")
esES("")
T_("BZ2_bzWriteOpen, bz2err = %d")
esES("")
T_("BZ2_bzWrite, bz2err = %d")
esES("")
T_("BZ2_bzWriteClose, bz2err = %d")
esES("")
T_("ftello")
esES("")
T_("fseeko")
esES("")
T_("fclose")
esES("")
// bspatch.cpp
T_("New file is empty")
esES("Nuevo fichero est\303\241 vacio")
T_("fopen(%s)")
esES("")
T_("Corrupt patch")
esES("Parche corrompido")
T_("fread(%s)")
esES("")
T_("fclose(%s)")
esES("")
T_("fseeko(%s, %lld)")
esES("")
T_("BZ2_bzReadOpen, bz2err = %d")
esES("")
T_("Impossible to open %s")
esES("Imposible abrir %s")

View file

@ -1,9 +1,10 @@
description "Functions and classes for general use\377B255,170,0";
uses
Core;
Core,
plugin\bz2;
library(WIN32) "oleaut32 ";
library(WIN32) oleaut32;
file
Functions4U.cpp,
@ -13,7 +14,13 @@ file
srcdoc.tpp,
src.tpp,
Functions4U.t,
License.txt;
License.txt,
bsdiffwrapper.h,
BSDiff readonly separator,
plugin/bsadditional.cpp,
plugin/bsdiff.cpp,
plugin/bspatch.cpp,
plugin/Credits.txt;
mainconfig
"" = "";

View file

@ -19,3 +19,4 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSE
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,32 @@
#ifndef _Functions4U_bsdiffwrapper_h_
#define _Functions4U_bsdiffwrapper_h_
#define ftello ftell
#define fseeko fseek
extern String errMsg;
String BsGetLastError();
bool Err(String str);
#if defined(_WINDOWS_) || defined(__MINGW32__)
#include <io.h>
#include <share.h>
#include <sys/stat.h>
#define lseek _lseek
#define read _read
#define write _write
#define close _close
typedef unsigned char u_char;
#if defined(__MINGW32__)
#define _SH_DENYNO 0x40
#else
typedef long pid_t;
typedef signed int ssize_t;
#endif
#endif
#endif

View file

@ -1,4 +1,5 @@
#ifndef _Functions4U_icpp_init_stub
#define _Functions4U_icpp_init_stub
#include "Core/init"
#include "plugin\bz2/init"
#endif

View file

@ -0,0 +1,38 @@
Binary diff/patch utility version 4.3, written by
Copyright 2003-2005 Colin Percival <cperciva@freebsd.org>
This is a quick native Win32-Port by
Andreas John <dynacore@tesla.inka.de>
-------------------------------------------------------------------------
Quick overview from the homepage of these tools:
http://www.daemonology.net/bsdiff/
Binary diff/patch utility
bsdiff and bspatch are tools for building and applying patches to binary
files. By using suffix sorting (specifically, Larsson and Sadakane's
qsufsort) and taking advantage of how executable files change, bsdiff
routinely produces binary patches 50-80% smaller than those produced by
Xdelta, and 15% smaller than those produced by .RTPatch (a $2750/seat
commercial patch tool).
These programs were originally named bdiff and bpatch, but the large
number of other programs using those names lead to confusion; I'm not
sure if the "bs" in refers to "binary software" (because bsdiff produces
exceptionally small patches for executable files) or "bytewise
subtraction" (which is the key to how well it performs). Feel free to
offer other suggestions.
bsdiff and bspatch use bzip2; by default they assume it is in /usr/bin.
bsdiff is quite memory-hungry. It requires max(17*n,9*n+m)+O(1) bytes of
memory, where n is the size of the old file and m is the size of the new
file. bspatch requires n+m+O(1) bytes.
bsdiff runs in O((n+m) log n) time; on a 200MHz Pentium Pro, building a
binary patch for a 4MB file takes about 90 seconds. bspatch runs in
O(n+m) time; on the same machine, applying that patch takes about two
seconds.
Providing that off_t is defined properly, bsdiff and bspatch support
files of up to 2^61-1 = 2Ei-1 bytes.

View file

@ -0,0 +1,18 @@
#include <Core/Core.h>
using namespace Upp;
String errMsg;
#include "../bsdiffwrapper.h"
String BsGetLastError() {
return errMsg;
}
bool Err(String str) {
errMsg = str;
return false;
}

View file

@ -0,0 +1,446 @@
/*-
* Copyright 2003-2005 Colin Percival
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#if 0
__FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05 cperciva Exp $");
#endif
#include "bzlib.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
//#include <err.h>
//#include <unistd.h>
#include <Core/Core.h>
using namespace Upp;
#include "../bsdiffwrapper.h"
#define MIN(x,y) (((x)<(y)) ? (x) : (y))
static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h)
{
off_t i,j,k,x,tmp,jj,kk;
if(len<16) {
for(k=start;k<start+len;k+=j) {
j=1;x=V[I[k]+h];
for(i=1;k+i<start+len;i++) {
if(V[I[k+i]+h]<x) {
x=V[I[k+i]+h];
j=0;
};
if(V[I[k+i]+h]==x) {
tmp=I[k+j];I[k+j]=I[k+i];I[k+i]=tmp;
j++;
};
};
for(i=0;i<j;i++) V[I[k+i]]=k+j-1;
if(j==1) I[k]=-1;
};
return;
};
x=V[I[start+len/2]+h];
jj=0;kk=0;
for(i=start;i<start+len;i++) {
if(V[I[i]+h]<x) jj++;
if(V[I[i]+h]==x) kk++;
};
jj+=start;kk+=jj;
i=start;j=0;k=0;
while(i<jj) {
if(V[I[i]+h]<x) {
i++;
} else if(V[I[i]+h]==x) {
tmp=I[i];I[i]=I[jj+j];I[jj+j]=tmp;
j++;
} else {
tmp=I[i];I[i]=I[kk+k];I[kk+k]=tmp;
k++;
};
};
while(jj+j<kk) {
if(V[I[jj+j]+h]==x) {
j++;
} else {
tmp=I[jj+j];I[jj+j]=I[kk+k];I[kk+k]=tmp;
k++;
};
};
if(jj>start) split(I,V,start,jj-start,h);
for(i=0;i<kk-jj;i++) V[I[jj+i]]=kk-1;
if(jj==kk-1) I[jj]=-1;
if(start+len>kk) split(I,V,kk,start+len-kk,h);
}
static void qsufsort(off_t *I,off_t *V,u_char *old,off_t oldsize)
{
off_t buckets[256];
off_t i,h,len;
for(i=0;i<256;i++) buckets[i]=0;
for(i=0;i<oldsize;i++) buckets[old[i]]++;
for(i=1;i<256;i++) buckets[i]+=buckets[i-1];
for(i=255;i>0;i--) buckets[i]=buckets[i-1];
buckets[0]=0;
for(i=0;i<oldsize;i++) I[++buckets[old[i]]]=i;
I[0]=oldsize;
for(i=0;i<oldsize;i++) V[i]=buckets[old[i]];
V[oldsize]=0;
for(i=1;i<256;i++) if(buckets[i]==buckets[i-1]+1) I[buckets[i]]=-1;
I[0]=-1;
for(h=1;I[0]!=-(oldsize+1);h+=h) {
len=0;
for(i=0;i<oldsize+1;) {
if(I[i]<0) {
len-=I[i];
i-=I[i];
} else {
if(len) I[i-len]=-len;
len=V[I[i]]+1-i;
split(I,V,i,len,h);
i+=len;
len=0;
};
};
if(len) I[i-len]=-len;
};
for(i=0;i<oldsize+1;i++) I[V[i]]=i;
}
static off_t matchlen(u_char *old,off_t oldsize,u_char *nnew,off_t newsize)
{
off_t i;
for(i=0;(i<oldsize)&&(i<newsize);i++)
if(old[i]!=nnew[i]) break;
return i;
}
static off_t search(off_t *I,u_char *old,off_t oldsize,
u_char *nnew,off_t newsize,off_t st,off_t en,off_t *pos)
{
off_t x,y;
if(en-st<2) {
x=matchlen(old+I[st],oldsize-I[st],nnew,newsize);
y=matchlen(old+I[en],oldsize-I[en],nnew,newsize);
if(x>y) {
*pos=I[st];
return x;
} else {
*pos=I[en];
return y;
}
};
x=st+(en-st)/2;
if(memcmp(old+I[x],nnew,MIN(oldsize-I[x],newsize))<0) {
return search(I,old,oldsize,nnew,newsize,x,en,pos);
} else {
return search(I,old,oldsize,nnew,newsize,st,x,pos);
};
}
static void offtout(off_t x,u_char *buf)
{
off_t y;
if(x<0) y=-x; else y=x;
buf[0]=y%256;y-=buf[0];
y=y/256;buf[1]=y%256;y-=buf[1];
y=y/256;buf[2]=y%256;y-=buf[2];
y=y/256;buf[3]=y%256;y-=buf[3];
y=y/256;buf[4]=y%256;y-=buf[4];
y=y/256;buf[5]=y%256;y-=buf[5];
y=y/256;buf[6]=y%256;y-=buf[6];
y=y/256;buf[7]=y%256;
if(x<0) buf[7]|=0x80;
}
bool BSDiff(String oldfile, String newfile, String patchfile)
{
if (!FileExists(oldfile))
return Err(Format(t_("File %s does not exist"), oldfile));
if (!FileExists(newfile))
return Err(Format(t_("File %s does not exist"), newfile));
if (patchfile.IsEmpty())
return Err(t_("Patch file is empty"));
int fd;
u_char *old,*nnew;
off_t oldsize,newsize;
off_t *I,*V;
off_t scan,pos,len;
off_t lastscan,lastpos,lastoffset;
off_t oldscore,scsc;
off_t s,Sf,lenf,Sb,lenb;
off_t overlap,Ss,lens;
off_t i;
off_t dblen,eblen;
u_char *db,*eb;
u_char buf[8];
u_char header[32];
FILE * pf;
BZFILE * pfbz2;
int bz2err;
//if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
/* Allocate oldsize+1 bytes instead of oldsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
if(
#ifdef PLATFORM_POSIX
((fd = open(oldfile, O_RDONLY, 0)) < 0) ||
#else
((fd = _wsopen(oldfile.ToWString(), O_RDONLY|O_BINARY, _SH_DENYNO, 0)) < 0) ||
#endif
((oldsize=lseek(fd,0,SEEK_END))==-1) ||
((old=(u_char *)malloc(oldsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0))
return Err(Format(t_("Error opening %s"), oldfile));
// read() reads in chunks
int r = oldsize;
while (r > 0 && (i = read(fd,old+oldsize-r,r))>0)
r -=i ;
if (r > 0 || close(fd) == -1)
return Err(Format(t_("Error opening %s"), oldfile));
if(((I=(off_t *)malloc((oldsize+1)*sizeof(off_t)))==NULL) ||
((V=(off_t *)malloc((oldsize+1)*sizeof(off_t)))==NULL)) Err(t_("Not enough memory"));
qsufsort(I,V,old,oldsize);
free(V);
/* Allocate newsize+1 bytes instead of newsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
if(
#ifdef PLATFORM_POSIX
((fd = open(newfile, O_RDONLY, 0)) < 0) ||
#else
((fd = _wsopen(newfile.ToWString(), O_RDONLY|O_BINARY, _SH_DENYNO, 0)) < 0) ||
#endif
((newsize=lseek(fd,0,SEEK_END))==-1) ||
((nnew=(u_char *)malloc(newsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0))
return Err(Format(t_("Error opening %s"), newfile));
// read() reads in chunks
r = newsize;
while (r > 0 && (i = read(fd, nnew+newsize-r,r))>0)
r -= i;
if (r > 0 || close(fd)==-1)
return Err(Format(t_("Error opening %s"), newfile));
if(((db=(u_char *)malloc(newsize+1))==NULL) ||
((eb=(u_char *)malloc(newsize+1))==NULL)) Err(t_("Not enough memory"));
dblen=0;
eblen=0;
/* Create the patch file */
if (
#ifdef PLATFORM_POSIX
(pf = fopen(patchfile, "w")) == NULL)
#else
(pf = _wfopen(patchfile.ToWString(), L"wb")) == NULL)
#endif
return Err(Format(t_("Error opening %s"), patchfile));
/* Header is
0 8 "BSDIFF40"
8 8 length of bzip2ed ctrl block
16 8 length of bzip2ed diff block
24 8 length of new file */
/* File is
0 32 Header
32 ?? Bzip2ed ctrl block
?? ?? Bzip2ed diff block
?? ?? Bzip2ed extra block */
memcpy(header,"BSDIFF40",8);
offtout(0, header + 8);
offtout(0, header + 16);
offtout(newsize, header + 24);
if (fwrite(header, 32, 1, pf) != 1)
return Err(Format(t_("fwrite(%s)"), patchfile));
/* Compute the differences, writing ctrl as we go */
if ((pfbz2 = BZ2_bzWriteOpen(&bz2err, pf, 9, 0, 0)) == NULL)
return Err(Format(t_("BZ2_bzWriteOpen, bz2err = %d"), bz2err));
scan=0;len=0;
lastscan=0;lastpos=0;lastoffset=0;
while(scan<newsize) {
oldscore=0;
for(scsc=scan+=len;scan<newsize;scan++) {
len=search(I,old,oldsize,nnew+scan,newsize-scan,
0,oldsize,&pos);
for(;scsc<scan+len;scsc++)
if((scsc+lastoffset<oldsize) &&
(old[scsc+lastoffset] == nnew[scsc]))
oldscore++;
if(((len==oldscore) && (len!=0)) ||
(len>oldscore+8)) break;
if((scan+lastoffset<oldsize) &&
(old[scan+lastoffset] == nnew[scan]))
oldscore--;
};
if((len!=oldscore) || (scan==newsize)) {
s=0;Sf=0;lenf=0;
for(i=0;(lastscan+i<scan)&&(lastpos+i<oldsize);) {
if(old[lastpos+i]==nnew[lastscan+i]) s++;
i++;
if(s*2-i>Sf*2-lenf) { Sf=s; lenf=i; };
};
lenb=0;
if(scan<newsize) {
s=0;Sb=0;
for(i=1;(scan>=lastscan+i)&&(pos>=i);i++) {
if(old[pos-i]==nnew[scan-i]) s++;
if(s*2-i>Sb*2-lenb) { Sb=s; lenb=i; };
};
};
if(lastscan+lenf>scan-lenb) {
overlap=(lastscan+lenf)-(scan-lenb);
s=0;Ss=0;lens=0;
for(i=0;i<overlap;i++) {
if(nnew[lastscan+lenf-overlap+i]==
old[lastpos+lenf-overlap+i]) s++;
if(nnew[scan-lenb+i]==
old[pos-lenb+i]) s--;
if(s>Ss) { Ss=s; lens=i+1; };
};
lenf+=lens-overlap;
lenb-=lens;
};
for(i=0;i<lenf;i++)
db[dblen+i]=nnew[lastscan+i]-old[lastpos+i];
for(i=0;i<(scan-lenb)-(lastscan+lenf);i++)
eb[eblen+i]=nnew[lastscan+lenf+i];
dblen+=lenf;
eblen+=(scan-lenb)-(lastscan+lenf);
offtout(lenf,buf);
BZ2_bzWrite(&bz2err, pfbz2, buf, 8);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWrite, bz2err = %d"), bz2err));
offtout((scan-lenb)-(lastscan+lenf),buf);
BZ2_bzWrite(&bz2err, pfbz2, buf, 8);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWrite, bz2err = %d"), bz2err));
offtout((pos-lenb)-(lastpos+lenf),buf);
BZ2_bzWrite(&bz2err, pfbz2, buf, 8);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWrite, bz2err = %d"), bz2err));
lastscan=scan-lenb;
lastpos=pos-lenb;
lastoffset=pos-scan;
};
};
BZ2_bzWriteClose(&bz2err, pfbz2, 0, NULL, NULL);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWriteClose, bz2err = %d"), bz2err));
/* Compute size of compressed ctrl data */
if ((len = ftello(pf)) == -1)
return Err(t_("ftello"));
offtout(len-32, header + 8);
/* Write compressed diff data */
if ((pfbz2 = BZ2_bzWriteOpen(&bz2err, pf, 9, 0, 0)) == NULL)
return Err(Format(t_("BZ2_bzWriteOpen, bz2err = %d"), bz2err));
BZ2_bzWrite(&bz2err, pfbz2, db, dblen);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWrite, bz2err = %d"), bz2err));
BZ2_bzWriteClose(&bz2err, pfbz2, 0, NULL, NULL);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWriteClose, bz2err = %d"), bz2err));
/* Compute size of compressed diff data */
if ((newsize = ftello(pf)) == -1)
return Err(t_("ftello"));
offtout(newsize - len, header + 16);
/* Write compressed extra data */
if ((pfbz2 = BZ2_bzWriteOpen(&bz2err, pf, 9, 0, 0)) == NULL)
return Err(Format(t_("BZ2_bzWriteOpen, bz2err = %d"), bz2err));
BZ2_bzWrite(&bz2err, pfbz2, eb, eblen);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWrite, bz2err = %d"), bz2err));
BZ2_bzWriteClose(&bz2err, pfbz2, 0, NULL, NULL);
if (bz2err != BZ_OK)
return Err(Format(t_("BZ2_bzWriteClose, bz2err = %d"), bz2err));
/* Seek to the beginning, write the header, and close the file */
if (fseeko(pf, 0, SEEK_SET))
return Err(t_("fseeko"));
if (fwrite(header, 32, 1, pf) != 1)
return Err(Format(t_("fwrite(%s)"), patchfile));
if (fclose(pf))
return Err(t_("fclose"));
/* Free the memory we used */
free(db);
free(eb);
free(I);
free(old);
free(nnew);
return 1;
}

View file

@ -0,0 +1,257 @@
/*-
* Copyright 2003-2005 Colin Percival
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#if 0
__FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:06 cperciva Exp $");
#endif
#include "bzlib.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
//#include <err.h>
//#include <unistd.h>
#include <Core/Core.h>
using namespace Upp;
#include "../bsdiffwrapper.h"
static off_t offtin(u_char *buf)
{
off_t y;
y=buf[7]&0x7F;
y=y*256;y+=buf[6];
y=y*256;y+=buf[5];
y=y*256;y+=buf[4];
y=y*256;y+=buf[3];
y=y*256;y+=buf[2];
y=y*256;y+=buf[1];
y=y*256;y+=buf[0];
if(buf[7]&0x80) y=-y;
return y;
}
bool BSPatch(String oldfile, String newfile, String patchfile)
{
if (!FileExists(oldfile))
return Err(Format(t_("File %s does not exist"), oldfile));
if (!FileExists(patchfile))
return Err(Format(t_("File %s does not exist"), oldfile));
if (newfile.IsEmpty())
return Err(t_("New file is empty"));
FILE * f, * cpf, * dpf, * epf;
BZFILE * cpfbz2, * dpfbz2, * epfbz2;
int cbz2err, dbz2err, ebz2err;
int fd;
ssize_t oldsize,newsize;
ssize_t bzctrllen,bzdatalen;
u_char header[32],buf[8];
u_char *old, *nnew;
off_t oldpos,newpos;
off_t ctrl[3];
off_t lenread;
off_t i;
//if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
/* Open patch file */
if (
#ifdef PLATFORM_POSIX
(f = fopen(patchfile, "r")) == NULL)
#else
(f = _wfopen(patchfile.ToWString(), L"rb")) == NULL)
#endif
return Err(Format(t_("fopen(%s)"), patchfile));
/*
File format:
0 8 "BSDIFF40"
8 8 X
16 8 Y
24 8 sizeof(newfile)
32 X bzip2(control block)
32+X Y bzip2(diff block)
32+X+Y ??? bzip2(extra block)
with control block a set of triples (x,y,z) meaning "add x bytes
from oldfile to x bytes from the diff block; copy y bytes from the
extra block; seek forwards in oldfile by z bytes".
*/
/* Read header */
if (fread(header, 1, 32, f) < 32) {
if (feof(f))
return Err(t_("Corrupt patch"));
return Err(Format(t_("fread(%s)"), patchfile));
}
/* Check for appropriate magic */
if (memcmp(header, "BSDIFF40", 8) != 0)
return Err(t_("Corrupt patch"));
/* Read lengths from header */
bzctrllen=offtin(header+8);
bzdatalen=offtin(header+16);
newsize=offtin(header+24);
if((bzctrllen<0) || (bzdatalen<0) || (newsize<0))
return Err(t_("Corrupt patch"));
/* Close patch file and re-open it via libbzip2 at the right places */
if (fclose(f))
return Err(Format(t_("fclose(%s)"), /*argv[3]*/patchfile));
if (
#ifdef PLATFORM_POSIX
(cpf = fopen(patchfile, "r")) == NULL)
#else
(cpf = _wfopen(patchfile.ToWString(), L"rb")) == NULL)
#endif
return Err(Format(t_("fopen(%s)"), patchfile));
if (fseeko(cpf, 32, SEEK_SET))
return Err(Format(t_("fseeko(%s, %lld)"), patchfile,
(long long)32));
if ((cpfbz2 = BZ2_bzReadOpen(&cbz2err, cpf, 0, 0, NULL, 0)) == NULL)
return Err(Format(t_("BZ2_bzReadOpen, bz2err = %d"), cbz2err));
if (
#ifdef PLATFORM_POSIX
(dpf = fopen(patchfile, "r")) == NULL)
#else
(dpf = _wfopen(patchfile.ToWString(), L"rb")) == NULL)
#endif
return Err(Format(t_("fopen(%s)"), patchfile));
if (fseeko(dpf, 32 + bzctrllen, SEEK_SET))
return Err(Format(t_("fseeko(%s, %lld)"), patchfile,
(long long)(32 + bzctrllen)));
if ((dpfbz2 = BZ2_bzReadOpen(&dbz2err, dpf, 0, 0, NULL, 0)) == NULL)
return Err(Format(t_("BZ2_bzReadOpen, bz2err = %d"), dbz2err));
if (
#ifdef PLATFORM_POSIX
(epf = fopen(patchfile, "r")) == NULL)
#else
(epf = _wfopen(patchfile.ToWString(), L"rb")) == NULL)
#endif
return Err(Format(t_("fopen(%s)"), patchfile));
if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET))
return Err(Format(t_("fseeko(%s, %lld)"), patchfile,
(long long)(32 + bzctrllen + bzdatalen)));
if ((epfbz2 = BZ2_bzReadOpen(&ebz2err, epf, 0, 0, NULL, 0)) == NULL)
return Err(Format(t_("BZ2_bzReadOpen, bz2err = %d"), ebz2err));
if(
#ifdef PLATFORM_POSIX
((fd = open(oldfile, O_RDONLY, 0)) < 0) ||
#else
((fd = _wsopen(oldfile.ToWString(), O_RDONLY|O_BINARY, _SH_DENYNO, 0)) < 0) ||
#endif
((oldsize=lseek(fd,0,SEEK_END))==-1) ||
((old=(u_char *)malloc(oldsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0))
Err(Format(t_("Error opening %s"), oldfile));
int r = oldsize;
while(r>0 && (i=read(fd,old+oldsize-r,r))>0)
r -= i;
if (r>0 || close(fd)==-1)
Err(Format(t_("Error opening %s"), oldfile));
if((nnew=(u_char *)malloc(newsize+1))==NULL)
return Err(t_("Not enough memory"));
oldpos=0;newpos=0;
while(newpos<newsize) {
/* Read control data */
for(i=0;i<=2;i++) {
lenread = BZ2_bzRead(&cbz2err, cpfbz2, buf, 8);
if ((lenread < 8) || ((cbz2err != BZ_OK) &&
(cbz2err != BZ_STREAM_END)))
return Err(t_("Corrupt patch"));
ctrl[i]=offtin(buf);
};
/* Sanity-check */
if(newpos+ctrl[0]>newsize)
return Err(t_("Corrupt patch"));
/* Read diff string */
lenread = BZ2_bzRead(&dbz2err, dpfbz2, nnew + newpos, ctrl[0]);
if ((lenread < ctrl[0]) ||
((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END)))
return Err(t_("Corrupt patch"));
/* Add old data to diff string */
for(i=0;i<ctrl[0];i++)
if((oldpos+i>=0) && (oldpos+i<oldsize))
nnew[newpos+i]+=old[oldpos+i];
/* Adjust pointers */
newpos+=ctrl[0];
oldpos+=ctrl[0];
/* Sanity-check */
if(newpos+ctrl[1]>newsize)
return Err(t_("Corrupt patch"));
/* Read extra string */
lenread = BZ2_bzRead(&ebz2err, epfbz2, nnew + newpos, ctrl[1]);
if ((lenread < ctrl[1]) ||
((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END)))
return Err(t_("Corrupt patch"));
/* Adjust pointers */
newpos+=ctrl[1];
oldpos+=ctrl[2];
};
/* Clean up the bzip2 reads */
BZ2_bzReadClose(&cbz2err, cpfbz2);
BZ2_bzReadClose(&dbz2err, dpfbz2);
BZ2_bzReadClose(&ebz2err, epfbz2);
if (fclose(cpf) || fclose(dpf) || fclose(epf))
return Err(Format(t_("fclose(%s)"), patchfile));
/* Write the new file */
if(
#ifdef PLATFORM_POSIX
((fd = open(newfile, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0) ||
#else
((fd = _wsopen(newfile.ToWString(), O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE)) < 0) ||
#endif
(write(fd,nnew,newsize)!=newsize) || (close(fd)==-1))
return Err(Format(t_("Impossible to open %s"), newfile));
free(nnew);
free(old);
return 1;
}

View file

@ -0,0 +1,321 @@
/*-------------------------------------------------------------*/
/*--- Public header file for the library. ---*/
/*--- bzlib.h ---*/
/*-------------------------------------------------------------*/
/*--
This file is a part of bzip2 and/or libbzip2, a program and
library for lossless, block-sorting data compression.
Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#ifndef _BZLIB_H
#define _BZLIB_H
#ifdef __cplusplus
extern "C" {
#endif
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
#define BZ_OK 0
#define BZ_RUN_OK 1
#define BZ_FLUSH_OK 2
#define BZ_FINISH_OK 3
#define BZ_STREAM_END 4
#define BZ_SEQUENCE_ERROR (-1)
#define BZ_PARAM_ERROR (-2)
#define BZ_MEM_ERROR (-3)
#define BZ_DATA_ERROR (-4)
#define BZ_DATA_ERROR_MAGIC (-5)
#define BZ_IO_ERROR (-6)
#define BZ_UNEXPECTED_EOF (-7)
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
typedef
struct {
char *next_in;
unsigned int avail_in;
unsigned int total_in_lo32;
unsigned int total_in_hi32;
char *next_out;
unsigned int avail_out;
unsigned int total_out_lo32;
unsigned int total_out_hi32;
void *state;
void *(*bzalloc)(void *,int,int);
void (*bzfree)(void *,void *);
void *opaque;
}
bz_stream;
#ifndef BZ_IMPORT
#define BZ_EXPORT
#endif
/* Need a definitition for FILE */
#include <stdio.h>
#ifdef _WIN32
# include <windows.h>
# ifdef small
/* windows.h define small to char */
# undef small
# endif
# ifdef BZ_EXPORT
# define BZ_API(func) WINAPI func
# define BZ_EXTERN extern
# else
/* import windows dll dynamically */
# define BZ_API(func) (WINAPI * func)
# define BZ_EXTERN
# endif
#else
# define BZ_API(func) func
# define BZ_EXTERN extern
#endif
/*-- Core (low-level) library functions --*/
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
bz_stream* strm,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
bz_stream* strm,
int action
);
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
bz_stream *strm,
int verbosity,
int small
);
BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
bz_stream *strm
);
/*-- High(er) level library functions --*/
#ifndef BZ_NO_STDIO
#define BZ_MAX_UNUSED 5000
typedef void BZFILE;
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
int* bzerror,
FILE* f,
int verbosity,
int small,
void* unused,
int nUnused
);
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
int* bzerror,
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
int* bzerror,
BZFILE* b,
void** unused,
int* nUnused
);
BZ_EXTERN int BZ_API(BZ2_bzRead) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
int* bzerror,
FILE* f,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in,
unsigned int* nbytes_out
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32,
unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32
);
#endif
/*-- Utility functions --*/
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int small,
int verbosity
);
/*--
Code contributed by Yoshioka Tsuneo
(QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the
threading-safeness of it.
If this code breaks, please contact both Yoshioka and me.
--*/
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
void
);
#ifndef BZ_NO_STDIO
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
const char *path,
const char *mode
);
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
int fd,
const char *mode
);
BZ_EXTERN int BZ_API(BZ2_bzread) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzflush) (
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzclose) (
BZFILE* b
);
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
BZFILE *b,
int *errnum
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*-------------------------------------------------------------*/
/*--- end bzlib.h ---*/
/*-------------------------------------------------------------*/

View file

@ -1,4 +1,4 @@
topic "Functions reference";
topic "Functions4U. Reference";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,0#27521748481378242620020725143825:desc]

View file

@ -1,4 +1,4 @@
TITLE("Functions reference")
TITLE("Functions4U. Reference")
COMPRESSED
120,156,212,186,249,83,163,105,122,32,248,175,16,246,184,163,218,174,174,205,179,78,207,132,189,227,233,177,99,109,183,163,171,189,251,67,71,118,39,149,73,85,49,206,76,114,129,236,118,143,237,9,157,232,190,208,137,64,232,150,16,135,14,36,208,9,186,37,36,14,73,156,66,232,6,116,128,208,129,64,232,214,126,18,144,73,86,101,102,101,121,118,34,118,51,50,144,190,239,125,158,231,125,174,247,185,94,253,250,78,215,127,248,15,183,62,188,245,199,183,126,224,223,231,127,213,243,117,247,139,39,131,15,126,221,123,239,222,167,95,116,223,185,255,197,63,253,31,191,248,236,139,54,254,109,0,255,238,39,183,239,126,122,255,238,237,123,119,62,6,254,220,190,123,251,206,253,59,119,239,221,254,244,206,103,247,62,189,123,247,211,91,159,63,122,210,61,48,240,224,215,79,238,124,250,105,7,233,14,128,116,231,147,251,119,110,127,114,239,211,123,159,222,190,251,201,167,119,0,220,59,183,110,221,185,245,201,157,251,183,239,221,253,244,206,253,207,31,247,12,60,122,240,235,91,0,
248,93,0,252,179,143,239,126,118,235,246,173,91,159,220,190,125,235,238,157,79,110,221,189,127,239,246,237,187,119,0,18,119,62,185,115,251,214,253,207,123,158,61,126,240,235,191,254,248,139,54,194,189,182,80,247,63,6,88,255,24,160,118,239,222,45,128,122,27,237,222,221,219,119,111,221,185,123,255,246,103,247,63,254,252,171,158,111,122,159,189,73,164,251,63,40,210,39,183,62,239,29,236,121,122,37,81,247,189,47,254,244,47,238,127,113,27,64,253,248,195,143,255,248,19,96,219,123,247,129,205,62,107,75,116,23,64,187,115,231,227,251,159,221,190,127,15,96,233,222,173,59,159,247,247,252,223,47,122,251,123,158,246,60,27,188,162,208,123,251,246,157,219,95,124,117,251,147,47,0,22,254,199,255,248,31,31,221,190,119,235,82,83,159,0,188,220,190,5,240,125,231,54,240,14,144,227,147,219,247,63,187,245,217,253,79,111,127,122,235,238,39,247,238,220,255,4,16,253,121,119,127,247,211,43,73,190,186,119,231,139,43,57,62,253,240,211,63,254,248,246,199,128,70,111,125,

View file

@ -1,3 +1,15 @@
TOPIC("bsadditional$en-us")
#include "bsadditional$en-us.tppi"
END_TOPIC
TOPIC("bsdiff$en-us")
#include "bsdiff$en-us.tppi"
END_TOPIC
TOPIC("bspatch$en-us")
#include "bspatch$en-us.tppi"
END_TOPIC
TOPIC("Functions4U$en-us")
#include "Functions4U$en-us.tppi"
END_TOPIC

View file

@ -0,0 +1,4 @@
TITLE("")
COMPRESSED
120,156,133,142,77,75,195,64,16,134,255,202,130,173,180,197,195,124,237,71,118,111,162,40,40,120,240,184,108,211,216,172,37,88,83,72,226,73,252,239,110,218,147,39,231,48,195,48,243,60,188,81,45,22,112,3,87,240,79,249,187,252,222,124,29,167,20,31,77,128,2,225,12,105,83,78,70,163,136,128,144,65,96,18,70,6,98,141,149,54,254,45,31,186,62,197,78,196,133,134,116,248,120,122,169,2,21,154,10,205,22,217,105,198,2,150,134,140,164,137,5,29,85,226,152,45,248,253,169,205,221,148,63,83,60,146,115,103,142,11,71,86,19,90,113,226,144,173,163,130,19,0,129,165,146,131,29,105,223,230,113,159,226,28,82,202,123,101,184,2,4,176,56,199,179,192,90,16,153,138,130,44,33,104,159,251,54,197,239,250,71,197,17,131,186,78,113,164,224,111,199,135,60,61,55,227,116,63,12,167,97,183,218,173,189,138,245,246,117,26,186,254,176,85,151,153,234,184,81,127,63,211,106,61,27,56,44,151,103,149,92,140,48,239,233,23,182,86,91,233,

View file

@ -0,0 +1,57 @@
topic "Functions4U. BSDiff Reference";
[ $$0,0#00000000000000000000000000000000:Default]
[H6;0 $$1,0#05600065144404261032431302351956:begin]
[i448;a25;kKO9;2 $$2,0#37138531426314131252341829483370:codeitem]
[l288;2 $$3,0#27521748481378242620020725143825:desc]
[0 $$4,0#96390100711032703541132217272105:end]
[{_}%EN-US
[s0; [*R+184 Functions4U. Reference]&]
[s0;2 &]
[s0; [* BSDiff functions]&]
[s0;2 &]
[s0; [2 BSDiff functions permit to:]&]
[s0; [2 `- Compare two binary or text files to get a new differences
file (patch)]&]
[s0; [2 `- Create a new file based in an old version and a file with
the differences (patch)]&]
[s0;2 &]
[s0; [2 Patch file size is related with the size of the change in original
file compared with the file full size. Small changes let to get
small patch files too.]&]
[s0;2 &]
[s3;l0; In arithmetical notation it would be: &]
[s0;i150;O0;%- [%%2 BSDiff does:-|][*@3;2 patchfile `= newfile `- oldfile]&]
[s0;i150;O0;%- [%%2 BSPatch does:-|][*@3;2 newfile `= oldfile `+ patchfile]&]
[s0;2 &]
[s0; [2 BSDiff is a BSD licensed binary diff/patch utility written
by Colin Percival (Copyright 2003`-2005 Colin Percival <cperciva`@freebsd.org>),
ported to Win32 by Andreas John <dynacore`@tesla.inka.de>.]&]
[s0;2 &]
[s0; [2 BSDiff/BSPatch functions are a light wrapper to BSDiff utilities.]&]
[s0;2 &]
[ {{10000@1 [s0; [*2 BSDiff functions]]}}&]
[s1;2%- &]
[s2;:BSDiff`(String`,String`,String`):%- [@(0.0.255) bool]_[* BSDiff]([_^String^ String]_[*@3 o
ldfile], [_^String^ String]_[*@3 newfile], [_^String^ String]_[*@3 patchfile])&]
[s3; Takes [%-*@3 oldfile] and [%-*@3 newfile], compares them and put
the differences in [%-*@3 patchfile].so that it is possible to
rebuild [%-*@3 newfile].&]
[s3; In arithmetical notation it would be: &]
[s0;l448;%- [*@3;2 patchfile `= newfile `- oldfile]&]
[s0;l288; [2 Returns true if correct. Error String can be got with
BSGetLastError()]&]
[s4;%- &]
[s1;%- &]
[s2;:BSPatch`(String`,String`,String`):%- [@(0.0.255) bool]_[* BSPatch]([_^String^ String]_
[*@3 oldfile], [_^String^ String]_[*@3 newfile], [_^String^ String]_[*@3 patchfile])&]
[s3; Takes [%-*@3 oldfile] and [%-*@3 patchfile], to rebuild [%-*@3 newfile].&]
[s3; In arithmetical notation it would be: &]
[s0;l448;%- [*@3;2 newfile `= oldfile `+ patchfile]&]
[s0;l288; [2 Returns true if correct. Error String can be got with
BSGetLastError()]&]
[s4; &]
[s1;%- &]
[s2;:BsGetLastError`(`):%- [_^String^ String]_[* BsGetLastError]()&]
[s3; Returns the last BSDiff/BSPatch error message.&]
[s4;%- &]
[s0; ]

View file

@ -0,0 +1,7 @@
TITLE("Functions4U. BSDiff Reference")
COMPRESSED
120,156,205,85,107,111,219,54,20,253,43,23,88,51,56,109,172,138,164,100,43,86,91,120,125,237,137,181,72,86,236,131,160,198,180,116,109,19,145,69,131,164,235,101,89,254,251,46,37,217,142,147,101,91,7,20,152,63,88,180,121,206,125,158,123,149,193,163,71,225,73,248,85,248,15,159,209,107,156,201,117,229,242,236,187,65,26,18,137,121,82,60,160,171,65,204,162,40,10,35,62,96,161,224,145,96,34,228,34,102,167,241,96,52,197,185,170,243,76,69,81,146,74,30,167,151,63,190,59,77,57,177,57,177,197,144,137,36,22,140,136,244,197,4,227,49,23,17,75,248,105,148,8,49,12,71,133,46,81,57,92,230,89,197,147,164,225,9,226,241,97,204,217,48,74,162,132,137,97,194,137,206,195,144,135,67,78,113,136,132,199,163,18,109,145,103,62,200,136,224,167,3,113,26,178,48,28,50,31,222,48,20,113,196,152,224,100,130,15,57,11,227,17,214,101,158,93,95,220,28,189,249,185,255,225,28,50,27,166,144,61,62,123,194,146,8,222,174,235,194,41,93,219,232,67,0,
103,56,67,131,117,129,249,215,185,71,113,104,159,132,134,151,231,175,213,108,6,179,45,254,30,132,111,33,123,12,172,208,44,149,3,167,71,249,30,54,233,195,43,189,92,73,131,224,54,26,166,170,150,230,10,180,1,135,191,57,152,169,10,45,49,96,142,14,36,212,184,129,146,172,182,113,217,230,26,122,43,233,138,197,241,29,155,6,165,195,142,210,192,166,210,98,9,170,6,89,131,174,74,248,132,198,82,88,244,179,36,88,3,217,40,183,0,183,192,3,31,135,230,111,103,248,222,95,180,76,171,126,71,80,22,12,86,228,182,220,91,106,46,244,172,57,23,11,89,207,209,135,160,141,34,165,200,170,37,23,109,254,183,88,205,223,179,117,85,53,252,0,206,151,146,206,45,223,66,133,110,91,18,219,92,172,118,129,248,90,233,224,32,86,145,86,20,238,247,148,168,33,243,75,116,170,32,199,181,118,210,119,5,168,33,27,189,166,122,76,113,212,229,166,88,28,166,239,194,244,168,15,217,209,209,174,147,165,70,59,234,255,145,103,143,199,130,108,55,78,155,64,39,207,125,149,
219,99,223,215,214,31,243,135,108,181,85,187,99,108,199,127,190,229,195,228,201,222,197,195,242,162,154,75,127,134,74,21,88,251,14,119,10,242,45,124,218,22,102,237,84,165,220,21,108,168,0,14,107,152,94,145,228,42,106,195,123,52,133,250,68,213,232,189,210,171,43,234,201,194,1,13,151,152,244,233,59,190,11,122,86,172,218,227,100,60,51,136,83,91,6,218,204,95,28,159,192,74,27,223,116,234,201,175,170,22,220,59,248,166,46,73,129,22,126,208,139,26,158,149,87,181,44,180,193,201,216,161,173,100,160,234,75,25,148,248,34,120,48,177,167,219,66,237,199,199,143,136,164,60,125,148,27,35,87,20,141,119,217,21,162,77,82,161,61,176,9,215,215,204,239,179,49,219,14,58,191,63,187,249,205,141,167,176,148,83,151,252,137,167,163,22,52,233,157,59,163,234,249,228,228,206,243,120,228,27,58,238,133,65,24,240,56,62,134,169,214,85,126,177,219,12,121,47,187,248,216,98,63,66,251,244,183,99,177,147,199,9,60,132,232,180,240,55,136,189,46,142,91,133,195,47,
242,146,180,159,29,245,111,187,104,70,187,251,111,111,180,155,54,235,7,109,217,64,86,107,119,111,234,169,241,29,115,239,44,176,154,112,210,249,153,33,221,173,180,181,106,74,74,165,38,24,156,174,85,117,207,91,208,133,247,57,211,87,249,183,135,175,238,231,140,89,243,198,240,234,57,67,183,54,36,22,103,214,180,105,102,148,173,49,88,184,0,222,24,67,75,181,45,35,20,180,3,167,8,115,237,218,157,243,242,252,91,116,63,73,235,26,84,175,93,118,81,218,201,129,165,183,117,209,200,242,63,9,163,97,254,239,148,177,167,156,124,217,78,254,187,29,247,101,58,121,191,143,246,54,110,210,235,26,247,87,101,133,67,108,222,219,150,118,23,33,205,78,69,215,119,87,23,54,129,46,209,90,57,199,224,64,82,180,138,242,63,1,10,184,11,140,

View file

@ -0,0 +1,4 @@
TITLE("")
COMPRESSED
120,156,133,206,189,74,68,65,12,5,224,87,185,224,218,41,36,39,201,252,182,10,130,160,133,88,13,131,172,123,103,229,226,186,22,187,86,226,187,155,235,11,152,34,77,206,23,78,155,54,27,186,162,11,250,103,202,205,216,111,191,14,231,222,238,66,37,71,188,34,11,126,10,198,170,74,138,192,36,80,97,33,136,113,182,80,94,199,219,114,236,109,81,77,117,11,171,239,247,143,185,194,53,92,75,100,73,38,236,208,23,11,195,32,202,9,89,147,72,164,178,251,156,199,114,30,31,189,29,144,210,159,19,119,136,6,142,154,52,177,196,4,231,32,2,69,120,15,73,176,50,143,211,174,183,181,164,122,60,7,201,196,68,145,215,122,145,196,148,89,224,47,16,193,100,101,28,231,222,190,95,126,46,111,31,174,159,159,166,118,162,58,245,95,90,209,64,106,

View file

@ -5,6 +5,8 @@ topic "News and changes Log";
[s0; [*R+184 Functions4U. News and changes log]&]
[s0;2 &]
[s0;2 &]
[s0; [2 2009/12/28-|Added BSDiff functions to `"diff`" and `"patch`"
binary files]&]
[s0; [2 2009/12/23-|Added RemoveAccents()]&]
[s0; [2 2009/12/12-|LoadFile`_Safe fixed bug... I forgot to bring it
from SysInfo]&]

View file

@ -1,5 +1,5 @@
TITLE("News and changes Log")
COMPRESSED
120,156,133,143,77,75,195,64,16,64,255,202,128,85,180,154,116,191,154,166,237,169,152,22,10,210,67,66,79,203,82,183,201,110,12,164,187,146,221,84,197,246,191,155,28,4,69,197,185,204,229,189,55,12,135,193,0,221,161,11,244,207,204,18,165,101,91,123,193,101,76,231,195,52,234,60,220,121,20,83,140,112,68,216,132,17,68,17,97,152,140,113,28,51,60,25,199,116,26,69,179,92,62,251,202,26,193,223,119,231,203,229,38,216,102,192,29,154,3,31,166,183,56,102,176,106,77,222,3,142,109,67,216,168,23,7,210,20,144,63,73,83,42,7,181,45,197,149,232,5,2,223,55,112,2,4,161,233,8,147,17,161,193,105,81,20,170,128,84,29,236,81,45,242,92,25,239,174,111,196,79,22,147,224,244,96,101,177,170,106,245,184,203,164,86,160,171,215,78,221,183,101,24,134,176,6,109,155,210,122,240,22,246,77,101,74,168,60,232,198,30,32,123,115,107,163,237,47,77,212,53,19,85,43,223,101,18,187,60,254,121,188,7,239,27,37,123,240,203,227,159,164,248,0,9,187,
113,46,
120,156,133,144,81,107,194,48,16,199,191,202,209,185,177,185,89,147,180,214,170,79,110,85,16,134,15,22,159,74,177,105,155,212,66,77,164,137,110,50,247,221,151,14,10,27,116,236,94,142,11,191,255,239,142,68,208,235,161,39,116,131,254,169,105,192,56,61,85,58,142,168,239,204,250,27,207,228,176,201,57,216,193,8,123,196,29,187,4,57,136,184,152,140,176,239,187,120,60,242,157,137,231,77,51,122,212,165,20,113,244,177,251,188,93,172,7,219,16,34,133,102,16,245,55,143,216,119,97,121,18,89,3,40,119,107,195,154,189,41,160,34,135,108,79,69,193,20,84,178,136,239,226,38,64,224,119,135,136,0,65,104,50,196,100,72,252,193,117,158,231,44,135,231,48,40,57,7,222,74,65,75,72,172,220,188,37,214,183,56,177,142,84,103,123,51,165,165,160,245,5,120,89,49,21,119,56,157,214,185,97,7,121,102,243,44,99,66,171,251,135,14,22,147,193,245,85,210,124,105,92,201,46,164,156,25,237,187,137,166,167,194,182,109,88,1,151,117,33,117,115,77,90,151,162,128,
82,3,175,229,1,194,139,90,9,46,59,156,200,56,3,86,49,109,52,129,92,156,255,92,222,128,47,53,163,13,248,227,51,91,50,254,2,63,169,139,203,

View file

@ -29,6 +29,8 @@ topic "General description";
[s0; &]
[s0;i150;O0; [^topic`:`/`/Functions4U`/src`/Functions4U`$en`-us`#FileCat`(const char`*`,const char`*`)^ F
ile Handling]&]
[s0;i150;O0; [^topic`:`/`/Functions4U`/src`/bsdiff`$en`-us^ File binary
comparison (BSDiff)]&]
[s0;i150;O0; [^topic`:`/`/Functions4U`/src`/Functions4U`$en`-us`#Replace`(String`,String`,String`)^ S
tring functions]&]
[s0;i150;O0; [^topic`:`/`/Functions4U`/src`/Functions4U`$en`-us`#Sign`(T`)^ Math

View file

@ -1,8 +1,8 @@
TITLE("General description")
COMPRESSED
120,156,181,84,107,111,219,70,16,252,43,4,228,6,142,77,219,183,123,183,247,32,139,34,128,83,55,1,154,164,176,227,79,130,28,82,212,217,38,170,80,138,72,161,69,139,250,183,119,78,143,38,206,151,62,224,90,144,100,145,156,157,217,217,217,27,115,118,112,160,114,53,82,127,243,87,188,140,183,245,122,62,76,198,115,246,190,108,137,88,149,53,185,242,93,40,31,30,30,78,201,40,95,166,98,132,98,164,140,38,38,92,83,134,29,73,80,65,60,121,165,157,97,113,74,138,101,189,170,63,78,198,181,215,229,209,165,5,138,115,25,105,210,164,200,178,193,83,74,43,54,196,66,222,27,114,226,117,176,182,104,234,229,208,46,186,201,248,149,41,167,9,106,128,212,64,42,231,173,33,224,140,176,118,98,128,55,6,10,53,184,157,117,174,24,218,97,30,39,227,54,73,135,224,243,36,212,228,118,4,129,236,128,52,108,172,209,158,53,121,102,27,180,9,6,202,137,139,118,136,208,57,53,92,214,120,39,152,128,207,136,33,13,83,140,19,141,199,28,190,141,10,196,32,245,74,
4,124,241,215,189,83,83,120,148,124,74,88,11,74,118,146,16,222,120,210,206,179,97,203,16,161,28,122,77,10,164,152,197,190,1,86,51,149,231,47,164,36,224,92,238,70,172,130,98,235,2,248,160,21,237,234,16,72,123,240,25,18,69,186,104,22,51,180,56,101,81,122,67,230,49,8,139,162,27,71,196,18,244,178,246,96,115,164,53,62,197,120,87,244,49,141,98,88,172,38,227,163,23,135,234,84,157,178,200,243,4,15,128,123,109,180,54,54,24,82,26,52,168,97,146,93,86,97,152,36,236,139,105,221,131,115,99,39,165,20,193,112,237,69,131,212,226,3,243,68,87,26,166,112,48,94,107,175,138,102,94,247,253,206,153,228,202,81,106,143,40,39,26,185,100,168,104,54,33,57,162,25,206,178,149,64,176,86,172,81,92,172,226,167,117,187,138,31,99,7,111,91,196,162,220,207,101,151,65,40,219,70,144,115,98,132,80,172,85,201,41,65,10,88,11,92,86,228,13,20,225,133,217,14,187,20,78,201,186,109,36,72,231,164,71,129,141,134,146,96,12,122,71,1,10,68,
164,60,94,232,12,142,108,66,65,187,52,237,232,183,112,147,147,25,57,196,23,51,10,38,209,7,157,156,99,24,207,86,9,38,192,91,56,39,191,249,0,142,19,251,244,222,120,78,146,19,246,0,18,73,4,125,107,152,204,30,189,11,92,215,155,92,147,243,197,219,248,75,255,178,30,226,46,37,71,231,7,219,120,145,205,201,142,84,194,139,15,24,29,153,228,159,54,38,112,208,90,56,136,182,10,62,246,219,69,78,224,180,71,155,53,252,171,136,203,201,97,163,208,171,8,186,223,192,208,185,163,36,133,125,176,201,133,93,145,234,100,222,118,73,7,50,129,18,199,68,46,149,240,216,17,239,173,210,1,54,160,123,37,8,54,142,0,143,17,99,194,140,212,167,51,160,249,185,190,139,213,201,110,57,55,228,41,117,162,197,167,172,2,9,209,160,71,157,160,148,197,21,239,177,60,197,93,189,220,133,142,85,206,10,201,193,89,35,216,62,176,32,114,42,164,115,3,71,0,92,199,177,19,100,155,186,234,164,139,253,16,103,24,184,168,77,171,76,57,19,252,66,230,68,188,49,
22,74,193,234,210,49,148,198,134,77,21,167,139,159,106,108,199,239,31,254,248,230,251,183,39,215,87,217,184,231,50,27,31,35,73,217,197,186,107,210,137,212,155,235,201,179,201,184,87,101,246,166,237,155,56,159,215,93,92,172,251,236,118,255,64,54,44,178,105,204,214,125,156,101,109,151,93,87,199,213,241,233,14,178,251,122,61,224,78,51,95,99,255,191,192,221,46,86,197,163,231,90,108,123,249,14,63,199,55,195,98,217,54,85,81,157,85,103,95,40,169,206,250,85,243,248,202,65,236,170,147,117,95,141,46,218,121,60,175,135,234,176,193,141,33,107,238,235,85,117,84,229,143,126,61,191,201,210,99,217,171,186,155,97,186,119,147,39,224,189,140,203,121,221,196,234,240,106,88,161,100,149,127,245,13,206,237,127,159,59,127,10,218,171,246,174,171,14,223,167,242,111,234,225,254,127,43,126,181,140,77,91,207,49,172,249,44,174,158,164,250,69,59,188,238,46,112,62,197,253,176,174,218,223,98,245,161,250,246,125,245,93,245,108,63,179,199,23,33,229,135,85,189,188,111,155,
36,230,171,102,247,57,251,247,106,110,178,203,120,27,87,177,107,226,174,214,127,40,241,79,216,103,11,160,207,239,235,238,46,246,63,46,238,62,131,211,137,151,33,143,41,163,233,102,134,187,251,182,38,127,2,59,138,111,177,
120,156,181,84,107,111,219,70,16,252,43,4,228,6,142,77,59,183,123,183,247,32,139,34,168,19,55,1,154,164,136,147,79,130,18,82,212,217,38,170,80,170,72,161,47,52,191,189,115,18,213,196,65,129,54,69,106,65,146,69,114,118,102,103,103,111,202,217,209,145,202,213,68,253,195,95,241,40,94,215,219,229,48,155,46,217,251,178,37,98,85,214,228,202,23,161,124,255,254,253,57,25,229,203,84,140,80,140,148,209,196,132,107,202,176,35,9,42,136,39,175,180,51,44,78,73,177,174,55,245,187,217,180,246,186,60,121,105,129,226,92,38,154,52,41,178,108,240,148,210,138,13,177,144,247,134,156,120,29,172,45,154,122,61,180,171,110,54,125,98,202,121,130,26,32,53,144,202,121,107,8,56,35,172,157,24,224,141,129,66,13,110,103,157,43,134,118,88,198,217,180,77,210,33,248,34,9,53,185,157,64,32,59,32,13,27,107,180,103,77,158,217,6,109,130,129,114,226,162,29,34,116,206,13,151,53,222,9,38,224,51,98,72,195,20,227,68,227,49,135,111,163,2,49,72,189,
18,1,95,252,229,224,212,28,30,37,159,18,214,130,146,157,36,132,55,158,180,243,108,216,50,68,40,135,94,147,2,41,22,177,111,128,213,76,229,197,67,41,9,56,151,187,9,171,160,216,186,0,62,104,69,187,58,4,210,30,124,134,68,145,46,154,213,2,45,206,89,148,222,145,121,12,194,162,232,206,17,177,4,189,172,61,216,28,105,141,79,49,222,21,125,76,163,24,86,155,217,244,228,225,177,58,87,231,44,114,63,193,3,224,94,27,173,141,13,134,148,6,13,106,152,100,151,85,24,38,9,251,98,94,247,224,220,217,73,41,69,48,92,123,209,32,181,248,192,60,209,149,134,41,28,140,215,218,171,162,89,214,125,63,58,147,92,57,73,237,17,229,68,19,151,12,21,205,38,36,71,52,195,89,182,18,8,214,138,53,138,139,77,252,105,219,110,226,187,216,193,219,22,177,40,15,115,25,51,8,101,251,8,114,78,140,16,138,181,42,57,37,72,1,107,129,203,138,188,129,34,188,48,219,97,76,225,156,172,219,71,130,116,78,122,18,216,104,40,9,198,160,119,20,160,64,
68,202,227,133,206,224,200,46,20,52,166,105,164,223,195,77,78,102,226,16,95,204,40,152,68,31,116,114,142,97,60,91,37,152,0,239,225,156,252,230,35,56,78,236,211,123,231,57,73,78,216,3,72,36,17,244,173,97,50,123,244,46,112,93,239,114,77,206,23,207,227,207,253,163,122,136,99,74,78,46,142,246,241,34,155,147,157,168,132,23,31,48,58,50,201,63,109,76,224,160,181,112,16,109,21,124,236,247,139,156,192,105,143,118,107,248,87,17,151,147,195,70,161,87,17,116,191,131,161,115,71,73,10,251,96,147,11,99,145,234,108,217,118,73,7,50,129,18,167,68,46,149,240,216,17,239,173,210,1,54,160,123,37,8,54,142,0,143,17,99,194,140,212,167,51,160,249,177,190,137,213,217,184,156,59,242,148,58,209,226,83,86,129,132,104,208,163,78,80,202,226,138,247,88,158,226,166,94,143,161,99,149,179,66,114,112,214,8,182,15,44,136,156,10,233,220,192,17,0,215,113,236,4,217,167,174,58,235,98,63,196,5,6,46,106,215,42,83,206,4,191,144,57,17,111,140,
133,82,176,186,116,12,165,177,97,83,197,233,226,135,26,219,241,251,219,63,190,122,252,252,236,245,85,54,237,185,204,166,167,72,82,118,185,237,154,116,34,245,230,245,236,222,108,218,171,50,123,214,246,77,92,46,235,46,174,182,125,118,125,120,32,27,86,217,60,102,219,62,46,178,182,203,94,87,167,213,233,249,8,25,191,158,14,184,211,44,183,216,255,143,112,215,171,77,113,231,185,22,219,94,190,192,207,233,155,97,181,110,155,170,168,30,84,15,62,82,82,61,232,55,205,221,43,71,177,171,206,182,125,53,185,108,151,241,162,30,170,227,6,55,134,172,185,173,55,213,73,149,223,249,117,255,77,150,30,203,158,212,221,2,211,189,153,125,30,239,188,95,180,215,215,7,202,177,214,188,237,234,205,175,89,179,122,135,157,107,251,85,151,29,127,123,245,8,207,221,255,204,234,127,219,213,203,184,94,214,77,172,142,175,134,13,4,87,249,39,223,232,104,255,223,7,95,191,4,237,85,123,211,85,199,175,82,249,103,245,112,251,191,21,191,90,199,166,173,151,136,194,114,17,55,95,
164,250,101,59,60,237,46,113,250,197,67,20,174,218,223,98,245,182,250,250,85,245,77,117,239,144,136,187,23,33,229,187,77,189,190,109,155,36,230,147,102,15,41,254,124,53,111,178,151,241,58,110,98,215,196,177,214,127,40,241,111,216,23,43,160,47,110,235,238,38,246,223,175,110,62,128,211,121,154,33,237,105,3,210,205,12,119,15,109,205,254,4,120,34,143,205,