/* * Apple // emulator for *ix * * This software package is subject to the GNU General Public License * version 3 or later (your choice) as published by the Free Software * Foundation. * * Copyright 1994 Alexander Jean-Claude Bottema * Copyright 1995 Stephen Lee * Copyright 1997, 1998 Aaron Culliney * Copyright 1998, 1999, 2000 Michael Deutschmann * Copyright 2013-2015 Aaron Culliney * */ #include "common.h" #include #define SAVE_MAGICK "A2VM" #define SAVE_MAGICK2 "A2V2" #define SAVE_VERSION 2 #define SAVE_MAGICK_LEN sizeof(SAVE_MAGICK) typedef struct module_ctor_node_s { struct module_ctor_node_s *next; long order; startup_callback_f ctor; } module_ctor_node_s; static module_ctor_node_s *head = NULL; static bool emulatorShuttingDown = false; const char *data_dir = NULL; char **argv = NULL; int argc = 0; const char *locale = NULL; CrashHandler_s *crashHandler = NULL; static void _init_common(void) { #if defined(CONFIG_DATADIR) assert(!data_dir); data_dir = STRDUP(CONFIG_DATADIR PATH_SEPARATOR PACKAGE_NAME); #elif MOBILE_DEVICE // data_dir handled elsewhere ... #else assert(!data_dir); char buf[PAGE_SIZE]; snprintf(buf, PAGE_SIZE, "%s/.apple2", HOMEDIR); data_dir = STRDUP(buf); #endif assert((uintptr_t)data_dir); mkdir(data_dir, (S_IRWXU|S_IRWXG)); log_init(); srandom((unsigned int)time(NULL)); LOG("Initializing common..."); } static __attribute__((constructor)) void __init_common(void) { emulator_registerStartupCallback(CTOR_PRIORITY_FIRST, &_init_common); } #if defined(CONFIG_DATADIR) static void _cli_help(void) { fprintf(stderr, "\n"); fprintf(stderr, "Usage: %s [-A