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 << CFG_NAME <<
": " << s << std::endl << std::flush;
315 int main(
int argc,
char** argv)
318 static const char* options_to_remove[] =
320 "-debug",
"-confprefix",
"-4", NULL
323 enum { OK, ERROR, ABORT } rv2 = OK;
325 unsigned int i, j, k;
335 if(0 > rv) rv2 = ERROR;
343 for(i = 1; i < (
unsigned int) argc; i++)
345 if(!std::strcmp(argv[i],
"-v") || !std::strcmp(argv[i],
"--version"))
352 else if(!std::strcmp(argv[i],
"-h") || !std::strcmp(argv[i],
"--help"))
359 else if(!std::strcmp(argv[i],
"-debug"))
363 else if(!std::strcmp(argv[i],
"-confprefix"))
367 else if(!std::strcmp(argv[i],
"-4"))
372 else if(!std::strcmp(argv[i],
"-display")
373 || !std::strcmp(argv[i],
"-geometry")
374 || !std::strcmp(argv[i],
"-iconic")
375 || !std::strcmp(argv[i],
"-notooltips"))
385 tmp =
new char[std::strlen(argv[i]) + (std::size_t) 1];
386 std::strcpy(tmp, argv[i]);
391 else if(
'-' == argv[i][0])
401 PRINT_ERROR(
"Use '-h' or read the man page for help");
407 <<
"Debug mode enabled" << std::endl << std::flush;
411 <<
"Force IPv4 network protocol" << std::endl << std::flush;
418 for(i = 1; i < (
unsigned int) argc; i++)
421 while(NULL != options_to_remove[j])
423 if(!std::strcmp(argv[i], options_to_remove[j]))
426 for (k = i; k < (
unsigned int) argc; k++)
428 argv[k] = argv[k + 1U];
432 if(i < (
unsigned int) argc &&
'-' != argv[i][0])
434 for (k = i; k < (
unsigned int) argc; k++)
436 argv[k] = argv[k + 1U];
446 if(removed) {
break; }
448 if(removed) {
goto repeat; }
452 <<
"Options passed to FLTK: ";
453 for(i = 1; i < (
unsigned int) argc; i++)
455 std::cout << argv[i] <<
" ";
457 std::cout << std::endl << std::flush;
466 <<
"Configuration directory path: "
477 main_config_loaded = 1;
496 #if !CFG_CMPR_DISABLE
502 #endif // !CFG_CMPR_DISABLE
509 #endif // CFG_USE_TLS
522 <<
"Shutdown" << std::endl << std::flush;
531 #endif // CFG_USE_TLS
532 #if !CFG_CMPR_DISABLE
534 #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 2024-04-27 using