aboutsummaryrefslogtreecommitdiff
path: root/importer
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-04-15 22:16:28 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-04-15 22:16:28 +0200
commit6dd0c4747aa57227b5898fc639e3f2b643ce013c (patch)
treee43ee077469b5c28fcf46dba51eb03e53214fad5 /importer
parent6ed576974dec969ad2745a451a6f680a3cdbcfc4 (diff)
downloaddict-6dd0c4747aa57227b5898fc639e3f2b643ce013c.tar.gz
dict-6dd0c4747aa57227b5898fc639e3f2b643ce013c.tar.bz2
dict-6dd0c4747aa57227b5898fc639e3f2b643ce013c.zip
feat: Remove C implementation
Diffstat (limited to 'importer')
-rw-r--r--importer/CMakeLists.txt9
-rw-r--r--importer/main.c82
2 files changed, 0 insertions, 91 deletions
diff --git a/importer/CMakeLists.txt b/importer/CMakeLists.txt
deleted file mode 100644
index 587952e..0000000
--- a/importer/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-project(dict_importer VERSION 0.1 LANGUAGES C)
-
-file(GLOB src CONFIGURE_DEPENDS "*.c")
-add_executable(dict_importer ${src})
-
-target_compile_options(dict_importer PRIVATE -Wall -Wextra -Wpedantic -Werror)
-target_include_directories(dict_importer PUBLIC "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}")
-target_link_libraries(dict_importer sqlite3 lib)
-
diff --git a/importer/main.c b/importer/main.c
deleted file mode 100644
index 087fc48..0000000
--- a/importer/main.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "../lib/util.h"
-#include "../lib/data.h"
-
-int run(const char *db, const char *txt);
-
-int main(int argc, char** argv)
-{
- int opt;
- char* txt = NULL;
- char* db = NULL;
-
- while ((opt = getopt(argc, argv, "t:d:h")) != -1) {
- switch(opt) {
- case 't':
- txt = copy_achar(optarg);
- break;
- case 'd':
- db = copy_achar(optarg);
- break;
- case 'h':
- // fall through
- default:
- printf("Usage: %s", argv[0]);
- goto end;
- }
- }
-
- int r = run(db, txt);
-
-end:
- if (txt != NULL)
- free(txt);
- if (db != NULL)
- free(db);
-
- return r;
-}
-
-int run(const char *db, const char *txt)
-{
- char * line = NULL;
- size_t len = 0;
- int count = 0;
- ssize_t read;
- Data *data;
- FILE *f;
- int total;
-
- printf("\33[?25l"); // hide cursor
-
- data = new_data(":memory:");
- f = fopen(txt, "r");
-
- bootstrap(data);
-
- total = count_file_lines(f);
- fseek(f, 0, SEEK_SET);
-
- while ((read = getline(&line, &len, f)) != -1) {
- if (line[0] == '#' || line[0] == '\n')
- continue;
-
- insert(data, line, read-1);
- count++;
-
- float t = ((float)count/(float)total)*100;
- printf("\rLoading data [%03.0f%%] %d/%d", t, count, total);
- }
-
- float t = ((float)count/(float)total)*100;
- printf("\rLoading data [%03.0f%%] %d/%d", t, count, total);
- int r = load_or_save_db(data->db, db, 1);
-
- printf("\rDONE!");
- printf("\33[?25h"); // reenable cursor
-
- return r;
-}