From 4dad971280a07058d01449d5e6db2b036470015d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 21 Apr 2015 12:14:01 +0200 Subject: [PATCH] improved logfile handling --- src/editor.c | 14 ++--- src/files.c | 94 +++++++++++++++++----------------- src/init.c | 106 +++++++++++++++++++------------------- src/libgame/misc.c | 119 +++++++++++++++++++++++++++++++------------ src/libgame/misc.h | 13 +++-- src/libgame/system.c | 12 ++--- src/libgame/system.h | 12 +++-- src/main.c | 108 +++++++++++++++++++-------------------- 8 files changed, 272 insertions(+), 206 deletions(-) diff --git a/src/editor.c b/src/editor.c index c0d5ffd9..3512218e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -5217,9 +5217,9 @@ void PrintEditorElementList() int cascade_element_show = EL_CASCADE_INACTIVE(cascade_element); char *headline = element_info[cascade_element_show].editor_description; - printf_line_with_prefix("# ", "-", 77); - printf("# %s\n", headline); - printf_line_with_prefix("# ", "-", 77); + PrintLineWithPrefix("# ", "-", 77); + Print("# %s\n", headline); + PrintLineWithPrefix("# ", "-", 77); } for (j = 0; j < *editor_elements_info[i].headline_list_size; j++) @@ -5229,21 +5229,21 @@ void PrintEditorElementList() if (IS_EDITOR_CASCADE(element)) element = EL_CHAR_MINUS; - printf("# %s\n", element_info[element].token_name); + Print("# %s\n", element_info[element].token_name); } if (j > 0) - printf("#\n"); + Print("#\n"); for (j = 0; j < *editor_elements_info[i].element_list_size; j++) { int element = (*editor_elements_info[i].element_list)[j]; - printf("# %s\n", element_info[element].token_name); + Print("# %s\n", element_info[element].token_name); } if (j > 0) - printf("#\n"); + Print("#\n"); } } diff --git a/src/files.c b/src/files.c index 6382467a..1d4562ae 100644 --- a/src/files.c +++ b/src/files.c @@ -7158,34 +7158,34 @@ void DumpLevel(struct LevelInfo *level) return; } - printf_line("-", 79); - printf("Level xxx (file version %08d, game version %08d)\n", - level->file_version, level->game_version); - printf_line("-", 79); - - printf("Level author: '%s'\n", level->author); - printf("Level title: '%s'\n", level->name); - printf("\n"); - printf("Playfield size: %d x %d\n", level->fieldx, level->fieldy); - printf("\n"); - printf("Level time: %d seconds\n", level->time); - printf("Gems needed: %d\n", level->gems_needed); - printf("\n"); - printf("Time for magic wall: %d seconds\n", level->time_magic_wall); - printf("Time for wheel: %d seconds\n", level->time_wheel); - printf("Time for light: %d seconds\n", level->time_light); - printf("Time for timegate: %d seconds\n", level->time_timegate); - printf("\n"); - printf("Amoeba speed: %d\n", level->amoeba_speed); - printf("\n"); - - printf("EM style slippery gems: %s\n", (level->em_slippery_gems ? "yes" : "no")); - printf("Player blocks last field: %s\n", (level->block_last_field ? "yes" : "no")); - printf("SP player blocks last field: %s\n", (level->sp_block_last_field ? "yes" : "no")); - printf("use spring bug: %s\n", (level->use_spring_bug ? "yes" : "no")); - printf("use step counter: %s\n", (level->use_step_counter ? "yes" : "no")); - - printf_line("-", 79); + PrintLine("-", 79); + Print("Level xxx (file version %08d, game version %08d)\n", + level->file_version, level->game_version); + PrintLine("-", 79); + + Print("Level author: '%s'\n", level->author); + Print("Level title: '%s'\n", level->name); + Print("\n"); + Print("Playfield size: %d x %d\n", level->fieldx, level->fieldy); + Print("\n"); + Print("Level time: %d seconds\n", level->time); + Print("Gems needed: %d\n", level->gems_needed); + Print("\n"); + Print("Time for magic wall: %d seconds\n", level->time_magic_wall); + Print("Time for wheel: %d seconds\n", level->time_wheel); + Print("Time for light: %d seconds\n", level->time_light); + Print("Time for timegate: %d seconds\n", level->time_timegate); + Print("\n"); + Print("Amoeba speed: %d\n", level->amoeba_speed); + Print("\n"); + + Print("EM style slippery gems: %s\n", (level->em_slippery_gems ? "yes" : "no")); + Print("Player blocks last field: %s\n", (level->block_last_field ? "yes" : "no")); + Print("SP player blocks last field: %s\n", (level->sp_block_last_field ? "yes" : "no")); + Print("use spring bug: %s\n", (level->use_spring_bug ? "yes" : "no")); + Print("use step counter: %s\n", (level->use_step_counter ? "yes" : "no")); + + PrintLine("-", 79); } @@ -7748,13 +7748,13 @@ void DumpTape(struct TapeInfo *tape) return; } - printf_line("-", 79); - printf("Tape of Level %03d (file version %08d, game version %08d)\n", - tape->level_nr, tape->file_version, tape->game_version); - printf(" (effective engine version %08d)\n", - tape->engine_version); - printf("Level series identifier: '%s'\n", tape->level_identifier); - printf_line("-", 79); + PrintLine("-", 79); + Print("Tape of Level %03d (file version %08d, game version %08d)\n", + tape->level_nr, tape->file_version, tape->game_version); + Print(" (effective engine version %08d)\n", + tape->engine_version); + Print("Level series identifier: '%s'\n", tape->level_identifier); + PrintLine("-", 79); tape_frame_counter = 0; @@ -7763,7 +7763,7 @@ void DumpTape(struct TapeInfo *tape) if (i >= MAX_TAPE_LEN) break; - printf("%04d: ", i); + Print("%04d: ", i); for (j = 0; j < MAX_PLAYERS; j++) { @@ -7771,24 +7771,24 @@ void DumpTape(struct TapeInfo *tape) { int action = tape->pos[i].action[j]; - printf("%d:%02x ", j, action); - printf("[%c%c%c%c|%c%c] - ", - (action & JOY_LEFT ? '<' : ' '), - (action & JOY_RIGHT ? '>' : ' '), - (action & JOY_UP ? '^' : ' '), - (action & JOY_DOWN ? 'v' : ' '), - (action & JOY_BUTTON_1 ? '1' : ' '), - (action & JOY_BUTTON_2 ? '2' : ' ')); + Print("%d:%02x ", j, action); + Print("[%c%c%c%c|%c%c] - ", + (action & JOY_LEFT ? '<' : ' '), + (action & JOY_RIGHT ? '>' : ' '), + (action & JOY_UP ? '^' : ' '), + (action & JOY_DOWN ? 'v' : ' '), + (action & JOY_BUTTON_1 ? '1' : ' '), + (action & JOY_BUTTON_2 ? '2' : ' ')); } } - printf("(%03d) ", tape->pos[i].delay); - printf("[%05d]\n", tape_frame_counter); + Print("(%03d) ", tape->pos[i].delay); + Print("[%05d]\n", tape_frame_counter); tape_frame_counter += tape->pos[i].delay; } - printf_line("-", 79); + PrintLine("-", 79); } diff --git a/src/init.c b/src/init.c index e54a016b..4808f114 100644 --- a/src/init.c +++ b/src/init.c @@ -4563,57 +4563,57 @@ void Execute_Command(char *command) if (strEqual(command, "print graphicsinfo.conf")) { - printf("# You can configure additional/alternative image files here.\n"); - printf("# (The entries below are default and therefore commented out.)\n"); - printf("\n"); - printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics")); - printf("\n"); - printf("%s\n", getFormattedSetupEntry("sort_priority", "100")); - printf("\n"); + Print("# You can configure additional/alternative image files here.\n"); + Print("# (The entries below are default and therefore commented out.)\n"); + Print("\n"); + Print("%s\n", getFormattedSetupEntry("name", "Classic Graphics")); + Print("\n"); + Print("%s\n", getFormattedSetupEntry("sort_priority", "100")); + Print("\n"); for (i = 0; image_config[i].token != NULL; i++) - printf("# %s\n", getFormattedSetupEntry(image_config[i].token, - image_config[i].value)); + Print("# %s\n", getFormattedSetupEntry(image_config[i].token, + image_config[i].value)); exit(0); } else if (strEqual(command, "print soundsinfo.conf")) { - printf("# You can configure additional/alternative sound files here.\n"); - printf("# (The entries below are default and therefore commented out.)\n"); - printf("\n"); - printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds")); - printf("\n"); - printf("%s\n", getFormattedSetupEntry("sort_priority", "100")); - printf("\n"); + Print("# You can configure additional/alternative sound files here.\n"); + Print("# (The entries below are default and therefore commented out.)\n"); + Print("\n"); + Print("%s\n", getFormattedSetupEntry("name", "Classic Sounds")); + Print("\n"); + Print("%s\n", getFormattedSetupEntry("sort_priority", "100")); + Print("\n"); for (i = 0; sound_config[i].token != NULL; i++) - printf("# %s\n", getFormattedSetupEntry(sound_config[i].token, - sound_config[i].value)); + Print("# %s\n", getFormattedSetupEntry(sound_config[i].token, + sound_config[i].value)); exit(0); } else if (strEqual(command, "print musicinfo.conf")) { - printf("# You can configure additional/alternative music files here.\n"); - printf("# (The entries below are default and therefore commented out.)\n"); - printf("\n"); - printf("%s\n", getFormattedSetupEntry("name", "Classic Music")); - printf("\n"); - printf("%s\n", getFormattedSetupEntry("sort_priority", "100")); - printf("\n"); + Print("# You can configure additional/alternative music files here.\n"); + Print("# (The entries below are default and therefore commented out.)\n"); + Print("\n"); + Print("%s\n", getFormattedSetupEntry("name", "Classic Music")); + Print("\n"); + Print("%s\n", getFormattedSetupEntry("sort_priority", "100")); + Print("\n"); for (i = 0; music_config[i].token != NULL; i++) - printf("# %s\n", getFormattedSetupEntry(music_config[i].token, - music_config[i].value)); + Print("# %s\n", getFormattedSetupEntry(music_config[i].token, + music_config[i].value)); exit(0); } else if (strEqual(command, "print editorsetup.conf")) { - printf("# You can configure your personal editor element list here.\n"); - printf("# (The entries below are default and therefore commented out.)\n"); - printf("\n"); + Print("# You can configure your personal editor element list here.\n"); + Print("# (The entries below are default and therefore commented out.)\n"); + Print("\n"); /* this is needed to be able to check element list for cascade elements */ InitElementPropertiesStatic(); @@ -4625,30 +4625,30 @@ void Execute_Command(char *command) } else if (strEqual(command, "print helpanim.conf")) { - printf("# You can configure different element help animations here.\n"); - printf("# (The entries below are default and therefore commented out.)\n"); - printf("\n"); + Print("# You can configure different element help animations here.\n"); + Print("# (The entries below are default and therefore commented out.)\n"); + Print("\n"); for (i = 0; helpanim_config[i].token != NULL; i++) { - printf("# %s\n", getFormattedSetupEntry(helpanim_config[i].token, - helpanim_config[i].value)); + Print("# %s\n", getFormattedSetupEntry(helpanim_config[i].token, + helpanim_config[i].value)); if (strEqual(helpanim_config[i].token, "end")) - printf("#\n"); + Print("#\n"); } exit(0); } else if (strEqual(command, "print helptext.conf")) { - printf("# You can configure different element help text here.\n"); - printf("# (The entries below are default and therefore commented out.)\n"); - printf("\n"); + Print("# You can configure different element help text here.\n"); + Print("# (The entries below are default and therefore commented out.)\n"); + Print("\n"); for (i = 0; helptext_config[i].token != NULL; i++) - printf("# %s\n", getFormattedSetupEntry(helptext_config[i].token, - helptext_config[i].value)); + Print("# %s\n", getFormattedSetupEntry(helptext_config[i].token, + helptext_config[i].value)); exit(0); } @@ -4752,7 +4752,7 @@ void Execute_Command(char *command) // check if there are any displays available if (num_displays < 0) { - printf("No displays available: %s\n", SDL_GetError()); + Print("No displays available: %s\n", SDL_GetError()); exit(-1); } @@ -4762,13 +4762,13 @@ void Execute_Command(char *command) int num_modes = SDL_GetNumDisplayModes(i); int j; - printf("Available display modes for display %d:\n", i); + Print("Available display modes for display %d:\n", i); // check if there are any display modes available for this display if (num_modes < 0) { - printf("No display modes available for display %d: %s\n", - i, SDL_GetError()); + Print("No display modes available for display %d: %s\n", + i, SDL_GetError()); exit(-1); } @@ -4779,13 +4779,13 @@ void Execute_Command(char *command) if (SDL_GetDisplayMode(i, j, &mode) < 0) { - printf("Cannot get display mode %d for display %d: %s\n", - j, i, SDL_GetError()); + Print("Cannot get display mode %d for display %d: %s\n", + j, i, SDL_GetError()); exit(-1); } - printf("- %d x %d\n", mode.w, mode.h); + Print("- %d x %d\n", mode.w, mode.h); } } @@ -4805,7 +4805,7 @@ void Execute_Command(char *command) /* check if there are any modes available */ if (modes == NULL) { - printf("No modes available!\n"); + Print("No modes available!\n"); exit(-1); } @@ -4813,14 +4813,14 @@ void Execute_Command(char *command) /* check if our resolution is restricted */ if (modes == (SDL_Rect **)-1) { - printf("All resolutions available.\n"); + Print("All resolutions available.\n"); } else { - printf("Available display modes:\n"); + Print("Available display modes:\n"); for (i = 0; modes[i]; i++) - printf("- %d x %d\n", modes[i]->w, modes[i]->h); + Print("- %d x %d\n", modes[i]->w, modes[i]->h); } exit(0); @@ -5666,7 +5666,7 @@ void DisplayExitMessage(char *format, va_list ap) sy += 3 * font_height; num_lines_printed = - DrawTextBuffer(sx, sy, program.error_filename, font_2, + DrawTextBuffer(sx, sy, program.log_filename[LOG_ERR_ID], font_2, line_length, line_length, max_lines, 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 660f4df6..56978dcc 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -41,7 +41,8 @@ /* logging functions */ /* ------------------------------------------------------------------------- */ -#define DUPLICATE_LOG_OUTPUT_TO_STDERR TRUE +#define DUPLICATE_LOG_OUT_TO_STDOUT TRUE +#define DUPLICATE_LOG_ERR_TO_STDERR TRUE #if defined(PLATFORM_ANDROID) @@ -93,15 +94,15 @@ static void vprintf_log(char *format, va_list ap) static void vprintf_log_nonewline(char *format, va_list ap) { - FILE *file = program.error_file; + FILE *file = program.log_file[LOG_ERR_ID]; -#if DUPLICATE_LOG_OUTPUT_TO_STDERR - if (file != stderr) +#if DUPLICATE_LOG_ERR_TO_STDERR + if (file != program.log_file_default[LOG_ERR_ID]) { va_list ap2; va_copy(ap2, ap); - vfprintf(stderr, format, ap2); + vfprintf(program.log_file_default[LOG_ERR_ID], format, ap2); va_end(ap2); } @@ -112,17 +113,17 @@ static void vprintf_log_nonewline(char *format, va_list ap) static void vprintf_log(char *format, va_list ap) { - FILE *file = program.error_file; + FILE *file = program.log_file[LOG_ERR_ID]; char *newline = STRING_NEWLINE; -#if DUPLICATE_LOG_OUTPUT_TO_STDERR - if (file != stderr) +#if DUPLICATE_LOG_ERR_TO_STDERR + if (file != program.log_file_default[LOG_ERR_ID]) { va_list ap2; va_copy(ap2, ap); - vfprintf(stderr, format, ap2); - fprintf(stderr, "%s", newline); + vfprintf(program.log_file_default[LOG_ERR_ID], format, ap2); + fprintf(program.log_file_default[LOG_ERR_ID], "%s", newline); va_end(ap2); } @@ -193,6 +194,50 @@ void printf_line_with_prefix(char *prefix, char *line_chars, int line_length) fprintf_line_with_prefix(stdout, prefix, line_chars, line_length); } +static void vPrint(char *format, va_list ap) +{ + FILE *file = program.log_file[LOG_OUT_ID]; + +#if DUPLICATE_LOG_OUT_TO_STDOUT + if (file != program.log_file_default[LOG_OUT_ID]) + { + va_list ap2; + va_copy(ap2, ap); + + vfprintf(program.log_file_default[LOG_OUT_ID], format, ap2); + + va_end(ap2); + } +#endif + + vfprintf(file, format, ap); +} + +void Print(char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vPrint(format, ap); + va_end(ap); +} + +void PrintLine(char *line_chars, int line_length) +{ + int i; + + for (i = 0; i < line_length; i++) + Print(line_chars); + + Print("\n"); +} + +void PrintLineWithPrefix(char *prefix, char *line_chars, int line_length) +{ + Print(prefix); + PrintLine(line_chars, line_length); +} + /* ------------------------------------------------------------------------- */ /* string functions */ @@ -1073,7 +1118,7 @@ void Error(int mode, char *format, ...) static boolean last_line_was_separator = FALSE; char *process_name = ""; - if (program.error_file == NULL) + if (program.log_file[LOG_ERR_ID] == NULL) return; #if defined(PLATFORM_ANDROID) @@ -3485,44 +3530,53 @@ void FreeCustomArtworkLists(struct ArtworkListInfo *artwork_info) /* (now also added for Windows, to create files in user data directory) */ /* ------------------------------------------------------------------------- */ -char *getErrorFilename(char *basename) +char *getLogFilename(char *basename) { return getPath2(getUserGameDataDir(), basename); } -void openErrorFile() +void OpenLogFiles() { + int i; + InitUserDataDirectory(); - if ((program.error_file = fopen(program.error_filename, MODE_WRITE)) == NULL) + for (i = 0; i < NUM_LOGS; i++) { - program.error_file = stderr; + if ((program.log_file[i] = fopen(program.log_filename[i], MODE_WRITE)) + == NULL) + { + program.log_file[i] = program.log_file_default[i]; // reset to default - Error(ERR_WARN, "cannot open file '%s' for writing: %s", - program.error_filename, strerror(errno)); - } + Error(ERR_WARN, "cannot open file '%s' for writing: %s", + program.log_filename[i], strerror(errno)); + } - /* error output should be unbuffered so it is not truncated in a crash */ - setbuf(program.error_file, NULL); + /* output should be unbuffered so it is not truncated in a crash */ + setbuf(program.log_file[i], NULL); + } } -void closeErrorFile() +void CloseLogFiles() { - if (program.error_file != stderr) /* do not close file 'stderr' */ - fclose(program.error_file); + int i; + + for (i = 0; i < NUM_LOGS; i++) + if (program.log_file[i] != program.log_file_default[i]) + fclose(program.log_file[i]); } -void dumpErrorFile() +void DumpLogFile(int nr) { - FILE *error_file = fopen(program.error_filename, MODE_READ); + FILE *log_file = fopen(program.log_filename[nr], MODE_READ); - if (error_file != NULL) - { - while (!feof(error_file)) - fputc(fgetc(error_file), stderr); + if (log_file == NULL) + return; - fclose(error_file); - } + while (!feof(log_file)) + fputc(fgetc(log_file), stdout); + + fclose(log_file); } void NotifyUserAboutErrorFile() @@ -3531,7 +3585,8 @@ void NotifyUserAboutErrorFile() char *title_text = getStringCat2(program.program_title, " Error Message"); char *error_text = getStringCat2("The program was aborted due to an error; " "for details, see the following error file:" - STRING_NEWLINE, program.error_filename); + STRING_NEWLINE, + program.log_filename[LOG_ERR_ID]); MessageBox(NULL, error_text, title_text, MB_OK); #endif diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 32097e0c..f73182d4 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -118,6 +118,10 @@ void fprintf_line_with_prefix(FILE *, char *, char *, int); void printf_line(char *, int); void printf_line_with_prefix(char *, char *, int); +void Print(char *, ...); +void PrintLine(char *, int); +void PrintLineWithPrefix(char *, char *, int); + char *int2str(int, int); char *i_to_a(unsigned int); int log_2(unsigned int); @@ -265,10 +269,11 @@ void LoadArtworkConfig(struct ArtworkListInfo *); void ReloadCustomArtworkList(struct ArtworkListInfo *); void FreeCustomArtworkLists(struct ArtworkListInfo *); -char *getErrorFilename(char *); -void openErrorFile(); -void closeErrorFile(); -void dumpErrorFile(); +char *getLogFilename(char *); +void OpenLogFiles(); +void CloseLogFiles(); +void DumpLogFile(int); + void NotifyUserAboutErrorFile(); #if DEBUG diff --git a/src/libgame/system.c b/src/libgame/system.c index 1088f17c..ecfc7fcc 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -93,8 +93,10 @@ void InitProgramInfo(char *argv0, char *config_filename, program.version_build = VERSION_BUILD(program_version); program.version_ident = program_version; - program.error_filename = getErrorFilename(ERROR_BASENAME); - program.error_file = stderr; + program.log_filename[LOG_OUT_ID] = getLogFilename(LOG_OUT_BASENAME); + program.log_filename[LOG_ERR_ID] = getLogFilename(LOG_ERR_BASENAME); + program.log_file[LOG_OUT_ID] = program.log_file_default[LOG_OUT_ID] = stdout; + program.log_file[LOG_ERR_ID] = program.log_file_default[LOG_ERR_ID] = stderr; } void SetWindowTitle() @@ -135,7 +137,7 @@ void InitPlatformDependentStuff(void) updateUserGameDataDir(); #endif - openErrorFile(); + OpenLogFiles(); #if defined(TARGET_SDL2) int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE; @@ -151,9 +153,7 @@ void InitPlatformDependentStuff(void) void ClosePlatformDependentStuff(void) { -#if defined(PLATFORM_WIN32) - closeErrorFile(); -#endif + CloseLogFiles(); } void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize, diff --git a/src/libgame/system.h b/src/libgame/system.h index b2840a24..2ced4223 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -438,7 +438,12 @@ #define TAPEFILE_EXTENSION "tape" #define SCOREFILE_EXTENSION "score" -#define ERROR_BASENAME "stderr.txt" +#define LOG_OUT_BASENAME "stdout.txt" +#define LOG_ERR_BASENAME "stderr.txt" + +#define LOG_OUT_ID 0 +#define LOG_ERR_ID 1 +#define NUM_LOGS 2 #define STRING_PARENT_DIRECTORY ".." #define STRING_TOP_DIRECTORY "/" @@ -677,8 +682,9 @@ struct ProgramInfo char *cookie_prefix; - char *error_filename; /* filename where to write error messages to */ - FILE *error_file; /* (used instead of 'stderr' on some systems) */ + char *log_filename[NUM_LOGS]; /* log filenames for out/err messages */ + FILE *log_file[NUM_LOGS]; /* log file handles for out/err files */ + FILE *log_file_default[NUM_LOGS]; /* default log file handles (out/err) */ int version_major; int version_minor; diff --git a/src/main.c b/src/main.c index 5bc7e681..683276e9 100644 --- a/src/main.c +++ b/src/main.c @@ -5552,76 +5552,76 @@ struct MusicPrefixInfo music_prefix_info[NUM_MUSIC_PREFIXES + 1] = static void print_usage() { - printf("\n" - "Usage: %s [OPTION]... [HOSTNAME [PORT]]\n" - "\n" - "Options:\n" - " -d, --display HOSTNAME[:SCREEN] specify X server display\n" - " -b, --basepath DIRECTORY alternative base DIRECTORY\n" - " -l, --level DIRECTORY alternative level DIRECTORY\n" - " -g, --graphics DIRECTORY alternative graphics DIRECTORY\n" - " -s, --sounds DIRECTORY alternative sounds DIRECTORY\n" - " -m, --music DIRECTORY alternative music DIRECTORY\n" - " -n, --network network multiplayer game\n" - " --serveronly only start network server\n" - " -v, --verbose verbose mode\n" - " -V, --version show program version\n" - " --debug display debugging information\n" - " -e, --execute COMMAND execute batch COMMAND\n" - "\n" - "Valid commands for '--execute' option:\n" - " \"print graphicsinfo.conf\" print default graphics config\n" - " \"print soundsinfo.conf\" print default sounds config\n" - " \"print musicinfo.conf\" print default music config\n" - " \"print editorsetup.conf\" print default editor config\n" - " \"print helpanim.conf\" print default helpanim config\n" - " \"print helptext.conf\" print default helptext config\n" - " \"dump level FILE\" dump level data from FILE\n" - " \"dump tape FILE\" dump tape data from FILE\n" - " \"autoplay LEVELDIR [NR ...]\" play level tapes for LEVELDIR\n" - " \"convert LEVELDIR [NR]\" convert levels in LEVELDIR\n" - " \"create images DIRECTORY\" write BMP images to DIRECTORY\n" - " \"create CE image DIRECTORY\" write BMP image to DIRECTORY\n" - "\n", - program.command_basename); + Print("\n" + "Usage: %s [OPTION]... [HOSTNAME [PORT]]\n" + "\n" + "Options:\n" + " -d, --display HOSTNAME[:SCREEN] specify X server display\n" + " -b, --basepath DIRECTORY alternative base DIRECTORY\n" + " -l, --level DIRECTORY alternative level DIRECTORY\n" + " -g, --graphics DIRECTORY alternative graphics DIRECTORY\n" + " -s, --sounds DIRECTORY alternative sounds DIRECTORY\n" + " -m, --music DIRECTORY alternative music DIRECTORY\n" + " -n, --network network multiplayer game\n" + " --serveronly only start network server\n" + " -v, --verbose verbose mode\n" + " -V, --version show program version\n" + " --debug display debugging information\n" + " -e, --execute COMMAND execute batch COMMAND\n" + "\n" + "Valid commands for '--execute' option:\n" + " \"print graphicsinfo.conf\" print default graphics config\n" + " \"print soundsinfo.conf\" print default sounds config\n" + " \"print musicinfo.conf\" print default music config\n" + " \"print editorsetup.conf\" print default editor config\n" + " \"print helpanim.conf\" print default helpanim config\n" + " \"print helptext.conf\" print default helptext config\n" + " \"dump level FILE\" dump level data from FILE\n" + " \"dump tape FILE\" dump tape data from FILE\n" + " \"autoplay LEVELDIR [NR ...]\" play level tapes for LEVELDIR\n" + " \"convert LEVELDIR [NR]\" convert levels in LEVELDIR\n" + " \"create images DIRECTORY\" write BMP images to DIRECTORY\n" + " \"create CE image DIRECTORY\" write BMP image to DIRECTORY\n" + "\n", + program.command_basename); } static void print_version() { - printf("%s %d.%d.%d.%d\n", - PROGRAM_TITLE_STRING, - PROGRAM_VERSION_MAJOR, - PROGRAM_VERSION_MINOR, - PROGRAM_VERSION_PATCH, - PROGRAM_VERSION_BUILD); + Print("%s %d.%d.%d.%d\n", + PROGRAM_TITLE_STRING, + PROGRAM_VERSION_MAJOR, + PROGRAM_VERSION_MINOR, + PROGRAM_VERSION_PATCH, + PROGRAM_VERSION_BUILD); if (options.debug) { SDL_version sdl_version; SDL_VERSION(&sdl_version); - printf("- SDL %d.%d.%d\n", - sdl_version.major, - sdl_version.minor, - sdl_version.patch); + Print("- SDL %d.%d.%d\n", + sdl_version.major, + sdl_version.minor, + sdl_version.patch); SDL_IMAGE_VERSION(&sdl_version); - printf("- SDL_image %d.%d.%d\n", - sdl_version.major, - sdl_version.minor, - sdl_version.patch); + Print("- SDL_image %d.%d.%d\n", + sdl_version.major, + sdl_version.minor, + sdl_version.patch); SDL_MIXER_VERSION(&sdl_version); - printf("- SDL_mixer %d.%d.%d\n", - sdl_version.major, - sdl_version.minor, - sdl_version.patch); + Print("- SDL_mixer %d.%d.%d\n", + sdl_version.major, + sdl_version.minor, + sdl_version.patch); SDL_NET_VERSION(&sdl_version); - printf("- SDL_net %d.%d.%d\n", - sdl_version.major, - sdl_version.minor, - sdl_version.patch); + Print("- SDL_net %d.%d.%d\n", + sdl_version.major, + sdl_version.minor, + sdl_version.patch); } } -- 2.34.1