|
version 1.1.1.1.2.2, 2011/05/09 14:35:56
|
version 1.3.2.1, 2012/11/13 10:00:30
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 54 static int sync_Errno;
|
Line 54 static int sync_Errno;
|
| static char sync_Error[STRSIZ]; |
static char sync_Error[STRSIZ]; |
| |
|
| |
|
| static inline int func_comp(sync_tag_t const *t1, sync_tag_t const *t2) | static inline int |
| | func_comp(sync_tag_t const *t1, sync_tag_t const *t2) |
| { |
{ |
| return t1->st_tag - t2->st_tag; |
return t1->st_tag - t2->st_tag; |
| } |
} |
| |
|
| // | /* |
| // Error maintenance functions ... | * Error maintenance functions ... |
| // | */ |
| |
|
| // sync_GetErrno() Get error code of last operation |
// sync_GetErrno() Get error code of last operation |
| inline int sync_GetErrno() | inline int |
| | sync_GetErrno() |
| { |
{ |
| return sync_Errno; |
return sync_Errno; |
| } |
} |
| |
|
| // sync_GetError() Get error text of last operation |
// sync_GetError() Get error text of last operation |
| inline const char *sync_GetError() | inline const char * |
| | sync_GetError() |
| { |
{ |
| return sync_Error; |
return sync_Error; |
| } |
} |
| |
|
| // sync_SetErr() Set error to variables for internal use!!! |
// sync_SetErr() Set error to variables for internal use!!! |
| inline void syncSetErr(int eno, char *estr, ...) | inline void |
| | syncSetErr(int eno, char *estr, ...) |
| { |
{ |
| va_list lst; |
va_list lst; |
| |
|
|
Line 87 inline void syncSetErr(int eno, char *estr, ...)
|
Line 91 inline void syncSetErr(int eno, char *estr, ...)
|
| va_end(lst); |
va_end(lst); |
| } |
} |
| |
|
| // ---------------------------------------------------------- | /* ---------------------------------------------------------- */ |
| |
|
| /* |
/* |
| * syncSignature() Calculate and create signature for diff | * syncSignature() - Calculate and create signature for diff |
| * @csInput = Input patched file name for calculating check sums | * |
| | * @csInput = Input file name for calculating check sums |
| * @csSig = Output Signature file name |
* @csSig = Output Signature file name |
| * @compress = 2 compress signatures output, 0 not compressed |
* @compress = 2 compress signatures output, 0 not compressed |
| * return: -1 error, 0 ok |
* return: -1 error, 0 ok |
| */ |
*/ |
| int syncSignature(const char *csInput, const char *csSig, int compress) | int |
| | syncSignature(const char *csInput, const char *csSig, int compress) |
| { |
{ |
| int inf, outf, f, ret; |
int inf, outf, f, ret; |
| u_char buf[CHUNK_MAX]; |
u_char buf[CHUNK_MAX]; |
|
Line 105 int syncSignature(const char *csInput, const char *csS
|
Line 111 int syncSignature(const char *csInput, const char *csS
|
| sync_chunk_t sc; |
sync_chunk_t sc; |
| char szTemp[MAXPATHLEN]; |
char szTemp[MAXPATHLEN]; |
| |
|
| inf = syncOpen(csInput, O_RDONLY); | inf = syncOpen(csInput, O_RDONLY, 0); |
| if (inf == -1) |
if (inf == -1) |
| return inf; |
return inf; |
| if (compress & 2) |
if (compress & 2) |
| f = syncTemp(szTemp, MAXPATHLEN); |
f = syncTemp(szTemp, MAXPATHLEN); |
| else |
else |
| f = syncOpen(csSig, O_WRONLY); | f = syncOpen(csSig, O_WRONLY, 0); |
| if (f == -1) { |
if (f == -1) { |
| syncClose(inf); |
syncClose(inf); |
| return f; |
return f; |
|
Line 138 int syncSignature(const char *csInput, const char *csS
|
Line 144 int syncSignature(const char *csInput, const char *csS
|
| |
|
| // build compressed delta file |
// build compressed delta file |
| if (compress & 2) { |
if (compress & 2) { |
| outf = syncOpen(csSig, O_WRONLY); | outf = syncOpen(csSig, O_WRONLY, 0); |
| if (outf == -1) { |
if (outf == -1) { |
| ret = outf; |
ret = outf; |
| goto end; |
goto end; |
|
Line 168 end:
|
Line 174 end:
|
| * @compress = 3 everything compress, 2 compressed signatures, 1 compress delta output, 0 not compressed |
* @compress = 3 everything compress, 2 compressed signatures, 1 compress delta output, 0 not compressed |
| * return: -1 error, 0 ok |
* return: -1 error, 0 ok |
| */ |
*/ |
| int syncDelta(const char *csInput, const char *csSig, const char *csDelta, int compress) | int |
| | syncDelta(const char *csInput, const char *csSig, const char *csDelta, int compress) |
| { |
{ |
| int inf, outf, f, sigf, ret, cnt; |
int inf, outf, f, sigf, ret, cnt; |
| size_t blk; |
size_t blk; |
|
Line 184 int syncDelta(const char *csInput, const char *csSig,
|
Line 191 int syncDelta(const char *csInput, const char *csSig,
|
| /* load signatures */ |
/* load signatures */ |
| |
|
| if (compress & 2) { |
if (compress & 2) { |
| f = syncOpen(csSig, O_RDONLY); | f = syncOpen(csSig, O_RDONLY, 0); |
| if (-1 == f) |
if (-1 == f) |
| return f; |
return f; |
| sigf = syncTemp(szTemp, MAXPATHLEN); |
sigf = syncTemp(szTemp, MAXPATHLEN); |
|
Line 201 int syncDelta(const char *csInput, const char *csSig,
|
Line 208 int syncDelta(const char *csInput, const char *csSig,
|
| } else |
} else |
| syncClose(f); |
syncClose(f); |
| } else { |
} else { |
| sigf = syncOpen(csSig, O_RDONLY); | sigf = syncOpen(csSig, O_RDONLY, 0); |
| if (-1 == sigf) |
if (-1 == sigf) |
| return sigf; |
return sigf; |
| } |
} |
|
Line 268 int syncDelta(const char *csInput, const char *csSig,
|
Line 275 int syncDelta(const char *csInput, const char *csSig,
|
| |
|
| /* build delta patch */ |
/* build delta patch */ |
| |
|
| inf = syncOpen(csInput, O_RDONLY); | inf = syncOpen(csInput, O_RDONLY, 0); |
| if (inf == -1) { |
if (inf == -1) { |
| free(tag_table); |
free(tag_table); |
| munmap(chunks, sb.st_size); |
munmap(chunks, sb.st_size); |
|
Line 277 int syncDelta(const char *csInput, const char *csSig,
|
Line 284 int syncDelta(const char *csInput, const char *csSig,
|
| if (compress & 1) |
if (compress & 1) |
| f = syncTemp(szTemp, MAXPATHLEN); |
f = syncTemp(szTemp, MAXPATHLEN); |
| else |
else |
| f = syncOpen(csDelta, O_WRONLY); | f = syncOpen(csDelta, O_WRONLY, 0); |
| if (f == -1) { |
if (f == -1) { |
| syncClose(inf); |
syncClose(inf); |
| free(tag_table); |
free(tag_table); |
|
Line 388 int syncDelta(const char *csInput, const char *csSig,
|
Line 395 int syncDelta(const char *csInput, const char *csSig,
|
| |
|
| // build compressed delta file |
// build compressed delta file |
| if (compress & 1) { |
if (compress & 1) { |
| outf = syncOpen(csDelta, O_WRONLY); | outf = syncOpen(csDelta, O_WRONLY, 0); |
| if (outf == -1) { |
if (outf == -1) { |
| ret = outf; |
ret = outf; |
| goto end; |
goto end; |
|
Line 421 end:
|
Line 428 end:
|
| * @compress = 1 compress delta input, 0 not compressed |
* @compress = 1 compress delta input, 0 not compressed |
| * return: -1 error, 0 ok, create delta patch, 1 ok, no differences and not create patch |
* return: -1 error, 0 ok, create delta patch, 1 ok, no differences and not create patch |
| */ |
*/ |
| int syncPatch(const char *csInput, const char *csDelta, const char *csPatch, int compress) | int |
| | syncPatch(const char *csInput, const char *csDelta, const char *csPatch, int compress) |
| { |
{ |
| int inf, outf, f, d, ret, readlen; |
int inf, outf, f, d, ret, readlen; |
| char szTemp[MAXPATHLEN]; |
char szTemp[MAXPATHLEN]; |
|
Line 434 int syncPatch(const char *csInput, const char *csDelta
|
Line 442 int syncPatch(const char *csInput, const char *csDelta
|
| sync_chunk_t sc, *suffix; |
sync_chunk_t sc, *suffix; |
| |
|
| if (compress & 1) { |
if (compress & 1) { |
| f = syncOpen(csDelta, O_RDONLY); | f = syncOpen(csDelta, O_RDONLY, 0); |
| if (f == -1) |
if (f == -1) |
| return f; |
return f; |
| d = syncTemp(szTemp, MAXPATHLEN); |
d = syncTemp(szTemp, MAXPATHLEN); |
|
Line 451 int syncPatch(const char *csInput, const char *csDelta
|
Line 459 int syncPatch(const char *csInput, const char *csDelta
|
| } else |
} else |
| syncClose(f); |
syncClose(f); |
| } else { |
} else { |
| d = syncOpen(csDelta, O_RDONLY); | d = syncOpen(csDelta, O_RDONLY, 0); |
| if (d == -1) |
if (d == -1) |
| return d; |
return d; |
| } |
} |
|
Line 482 int syncPatch(const char *csInput, const char *csDelta
|
Line 490 int syncPatch(const char *csInput, const char *csDelta
|
| return -1; |
return -1; |
| } |
} |
| |
|
| inf = syncOpen(csInput, O_RDONLY); | inf = syncOpen(csInput, O_RDONLY, 0); |
| if (inf == -1) { |
if (inf == -1) { |
| if (pieces) |
if (pieces) |
| free(pieces); |
free(pieces); |
| munmap(delta, sb.st_size); |
munmap(delta, sb.st_size); |
| return inf; |
return inf; |
| } |
} |
| outf = syncOpen(csPatch, O_WRONLY); | outf = syncOpen(csPatch, O_WRONLY, 0); |
| if (outf == -1) { |
if (outf == -1) { |
| syncClose(inf); |
syncClose(inf); |
| if (pieces) |
if (pieces) |