int (*finish)(struct bsdiff_compressor* compressor);
};
-#if defined(__linux__)
-#include <err.h>
-#else
-static int err(int eval, const char* fmt, ...)
-{
- const char* errortext;
- char* strp;
- va_list args;
-
- errortext = strerror(errno);
- if (fmt != NULL || strcmp(fmt,"") != 0) {
- strp = (char*)malloc(1024 * sizeof(char));
- va_start(args, fmt);
- vsnprintf(strp, 1023, fmt, args);
- va_end(args);
- fprintf(stderr, "%s: %s\b", strp, errortext);
- free(strp);
- } else {
- fprintf(stderr, "%s\n", errortext);
- }
-
- exit(eval);
- return 0;
-}
-
-static int errx(int eval, const char* fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
-
- exit(eval);
- return 0;
-}
-#endif
-
#define MIN(x,y) (((x)<(y)) ? (x) : (y))
static void split(int64_t *I,int64_t *V,int64_t start,int64_t len,int64_t h)
uint8_t buf[8 * 3];
if(((I=malloc((oldsize+1)*sizeof(int64_t)))==NULL) ||
- ((V=malloc((oldsize+1)*sizeof(int64_t)))==NULL)) err(1,NULL);
+ ((V=malloc((oldsize+1)*sizeof(int64_t)))==NULL)) return -1;
qsufsort(I,V,old,oldsize);
free(V);
if(((db=malloc(newsize+1))==NULL) ||
- ((eb=malloc(newsize+1))==NULL)) err(1,NULL);
+ ((eb=malloc(newsize+1))==NULL)) return -1;
dblen=0;
eblen=0;
filelen=0;
compresslen = compressor->write(compressor, buf, sizeof(buf));
if (compresslen == -1)
- errx(1, "compressor->write");
+ return -1;
filelen += compresslen;
lastscan=scan-lenb;
};
compresslen = compressor->finish(compressor);
if (compresslen == -1)
- errx(1, "compressor->finish");
+ return -1;
filelen += compresslen;
/* Compute size of compressed ctrl data */
/* Write compressed diff data */
compresslen = compressor->write(compressor, db, dblen);
if (compresslen == -1)
- errx(1, "compressor->write");
+ return -1;
filelen += compresslen;
compresslen = compressor->finish(compressor);
if (compresslen == -1)
- errx(1, "compressor->finish");
+ return -1;
filelen += compresslen;
/* Compute size of compressed diff data */
/* Write compressed extra data */
compresslen = compressor->write(compressor, eb, eblen);
if (compresslen == -1)
- errx(1, "compressor->write");
+ return -1;
compresslen = compressor->finish(compressor);
if (compresslen == -1)
- errx(1, "compressor->finish");
+ return -1;
/* Free the memory we used */
free(db);
#include <sys/types.h>
#include <bzlib.h>
+#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>