72 lines
1.5 KiB
C
72 lines
1.5 KiB
C
#include "blade.h"
|
|
|
|
// @todo switch to wait condition once something is being done with the main thread during runtime
|
|
ks_bool_t g_shutdown = KS_FALSE;
|
|
|
|
void idle(blade_handle_t *bh);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
blade_handle_t *bh = NULL;
|
|
config_t config;
|
|
config_setting_t *config_blade = NULL;
|
|
const char *cfgpath = "switchblade.cfg";
|
|
|
|
ks_global_set_default_logger(KS_LOG_LEVEL_DEBUG);
|
|
|
|
blade_init();
|
|
|
|
blade_handle_create(&bh);
|
|
|
|
config_init(&config);
|
|
if (!config_read_file(&config, cfgpath)) {
|
|
ks_log(KS_LOG_ERROR, "%s:%d - %s\n", config_error_file(&config), config_error_line(&config), config_error_text(&config));
|
|
config_destroy(&config);
|
|
return EXIT_FAILURE;
|
|
}
|
|
config_blade = config_lookup(&config, "blade");
|
|
if (!config_blade) {
|
|
ks_log(KS_LOG_ERROR, "Missing 'blade' config group\n");
|
|
config_destroy(&config);
|
|
return EXIT_FAILURE;
|
|
}
|
|
if (config_setting_type(config_blade) != CONFIG_TYPE_GROUP) {
|
|
ks_log(KS_LOG_ERROR, "The 'blade' config setting is not a group\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if (blade_handle_startup(bh, config_blade) != KS_STATUS_SUCCESS) {
|
|
ks_log(KS_LOG_ERROR, "Blade startup failed\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
idle(bh);
|
|
|
|
blade_handle_destroy(&bh);
|
|
|
|
config_destroy(&config);
|
|
|
|
blade_shutdown();
|
|
|
|
return 0;
|
|
}
|
|
|
|
void idle(blade_handle_t *bh)
|
|
{
|
|
while (!g_shutdown) {
|
|
ks_sleep_ms(1000);
|
|
}
|
|
}
|
|
|
|
|
|
/* For Emacs:
|
|
* Local Variables:
|
|
* mode:c
|
|
* indent-tabs-mode:t
|
|
* tab-width:4
|
|
* c-basic-offset:4
|
|
* End:
|
|
* For VIM:
|
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
|
|
*/
|