comparison src/file-io.cc @ 5749:26beffa9f66f

[project @ 2006-04-07 20:35:07 by jwe]
author jwe
date Fri, 07 Apr 2006 20:35:08 +0000
parents ab9a339fcec8
children ace8d8d26933
comparison
equal deleted inserted replaced
5748:8510034588a7 5749:26beffa9f66f
1991 retval(0) = status; 1991 retval(0) = status;
1992 1992
1993 return retval; 1993 return retval;
1994 } 1994 }
1995 1995
1996 void 1996 static octave_value
1997 symbols_of_file_io (void) 1997 const_value (const char *nm, const octave_value_list& args, int val)
1998 { 1998 {
1999 octave_value retval;
2000
2001 int nargin = args.length ();
2002
2003 if (nargin == 0)
2004 retval = val;
2005 else
2006 print_usage (nm);
2007
2008 return retval;
2009 }
2010
1999 #if ! defined (P_tmpdir) 2011 #if ! defined (P_tmpdir)
2000 #define P_tmpdir "/tmp" 2012 #define P_tmpdir "/tmp"
2001 #endif 2013 #endif
2002 2014
2003 DEFCONSTX ("P_tmpdir", SBV_P_tmpdir, P_tmpdir, 2015 DEFUNX ("P_tmpdir", FP_tmpdir, args, ,
2004 "-*- texinfo -*-\n\ 2016 "-*- texinfo -*-\n\
2005 @defvr {Built-in Constant} P_tmpdir\n\ 2017 @deftypefn {Built-in Function} {} P_tmpdir ()\n\
2006 The default name of the directory for temporary files on this system.\n\ 2018 Return the default name of the directory for temporary files on\n\
2007 The value of this variable is system dependent.\n\ 2019 this system. The name of this directory is system dependent.\n\
2008 @end defvr"); 2020 @end deftypefn")
2009 2021 {
2010 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be 2022 octave_value retval;
2011 // this way for Matlab compatibility. 2023
2012 2024 int nargin = args.length ();
2013 DEFCONSTX ("SEEK_SET", SBV_SEEK_SET, -1, 2025
2014 "-*- texinfo -*-\n\ 2026 if (nargin == 0)
2015 @defvr {Built-in Constant} SEEK_SET\n\ 2027 retval = P_tmpdir;
2016 @defvrx {Built-in Constant} SEEK_CUR\n\ 2028 else
2017 @defvrx {Built-in Constant} SEEK_END\n\ 2029 print_usage ("P_tmpdir");
2018 These variables may be used as the optional third argument for the\n\ 2030
2019 function @code{fseek}.\n\ 2031 return retval;
2020 \n\ 2032 }
2033
2034 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be
2035 // this way for Matlab compatibility.
2036
2037 DEFUNX ("SEEK_SET", FSEEK_SET, args, ,
2038 "-*- texinfo -*-\n\
2039 @deftypefn {Built-in Function} {} SEEK_SET ()\n\
2040 @deftypefnx {Built-in Function} {} SEEK_CUR ()\n\
2041 @deftypefnx {Built-in Function} {} SEEK_END ()\n\
2042 Return the value required to request that @code{fseek} perform\n\
2043 one of the following actions:\n\
2021 @table @code\n\ 2044 @table @code\n\
2022 @item SEEK_SET\n\ 2045 @item SEEK_SET\n\
2023 Position file relative to the beginning.\n\ 2046 Position file relative to the beginning.\n\
2024 \n\ 2047 \n\
2025 @item SEEK_CUR\n\ 2048 @item SEEK_CUR\n\
2026 Position file relative to the current position.\n\ 2049 Position file relative to the current position.\n\
2027 \n\ 2050 \n\
2028 @item SEEK_END\n\ 2051 @item SEEK_END\n\
2029 used with fseek to position file relative to the end.\n\ 2052 Position file relative to the end.\n\
2030 @end table\n\ 2053 @end table\n\
2031 @end defvr"); 2054 @end deftypefn")
2032 2055 {
2033 DEFCONSTX ("SEEK_CUR", SBV_SEEK_CUR, 0, 2056 return const_value ("SEEK_SET", args, -1);
2034 "-*- texinfo -*-\n\ 2057 }
2035 @defvr {Built-in Constant} SEEK_CUR\n\ 2058
2059 DEFUNX ("SEEK_CUR", FSEEK_CUR, args, ,
2060 "-*- texinfo -*-\n\
2061 @deftypefn {Built-in Function} {} SEEK_CUR ()\n\
2036 See SEEK_SET.\n\ 2062 See SEEK_SET.\n\
2037 @end defvr"); 2063 @end deftypefn")
2038 2064 {
2039 DEFCONSTX ("SEEK_END", SBV_SEEK_END, 1, 2065 return const_value ("SEEK_CUR", args, 0);
2040 "-*- texinfo -*-\n\ 2066 }
2041 @defvr {Built-in Constant} SEEK_END\n\ 2067
2068 DEFUNX ("SEEK_END", FSEEK_END, args, ,
2069 "-*- texinfo -*-\n\
2070 @deftypefn {Built-in Function} {} SEEK_END ()\n\
2042 See SEEK_SET.\n\ 2071 See SEEK_SET.\n\
2043 @end defvr"); 2072 @end deftypefn")
2044 2073 {
2045 DEFCONSTX ("stdin", SBV_stdin, stdin_file, 2074 return const_value ("SEEK_END", args, 1);
2046 "-*- texinfo -*-\n\ 2075 }
2047 @defvr {Built-in Constant} stdin\n\ 2076
2048 The standard input stream (file id 0). When Octave is used\n\ 2077 static octave_value
2049 interactively, this is filtered through the command line editing\n\ 2078 const_value (const char *nm, const octave_value_list& args,
2050 functions.\n\ 2079 const octave_value& val)
2080 {
2081 octave_value retval;
2082
2083 int nargin = args.length ();
2084
2085 if (nargin == 0)
2086 retval = val;
2087 else
2088 print_usage (nm);
2089
2090 return retval;
2091 }
2092
2093 DEFUNX ("stdin", Fstdin, args, ,
2094 "-*- texinfo -*-\n\
2095 @deftypefn {Built-in Function} {} stdin ()\n\
2096 Return the numeric value corresponding to the standard input stream.\n\
2097 When Octave is used interactively, this is filtered through the command\n\
2098 line editing functions.\n\
2051 @seealso{stdout, stderr}\n\ 2099 @seealso{stdout, stderr}\n\
2052 @end defvr"); 2100 @end deftypefn")
2053 2101 {
2054 DEFCONSTX ("stdout", SBV_stdout, stdout_file, 2102 return const_value ("stdin", args, stdin_file);
2055 "-*- texinfo -*-\n\ 2103 }
2056 @defvr {Built-in Constant} stdout\n\ 2104
2057 The standard output stream (file id 1). Data written to the\n\ 2105 DEFUNX ("stdout", Fstdout, args, ,
2058 standard output is normally filtered through the pager.\n\ 2106 "-*- texinfo -*-\n\
2107 @deftypefn {Built-in Function} {} stdout ()\n\
2108 Return the numeric value corresponding to the standard output stream.\n\
2109 Data written to the standard output is normally filtered through the pager.\n\
2059 @seealso{stdin, stderr}\n\ 2110 @seealso{stdin, stderr}\n\
2060 @end defvr"); 2111 @end deftypefn")
2061 2112 {
2062 DEFCONSTX ("stderr", SBV_stderr, stderr_file, 2113 return const_value ("stdout", args, stdout_file);
2063 "-*- texinfo -*-\n\ 2114 }
2064 @defvr {Built-in Constant} stderr\n\ 2115
2065 The standard error stream (file id 2). Even if paging is turned on,\n\ 2116 DEFUNX ("stderr", Fstderr, args, ,
2066 the standard error is not sent to the pager. It is useful for error\n\ 2117 "-*- texinfo -*-\n\
2067 messages and prompts.\n\ 2118 @deftypefn {Built-in Function} {} stderr ()\n\
2119 Return the numeric value corresponding to the standard error stream.\n\
2120 Even if paging is turned on, the standard error is not sent to the\n\
2121 pager. It is useful for error messages and prompts.\n\
2068 @seealso{stdin, stdout}\n\ 2122 @seealso{stdin, stdout}\n\
2069 @end defvr"); 2123 @end deftypefn")
2070 2124 {
2125 return const_value ("stderr", args, stderr_file);
2071 } 2126 }
2072 2127
2073 /* 2128 /*
2074 ;;; Local Variables: *** 2129 ;;; Local Variables: ***
2075 ;;; mode: C++ *** 2130 ;;; mode: C++ ***