wp_saver_rcpp_fw/main.cpp

92 lines
2.0 KiB
C++
Raw Normal View History

2021-11-19 09:24:55 +01:00
#include <string.h>
2021-11-21 13:03:38 +01:00
#include "core/settings.h"
#include "core/os/platform.h"
2021-11-19 09:24:55 +01:00
#include "core/file_cache.h"
#include "core/math/math.h"
2021-11-19 09:24:55 +01:00
#include "database/db_init.h"
2021-11-20 19:21:21 +01:00
// Backends
2021-11-19 09:24:55 +01:00
#include "backends/hash_hashlib/setup.h"
#include "core/database/database_manager.h"
#include "platform/platform_initializer.h"
#include "core/settings.h"
#include "app/wp_downloader.h"
2021-11-19 09:24:55 +01:00
void initialize_backends() {
initialize_database_backends();
backend_hash_hashlib_install_providers();
}
int main(int argc, char **argv, char **envp) {
PlatformInitializer::allocate_all();
PlatformInitializer::arg_setup(argc, argv, envp);
initialize_backends();
2021-11-20 01:40:38 +01:00
String database_folder = "./data/";
2021-11-19 09:24:55 +01:00
Settings *settings = new Settings(true);
settings->parse_ini_file("settings.ini");
2021-11-19 09:24:55 +01:00
bool download = Platform::get_singleton()->arg_parser.has_arg("-d");
2021-11-19 09:24:55 +01:00
if (download) {
Vector<Ref<WPDownloader> > downloaders;
DatabaseManager *dbm = new DatabaseManager();
2021-11-19 09:24:55 +01:00
2021-11-20 01:40:38 +01:00
bool save_original_data = settings->get_value_bool("save_original_data");
if (save_original_data) {
String sites = settings->get_value("sites");
int sc = sites.get_slice_count(',');
for (int i = 0; i < sc; ++i) {
String s = sites.get_slice(',', i);
uint32_t index = dbm->create_database("sqlite");
Database *db = dbm->databases[index];
db->connect(database_folder + s + ".sqlite");
Ref<WPDownloader> d;
d.instance();
d->setup(s, db);
//todo
//downloaders.push_back(d);
d->run();
2021-11-20 01:40:38 +01:00
}
}
2021-11-19 09:24:55 +01:00
delete dbm;
} else {
/*
FileCache *file_cache = new FileCache(true);
file_cache->wwwroot = "./www";
file_cache->wwwroot_refresh_cache();
DWebApplication *app = new DWebApplication();
app->load_settings();
app->setup_routes();
app->setup_middleware();
app->add_listener("127.0.0.1", 8080);
LOG_INFO << "Server running on 127.0.0.1:8080";
2021-11-19 09:24:55 +01:00
printf("Initialized!\n");
app->run();
delete app;
2021-11-19 09:24:55 +01:00
delete file_cache;
*/
2021-11-19 09:24:55 +01:00
}
delete settings;
PlatformInitializer::free_all();
return 0;
}