31 #if defined (HAVE_CONFIG_H)
37 #include <sys/types.h>
40 #if defined (__WIN32__) && ! defined (__CYGWIN__)
44 #if defined (OCTAVE_USE_WINDOWS_API)
79 return access (nm, mode);
85 #if defined (OCTAVE_USE_WINDOWS_API)
87 int status = _wchdir (wnm);
104 #if defined (HAVE_CTERMID)
114 return dup2 (fd1, fd2);
117 #if defined (__WIN32__) && ! defined (__CYGWIN__)
151 #define SHELL_SPECIAL_CHARS \
152 "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
154 #define SHELL_SPACE_CHARS \
155 " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
158 prepare_spawn (
char *
const *argv)
165 for (argc = 0; argv[argc] != NULL; argc++)
169 new_argv = (
char **)
malloc (argc + 1);
172 for (i = 0; i < argc; i++)
174 const char *
string = argv[i];
176 if (
string[0] ==
'\0')
177 new_argv[i] = strdup (
"\"\"");
178 else if (strpbrk (
string, SHELL_SPECIAL_CHARS) != NULL)
180 int quote_around = (strpbrk (
string, SHELL_SPACE_CHARS) != NULL);
182 unsigned int backslashes;
191 for (s =
string; *s !=
'\0'; s++)
195 length += backslashes + 1;
203 length += backslashes + 1;
211 for (s =
string; *s !=
'\0'; s++)
217 for (j = backslashes + 1; j > 0; j--)
229 for (j = backslashes; j > 0; j--)
235 new_argv[i] = quoted_string;
238 new_argv[i] = strdup (
string);
241 new_argv[argc] = NULL;
251 #if defined (__WIN32__) && ! defined (__CYGWIN__)
253 char **sanitized_argv = prepare_spawn (argv);
255 int status = spawnv (P_OVERLAY, file, sanitized_argv);
259 char **p = sanitized_argv;
262 free (sanitized_argv);
268 return execv (file, argv);
276 return execvp (file, argv);
282 #if defined (HAVE_FORK)
292 return ftruncate (fd, sz);
298 #if defined (OCTAVE_USE_WINDOWS_API)
299 wchar_t *tmp = _wgetcwd (NULL, 0);
325 #if defined (HAVE_GETEGID)
335 #if defined (HAVE_GETEUID)
345 #if defined (HAVE_GETGID)
355 return gethostname (nm,
len);
361 #if defined (HAVE_GETPGRP)
371 #if defined (HAVE_GETPID)
381 #if defined (HAVE_GETPPID)
391 #if defined (HAVE_GETUID)
407 return link (nm1, nm2);
419 #if defined (OCTAVE_USE_WINDOWS_API)
421 int status = _wrmdir (wnm);
432 #if defined (HAVE_SETSID)
448 return STDOUT_FILENO;
460 #if defined (OCTAVE_USE_WINDOWS_API)
462 int status = _wunlink (wnm);
473 #if defined (HAVE_VFORK)
483 #if defined (HAVE_FORK)
493 #if defined (HAVE_VFORK)
static octave_idx_type link(octave_idx_type s, octave_idx_type t, octave_idx_type *pp)
pid_t getpgrp(std::string &msg)
int symlink(const std::string &old_name, const std::string &new_name)
int rmdir(const std::string &name)
int execvp(const std::string &file, const string_vector &argv)
int chdir(const std::string &path_arg)
int dup2(int old_fd, int new_fd)
int unlink(const std::string &name)
pid_t fork(std::string &msg)
pid_t vfork(std::string &msg)
T::size_type strlen(const typename T::value_type *str)
octave_value::octave_value(const Array< char > &chm, char type) return retval
wchar_t * u8_to_wchar(const char *u8)
char * u8_from_wchar(const wchar_t *wc)
int octave_access_f_ok(void)
pid_t octave_setsid_wrapper(void)
gid_t octave_getgid_wrapper(void)
uid_t octave_geteuid_wrapper(void)
int octave_ftruncate_wrapper(int fd, off_t sz)
int octave_gethostname_wrapper(char *nm, size_t len)
int octave_rmdir_wrapper(const char *nm)
pid_t octave_fork_wrapper(void)
pid_t octave_getpgrp_wrapper(void)
pid_t octave_getppid_wrapper(void)
int octave_access_r_ok(void)
bool octave_have_vfork(void)
int octave_execvp_wrapper(const char *file, char *const *argv)
gid_t octave_getegid_wrapper(void)
int octave_execv_wrapper(const char *file, char *const *argv)
pid_t octave_getpid_wrapper(void)
int octave_close_wrapper(int fd)
int octave_access_wrapper(const char *nm, int mode)
int octave_unlink_wrapper(const char *nm)
int octave_chdir_wrapper(const char *nm)
int octave_symlink_wrapper(const char *nm1, const char *nm2)
uid_t octave_getuid_wrapper(void)
int octave_access_x_ok(void)
int octave_link_wrapper(const char *nm1, const char *nm2)
int octave_access_w_ok(void)
const char * octave_ctermid_wrapper(void)
int octave_stdout_fileno(void)
char * octave_getcwd_wrapper(char *nm, size_t len)
pid_t octave_vfork_wrapper(void)
int octave_isatty_wrapper(int fd)
bool octave_have_fork(void)
int octave_dup2_wrapper(int fd1, int fd2)
int octave_stdin_fileno(void)
int octave_pipe_wrapper(int *fd)