summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--AUTHORS6
-rw-r--r--Makefile.am31
-rw-r--r--Makefile.pre-autotools (renamed from Makefile)0
-rw-r--r--NEWS0
-rw-r--r--README0
-rw-r--r--configure.ac132
-rw-r--r--libtbd_io.h42
-rw-r--r--tbdiff-create/Makefile.am38
-rw-r--r--tbdiff-create/main.c (renamed from tbdiff_create.c)5
-rw-r--r--tbdiff-deploy/Makefile.am38
-rw-r--r--tbdiff-deploy/main.c (renamed from tbdiff_deploy.c)6
-rw-r--r--tbdiff/Makefile.am60
-rw-r--r--tbdiff/tbdiff-1.pc.in13
-rw-r--r--tbdiff/tbdiff-apply.c (renamed from libtbd_apply.c)12
-rw-r--r--tbdiff/tbdiff-common.h (renamed from tbdiff.h)14
-rw-r--r--tbdiff/tbdiff-create.c (renamed from libtbd_create.c)13
-rw-r--r--tbdiff/tbdiff-io.c (renamed from libtbd_io.c)19
-rw-r--r--tbdiff/tbdiff-io.h63
-rw-r--r--tbdiff/tbdiff-private.h (renamed from tbdiff-private.h)8
-rw-r--r--tbdiff/tbdiff-stat.c (renamed from libtbd_stat.c)6
-rw-r--r--tbdiff/tbdiff-stat.h (renamed from libtbd_stat.h)12
-rw-r--r--tbdiff/tbdiff-xattrs.c (renamed from libtbd_xattrs.c)7
-rw-r--r--tbdiff/tbdiff-xattrs.h (renamed from libtbd_xattrs.h)12
-rw-r--r--tbdiff/tbdiff.h31
-rw-r--r--tests/Makefile.am22
-rwxr-xr-xtests/run_tests.sh2
27 files changed, 509 insertions, 87 deletions
diff --git a/.gitignore b/.gitignore
index acb9c63..a2f5be1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
-tbdiff-create
-tbdiff-deploy
+tbdiff-create/tbdiff-create
+tbdiff-deploy/tbdiff-deploy
*.o
*.log
*.d
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..521e446
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,6 @@
+Alberto Ruiz <alberto.ruiz@codethink.co.uk>
+Ben Brewer <ben.brewer@codethink.co.uk>
+Daniel Silverstone <daniel.silverstone@codethink.co.uk>
+Danny Abukalam <danny.abukalam@codethink.co.uk>
+Jannis Pohlmann <jannis.pohlmann@codethink.co.uk>
+Richard Maw <richard.maw@codethink.co.uk>
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..2560896
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,31 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2011-2012 Codethink Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+SUBDIRS = \
+ tbdiff \
+ tbdiff-create \
+ tbdiff-deploy \
+ tests
+
+.PHONY: ChangeLog
+
+ChangeLog: Makefile
+ (GIT_DIR=$(top_srcdir)/.git git log > .changelog.tmp \
+ && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) \
+ || (touch ChangeLog; echo 'Git directory not found: installing possibly empty changelog.' >&2)
+
+dist-hook: ChangeLog
diff --git a/Makefile b/Makefile.pre-autotools
index da4a3c1..da4a3c1 100644
--- a/Makefile
+++ b/Makefile.pre-autotools
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..8c68def
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,132 @@
+# vi:set et ai sw=2 sts=2 ts=2: */
+# -
+# Copyright (c) 2011-2012 Codethink Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+dnl ***************************
+dnl *** Version information ***
+dnl ***************************
+m4_define([tbdiff_verinfo], [0:0:0])
+m4_define([tbdiff_version_api_major], [1])
+m4_define([tbdiff_version_major], [0])
+m4_define([tbdiff_version_minor], [0])
+m4_define([tbdiff_version_micro], [0])
+m4_define([tbdiff_version], [tbdiff_version_major().tbdiff_version_minor().tbdiff_version_micro()])
+
+dnl ************************************
+dnl *** Minimum debugging by default ***
+dnl ************************************
+m4_define([tbdiff_debug_default], [minimum])
+
+dnl ***************************
+dnl *** Initialize autoconf ***
+dnl ***************************
+AC_COPYRIGHT([Copyright (c) 2011-2012 Codethink Ltd])
+AC_INIT([tbdiff], [tbdiff_version], [baserock-dev@baserock.org])
+AC_PREREQ([2.50])
+AC_CANONICAL_TARGET()
+
+dnl ***************************
+dnl *** Initialize automake ***
+dnl ***************************
+AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
+AC_CONFIG_MACRO_DIR([m4])
+AC_SUBST([ACLOCAL_AMFLAGS], ["$ACLOCAL_FLAGS -I m4"])
+AM_CONFIG_HEADER([config.h])
+AM_MAINTAINER_MODE()
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+dnl **************************
+dnl *** Libtool versioning ***
+dnl **************************
+TBDIFF_VERINFO=tbdiff_verinfo()
+AC_SUBST([TBDIFF_VERINFO])
+
+dnl ****************************
+dnl *** Subst tbdiff version ***
+dnl ****************************
+TBDIFF_VERSION_MAJOR=tbdiff_version_major()
+TBDIFF_VERSION_MINOR=tbdiff_version_minor()
+TBDIFF_VERSION_MICRO=tbdiff_version_micro()
+TBDIFF_VERSION_API_MAJOR=tbdiff_version_api_major()
+TBDIFF_VERSION_API=$TBDIFF_VERSION_API_MAJOR
+AC_SUBST([TBDIFF_VERSION_MAJOR])
+AC_SUBST([TBDIFF_VERSION_MINOR])
+AC_SUBST([TBDIFF_VERSION_MICRO])
+AC_SUBST([TBDIFF_VERSION_API_MAJOR])
+AC_SUBST([TBDIFF_VERSION_API])
+
+dnl *******************************
+dnl *** Check for UNIX variants ***
+dnl *******************************
+AC_AIX()
+AC_ISC_POSIX()
+AC_MINIX()
+
+dnl ********************************
+dnl *** Check for basic programs ***
+dnl ********************************
+AM_PROG_AS()
+AC_PROG_CC()
+AM_PROG_CC_C_O()
+AC_PROG_INSTALL()
+
+dnl ***********************
+dnl *** Prepare libtool ***
+dnl ***********************
+LT_PREREQ([2.2.6])
+LT_INIT([disable-static])
+
+dnl ***************************************
+dnl *** Check for standard header files ***
+dnl ***************************************
+AC_HEADER_STDC()
+AC_CHECK_HEADERS([assert.h attr/xattr.h dirent.h endian.h errno.h fcntl.h \
+ inttypes.h stdbool.h stddef.h stdint.h stdio.h stdlib.h \
+ string.h sys/stat.h sys/time.h sys/types.h time.h unistd.h \
+ utime.h])
+
+dnl ************************************
+dnl *** Check for standard functions ***
+dnl ************************************
+dnl AC_CHECK_FUNCS([])
+
+dnl ************************************
+dnl *** Check for required libraries ***
+dnl ************************************
+dnl AC_CHECK_LIBS([])
+
+dnl ***********************************
+dnl *** Check for required packages ***
+dnl ***********************************
+dnl PKG_CHECK_MODULES([...], [...])
+
+AC_OUTPUT([
+Makefile
+tbdiff/Makefile
+tbdiff/tbdiff-1.pc
+tbdiff-create/Makefile
+tbdiff-deploy/Makefile
+tests/Makefile
+])
+
+dnl ***************************
+dnl *** Print configuration ***
+dnl ***************************
+echo
+echo "Build Configuration:"
+echo
+echo " * Debug: $enable_debug"
+echo
diff --git a/libtbd_io.h b/libtbd_io.h
deleted file mode 100644
index 242dc35..0000000
--- a/libtbd_io.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __LIBTBD_IO_H__
-#define __LIBTBD_IO_H__
-
-
-#include <endian.h>
-#include <unistd.h>
-#include <assert.h>
-#include "libtbd_stat.h"
-
-size_t tbd_write_uint16_t (uint16_t value, FILE* stream);
-
-size_t tbd_write_uint32_t (uint32_t value, FILE* stream);
-
-size_t tbd_write_uint64_t (uint64_t value, FILE* stream);
-
-size_t tbd_write_time_t (time_t value, FILE* stream);
-
-size_t tbd_write_mode_t (mode_t value, FILE* stream);
-
-size_t tbd_write_uid_t (uid_t value, FILE* stream);
-
-size_t tbd_write_gid_t (gid_t value, FILE* stream);
-
-size_t tbd_write_size_t (size_t value, FILE* stream);
-
-size_t tbd_read_uint16_t (uint16_t *value, FILE* stream);
-
-size_t tbd_read_uint32_t (uint32_t *value, FILE* stream);
-
-size_t tbd_read_uint64_t (uint64_t *value, FILE* stream);
-
-size_t tbd_read_time_t (time_t *value, FILE* stream);
-
-size_t tbd_read_mode_t (mode_t *value, FILE* stream);
-
-size_t tbd_read_uid_t (uid_t *value, FILE* stream);
-
-size_t tbd_read_gid_t (gid_t *value, FILE* stream);
-
-size_t tbd_read_size_t (size_t *value, FILE* stream);
-
-#endif
diff --git a/tbdiff-create/Makefile.am b/tbdiff-create/Makefile.am
new file mode 100644
index 0000000..5104140
--- /dev/null
+++ b/tbdiff-create/Makefile.am
@@ -0,0 +1,38 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2011-2012 Codethink Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# vi:set ts=8 sw=8 noet ai nocindent:
+
+bin_PROGRAMS = \
+ tbdiff-create
+
+tbdiff_create_SOURCES = \
+ main.c
+
+tbdiff_create_CFLAGS = \
+ -I$(top_srcdir) \
+ $(PLATFORM_CFLAGS) \
+ $(PLATFORM_CPPFLAGS)
+
+tbdiff_create_LDFLAGS = \
+ -no-undefined \
+ $(PLATFORM_LDFLAGS)
+
+tbdiff_create_DEPENDENCIES = \
+ $(top_builddir)/tbdiff/libtbdiff-$(TBDIFF_VERSION_API).la
+
+tbdiff_create_LDADD = \
+ $(top_builddir)/tbdiff/libtbdiff-$(TBDIFF_VERSION_API).la
diff --git a/tbdiff_create.c b/tbdiff-create/main.c
index 88dd405..d20feba 100644
--- a/tbdiff_create.c
+++ b/tbdiff-create/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -21,8 +21,7 @@
#include <unistd.h>
-#include "libtbd_stat.h"
-#include "tbdiff.h"
+#include <tbdiff/tbdiff.h>
int
diff --git a/tbdiff-deploy/Makefile.am b/tbdiff-deploy/Makefile.am
new file mode 100644
index 0000000..b97cceb
--- /dev/null
+++ b/tbdiff-deploy/Makefile.am
@@ -0,0 +1,38 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2011-2012 Codethink Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# vi:set ts=8 sw=8 noet ai nocindent:
+
+bin_PROGRAMS = \
+ tbdiff-deploy
+
+tbdiff_deploy_SOURCES = \
+ main.c
+
+tbdiff_deploy_CFLAGS = \
+ -I$(top_srcdir) \
+ $(PLATFORM_CFLAGS) \
+ $(PLATFORM_CPPFLAGS)
+
+tbdiff_deploy_LDFLAGS = \
+ -no-undefined \
+ $(PLATFORM_LDFLAGS)
+
+tbdiff_deploy_DEPENDENCIES = \
+ $(top_builddir)/tbdiff/libtbdiff-$(TBDIFF_VERSION_API).la
+
+tbdiff_deploy_LDADD = \
+ $(top_builddir)/tbdiff/libtbdiff-$(TBDIFF_VERSION_API).la
diff --git a/tbdiff_deploy.c b/tbdiff-deploy/main.c
index c766d93..b5b7ce9 100644
--- a/tbdiff_deploy.c
+++ b/tbdiff-deploy/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,8 +15,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "tbdiff.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
@@ -24,6 +22,8 @@
#include <unistd.h>
#include <errno.h>
+#include <tbdiff/tbdiff.h>
+
int
main(int argc,
char **argv)
diff --git a/tbdiff/Makefile.am b/tbdiff/Makefile.am
new file mode 100644
index 0000000..1b2644f
--- /dev/null
+++ b/tbdiff/Makefile.am
@@ -0,0 +1,60 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2011-2012 Codethink Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+lib_LTLIBRARIES = \
+ libtbdiff-1.la
+
+libtbdiff_headers = \
+ tbdiff-common.h \
+ tbdiff-io.h \
+ tbdiff-stat.h \
+ tbdiff-xattrs.h \
+ tbdiff-private.h \
+ tbdiff.h
+
+libtbdiff_sources = \
+ tbdiff-apply.c \
+ tbdiff-create.c \
+ tbdiff-io.c \
+ tbdiff-stat.c \
+ tbdiff-xattrs.c
+
+libtbdiffincludedir = $(includedir)/tbdiff-$(TBDIFF_VERSION_API)/tbdiff
+
+libtbdiffinclude_HEADERS = \
+ $(libtbdiff_headers)
+
+libtbdiff_1_la_SOURCES = \
+ $(libtbdiff_sources) \
+ $(libtbdiff_headers)
+
+libtbdiff_1_la_CFLAGS = \
+ -DDATADIR=\"$(datadir)\" \
+ -DTBDIFF_COMPILATION \
+ -DTBDIFF_VERSION_API=\"$(TBDIFF_VERSION_API)\" \
+ -I$(top_srcdir) \
+ $(PLATFORM_CFLAGS) \
+ $(PLATFORM_CPPFLAGS)
+
+libtbdiff_1_la_LDFLAGS = \
+ -no-undefined \
+ -export-dynamic \
+ -version-info $(TBDIFF_VERINFO) \
+ $(PLATFORM_LDFLAGS)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = tbdiff-1.pc
diff --git a/tbdiff/tbdiff-1.pc.in b/tbdiff/tbdiff-1.pc.in
new file mode 100644
index 0000000..45d5460
--- /dev/null
+++ b/tbdiff/tbdiff-1.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+tbdiff_api_version=@TBDIFF_VERSION_API@
+
+Name: @PACKAGE_TARNAME@
+Description: Supporting library for tbdiff-create and tbdiff-deploy
+Requires:
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -ltbdiff-${tbdiff_api_version}
+Cflags: -I${includedir}/tbdiff-${tbdiff_api_version}
diff --git a/libtbd_apply.c b/tbdiff/tbdiff-apply.c
index bac1ae2..e281d73 100644
--- a/libtbd_apply.c
+++ b/tbdiff/tbdiff-apply.c
@@ -1,5 +1,5 @@
/*
- * Copyright(C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,9 +15,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "tbdiff.h"
-#include "tbdiff-private.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -33,8 +30,11 @@
#include <utime.h>
#include <attr/xattr.h>
-#include "libtbd_xattrs.h"
-#include "libtbd_io.h"
+
+#include <tbdiff/tbdiff-common.h>
+#include <tbdiff/tbdiff-io.h>
+#include <tbdiff/tbdiff-private.h>
+#include <tbdiff/tbdiff-xattrs.h>
char*
tbd_apply_fread_string(FILE *stream)
diff --git a/tbdiff.h b/tbdiff/tbdiff-common.h
index 893a0a5..d4ac2c8 100644
--- a/tbdiff.h
+++ b/tbdiff/tbdiff-common.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,13 +15,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __TBDIFF_H__
-#define __TBDIFF_H__
+#if !defined (TBDIFF_INSIDE_TBDIFF_H) && !defined (TBDIFF_COMPILATION)
+#error "Only <tbdiff/tbdiff.h> may be included directly. This file might disappear or change contents."
+#endif
+
+#ifndef __TBDIFF_COMMON_H__
+#define __TBDIFF_COMMON_H__
#include <stdio.h>
#include <stdint.h>
-#include "libtbd_stat.h"
+#include <tbdiff/tbdiff-stat.h>
typedef enum {
TBD_CMD_IDENTIFY = 0x00,
@@ -96,4 +100,4 @@ tbd_error(tbd_error_e e, char const *s, char const *func, int line,
extern int tbd_apply (FILE *stream);
extern int tbd_create(FILE *stream, tbd_stat_t *a, tbd_stat_t *b);
-#endif /* __TBDIFF_H__ */
+#endif /* !__TBDIFF_COMMON_H__ */
diff --git a/libtbd_create.c b/tbdiff/tbdiff-create.c
index f6dc16d..ec5a8ce 100644
--- a/libtbd_create.c
+++ b/tbdiff/tbdiff-create.c
@@ -1,5 +1,5 @@
/*
- * Copyright(C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,12 +15,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "tbdiff.h"
-#include "tbdiff-private.h"
-
-#include "libtbd_xattrs.h"
-#include "libtbd_io.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -31,6 +25,11 @@
#include <dirent.h>
#include <unistd.h>
+#include <tbdiff/tbdiff-common.h>
+#include <tbdiff/tbdiff-io.h>
+#include <tbdiff/tbdiff-private.h>
+#include <tbdiff/tbdiff-xattrs.h>
+
#define PATH_BUFFER_LENGTH 4096
static int
diff --git a/libtbd_io.c b/tbdiff/tbdiff-io.c
index c4d6d11..698273b 100644
--- a/libtbd_io.c
+++ b/tbdiff/tbdiff-io.c
@@ -1,8 +1,25 @@
+/*
+ * Copyright (C) 2011-2012 Codethink Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
#include <endian.h>
#include <unistd.h>
#include <assert.h>
-#include "libtbd_stat.h"
+#include <tbdiff/tbdiff-stat.h>
#if __BYTE_ORDER == __BIG_ENDIAN
//inverts the indices of an array of bytes.
diff --git a/tbdiff/tbdiff-io.h b/tbdiff/tbdiff-io.h
new file mode 100644
index 0000000..73e7711
--- /dev/null
+++ b/tbdiff/tbdiff-io.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011-2012 Codethink Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#if !defined (TBDIFF_INSIDE_TBDIFF_H) && !defined (TBDIFF_COMPILATION)
+#error "Only <tbdiff/tbdiff.h> may be included directly. This file might disappear or change contents."
+#endif
+
+#ifndef __TBDIFF_IO_H__
+#define __TBDIFF_IO_H__
+
+#include <endian.h>
+#include <unistd.h>
+#include <assert.h>
+
+#include <tbdiff/tbdiff-stat.h>
+
+size_t tbd_write_uint16_t (uint16_t value, FILE* stream);
+
+size_t tbd_write_uint32_t (uint32_t value, FILE* stream);
+
+size_t tbd_write_uint64_t (uint64_t value, FILE* stream);
+
+size_t tbd_write_time_t (time_t value, FILE* stream);
+
+size_t tbd_write_mode_t (mode_t value, FILE* stream);
+
+size_t tbd_write_uid_t (uid_t value, FILE* stream);
+
+size_t tbd_write_gid_t (gid_t value, FILE* stream);
+
+size_t tbd_write_size_t (size_t value, FILE* stream);
+
+size_t tbd_read_uint16_t (uint16_t *value, FILE* stream);
+
+size_t tbd_read_uint32_t (uint32_t *value, FILE* stream);
+
+size_t tbd_read_uint64_t (uint64_t *value, FILE* stream);
+
+size_t tbd_read_time_t (time_t *value, FILE* stream);
+
+size_t tbd_read_mode_t (mode_t *value, FILE* stream);
+
+size_t tbd_read_uid_t (uid_t *value, FILE* stream);
+
+size_t tbd_read_gid_t (gid_t *value, FILE* stream);
+
+size_t tbd_read_size_t (size_t *value, FILE* stream);
+
+#endif /* !__TBDIFF_IO_H__ */
diff --git a/tbdiff-private.h b/tbdiff/tbdiff-private.h
index 12580a4..8287670 100644
--- a/tbdiff-private.h
+++ b/tbdiff/tbdiff-private.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,9 +15,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#if !defined (TBDIFF_INSIDE_TBDIFF_H) && !defined (TBDIFF_COMPILATION)
+#error "Only <tbdiff/tbdiff.h> may be included directly. This file might disappear or change contents."
+#endif
+
#ifndef __TBDIFF_PRIVATE_H__
#define __TBDIFF_PRIVATE_H__
#define TB_DIFF_PROTOCOL_ID "Codethink:TBDIFFv0"
-#endif
+#endif /* !__TBDIFF_PRIVATE_H__ */
diff --git a/libtbd_stat.c b/tbdiff/tbdiff-stat.c
index 08fb639..fd8964e 100644
--- a/libtbd_stat.c
+++ b/tbdiff/tbdiff-stat.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,8 +15,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "libtbd_stat.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
@@ -29,7 +27,7 @@
#include <errno.h>
#include <fcntl.h>
-
+#include <tbdiff/tbdiff-stat.h>
static tbd_stat_t*
tbd_stat_from_path(const char *name,
diff --git a/libtbd_stat.h b/tbdiff/tbdiff-stat.h
index c43c023..d23cc80 100644
--- a/libtbd_stat.h
+++ b/tbdiff/tbdiff-stat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,8 +15,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __LIBTBD_STAT_H__
-#define __LIBTBD_STAT_H__
+#if !defined (TBDIFF_INSIDE_TBDIFF_H) && !defined (TBDIFF_COMPILATION)
+#error "Only <tbdiff/tbdiff.h> may be included directly. This file might disappear or change contents."
+#endif
+
+#ifndef __TBDIFF_STAT_H__
+#define __TBDIFF_STAT_H__
#include <stdio.h>
#include <stdint.h>
@@ -55,4 +59,4 @@ extern char* tbd_stat_path(tbd_stat_t *file);
extern int tbd_stat_open(tbd_stat_t *file, int flags);
extern FILE* tbd_stat_fopen(tbd_stat_t *file, const char *mode);
-#endif /* __LIBTBD_STAT_H__ */
+#endif /* !__TBDIFF_STAT_H__ */
diff --git a/libtbd_xattrs.c b/tbdiff/tbdiff-xattrs.c
index 51c6168..95d263f 100644
--- a/libtbd_xattrs.c
+++ b/tbdiff/tbdiff-xattrs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,14 +15,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "libtbd_xattrs.h"
-#include "tbdiff.h"
#include <string.h>
#include <stdlib.h>
#include <attr/xattr.h>
#include <errno.h>
+#include <tbdiff/tbdiff-common.h>
+#include <tbdiff/tbdiff-xattrs.h>
+
int tbd_xattrs_names(char const *path, tbd_xattrs_names_t *names)
{
char *attrnames = NULL;
diff --git a/libtbd_xattrs.h b/tbdiff/tbdiff-xattrs.h
index 5f4cd5e..ba4a79e 100644
--- a/libtbd_xattrs.h
+++ b/tbdiff/tbdiff-xattrs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Codethink Ltd.
+ * Copyright (C) 2011-2012 Codethink Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
@@ -15,8 +15,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef _LIBTBD_XATTRS_H
-#define _LIBTBD_XATTRS_H
+#if !defined (TBDIFF_INSIDE_TBDIFF_H) && !defined (TBDIFF_COMPILATION)
+#error "Only <tbdiff/tbdiff.h> may be included directly. This file might disappear or change contents."
+#endif
+
+#ifndef _TBDIFF_XATTRS_H
+#define _TBDIFF_XATTRS_H
#include <stddef.h>
#include <stdint.h>
@@ -57,4 +61,4 @@ typedef int (*tbd_xattrs_pairs_callback_t)(char const *name, void const *data,
size_t size, void *ud);
extern int tbd_xattrs_pairs(tbd_xattrs_names_t const *names, char const *path,
tbd_xattrs_pairs_callback_t f, void *ud);
-#endif
+#endif /* !__TBDIFF_XATTRS_H__ */
diff --git a/tbdiff/tbdiff.h b/tbdiff/tbdiff.h
new file mode 100644
index 0000000..b7027e9
--- /dev/null
+++ b/tbdiff/tbdiff.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011-2012 Codethink Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __TBDIFF_H__
+#define __TBDIFF_H__
+
+#define TBDIFF_INSIDE_TBDIFF_H
+
+#include <tbdiff/tbdiff-common.h>
+#include <tbdiff/tbdiff-io.h>
+#include <tbdiff/tbdiff-private.h>
+#include <tbdiff/tbdiff-stat.h>
+#include <tbdiff/tbdiff-xattrs.h>
+
+#undef TBDIFF_INSIDE_TBDIFF_H
+
+#endif /* !__TBDIFF_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..400dc22
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,22 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2011-2012 Codethink Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License Version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+INCLUDES = \
+ -I$(top_srcdir)
+
+TESTS = \
+ run_tests.sh
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 32e7c97..21df2b2 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -18,7 +18,7 @@ for i in [0-9][0-9]*.sh
do
cd $ALLTESTSDIR
echo "#### Running $i"
- fakeroot -- ./$i ../tbdiff-create ../tbdiff-deploy
+ fakeroot -- ./$i ../tbdiff-create/tbdiff-create ../tbdiff-deploy/tbdiff-deploy
if [ $? -ne 0 ]
then
echo "Test program $i failed" 1>&2