Enumerations | Functions | Variables

toplev.cc File Reference

#include <cassert>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <new>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include "cmd-edit.h"
#include "cmd-hist.h"
#include "file-ops.h"
#include "lo-error.h"
#include "lo-mappers.h"
#include "oct-env.h"
#include "oct-locbuf.h"
#include "quit.h"
#include "singleton-cleanup.h"
#include "str-vec.h"
#include "defaults.h"
#include "defun.h"
#include "error.h"
#include "file-io.h"
#include "graphics.h"
#include "input.h"
#include "lex.h"
#include "oct-conf.h"
#include "oct-hist.h"
#include "oct-map.h"
#include "oct-obj.h"
#include "ov.h"
#include "pager.h"
#include "parse.h"
#include "pathsearch.h"
#include "procstream.h"
#include "pt-eval.h"
#include "pt-jump.h"
#include "pt-stmt.h"
#include "sighandlers.h"
#include "sysdep.h"
#include "syswait.h"
#include "toplev.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"
#include "version.h"
Include dependency graph for toplev.cc:

Go to the source code of this file.

Enumerations

enum  system_exec_type { et_sync, et_async }

Functions

void clean_up_and_exit (int retval)
 DEFALIAS (exit, quit)
 DEFUN (system, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} system (\"@var{string}\")\n\ @deftypefnx {Built-in Function} {} system (\"@var{string}\", @var{return_output})\n\ @deftypefnx {Built-in Function} {} system (\"@var{string}\", @var{return_output}, @var{type})\n\ @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} system (@dots{})\n\ Execute a shell command specified by @var{string}.\n\ If the optional argument @var{type} is \"async\", the process\n\ is started in the background and the process ID of the child process\n\ is returned immediately. Otherwise, the child process is started and\n\ Octave waits until it exits. If the @var{type} argument is omitted, it\n\ defaults to the value \"sync\".\n\ \n\ If @var{system} is called with one or more output arguments, or if the\n\ optional argument @var{return_output} is true and the subprocess is started\n\ synchronously, then the output from the command is returned as a variable. \n\ Otherwise, if the subprocess is executed synchronously, its output is sent\n\ to the standard output. To send the output of a command executed with\n\ @code{system} through the pager, use a command like\n\ \n\ @example\n\ @group\n\ [output, text] = system (\"cmd\");\n\ disp (text);\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ or\n\ \n\ @example\n\ printf (\"%s\\n\", nthargout (2, \"system\", \"cmd\"));\n\ @end example\n\ \n\ The @code{system} function can return two values. The first is the\n\ exit status of the command and the second is any output from the\n\ command that was written to the standard output stream. For example,\n\ \n\ @example\n\ [status, output] = system (\"echo foo; exit 2\");\n\ @end example\n\ \n\ @noindent\n\ will set the variable @code{output} to the string @samp{foo}, and the\n\ variable @code{status} to the integer @samp{2}.\n\ \n\ For commands run asynchronously, @var{status} is the process id of the\n\ command shell that is started to run the command.\n\ @seealso{unix, dos}\n\ @end deftypefn")
 DEFUN (quit, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} exit (@var{status})\n\ @deftypefnx {Built-in Function} {} quit (@var{status})\n\ Exit the current Octave session. If the optional integer value\n\ @var{status} is supplied, pass that value to the operating system as the\n\ Octave's exit status. The default value is zero.\n\ @end deftypefn")
 DEFUN (warranty,,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} warranty ()\n\ Describe the conditions for copying and distributing Octave.\n\ @end deftypefn")
 DEFUN (atexit, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} atexit (@var{fcn})\n\ @deftypefnx {Built-in Function} {} atexit (@var{fcn}, @var{flag})\n\ Register a function to be called when Octave exits. For example,\n\ \n\ @example\n\ @group\n\ function last_words ()\n\ disp (\"Bye bye\");\n\ endfunction\n\ atexit (\"last_words\");\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ will print the message \"Bye bye\" when Octave exits.\n\ \n\ The additional argument @var{flag} will register or unregister\n\ @var{fcn} from the list of functions to be called when Octave\n\ exits. If @var{flag} is true, the function is registered, and if\n\ @var{flag} is false, it is unregistered. For example,\n\ after registering the function @code{last_words} above,\n\ \n\ @example\n\ atexit (\"last_words\", false);\n\ @end example\n\ \n\ @noindent\n\ will remove the function from the list and Octave will not call\n\ @code{last_words} when it exits.\n\ \n\ Note that @code{atexit} only removes the first occurrence of a function\n\ from the list, so if a function was placed in the list multiple\n\ times with @code{atexit}, it must also be removed from the list\n\ multiple times.\n\ @end deftypefn")
 DEFUN (octave_config_info, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} octave_config_info ()\n\ @deftypefnx {Built-in Function} {} octave_config_info (@var{option})\n\ Return a structure containing configuration and installation\n\ information for Octave.\n\ \n\ If @var{option} is a string, return the configuration information for the\n\ specified option.\n\ \n\ @end deftypefn")
void do_octave_atexit (void)
int main_loop (void)
void octave_add_atexit_function (const std::string &fname)
bool octave_remove_atexit_function (const std::string &fname)
void recover_from_exception (void)
static octave_value_list run_command_and_return_output (const std::string &cmd_str)
static int wait_for_input (int fid)

Variables

static const charbt_fieldnames []
static const octave_fields bt_fields (bt_fieldnames)
int exit_status = 0
tree_statement_listglobal_command = 0
std::list< std::string > octave_atexit_functions
void(* octave_exit )(int) = ::exit
bool octave_initialized = false
bool octave_interpreter_ready = false
bool quit_allowed = true
bool quitting_gracefully = false

Enumeration Type Documentation

Enumerator:
et_sync 
et_async 

Definition at line 825 of file toplev.cc.


Function Documentation

void clean_up_and_exit ( int  retval  ) 

Definition at line 668 of file toplev.cc.

References do_octave_atexit(), and octave_exit.

Referenced by execute_eval_option_code(), main_loop(), octave_main(), and safe_source_file().

DEFALIAS ( exit  ,
quit   
)
DEFUN ( system  ,
args  ,
nargout   
)
DEFUN ( quit  ,
args   
)
DEFUN ( warranty   ) 

Definition at line 720 of file toplev.cc.

References octave_stdout.

DEFUN ( atexit  ,
args  ,
nargout   
)
DEFUN ( octave_config_info  ,
args   
)
void do_octave_atexit ( void   ) 
int main_loop ( void   ) 
void octave_add_atexit_function ( const std::string &  fname  ) 

Definition at line 1102 of file toplev.cc.

References octave_atexit_functions.

Referenced by DEFUN().

bool octave_remove_atexit_function ( const std::string &  fname  ) 

Definition at line 1108 of file toplev.cc.

References octave_atexit_functions.

Referenced by DEFUN().

void recover_from_exception ( void   ) 
static octave_value_list run_command_and_return_output ( const std::string &  cmd_str  )  [static]
static int wait_for_input ( int  fid  )  [static]

Definition at line 751 of file toplev.cc.

Referenced by run_command_and_return_output().


Variable Documentation

const char* bt_fieldnames[] [static]
Initial value:
 { "file", "name", "line",
    "column", "scope", "context", 0 }

Definition at line 254 of file toplev.cc.

Definition at line 88 of file toplev.cc.

Referenced by execute_eval_option_code(), and safe_source_file().

Definition at line 98 of file toplev.cc.

Referenced by get_debug_input().

std::list<std::string> octave_atexit_functions
void(* octave_exit)(int) = ::exit

Definition at line 80 of file toplev.cc.

Referenced by clean_up_and_exit().

Definition at line 92 of file toplev.cc.

Referenced by execute_pkg_add_or_del(), and octave_main().

Definition at line 83 of file toplev.cc.

Referenced by DEFUN(), octave_main(), and octave_oncleanup::~octave_oncleanup().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines