UFO: Alien Invasion
Loading...
Searching...
No Matches
android_system.cpp
Go to the documentation of this file.
1
5
6
/*
7
Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24
*/
25
26
#include <unistd.h>
27
#include <sys/time.h>
28
#include <stdlib.h>
29
#include <sys/stat.h>
30
#include <sys/types.h>
31
#include <pwd.h>
32
#include <dlfcn.h>
33
#include <fcntl.h>
34
#include <locale.h>
35
#include <signal.h>
36
#include <dirent.h>
37
38
#include "
../../common/common.h
"
39
#include "
../system.h
"
40
41
#include <android/log.h>
42
#include "
../android/android_debugger.h
"
43
44
const
char
*
Sys_GetCurrentUser
(
void
)
45
{
46
char
*
user
= getenv(
"USER"
);
47
if
(
user
)
48
return
user
;
49
return
"Player"
;
50
}
51
57
void
Sys_Error
(
const
char
*error, ...)
58
{
59
va_list argptr;
60
char
string
[1024];
61
62
Sys_Backtrace
();
63
64
#ifdef COMPILE_UFO
65
Com_BreakIntoDebugger
();
66
Sys_ConsoleShutdown
();
67
#endif
68
69
#ifdef COMPILE_MAP
70
Mem_Shutdown
();
71
#endif
72
73
va_start(argptr,error);
74
Q_vsnprintf
(
string
,
sizeof
(
string
), error, argptr);
75
va_end(argptr);
76
77
__android_log_print(ANDROID_LOG_FATAL,
"UFOAI"
,
"Error: %s"
,
string
);
78
79
exit(1);
80
}
81
86
void
Sys_Quit
(
void
)
87
{
88
#ifdef COMPILE_UFO
89
CL_Shutdown
();
90
Qcommon_Shutdown
();
91
Sys_ConsoleShutdown
();
92
#elif COMPILE_MAP
93
Mem_Shutdown
();
94
#endif
95
96
exit(0);
97
}
98
102
void
Sys_Backtrace
(
void
)
103
{
104
#ifdef COMPILE_UFO
105
Com_BreakIntoDebugger
();
106
#endif
107
108
const
char
*dumpFile =
"crashdump.txt"
;
109
FILE
*file =
Sys_Fopen
(dumpFile,
"w"
);
110
FILE
*crash = file !=
nullptr
? file : stderr;
111
112
fprintf(crash,
"======start======\n"
);
113
114
fprintf(crash,
BUILDSTRING
", cpu: "
CPUSTRING
", version: "
UFO_VERSION
"\n\n"
);
115
fflush(crash);
116
117
androidDumpBacktrace
(crash);
118
119
fprintf(crash,
"======end========\n"
);
120
121
if
(file !=
nullptr
)
122
fclose(file);
123
}
Sys_ConsoleShutdown
void Sys_ConsoleShutdown(void)
Definition
android_console.cpp:36
androidDumpBacktrace
void androidDumpBacktrace(FILE *out)
Definition
android_debugger.cpp:21
android_debugger.h
Sys_Backtrace
void Sys_Backtrace(void)
On platforms supporting it, print a backtrace.
Definition
android_system.cpp:102
Sys_Error
void Sys_Error(const char *error,...)
Errors out of the game.
Definition
android_system.cpp:57
Sys_Quit
void Sys_Quit(void)
Definition
android_system.cpp:86
Sys_GetCurrentUser
const char * Sys_GetCurrentUser(void)
Definition
android_system.cpp:44
CL_Shutdown
void CL_Shutdown(void)
Saves configuration file and shuts the client systems down.
Definition
cl_main.cpp:1219
Com_BreakIntoDebugger
void Com_BreakIntoDebugger(void)
Definition
common.cpp:512
Qcommon_Shutdown
void Qcommon_Shutdown(void)
Definition
common.cpp:1555
common.h
definitions common between client and server, but not game lib
CPUSTRING
#define CPUSTRING
Definition
common.h:109
UFO_VERSION
#define UFO_VERSION
Definition
common.h:36
BUILDSTRING
#define BUILDSTRING
Definition
common.h:121
Mem_Shutdown
void Mem_Shutdown(void)
Definition
mem.cpp:518
Q_vsnprintf
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
Definition
shared.cpp:535
system.h
System specific stuff.
Sys_Fopen
FILE * Sys_Fopen(const char *filename, const char *mode)
Definition
unix_files.cpp:240
FILE
#define FILE
Definition
test_webapi.cpp:30
user
static const char * user
Definition
test_webapi.cpp:35
src
ports
android
android_system.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.16.1