23 #if defined (HAVE_CONFIG_H)
36 #if defined (HAVE_TERMIOS_H)
38 #elif defined (HAVE_TERMIO_H)
40 #elif defined (HAVE_SGTTY_H)
44 #if defined (HAVE_CONIO_H)
48 #if defined (HAVE_SYS_IOCTL_H)
49 # include <sys/ioctl.h>
52 #if defined (HAVE_FLOATINGPOINT_H)
53 # include <floatingpoint.h>
56 #if defined (HAVE_IEEEFP_H)
60 #if defined (HAVE_OMP_H)
92 #if ! defined (STDIN_FILENO)
93 # define STDIN_FILENO 1
96 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
100 # if defined (HAVE_FLOATINGPOINT_H)
102 # if ! defined (FP_X_DNML)
105 fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP));
110 #if defined (__MINGW32__) || defined (_MSC_VER)
112 #define WIN32_LEAN_AND_MEAN
114 #include <tlhelp32.h>
115 #include <shellapi.h>
118 w32_set_octave_home (
void)
122 HANDLE
h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE
123 #
if defined (TH32CS_SNAPMODULE32)
124 | TH32CS_SNAPMODULE32
128 if (h != INVALID_HANDLE_VALUE)
130 MODULEENTRY32 mod_info;
132 ZeroMemory (&mod_info,
sizeof (mod_info));
133 mod_info.dwSize =
sizeof (mod_info);
135 if (Module32First (h, &mod_info))
141 if (mod_name.find (
"octinterp") != std::string::npos)
143 bin_dir = mod_info.szExePath;
144 if (bin_dir[bin_dir.length () - 1] !=
'\\')
145 bin_dir.append (1,
'\\');
149 while (Module32Next (h, &mod_info));
155 if (! bin_dir.empty ())
157 size_t pos = bin_dir.rfind (
"\\bin\\");
159 if (pos != std::string::npos)
167 w32_set_octave_home ();
186 #if defined (__MINGW32__) || defined (_MSC_VER)
188 typedef HRESULT (WINAPI *SETCURRENTAPPID)(PCWSTR AppID);
190 HMODULE hShell = LoadLibrary (
"shell32.dll");
194 SETCURRENTAPPID pfnSetCurrentProcessExplicitAppUserModelID =
195 reinterpret_cast<SETCURRENTAPPID
> (GetProcAddress (hShell,
196 "SetCurrentProcessExplicitAppUserModelID"));
198 if (pfnSetCurrentProcessExplicitAppUserModelID)
199 pfnSetCurrentProcessExplicitAppUserModelID (L
"gnu.octave");
201 FreeLibrary (hShell);
213 if (
args.length () != 1)
216 std::string file =
args(0).xstring_value (
"__open_with_system_app__: argument must be a filename");
220 #if defined (OCTAVE_USE_WINDOWS_API)
221 HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
225 retval = (
reinterpret_cast<ptrdiff_t
> (status) > 32);
226 #elif defined (__APPLE__)
228 =
Fsystem (
ovl (
"open " + file +
" 2> /dev/null",
232 retval = (
tmp(0).double_value () == 0);
235 =
Fsystem (
ovl (
"xdg-open " + file +
" 2> /dev/null",
239 retval = (
tmp(0).double_value () == 0);
245 #if defined (__MINGW32__)
253 #if defined (_MSC_VER)
266 #if defined (OCTAVE_USE_WINDOWS_API)
270 const char *f1 = file1.c_str ();
271 const char *f2 = file2.c_str ();
273 bool f1_is_dir = GetFileAttributes (f1) & FILE_ATTRIBUTE_DIRECTORY;
274 bool f2_is_dir = GetFileAttributes (f2) & FILE_ATTRIBUTE_DIRECTORY;
279 DWORD share = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;
282 = CreateFile (f1, 0, share, 0, OPEN_EXISTING,
283 f1_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
285 if (hfile1 != INVALID_HANDLE_VALUE)
288 = CreateFile (f2, 0, share, 0, OPEN_EXISTING,
289 f2_is_dir ? FILE_FLAG_BACKUP_SEMANTICS : 0, 0);
291 if (hfile2 != INVALID_HANDLE_VALUE)
293 BY_HANDLE_FILE_INFORMATION hfi1;
294 BY_HANDLE_FILE_INFORMATION hfi2;
296 if (GetFileInformationByHandle (hfile1, &hfi1)
297 && GetFileInformationByHandle (hfile2, &hfi2))
299 retval = (hfi1.dwVolumeSerialNumber == hfi2.dwVolumeSerialNumber
300 && hfi1.nFileIndexHigh == hfi2.nFileIndexHigh
301 && hfi1.nFileIndexLow == hfi2.nFileIndexLow);
304 CloseHandle (hfile2);
307 CloseHandle (hfile1);
319 return (fs_file1 && fs_file2
320 && fs_file1.
ino () == fs_file2.
ino ()
321 && fs_file1.
dev () == fs_file2.
dev ());
332 #if defined (HAVE_OMP_GET_NUM_THREADS)
333 omp_get_num_threads ();
336 #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
338 #elif defined (__MINGW32__)
340 #elif defined (_MSC_VER)
348 #if defined (OCTAVE_USE_WINDOWS_API)
350 SetProcessShutdownParameters (0x280, SHUTDOWN_NORETRY);
369 static bool curr_on =
false;
374 if (octave::application::interactive ()
375 && ! octave::application::forced_interactive ())
376 error (
"stdin is not a tty!");
382 #if defined (HAVE_TERMIOS_H)
385 static struct termios save_term;
391 tcgetattr (tty_fd, &s);
402 s.c_lflag &= ~(ICANON |
ECHO | ECHOE | ECHOK | ECHONL);
403 s.c_oflag |= (OPOST | ONLCR);
405 s.c_oflag &= ~(OCRNL);
408 s.c_oflag &= ~(ONOCR);
411 s.c_oflag &= ~(ONLRET);
413 s.c_cc[VMIN] = wait ? 1 : 0;
423 tcsetattr (tty_fd, wait ? TCSAFLUSH : TCSADRAIN, &s);
425 #elif defined (HAVE_TERMIO_H)
428 static struct termio save_term;
434 ioctl (tty_fd, TCGETA, &s);
445 s.c_lflag &= ~(ICANON |
ECHO | ECHOE | ECHOK | ECHONL);
446 s.c_oflag |= (OPOST | ONLCR);
448 s.c_oflag &= ~(OCRNL);
451 s.c_oflag &= ~(ONOCR);
454 s.c_oflag &= ~(ONLRET);
456 s.c_cc[VMIN] = wait ? 1 : 0;
465 ioctl (tty_fd, TCSETAW, &s);
467 #elif defined (HAVE_SGTTY_H)
470 static struct sgttyb save_term;
476 ioctl (tty_fd, TIOCGETP, &s);
487 s.sg_flags |= CBREAK;
488 s.sg_flags &= ~(
ECHO);
497 ioctl (tty_fd, TIOCSETN, &s);
512 #if defined (__MINGW32__) || defined (_MSC_VER)
513 if (mode && mode[0] && ! mode[1])
520 return _popen (command, tmode);
523 return _popen (command, mode);
525 return popen (command, mode);
532 #if defined (__MINGW32__) || defined (_MSC_VER)
544 #if defined (HAVE__KBHIT) && defined (HAVE__GETCH)
551 c = (! _kbhit ()) ? 0 : _getch ();
565 int c = std::cin.get ();
567 if (std::cin.fail () || std::cin.eof ())
582 #if defined (OCTAVE_USE_WINDOWS_API)
586 #if defined (P_tmpdir)
594 if (retval.empty () || retval ==
"\\")
607 #elif defined (P_tmpdir)
625 bool skip_redisplay =
true;
650 if (
args.length () != 1)
676 if (nargin < 1 || nargin > 2)
682 ?
args(1).xstring_value (
"setenv: VALUE must be a string")
710 if (
args.length () != 1)
756 if (octave::application::interactive ())
765 char s[2] = {
static_cast<char> (
c),
'\0' };
813 double dval =
args(0).double_value ();
816 warning (
"pause: NaN is an invalid delay");
870 DEFUN (native_float_format, , ,
914 if (
args.length () != 1)
937 DEFUN (get_home_directory, , ,
963 DEFUN (have_window_system, , ,
OCTINTERP_API void octave_sleep(double seconds)
For example cd octave end example noindent changes the current working directory to file
string_vector xstring_vector_value(const char *fmt,...) const
static void putenv(const std::string &name, const std::string &value)
FILE * octave_popen(const char *command, const char *mode)
void raw_mode(bool on, bool wait)
int octave_pclose(FILE *f)
OCTINTERP_API void print_usage(void)
void set_application_id(void)
identity matrix If supplied two scalar respectively For allows like xample val
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
int octave_kbhit(bool wait)
OCTINTERP_API octave_value_list Fdrawnow(const octave_value_list &=octave_value_list(), int=0)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
octave::mach_info::float_format flt_fmt
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any simply delete all the lines from the buffer before leaving the editor When invoked with no edit the previously executed command
void sysdep_cleanup(void)
static std::string tilde_expand(const std::string &)
static std::string getenv(const std::string &name)
OCTINTERP_API octave_value_list Fsystem(const octave_value_list &=octave_value_list(), int=0)
#define DEFALIAS(alias, name)
nd deftypefn *std::string name
int octave_isatty_wrapper(int fd)
static std::string get_home_directory(void)
bool same_file_internal(const std::string &file1, const std::string &file2)
return ovl(octave::sys::env::getenv(name))
void warn_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
bool is_cellstr(void) const
end example noindent will set var
static bool prefer_env_winsize(bool)
interrupt_handler ignore_interrupts(void)
static std::string float_format_as_string(float_format)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
dim_vector dims(void) const
static float_format native_float_format(void)
void warning(const char *fmt,...)
defaults to zero A value of zero computes the digamma a value the trigamma and so on The digamma function is defined
int octave_unsetenv_wrapper(const char *name)
static bool display_available(void)
interrupt_handler set_interrupt_handler(const volatile interrupt_handler &h, bool restart_syscalls)
std::string get_P_tmpdir(void)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
static void clear_screen(bool skip_redisplay=false)