File: merge-index-main.c

package info (click to toggle)
astrometry.net 0.93%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,372 kB
  • sloc: ansic: 163,192; python: 18,357; makefile: 1,522; sh: 138; cpp: 78; pascal: 67; awk: 56; perl: 9
file content (76 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 # This file is part of the Astrometry.net suite.
 # Licensed under a 3-clause BSD style license - see LICENSE
 */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include "quadfile.h"
#include "codekd.h"
#include "starkd.h"
#include "fitsioutils.h"
#include "errors.h"
#include "boilerplate.h"
#include "ioutils.h"
#include "merge-index.h"

#define OPTIONS "hq:c:s:o:"

static void printHelp(char* progname) {
    BOILERPLATE_HELP_HEADER(stdout);
    printf("\nUsage: %s\n"
           "   -q <input-quad-filename>\n"
           "   -c <input-code-kdtree-filename>\n"
           "   -s <input-star-kdtree-filename>\n"
           "   -o <output-index-filename>\n"
           "\n", progname);
}


int main(int argc, char **args) {
    int argchar;
    char* progname = args[0];
    char* quadfn = NULL;
    char* codefn = NULL;
    char* starfn = NULL;
    char* outfn = NULL;

    while ((argchar = getopt (argc, args, OPTIONS)) != -1)
        switch (argchar) {
        case 'q':
            quadfn = optarg;
            break;
        case 'c':
            codefn = optarg;
            break;
        case 's':
            starfn = optarg;
            break;
        case 'o':
            outfn = optarg;
            break;
        case '?':
            fprintf(stderr, "Unknown option `-%c'.\n", optopt);
        case 'h':
            printHelp(progname);
            return 0;
        default:
            return -1;
        }

    if (!(quadfn && starfn && codefn && outfn)) {
        printHelp(progname);
        fprintf(stderr, "\nYou must specify all filenames (-q, -c, -s, -o)\n");
        exit(-1);
    }

    fits_use_error_system();

    if (merge_index_files(quadfn, codefn, starfn, outfn)) {
        exit(-1);
    }
    return 0;
}