summaryrefslogtreecommitdiff
path: root/bspatch_main.cc
blob: 2a71a1cb151f246c59680ac114af7c2895f111b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2015 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <err.h>
#include <stdlib.h>

#include "bsdiff/bspatch.h"

#define USAGE_TEMPLATE_STR                                          \
  "usage: %s oldfile newfile patchfile [old-extents new-extents]\n" \
  "with extents taking the form \"off_1:len_1,...,off_n:len_n\"\n"

int main(int argc, char* argv[]) {
  const char* old_extents = NULL;
  const char* new_extents = NULL;

  if ((argc != 6) && (argc != 4))
    errx(1, USAGE_TEMPLATE_STR, argv[0]);

  if (argc == 6) {
    old_extents = argv[4];
    new_extents = argv[5];
  }

  return bsdiff::bspatch(argv[1], argv[2], argv[3], old_extents, new_extents);
}