change: support -v/-h flags

laumann
Aug 26, 2022, 8:45 PM
3FT3XTJMUAXQ257T5GB7YWWTI7QBKKVC7WA6DCH5UY26RLQO5PFQC

Dependencies

  • [2] WMFNGOYT change: reduce printed noise, rework some code
  • [3] KDJUAAAL change: prefix function names with change_
  • [4] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change
  • [5] RIWSVVAS change: decompress the 'contents' with zstd_seekable
  • [6] QEFCNNVC change: display offsets for given change file
  • [*] OBKF6SII change: decompress the hashed section too

Change contents

  • edit in change.c at line 29
    [8.238]
    [2.0]
    }
    static void
    cmd_change_usage() {
    printf("ani change [-h] [-v] <hash>\n");
  • replacement in change.c at line 218
    [3.2203][3.87:112]()
    change(const char *hash)
    [3.2203]
    [3.2212]
    change(const char *hash, int verbose)
  • replacement in change.c at line 269
    [3.188][2.847:904]()
    /* dump_buf("contents", contents, off.contents_len); */
    [3.188]
    [3.239]
    if (verbose)
    dump_buf("contents", contents, off.contents_len);
  • replacement in change.c at line 286
    [3.2999][3.2999:3043]()
    int cmd_change(int argc, const char **argv)
    [3.2999]
    [3.3043]
    int cmd_change(int argc, char **argv)
  • edit in change.c at line 290
    [3.2927]
    [3.416]
    int verbose;
    int c;
  • replacement in change.c at line 293
    [3.417][3.417:505]()
    if (argc < 2) {
    fprintf(stderr, "error: invalid number of arguments. See --help\n");
    [3.417]
    [3.505]
    verbose = 0;
    while ((c = getopt(argc, argv, "hv")) != -1) {
    switch (c) {
    case 'v':
    verbose = 1;
    break;
    case 'h':
    cmd_change_usage();
    return 0;
    case '?':
    fprintf(stderr, "unrecognized option: '-%c'\n", optopt);
    return -1;
    }
    }
    if (optind >= argc) {
    fprintf(stderr, "error: invalid number of arguments. See -h\n");
  • replacement in change.c at line 312
    [3.521][3.521:538]()
    hash = argv[1];
    [3.521]
    [3.538]
    hash = argv[optind];
  • replacement in change.c at line 324
    [3.742][3.742:764]()
    return change(hash);
    [3.742]
    [3.3099]
    return change(hash, verbose);