2000-05-01 05:42:38 -04:00
|
|
|
/**********************************************************************
|
1999-08-13 01:45:20 -04:00
|
|
|
|
|
|
|
rubyio.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
created at: Fri Nov 12 16:47:09 JST 1993
|
|
|
|
|
2003-01-16 02:34:03 -05:00
|
|
|
Copyright (C) 1993-2003 Yukihiro Matsumoto
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
**********************************************************************/
|
1999-08-13 01:45:20 -04:00
|
|
|
|
* intern.h: add prototypes.
rb_gc_enable(), rb_gc_disable(), rb_gc_start(), rb_str_new5()
rb_str_buf_append(), rb_str_buf_cat(), rb_str_buf_cat2(),
rb_str_dup_frozen()
* ruby.h: added declaration.
rb_defout, rb_stdin, rb_stdout, rb_stderr, ruby_errinfo
* rubyio.h: changed double include guard macro to RUBYIO_H.
* array.c (inspect_call): make static.
* eval.c (dvar_asgn): ditto.
* io.c (rb_io_close_read): ditto.
* lex.c (rb_reserved_word): ditto.
* ruby.c: (req_list_head, req_list_last): ditto.
* ruby.c (require_libraries): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-12-17 02:52:35 -05:00
|
|
|
#ifndef RUBYIO_H
|
|
|
|
#define RUBYIO_H
|
1999-08-13 01:45:20 -04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2004-11-19 11:59:11 -05:00
|
|
|
#if defined(HAVE_STDIO_EXT_H)
|
|
|
|
#include <stdio_ext.h>
|
|
|
|
#endif
|
|
|
|
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
typedef struct rb_io_t {
|
2004-12-08 08:26:27 -05:00
|
|
|
int fd; /* file descriptor */
|
|
|
|
FILE *stdio_file; /* stdio ptr for read/write if available */
|
1999-08-13 01:45:20 -04:00
|
|
|
int mode; /* mode flags */
|
* configure.in (pid_t, uid_t, gid_t): check if defined.
* intern.h, process.c, rubyio.h, ext/etc/etc.c, ext/pty/pty.c: use
rb_{pid,uid,gid}_t instead of plain int. [ruby-dev:30376]
* ext/etc/extconf.rb (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM,
NUM2GIDT): moved to configure.in.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-17 23:11:57 -05:00
|
|
|
rb_pid_t pid; /* child's pid (for pipes) */
|
1999-08-13 01:45:20 -04:00
|
|
|
int lineno; /* number of lines read */
|
|
|
|
char *path; /* pathname for file */
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
void (*finalize)(struct rb_io_t*,int); /* finalize proc */
|
2004-02-25 07:17:39 -05:00
|
|
|
long refcnt;
|
2004-12-08 08:26:27 -05:00
|
|
|
char *wbuf; /* wbuf_off + wbuf_len <= wbuf_capa */
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
int wbuf_off;
|
|
|
|
int wbuf_len;
|
|
|
|
int wbuf_capa;
|
2004-12-08 08:26:27 -05:00
|
|
|
char *rbuf; /* rbuf_off + rbuf_len <= rbuf_capa */
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
int rbuf_off;
|
|
|
|
int rbuf_len;
|
|
|
|
int rbuf_capa;
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
} rb_io_t;
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2007-02-24 20:16:58 -05:00
|
|
|
#define HAVE_RB_IO_T 1
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
#define FMODE_READABLE 1
|
|
|
|
#define FMODE_WRITABLE 2
|
|
|
|
#define FMODE_READWRITE 3
|
2004-10-06 03:40:06 -04:00
|
|
|
#define FMODE_APPEND 64
|
2004-10-17 22:29:43 -04:00
|
|
|
#define FMODE_CREATE 128
|
1999-08-13 01:45:20 -04:00
|
|
|
#define FMODE_BINMODE 4
|
|
|
|
#define FMODE_SYNC 8
|
2005-02-07 09:18:41 -05:00
|
|
|
#define FMODE_TTY 16
|
2004-12-23 05:12:35 -05:00
|
|
|
#define FMODE_DUPLEX 32
|
2005-07-17 21:00:23 -04:00
|
|
|
#define FMODE_WSPLIT 0x200
|
|
|
|
#define FMODE_WSPLIT_INITIALIZED 0x400
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2000-11-10 02:16:52 -05:00
|
|
|
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
|
1999-08-13 01:45:20 -04:00
|
|
|
|
|
|
|
#define MakeOpenFile(obj, fp) do {\
|
2001-10-03 03:19:19 -04:00
|
|
|
if (RFILE(obj)->fptr) {\
|
|
|
|
rb_io_close(obj);\
|
|
|
|
free(RFILE(obj)->fptr);\
|
|
|
|
RFILE(obj)->fptr = 0;\
|
|
|
|
}\
|
2000-03-23 03:37:35 -05:00
|
|
|
fp = 0;\
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
fp->fd = -1;\
|
2004-12-08 08:26:27 -05:00
|
|
|
fp->stdio_file = NULL;\
|
1999-08-13 01:45:20 -04:00
|
|
|
fp->mode = 0;\
|
|
|
|
fp->pid = 0;\
|
|
|
|
fp->lineno = 0;\
|
|
|
|
fp->path = NULL;\
|
|
|
|
fp->finalize = 0;\
|
2004-02-25 07:17:39 -05:00
|
|
|
fp->refcnt = 1;\
|
* rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
Use own buffering mechanism instead of stdio.
* io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
EOF flag removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-06 03:40:30 -05:00
|
|
|
fp->wbuf = NULL;\
|
|
|
|
fp->wbuf_off = 0;\
|
|
|
|
fp->wbuf_len = 0;\
|
|
|
|
fp->wbuf_capa = 0;\
|
|
|
|
fp->rbuf = NULL;\
|
|
|
|
fp->rbuf_off = 0;\
|
|
|
|
fp->rbuf_len = 0;\
|
|
|
|
fp->rbuf_capa = 0;\
|
1999-08-13 01:45:20 -04:00
|
|
|
} while (0)
|
|
|
|
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
FILE *rb_io_stdio_file(rb_io_t *fptr);
|
1999-08-13 01:45:20 -04:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
FILE *rb_fopen(const char*, const char*);
|
|
|
|
FILE *rb_fdopen(int, const char*);
|
|
|
|
int rb_io_mode_flags(const char*);
|
|
|
|
int rb_io_modenum_flags(int);
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
void rb_io_check_writable(rb_io_t*);
|
|
|
|
void rb_io_check_readable(rb_io_t*);
|
|
|
|
int rb_io_fptr_finalize(rb_io_t*);
|
|
|
|
void rb_io_synchronized(rb_io_t*);
|
|
|
|
void rb_io_check_initialized(rb_io_t*);
|
|
|
|
void rb_io_check_closed(rb_io_t*);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
int rb_io_wait_readable(int);
|
|
|
|
int rb_io_wait_writable(int);
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
void rb_io_set_nonblock(rb_io_t *fptr);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
|
|
|
|
VALUE rb_io_taint_check(VALUE);
|
|
|
|
NORETURN(void rb_eof_error(void));
|
|
|
|
|
* file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
renamed from OpenFile.
* ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
ext/readline/readline.c, ext/socket/socket.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:30:50 -05:00
|
|
|
void rb_io_read_check(rb_io_t*);
|
|
|
|
int rb_io_read_pending(rb_io_t*);
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
void rb_read_check(FILE*);
|
|
|
|
|
|
|
|
DEPRECATED(int rb_getc(FILE*));
|
|
|
|
DEPRECATED(long rb_io_fread(char *, long, FILE *));
|
|
|
|
DEPRECATED(long rb_io_fwrite(const char *, long, FILE *));
|
|
|
|
DEPRECATED(int rb_read_pending(FILE*));
|
1999-08-13 01:45:20 -04:00
|
|
|
#endif
|