k8clock moved to separate dir
[k8muffin.git] / src / tagsearch.c
blob5cd6e46a81ab99e8178fb14a1abc58f8cb49847b
1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef _BSD_SOURCE
18 # define _BSD_SOURCE
19 #endif
20 #ifndef _GNU_SOURCE
21 # define _GNU_SOURCE
22 #endif
23 #include <ctype.h>
24 #include <dirent.h>
25 #include <iconv.h>
26 #include <limits.h>
27 #include <stdint.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <time.h>
32 #include <unistd.h>
34 #include <sys/stat.h>
35 #include <sys/types.h>
37 #include "libdbg/dbglog.h"
38 #include "translit.h"
40 #include "uthash.h"
41 #include "libk8clock/k8clock.h"
44 ////////////////////////////////////////////////////////////////////////////////
45 #include "tagload.c"
46 #include "search.c"
49 ////////////////////////////////////////////////////////////////////////////////
50 int main (int argc, char *argv[]) {
51 uint64_t stt, ste;
52 dbglog_set_screenout(1);
53 dbglog_set_fileout(0);
55 printf("loading database...\n");
56 stt = k8clock();
57 if (tagdb_load("tags.dat") != 0) { fprintf(stderr, "FATAL: can't open tagfile!\n"); return -1; }
58 ste = k8clock();
59 printf("database load time: %.15g seconds\n", (double)(ste-stt)/1000.0);
60 printf("building hashes...\n");
61 stt = k8clock();
62 build_hashes();
63 ste = k8clock();
64 printf("hash build time: %.15g seconds\n", (double)(ste-stt)/1000.0);
65 if (argc > 1) {
66 for (int f = 1; f < argc; ++f) {
67 dirinfo_t *di = list_dir(argv[f]);
68 // dump
69 if (di != NULL) {
70 dlogf("=====================\n");
71 for (int f = 0; f < di->fcount; ++f) fprintf(stderr, "%s\n", di->items[f].name);
72 free(di->items);
73 free(di);
76 } else {
77 char s[128];
78 fgets(s, sizeof(s), stdin);
80 clear_hashes();
81 tagdb_unload();
82 return 0;