*/ int main(int argc, char **argv) /* ***********************************************************************/ { char *cmd; // Parse command line arguments. Done early. May affect REBOL boot. Parse_Args(argc, argv, &Main_Args); Print_Str("REBOL 3.0\n"); REBOL_Init(&Main_Args); // Evaluate user input: while (TRUE) { cmd = Prompt_User(); REBOL_Do_String(cmd); if (!IS_UNSET(DS_TOP)) { //if (DSP > 0) { if (!IS_ERROR(DS_TOP)) { Prin("== "); Print_Value(DS_TOP, 0, TRUE); } else Print_Value(DS_TOP, 0, FALSE); //} } //DS_DROP; // result } return 0; }
REBOOL Host_Start_Exiting(int *exit_status, int argc, REBCHR **argv) { REBYTE vers[8]; REBINT startup_rc; REBYTE *embedded_script = NULL; REBI64 embedded_size = 0; Host_Lib = &Host_Lib_Init; embedded_script = OS_Read_Embedded(&embedded_size); // !!! Note we may have to free Main_Args.home_dir below after this Parse_Args(argc, argv, &Main_Args); vers[0] = 5; // len RL_Version(&vers[0]); // Must be done before an console I/O can occur. Does not use reb-lib, // so this device should open even if there are other problems. Open_StdIO(); // also sets up interrupt handler // Initialize the REBOL library (reb-lib): if (!CHECK_STRUCT_ALIGN) Host_Crash("Incompatible struct alignment"); if (!Host_Lib) Host_Crash("Missing host lib"); // !!! Second part will become vers[2] < RL_REV on release!!! if (vers[1] != RL_VER || vers[2] != RL_REV) Host_Crash("Incompatible reb-lib DLL"); startup_rc = RL_Init(&Main_Args, Host_Lib); // !!! Not a good abstraction layer here, but Parse_Args may have put // an OS_ALLOC'd string into home_dir, via OS_Get_Current_Dir if (Main_Args.home_dir) OS_FREE(Main_Args.home_dir); if (startup_rc == 1) Host_Crash("Host-lib wrong size"); if (startup_rc == 2) Host_Crash("Host-lib wrong version/checksum"); //Initialize core extension commands Init_Core_Ext(); #ifdef TEST_EXTENSIONS Init_Ext_Test(); #endif #ifdef TO_WINDOWS // no console, we must be the child process if (GetStdHandle(STD_OUTPUT_HANDLE) == 0) { App_Instance = GetModuleHandle(NULL); } #ifdef REB_CORE else //use always the console for R3/core { // GetWindowsLongPtr support 32 & 64 bit windows App_Instance = (HINSTANCE)GetWindowLongPtr(GetConsoleWindow(), GWLP_HINSTANCE); } #else //followinng R3/view code behaviors when compiled as: //-"console app" mode: stdio redirection works but blinking console window during start //-"GUI app" mode stdio redirection doesn't work properly, no blinking console window during start else if (argc > 1) // we have command line args
int main(int argc, char **argv) #endif { REBYTE vers[8]; REBYTE *line; REBINT n; const char *env_always_malloc = NULL; REBYTE *embedded_script = NULL; REBI64 embedded_size = 0; #ifdef TO_WIN32 // In Win32 get args manually: // Fetch the win32 unicoded program arguments: argv = (char **)CommandLineToArgvW(GetCommandLineW(), &argc); #endif Host_Lib = &Host_Lib_Init; env_always_malloc = getenv("R3_ALWAYS_MALLOC"); if (env_always_malloc != NULL) { always_malloc = atoi(env_always_malloc); } embedded_script = OS_Read_Embedded(&embedded_size); Parse_Args(argc, (REBCHR **)argv, &Main_Args); vers[0] = 5; // len RL_Version(&vers[0]); // Must be done before an console I/O can occur. Does not use reb-lib, // so this device should open even if there are other problems. Open_StdIO(); // also sets up interrupt handler // Initialize the REBOL library (reb-lib): if (!CHECK_STRUCT_ALIGN) Host_Crash("Incompatible struct alignment"); if (!Host_Lib) Host_Crash("Missing host lib"); // !!! Second part will become vers[2] < RL_REV on release!!! if (vers[1] != RL_VER || vers[2] != RL_REV) Host_Crash("Incompatible reb-lib DLL"); n = RL_Init(&Main_Args, Host_Lib); if (n == 1) Host_Crash("Host-lib wrong size"); if (n == 2) Host_Crash("Host-lib wrong version/checksum"); //Initialize core extension commands Init_Core_Ext(); #ifdef EXT_LICENSING Init_Licensing_Ext(); #endif //EXT_LICENSING #ifdef TEST_EXTENSIONS Init_Ext_Test(); #endif #ifdef TO_WIN32 // no console, we must be the child process if (GetStdHandle(STD_OUTPUT_HANDLE) == 0) { App_Instance = GetModuleHandle(NULL); } #ifdef REB_CORE else //use always the console for R3/core { // GetWindowsLongPtr support 32 & 64 bit windows App_Instance = (HINSTANCE)GetWindowLongPtr(GetConsoleWindow(), GWLP_HINSTANCE); } #else //followinng R3/view code behaviors when compiled as: //-"console app" mode: stdio redirection works but blinking console window during start //-"GUI app" mode stdio redirection doesn't work properly, no blinking console window during start else if (argc > 1) // we have command line args