Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
app_hooks.cpp File Reference
#include "precompiled.h"
#include "lib/app_hooks.h"
#include "lib/sysdep/sysdep.h"
#include <cstdio>
Include dependency graph for app_hooks.cpp:

Macros

#define OVERRIDE_IF_NONZERO(HOOKNAME)   if(new_ah->HOOKNAME) ah.HOOKNAME = new_ah->HOOKNAME;
 

Functions

static const OsPathdef_get_log_dir ()
 
static void def_bundle_logs (FILE *f)
 
static ErrorReactionInternal def_display_error (const wchar_t *text, size_t flags)
 
void app_hooks_update (AppHooks *new_ah)
 update the app hook function pointers. More...
 
bool app_hook_was_redefined (size_t offset_in_struct)
 was the app hook changed via app_hooks_update from its default value? More...
 
const OsPathah_get_log_dir ()
 return path to directory into which crash dumps should be written. More...
 
void ah_bundle_logs (FILE *f)
 gather all app-related logs/information and write it to file. More...
 
ErrorReactionInternal ah_display_error (const wchar_t *text, size_t flags)
 display an error dialog, thus overriding sys_display_error. More...
 

Variables

static AppHooks ah
 
static AppHooks default_ah = ah
 

Macro Definition Documentation

◆ OVERRIDE_IF_NONZERO

#define OVERRIDE_IF_NONZERO (   HOOKNAME)    if(new_ah->HOOKNAME) ah.HOOKNAME = new_ah->HOOKNAME;

Function Documentation

◆ ah_bundle_logs()

void ah_bundle_logs ( FILE *  f)

gather all app-related logs/information and write it to file.

used when writing a crash log so that all relevant info is in one file.

the default implementation attempts to gather 0ad data, but is fail-safe (doesn't complain if file not found).

Parameters
ffile into which to write.

◆ ah_display_error()

ErrorReactionInternal ah_display_error ( const wchar_t *  text,
size_t  flags 
)

display an error dialog, thus overriding sys_display_error.

Parameters
texterror message.
flagssee DebugDisplayErrorFlags.
Returns
ErrorReactionInternal.

the default implementation just returns ERI_NOT_IMPLEMENTED, which causes the normal sys_display_error to be used.

◆ ah_get_log_dir()

const OsPath & ah_get_log_dir ( )

return path to directory into which crash dumps should be written.

must be callable at any time - in particular, before VFS init. paths are typically relative to sys_ExecutablePathname.

Returns
path ending with directory separator (e.g. '/').

◆ app_hook_was_redefined()

bool app_hook_was_redefined ( size_t  offset_in_struct)

was the app hook changed via app_hooks_update from its default value?

Parameters
offset_in_structbyte offset within AppHooks (determined via offsetof) of the app hook function pointer.

◆ app_hooks_update()

void app_hooks_update ( AppHooks ah)

update the app hook function pointers.

Parameters
ahAppHooks struct. any of its function pointers that are non-zero override the previous function pointer value (these default to the stub hooks which are functional but basic).

◆ def_bundle_logs()

static void def_bundle_logs ( FILE *  f)
static

◆ def_display_error()

static ErrorReactionInternal def_display_error ( const wchar_t *  text,
size_t  flags 
)
static

◆ def_get_log_dir()

static const OsPath & def_get_log_dir ( )
static

Variable Documentation

◆ ah

AppHooks ah
static
Initial value:
=
{
}
static const OsPath & def_get_log_dir()
Definition: app_hooks.cpp:35
static ErrorReactionInternal def_display_error(const wchar_t *text, size_t flags)
Definition: app_hooks.cpp:49
static void def_bundle_logs(FILE *f)
Definition: app_hooks.cpp:44

◆ default_ah

AppHooks default_ah = ah
static