summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Endsley <mendsley@gmail.com>2015-03-26 09:42:25 -0700
committerMatthew Endsley <mendsley@gmail.com>2015-03-26 09:42:25 -0700
commit1edf9f656850c0c64dae260960fabd8249ea9c60 (patch)
treef3f0a71687a6d37891003bf6a1e99f63e4ce293a
parent95f126c7eec42de0dec71b93362b9ea05033c62d (diff)
parentd1204147fe5fecb7da423f2562b29d01fb60b521 (diff)
downloadbsdiff-1edf9f656850c0c64dae260960fabd8249ea9c60.tar.gz
Merge pull request #6 from giuseppe/master
-rw-r--r--.gitignore11
-rw-r--r--Makefile-bsdiff.am32
-rw-r--r--Makefile.am11
-rw-r--r--README.md5
-rwxr-xr-xautogen.sh6
-rw-r--r--bsdiff.c18
-rw-r--r--bsdiff.h45
-rw-r--r--bspatch.c13
-rw-r--r--bspatch.h42
-rw-r--r--configure.ac30
10 files changed, 179 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e13492
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+.deps/*
+.libs/*
+*.lo
+*.o
+.dirstamp
+Makefile-bsdiff.am.inc
+AUTHORS
+NEWS
+README
+ChangeLog
+COPYING
diff --git a/Makefile-bsdiff.am b/Makefile-bsdiff.am
new file mode 100644
index 0000000..1d810ed
--- /dev/null
+++ b/Makefile-bsdiff.am
@@ -0,0 +1,32 @@
+# Copyright (C) 2015 Giuseppe Scrivano <gscrivan@redhat.com>
+#
+# 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.
+#
+
+EXTRA_DIST += $(libbsdiff_srcpath)/bsdiff.h $(libbsdiff_srcpath)/bspatch.h $(libbsdiff_srcpath)/LICENSE $(libbsdiff_srcpath)/README.md
+
+libbsdiff_la_SOURCES = \
+ $(libbsdiff_srcpath)/bsdiff.c \
+ $(libbsdiff_srcpath)/bspatch.c \
+ $(NULL)
+
+libbsdiff_la_CFLAGS = $(AM_CFLAGS)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..abd3d7e
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,11 @@
+bin_PROGRAMS = bsdiff bspatch
+
+bsdiff_SOURCES = bsdiff.c
+
+bspatch_SOURCES = bspatch.c
+
+bsdiff_CFLAGS = -DBSDIFF_EXECUTABLE
+bspatch_CFLAGS = -DBSPATCH_EXECUTABLE
+
+EXTRA_DIST = bsdiff.h bspatch.h
+
diff --git a/README.md b/README.md
index 427ab23..a4b1d23 100644
--- a/README.md
+++ b/README.md
@@ -33,11 +33,6 @@ The overarching goal was to modify the original bsdiff/bspatch code from Colin
and eliminate external dependencies and provide a simple interface to the core
functionality.
-You can define `BSDIFF_HEADER_ONLY` or `BSPATCH_HEADER_ONLY` to only include
-the header parts of the file. If including a `.c` file makes you feel really
-dirty you can copy paste the header portion at the top of the file into your own
-`.h` file.
-
I've exposed relevant functions via the `_stream` classes. The only external
dependency not exposed is `memcmp` in `bsdiff`.
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..ce934ac
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+touch AUTHORS NEWS README ChangeLog
+cp LICENSE COPYING
+
+autoreconf -fis
diff --git a/bsdiff.c b/bsdiff.c
index 3857c01..628f1c1 100644
--- a/bsdiff.c
+++ b/bsdiff.c
@@ -25,21 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stddef.h>
-#include <stdint.h>
-
-struct bsdiff_stream
-{
- void* opaque;
-
- void* (*malloc)(size_t size);
- void (*free)(void* ptr);
- int (*write)(struct bsdiff_stream* stream, const void* buffer, int size);
-};
-
-int bsdiff(const uint8_t* old, int64_t oldsize, const uint8_t* new, int64_t newsize, struct bsdiff_stream* stream);
-
-#if !defined(BSDIFF_HEADER_ONLY)
+#include "bsdiff.h"
#include <limits.h>
#include <string.h>
@@ -457,5 +443,3 @@ int main(int argc,char *argv[])
}
#endif
-
-#endif
diff --git a/bsdiff.h b/bsdiff.h
new file mode 100644
index 0000000..b37da5f
--- /dev/null
+++ b/bsdiff.h
@@ -0,0 +1,45 @@
+/*-
+ * Copyright 2003-2005 Colin Percival
+ * Copyright 2012 Matthew Endsley
+ * 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.
+ */
+
+#ifndef BSDIFF_H
+# define BSDIFF_H
+
+# include <stddef.h>
+# include <stdint.h>
+
+struct bsdiff_stream
+{
+ void* opaque;
+
+ void* (*malloc)(size_t size);
+ void (*free)(void* ptr);
+ int (*write)(struct bsdiff_stream* stream, const void* buffer, int size);
+};
+
+int bsdiff(const uint8_t* old, int64_t oldsize, const uint8_t* new, int64_t newsize, struct bsdiff_stream* stream);
+
+#endif
diff --git a/bspatch.c b/bspatch.c
index b850db7..881d7e3 100644
--- a/bspatch.c
+++ b/bspatch.c
@@ -25,17 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdint.h>
-
-struct bspatch_stream
-{
- void* opaque;
- int (*read)(const struct bspatch_stream* stream, void* buffer, int length);
-};
-
-int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, struct bspatch_stream* stream);
-
-#if !defined(BSPATCH_HEADER_ONLY)
+#include "bspatch.h"
static int64_t offtin(uint8_t *buf)
{
@@ -195,4 +185,3 @@ int main(int argc,char * argv[])
}
#endif
-#endif
diff --git a/bspatch.h b/bspatch.h
new file mode 100644
index 0000000..099c36e
--- /dev/null
+++ b/bspatch.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright 2003-2005 Colin Percival
+ * Copyright 2012 Matthew Endsley
+ * 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.
+ */
+
+#ifndef BSPATCH_H
+# define BSPATCH_H
+
+# include <stdint.h>
+
+struct bspatch_stream
+{
+ void* opaque;
+ int (*read)(const struct bspatch_stream* stream, void* buffer, int length);
+};
+
+int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, struct bspatch_stream* stream);
+
+#endif
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..69de743
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,30 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([bsdiff], [0.1])
+AC_CONFIG_SRCDIR([bsdiff.c])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([1.9])
+
+# Checks for programs.
+AC_PROG_CC
+
+# Checks for libraries.
+# FIXME: Replace `main' with a function in `-lbz2':
+AC_CHECK_LIB([bz2], [BZ2_bzReadOpen])
+
+AC_CHECK_HEADERS([fcntl.h limits.h stddef.h stdint.h stdlib.h string.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_INT64_T
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([memset])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT