35 #if defined (HAVE_CONFIG_H)
46 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
62 #if ! defined (OCTAVE_VERSION)
63 # define OCTAVE_VERSION %OCTAVE_VERSION%
66 #if ! defined (OCTAVE_ARCHLIBDIR)
67 # define OCTAVE_ARCHLIBDIR %OCTAVE_ARCHLIBDIR%
70 #if ! defined (OCTAVE_BINDIR)
71 # define OCTAVE_BINDIR %OCTAVE_BINDIR%
74 #if ! defined (OCTAVE_PREFIX)
75 # define OCTAVE_PREFIX %OCTAVE_PREFIX%
78 #if ! defined (OCTAVE_EXEC_PREFIX)
79 # define OCTAVE_EXEC_PREFIX %OCTAVE_EXEC_PREFIX%
86 #if defined (HAVE_OCTAVE_QT_GUI) && ! defined (OCTAVE_USE_WINDOWS_API)
204 #if defined (OCTAVE_USE_WINDOWS_API)
208 std::cerr << argv[0] <<
": failed to exec '" << file <<
"'" << std::endl;
220 char *tmp =
new char [
len+1];
221 tmp = strcpy (tmp, s);
225 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
228 wmain (
int argc,
wchar_t **wargv)
230 static char **argv =
new char * [argc + 1];
231 std::vector<std::string> argv_str;
234 std::wstring_convert<std::codecvt_utf8<wchar_t>,
wchar_t> wchar_conv;
235 for (
int i_arg = 0; i_arg < argc; i_arg++)
236 argv_str.push_back (wchar_conv.to_bytes (wargv[i_arg]));
239 for (
int i_arg = 0; i_arg < argc; i_arg++)
240 argv[i_arg] = &argv_str[i_arg][0];
241 argv[argc] =
nullptr;
252 bool start_gui =
false;
253 bool gui_libs =
true;
255 bool eval_code =
false;
256 bool persist_octave =
false;
262 std::string octave_cli
264 std::string octave_gui = octave_archlibdir +
dir_sep_char +
"octave-gui";
266 #if defined (HAVE_OCTAVE_QT_GUI)
271 std::string file = octave_gui;
273 std::string file = octave_cli;
278 static char **new_argv =
new char * [argc + 2];
283 bool warn_display =
true;
284 bool no_display =
false;
299 int old_optind = next_optind;
324 new_argv[k++] = argv[old_optind];
334 idx_gui = old_optind;
340 new_argv[k++] = argv[old_optind];
348 persist_octave =
true;
349 new_argv[k++] = argv[old_optind];
354 new_argv[k++] = argv[old_optind];
359 for (
int i = old_optind; i < next_optind; i++)
360 new_argv[k++] = argv[i];
365 warn_display =
false;
366 new_argv[k++] = argv[old_optind];
372 new_argv[k++] = argv[old_optind];
376 for (
int i = old_optind; i < next_optind; i++)
377 new_argv[k++] = argv[i];
383 if (next_optind < argc)
386 for (
int i = next_optind; i < argc; i++)
387 new_argv[k++] = argv[i];
390 if (start_gui && eval_code && ! persist_octave)
402 std::cerr <<
"octave: conflicting options: --no-gui-libs and --gui"
409 std::cerr <<
"octave: conflicting options: --server and --gui"
414 #if ! defined (HAVE_OCTAVE_QT_GUI)
415 std::cerr <<
"octave: GUI features missing or disabled in this build"
422 for (
int j = k; j > 1; j--)
423 new_argv[j] = new_argv[j-1];
425 new_argv[1] = argv[idx_gui];
429 new_argv[k] =
nullptr;
438 else if (gui_libs || start_gui)
453 if (! display_check_err_msg)
454 display_check_err_msg =
"graphical display unavailable";
456 std::cerr <<
"octave: " << display_check_err_msg << std::endl;
457 std::cerr <<
"octave: disabling GUI features" << std::endl;
462 #if defined (OCTAVE_USE_WINDOWS_API)
466 new_argv[0] =
strsave (file.c_str ());
495 std::cerr <<
"octave: fork failed!" << std::endl;
505 std::cerr <<
"octave: error calling setsid!" << std::endl;
542 std::cerr <<
"octave exited with signal "
554 std::cerr << argv[0] <<
": " << std::strerror (errno) << std::endl;
void octave_unblock_async_signals(void)
void octave_block_async_signals(void)
const char * display_available(int *dpy_avail)
int octave_getopt_long_wrapper(int argc, char **argv, const char *shortopts, const struct octave_getopt_options *longopts, int *longind)
int octave_optind_wrapper(void)
int octave_set_opterr_wrapper(int val)
#define OCTAVE_ARCHLIBDIR
static bool fork_and_exec
static void gui_driver_set_signal_handler(const char *signame, octave_sig_handler *handler)
static char * strsave(const char *s)
static void gui_driver_sig_handler(int sig)
static std::string get_octave_archlibdir(void)
int main(int argc, char **argv)
static void install_signal_handlers(void)
static int octave_exec(const std::string &file, char **argv)
static std::string get_octave_bindir(void)
T::size_type strlen(const typename T::value_type *str)
static const char * short_opts
#define NO_GUI_LIBS_OPTION
#define EXPERIMENTAL_TERMINAL_WIDGET_OPTION
struct octave_getopt_options long_opts[]
static void set_octave_home(void)
static std::string prepend_octave_exec_home(const std::string &s)
static const char dir_sep_char
static std::string octave_getenv(const std::string &name)
void octave_block_signal_by_name(const char *signame)
void octave_unblock_signal_by_name(const char *signame)
int octave_kill_wrapper(pid_t pid, int signum)
octave_sig_handler * octave_set_signal_handler_by_name(const char *signame, octave_sig_handler *handler, bool restart_syscalls)
void octave_sig_handler(int)
pid_t octave_setsid_wrapper(void)
pid_t octave_fork_wrapper(void)
int octave_execv_wrapper(const char *file, char *const *argv)
pid_t octave_waitpid_wrapper(pid_t pid, int *statusp, int options)
bool octave_wifsignaled_wrapper(int status)
int octave_wexitstatus_wrapper(int status)
bool octave_wifexited_wrapper(int status)
int octave_wtermsig_wrapper(int status)