diff options
author | Ben Brewer <ben.brewer@codethink.co.uk> | 2014-06-04 16:57:00 +0100 |
---|---|---|
committer | Ben Brewer <ben.brewer@codethink.co.uk> | 2014-06-04 16:57:00 +0100 |
commit | 0b9a35045c6fb7baa7a2b29408c2df9017111432 (patch) | |
tree | 899dc8dee7ef09aa38b9341a1a2a5421102f31ac /tbdiff-deploy/main.c | |
parent | 20d5fb340c6ad1e7b16c6dc17e3f6c364a5a5515 (diff) | |
parent | 1de58f93e1b19442d40badde4b68fc34bb08f386 (diff) | |
download | tbdiff-0b9a35045c6fb7baa7a2b29408c2df9017111432.tar.gz |
Merge branch 'baserock/benbrewer/post-overhaul-v2'
Reviewed-by: Michael Drake
Reviewed-by: Richard Maw
Diffstat (limited to 'tbdiff-deploy/main.c')
-rw-r--r-- | tbdiff-deploy/main.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tbdiff-deploy/main.c b/tbdiff-deploy/main.c index b5b7ce9..228a753 100644 --- a/tbdiff-deploy/main.c +++ b/tbdiff-deploy/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 Codethink Ltd. + * Copyright (C) 2011-2014 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 @@ -19,33 +19,43 @@ #include <stdio.h> #include <stdint.h> #include <stdbool.h> +#include <fcntl.h> #include <unistd.h> #include <errno.h> #include <tbdiff/tbdiff.h> +static void +print_usage(const char *name) +{ + printf("Usage: %s <patch-stream>\n", name); +} + int main(int argc, char **argv) { if(argc < 2) { fprintf(stderr, "Error: No patch stream specified.\n"); + print_usage(argv[0]); return EXIT_FAILURE; } - FILE* patch = fopen(argv[1], "rb"); - if(patch == NULL) { - fprintf(stderr, "Error: Can't open patch stream for reading.\n"); + int patch = open(argv[1], O_RDONLY); + if(patch < 0) { + fprintf(stderr, + "Error: Can't open patch stream for reading (err=%d).\n", + errno); return EXIT_FAILURE; } int err; if((err = tbd_apply(patch)) != 0) { - fclose(patch); + close(patch); fprintf(stderr, "Error: Error applying patch stream (err=%d).\n", err); return EXIT_FAILURE; } - fclose(patch); + close(patch); return EXIT_SUCCESS; } |