︙ | | |
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
+
|
#if defined(OF_MACOS)
# include <crt_externs.h>
#elif defined(OF_WINDOWS)
# include <windows.h>
extern int _CRT_glob;
extern void __wgetmainargs(int*, wchar_t***, wchar_t***, int, int*);
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif !defined(OF_IOS)
extern char **environ;
#endif
#ifdef OF_PSP
# include <pspkerneltypes.h>
# include <psploadexec.h>
|
︙ | | |
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
-
-
+
+
-
+
|
#ifdef HAVE_SIGACTION
# ifndef SA_RESTART
# define SA_RESTART 0
# endif
#endif
@interface OFApplication ()
- (void)OF_setArgumentCount: (int*)argc
andArgumentValues: (char**[])argv;
- (void)OF_setArgumentCount: (int *)argc
andArgumentValues: (char **[])argv;
#ifdef OF_WINDOWS
- (void)OF_setArgumentCount: (int)argc
andWideArgumentValues: (wchar_t*[])argv;
andWideArgumentValues: (wchar_t *[])argv;
#endif
- (void)OF_run;
@end
static OFApplication *app = nil;
static void
|
︙ | | |
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
-
+
-
+
-
+
-
+
|
return 0;
}
@implementation OFApplication
@synthesize programName = _programName, arguments = _arguments;
@synthesize environment = _environment;
+ (OFApplication*)sharedApplication
+ (OFApplication *)sharedApplication
{
return app;
}
+ (OFString*)programName
+ (OFString *)programName
{
return [app programName];
}
+ (OFArray*)arguments
+ (OFArray *)arguments
{
return [app arguments];
}
+ (OFDictionary*)environment
+ (OFDictionary *)environment
{
return [app environment];
}
+ (void)terminate
{
[self terminateWithStatus: EXIT_SUCCESS];
|
︙ | | |
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
-
+
|
sceKernelExitGame();
OF_UNREACHABLE
#endif
}
#ifdef OF_HAVE_SANDBOX
+ (void)activateSandbox: (OFSandbox*)sandbox
+ (void)activateSandbox: (OFSandbox *)sandbox
{
[app activateSandbox: sandbox];
}
#endif
- init
{
|
︙ | | |
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
-
-
+
+
|
{
[_arguments release];
[_environment release];
[super dealloc];
}
- (void)OF_setArgumentCount: (int*)argc
andArgumentValues: (char***)argv
- (void)OF_setArgumentCount: (int *)argc
andArgumentValues: (char ***)argv
{
#ifndef OF_WINDOWS
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
of_string_encoding_t encoding;
_argc = argc;
|
︙ | | |
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
-
+
-
-
+
+
-
+
-
+
|
_argc = argc;
_argv = argv;
#endif
}
#ifdef OF_WINDOWS
- (void)OF_setArgumentCount: (int)argc
andWideArgumentValues: (wchar_t**)argv
andWideArgumentValues: (wchar_t **)argv
{
void *pool = objc_autoreleasePoolPush();
OFMutableArray *arguments;
if (argc > 0) {
_programName = [[OFString alloc] initWithUTF16String: argv[0]];
arguments = [[OFMutableArray alloc] init];
for (int i = 1; i < argc; i++)
[arguments addObject:
[OFString stringWithUTF16String: argv[i]]];
[arguments makeImmutable];
_arguments = arguments;
}
objc_autoreleasePoolPop(pool);
}
#endif
- (void)getArgumentCount: (int**)argc
andArgumentValues: (char****)argv
- (void)getArgumentCount: (int **)argc
andArgumentValues: (char ****)argv
{
*argc = _argc;
*argv = _argv;
}
- (id <OFApplicationDelegate>)delegate
{
return _delegate;
}
- (void)setDelegate: (id <OFApplicationDelegate>)delegate
{
#ifdef HAVE_SIGACTION
struct sigaction sa = { .sa_flags = SA_RESTART };
sigemptyset(&sa.sa_mask);
# define REGISTER_SIGNAL(sig) \
if ([delegate respondsToSelector: \
@selector(applicationDidReceive##sig)]) { \
_##sig##Handler = (void(*)(id, SEL))[(id)delegate \
_##sig##Handler = (void (*)(id, SEL))[(id)delegate \
methodForSelector: \
@selector(applicationDidReceive##sig)]; \
\
sa.sa_handler = handle##sig; \
} else \
sa.sa_handler = SIG_DFL; \
\
OF_ENSURE(sigaction(sig, &sa, NULL) == 0);
#else
# define REGISTER_SIGNAL(sig) \
if ([delegate respondsToSelector: \
@selector(applicationDidReceive##sig)]) { \
_##sig##Handler = (void(*)(id, SEL))[(id)delegate \
_##sig##Handler = (void (*)(id, SEL))[(id)delegate \
methodForSelector: \
@selector(applicationDidReceive##sig)]; \
signal(sig, handle##sig); \
} else \
signal(sig, SIG_DFL);
#endif
|
︙ | | |
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
-
+
|
{
[[self class] terminateWithStatus: status];
OF_UNREACHABLE
}
#ifdef OF_HAVE_SANDBOX
- (void)activateSandbox: (OFSandbox*)sandbox
- (void)activateSandbox: (OFSandbox *)sandbox
{
# ifdef OF_HAVE_PLEDGE
void *pool = objc_autoreleasePoolPush();
const char *promises = [[sandbox pledgeString]
cStringWithEncoding: [OFLocalization encoding]];
if (pledge(promises, NULL) != 0)
|
︙ | | |