12 static const char *get_ctime(void);
13 static void log_printf(const char *format
, ...);
14 static void print_message(const char *type
, const char *message
,
15 const char *file
, int line
);
19 int STDCALL
WinMain(HINSTANCE hInst
, HINSTANCE hPrev
, LPSTR lpCmd
, int nShow
) {
21 int main(int argc
, char *argv
[]) {
27 load_settings(&smode
, &font
, &theme
);
31 reload_fonts(&font
, &smode
);
34 resize_theme(&theme
, &smode
);
36 main_loop(&smode
, &font
, &theme
);
38 write_settings(&smode
, &font
, &theme
);
46 char *duplicate_string(const char *str
, size_t len
) {
47 char *p
= malloc(len
+ 1);
52 static const char *get_ctime(void) {
58 static void log_printf(const char *format
, ...) {
59 FILE *log
= fopen(LOG_FILE
, "at");
62 va_start(arg
, format
);
64 vfprintf(stderr
, format
, arg
);
65 vfprintf(log
, format
, arg
);
72 static void print_message(const char *type
, const char *message
,
73 const char *file
, int line
) {
75 const char *sdlerror
= SDL_GetError(), *t
= get_ctime();
77 log_printf("xuni: %s from %s:%i at %s %s\n SDL: %s\n",
78 type
, file
, line
, t
, message
, sdlerror
);
81 void print_warning(const char *message
, const char *file
, int line
) {
82 print_message("Warning", message
, file
, line
);
85 void settings_error(const char *message
, const char *sfile
, int sline
) {
86 const char *t
= get_ctime();
88 log_printf("xuni: Error in settings file %s:%i at %s %s\n",
89 sfile
, sline
, t
, message
);
92 void fatal_error(const char *message
, const char *file
, int line
) {
93 print_message("Fatal error", message
, file
, line
);