Go to the documentation of this file.
37 #include "sighandler.h"
40 #include "compression.hxx"
55 #define MAIN_ERR_PREFIX "MAIN: "
71 static int main_config_loaded = 0;
77 static void print_version(
void)
79 std::cout << CFG_NAME <<
" " << CFG_VERSION <<
" for " << CFG_OS <<
"\n"
80 #if defined(CFG_MODIFIED) && CFG_MODIFIED != 0
81 <<
"(This is a modified version!)" <<
"\n"
82 #endif // CFG_MODIFIED
83 <<
"Unicode version: " << UC_VERSION <<
"\n"
84 <<
"Compiled with options:"
94 #if CFG_USE_XSI && !CFG_NLS_DISABLE
96 #endif // CFG_USE_XSI && !CFG_NLS_DISABLE
97 #if CFG_USE_POSIX_API >= 200112
99 #endif // CFG_USE_POSIX_API >= 200112
102 #endif // CFG_USE_TLS
105 #endif // CFG_DB_DISABLE
108 #endif // CFG_USE_XSI
111 #endif // CFG_USE_ZLIB
113 <<
"Build: " << BDATE << std::endl;
121 static void print_help(
void)
123 std::cout <<
"Usage: " << CFG_NAME <<
" [options]\n"
126 <<
" -4 Force usage of IPv4 network "
128 <<
" -confprefix path Specify configuration directory "
130 <<
" -debug Enable debug mode\n"
131 <<
" -display [host]:display X window system display\n"
132 <<
" -geometry WxH[+X+Y] Window size and position\n"
133 <<
" -h Print help message "
134 <<
"to standard output and exit\n"
135 <<
" -iconic Starts with minimized window\n"
136 <<
" -notooltips Disable tooltip messages\n"
137 <<
" -v Print version information "
138 <<
"to standard output and exit\n"
140 <<
"The GUI style can be customized with the environment "
141 <<
"variable FLTK_SCHEME.\n"
142 <<
"(See manual page for details)"
150 static void save_exit(
int ret)
152 if(main_config_loaded)
154 if(EXIT_SUCCESS == ret)
178 static void loop(
void)
180 static const char sbuf[] =
"Terminate due to signal";
191 std::clog << std::endl;
193 << sbuf << std::endl << std::flush;
285 len = std::strlen(msg);
286 s =
new char[len + (std::size_t) 1];
288 for(i = 0; i < len; ++i)
292 if(!(9 == c || 10 == c || (32 <= c && 126 >= c))) { s[i] =
'?'; }
293 else { s[i] = msg[i]; }
296 std::clog << std::flush;
297 std::cout << std::flush;
298 std::clog << CFG_NAME <<
": " << s << std::endl << std::flush;
317 int main(
int argc,
char** argv)
320 static const char* options_to_remove[] =
322 "-debug",
"-confprefix",
"-4", NULL
325 enum { OK, ERROR, ABORT } rv2 = OK;
327 unsigned int i, j, k;
337 if(0 > rv) rv2 = ERROR;
345 for(i = 1; i < (
unsigned int) argc; i++)
347 if(!std::strcmp(argv[i],
"-v") || !std::strcmp(argv[i],
"--version"))
354 else if(!std::strcmp(argv[i],
"-h") || !std::strcmp(argv[i],
"--help"))
361 else if(!std::strcmp(argv[i],
"-debug"))
365 else if(!std::strcmp(argv[i],
"-confprefix"))
369 else if(!std::strcmp(argv[i],
"-4"))
374 else if(!std::strcmp(argv[i],
"-display")
375 || !std::strcmp(argv[i],
"-geometry")
376 || !std::strcmp(argv[i],
"-iconic")
377 || !std::strcmp(argv[i],
"-notooltips"))
387 tmp =
new char[std::strlen(argv[i]) + (std::size_t) 1];
388 std::strcpy(tmp, argv[i]);
393 else if(
'-' == argv[i][0])
403 PRINT_ERROR(
"Use '-h' or read the man page for help");
409 <<
"Debug mode enabled" << std::endl << std::flush;
413 <<
"Force IPv4 network protocol" << std::endl << std::flush;
420 for(i = 1; i < (
unsigned int) argc; i++)
423 while(NULL != options_to_remove[j])
425 if(!std::strcmp(argv[i], options_to_remove[j]))
428 for (k = i; k < (
unsigned int) argc; k++)
430 argv[k] = argv[k + 1U];
434 if(i < (
unsigned int) argc &&
'-' != argv[i][0])
436 for (k = i; k < (
unsigned int) argc; k++)
438 argv[k] = argv[k + 1U];
448 if(removed) {
break; }
450 if(removed) {
goto repeat; }
454 <<
"Options passed to FLTK: ";
455 for(i = 1; i < (
unsigned int) argc; i++)
457 std::cout << argv[i] <<
" ";
459 std::cout << std::endl << std::flush;
468 <<
"Configuration directory path: "
479 main_config_loaded = 1;
498 #if !CFG_CMPR_DISABLE
504 #endif // !CFG_CMPR_DISABLE
511 #endif // CFG_USE_TLS
524 <<
"Shutdown" << std::endl << std::flush;
533 #endif // CFG_USE_TLS
534 #if !CFG_CMPR_DISABLE
536 #endif // !CFG_CMPR_DISABLE
void ts_environ_exit(void)
Destroy copy of environment variables.
void tls_exit(void)
Shutdown TLS subsystem.
void digest_exit(void)
Shutdown message digest module.
int db_exit(void)
Shutdown database.
#define MAIN_ERR_PREFIX
Message prefix for MAIN module.
void filter_exit(void)
Shutdown filter module.
struct conf config[CONF_NUM]
Global configuration.
int conf_store(struct conf *cfg)
Store configuration to config file.
void ts_environ_init(void)
Copy environment variables.
void nls_exit(void)
Shutdown NLS subsystem.
void hmac_exit(void)
Shutdown HMAC module.
int core_check_thread_ui(void)
Check whether code is running in UI thread (exported for UI)
int sighandler_install(void)
Install signal handlers.
int ui_unlock(void)
Unlock for multithread support.
int main_debug
Enable additional debug output if nonzero.
void hmac_init(void)
Initialize HMAC module.
int tls_init(void)
Init TLS subsystem.
int ui_exec(void)
Drive GUI.
void conf_delete(struct conf *cfg)
Delete configuration.
void cmpr_exit(void)
Shutdown compress module.
int cmpr_init(void)
Initialize compression module.
int ui_get_locale_utf8(void)
Check whether locale use UTF-8 encoding.
int sighandler_check_abort(void)
Check abort flag.
#define PRINT_ERROR(s)
Prepend module prefix and print error message.
int ts_unlock_ui(void)
Unlock UI thread.
int ui_lock(void)
Lock for multithread support.
int db_init(void)
Init database.
const char * main_confprefix
Configuration directory path from command line option or NULL otherwise.
void group_exit(void)
Shutdown group handling.
int conf_load(struct conf *cfg)
Load configuration from config file.
void group_init(void)
Initialize group handling.
int nls_init(void)
Init NLS subsystem.
void log_delete_logfile(void)
Delete logfile if present.
int filter_init(int utf8)
Initialize filter module.
int main(int argc, char **argv)
Program entry point.
void digest_init(void)
Initialize message digest module.
int ts_lock_ui(void)
Lock UI thread.
void ui_exit(void)
Shutdown GUI.
void print_error(const char *msg)
Print error message.
void ui_init(int argc, char **argv)
Init GUI.
Generated at 2026-01-27 using