-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.c
79 lines (69 loc) · 2.81 KB
/
main.c
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
/* View .tbi with .tbk
*
* The MIT License (MIT)
*
* Copyright (c) 2020-2021 [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**/
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "tbmate.h"
const int unit_base[40] = {
0, 1, 1, 4, 4, 8, 8, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 8,
8, 0, 0, 0, 0, 0, 0, 0
};
int main_pack(int argc, char *argv[]);
int main_view(int argc, char *argv[]);
int main_header(int argc, char *argv[]);
int main_bundle(int argc, char *argv[]);
static int usage()
{
fprintf(stderr, "\n");
fprintf(stderr, "Program: tbmate (Tabix Mate)\n");
fprintf(stderr, "Version: %s\n", PACKAGE_VERSION);
fprintf(stderr, "Contact: Wanding Zhou<[email protected]>\n\n");
fprintf(stderr, "Usage: tbmate <command> [options]\n\n");
fprintf(stderr, "Command:\n");
fprintf(stderr, " pack pack data to tbk\n");
fprintf(stderr, " view view data stored in tbk\n");
fprintf(stderr, " header view and set tbk data header\n");
fprintf(stderr, " bundle bundle tbk into a multi-tbk.\n");
fprintf(stderr, "\n");
return 1;
}
int main(int argc, char *argv[]) {
int ret;
if (argc < 2) return usage();
if (strcmp(argv[1], "pack") == 0) ret = main_pack(argc-1, argv+1);
else if (strcmp(argv[1], "view") == 0) ret = main_view(argc-1, argv+1);
else if (strcmp(argv[1], "header") == 0) ret = main_header(argc-1, argv+1);
else if (strcmp(argv[1], "bundle") == 0) ret = main_bundle(argc-1, argv+1);
else {
fprintf(stderr, "[main] unrecognized command '%s'\n", argv[1]);
return 1;
}
fflush(stdout); /* not enough for remote file systems */
fclose(stdout);
return ret;
}