version 1.1, 2021/05/27 20:31:43 |
version 1.2, 2021/05/27 20:44:14 |
|
|
#include <math.h> |
#include <math.h> |
#include <limits.h> |
#include <limits.h> |
#include "platform.h" |
#include "platform.h" |
|
#if defined(__OpenBSD__) |
|
#include <unistd.h> // For pledge() and unveil() |
|
#endif |
|
|
|
|
// Expanding a macro as a string constant requires two levels of macros |
// Expanding a macro as a string constant requires two levels of macros |
#define _str(x) #x |
#define _str(x) #x |
#define STRINGIFY(x) _str(x) |
#define STRINGIFY(x) _str(x) |
Line 84 int main(int argc, char *argv[]) |
|
Line 88 int main(int argc, char *argv[]) |
|
|
|
int i; |
int i; |
for (i = 1; i < argc; i++) { |
for (i = 1; i < argc; i++) { |
|
#if defined(__OpenBSD__) |
|
if (strcmp(argv[i], "--box") == 0) { |
|
if (i + 1 < argc) { |
|
if ( unveil("/usr","r")==-1 ) { |
|
perror("Unveil failure. Aborting."); |
|
exit (1); |
|
} |
|
if ( unveil(argv[i + 1],"rwc")==-1 ) { |
|
perror("Unveil failure. Aborting."); |
|
exit(1); |
|
} |
|
if ( chdir(argv[i+1])==-1 ) { |
|
perror("Could not change directory."); |
|
exit(1); |
|
} |
|
if ( pledge("stdio rpath wpath cpath fattr flock " |
|
"getpw id tty proc", NULL )==-1 ) { |
|
perror("Pledge failure. Aborting."); |
|
exit (1); |
|
} |
|
i++; |
|
continue; |
|
} |
|
} |
|
#endif // OpenBSD |
if (strcmp(argv[i], "--scores") == 0) { |
if (strcmp(argv[i], "--scores") == 0) { |
// just dump the scores and quit! |
// just dump the scores and quit! |
dumpScores(); |
dumpScores(); |