summaryrefslogtreecommitdiff
path: root/tbdiff-deploy/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tbdiff-deploy/main.c')
-rw-r--r--tbdiff-deploy/main.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/tbdiff-deploy/main.c b/tbdiff-deploy/main.c
new file mode 100644
index 0000000..b5b7ce9
--- /dev/null
+++ b/tbdiff-deploy/main.c
@@ -0,0 +1,51 @@
+/*
+ * 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 <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <tbdiff/tbdiff.h>
+
+int
+main(int argc,
+ char **argv)
+{
+ if(argc < 2) {
+ fprintf(stderr, "Error: No patch stream specified.\n");
+ return EXIT_FAILURE;
+ }
+
+ FILE* patch = fopen(argv[1], "rb");
+ if(patch == NULL) {
+ fprintf(stderr, "Error: Can't open patch stream for reading.\n");
+ return EXIT_FAILURE;
+ }
+
+ int err;
+ if((err = tbd_apply(patch)) != 0) {
+ fclose(patch);
+ fprintf(stderr, "Error: Error applying patch stream (err=%d).\n", err);
+ return EXIT_FAILURE;
+ }
+
+ fclose(patch);
+ return EXIT_SUCCESS;
+}