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 77 78 79 80 81 82 83 84 85 86
|
/*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "boilerplate.h"
#include "solvedfile.h"
#include "an-bool.h"
const char* OPTIONS = "ho:e";
void printHelp(char* progname) {
BOILERPLATE_HELP_HEADER(stderr);
fprintf(stderr, "\nUsage: %s -o <output-file> <input-file> ...\n"
" [-e]: no error if file no found (assume empty)\n"
"\n", progname);
}
int main(int argc, char** args) {
int argchar;
char* progname = args[0];
char** inputfiles = NULL;
int ninputfiles = 0;
int i;
char* outfile = NULL;
int N;
anbool* solved;
int noerr = 0;
while ((argchar = getopt (argc, args, OPTIONS)) != -1) {
switch (argchar) {
case 'o':
outfile = optarg;
break;
case 'e':
noerr = 1;
break;
case 'h':
default:
printHelp(progname);
exit(-1);
}
}
if (optind < argc) {
ninputfiles = argc - optind;
inputfiles = args + optind;
} else {
printHelp(progname);
exit(-1);
}
N = 0;
for (i=0; i<ninputfiles; i++) {
int n = solvedfile_getsize(inputfiles[i]);
if (n == -1) {
if (!noerr) {
fprintf(stderr, "Failed to get size of input file %s.\n", inputfiles[i]);
exit(-1);
}
}
if (n > N) N = n;
}
solved = calloc(N, sizeof(anbool));
for (i=0; i<ninputfiles; i++) {
il* slist;
int j;
slist = solvedfile_getall_solved(inputfiles[i], 1, N, 0);
for (j=0; j<il_size(slist); j++)
solved[il_get(slist, j) - 1] = TRUE;
il_free(slist);
}
if (solvedfile_set_file(outfile, solved, N)) {
fprintf(stderr, "Failed to set values in output file.\n");
exit(-1);
}
free(solved);
return 0;
}
|