summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2015-02-11 15:14:25 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2015-03-26 09:34:26 +0100
commit119890b3a68746f8733676e3f544ef90e1c165c3 (patch)
treed0ee6c2f17b849da85535b75a88551056c559bc4
parent95f126c7eec42de0dec71b93362b9ea05033c62d (diff)
downloadbsdiff-119890b3a68746f8733676e3f544ef90e1c165c3.tar.gz
build: split .c files into .c and .h
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--bsdiff.c21
-rw-r--r--bsdiff.h45
-rw-r--r--bspatch.c13
-rw-r--r--bspatch.h42
4 files changed, 89 insertions, 32 deletions
diff --git a/bsdiff.c b/bsdiff.c
index 3857c01..5be4476 100644
--- a/bsdiff.c
+++ b/bsdiff.c
@@ -25,24 +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 <limits.h>
-#include <string.h>
+#include "bsdiff.h"
#define MIN(x,y) (((x)<(y)) ? (x) : (y))
@@ -457,5 +440,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
+