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>
|
|
|
|
|
|
|
|
typedef struct OpenFile {
|
|
|
|
FILE *f; /* stdio ptr for read/write */
|
|
|
|
FILE *f2; /* additional ptr for rw pipes */
|
|
|
|
int mode; /* mode flags */
|
|
|
|
int pid; /* child's pid (for pipes) */
|
|
|
|
int lineno; /* number of lines read */
|
|
|
|
char *path; /* pathname for file */
|
2003-04-14 05:04:43 -04:00
|
|
|
void (*finalize) _((struct OpenFile*,int)); /* finalize proc */
|
2004-02-25 07:17:39 -05:00
|
|
|
long refcnt;
|
1999-08-13 01:45:20 -04:00
|
|
|
} OpenFile;
|
|
|
|
|
|
|
|
#define FMODE_READABLE 1
|
|
|
|
#define FMODE_WRITABLE 2
|
|
|
|
#define FMODE_READWRITE 3
|
|
|
|
#define FMODE_BINMODE 4
|
|
|
|
#define FMODE_SYNC 8
|
2002-02-06 23:18:08 -05:00
|
|
|
#define FMODE_WBUF 16
|
2002-10-02 10:59:25 -04:00
|
|
|
#define FMODE_RBUF 32
|
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;\
|
1999-08-13 01:45:20 -04:00
|
|
|
fp = RFILE(obj)->fptr = ALLOC(OpenFile);\
|
|
|
|
fp->f = fp->f2 = NULL;\
|
|
|
|
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;\
|
1999-08-13 01:45:20 -04:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define GetReadFile(fptr) ((fptr)->f)
|
|
|
|
#define GetWriteFile(fptr) (((fptr)->f2) ? (fptr)->f2 : (fptr)->f)
|
|
|
|
|
|
|
|
FILE *rb_fopen _((const char*, const char*));
|
|
|
|
FILE *rb_fdopen _((int, const char*));
|
|
|
|
int rb_getc _((FILE*));
|
2002-08-15 22:52:25 -04:00
|
|
|
long rb_io_fread _((char *, long, FILE *));
|
2002-12-20 04:29:41 -05:00
|
|
|
long rb_io_fwrite _((const char *, long, FILE *));
|
1999-08-13 01:45:20 -04:00
|
|
|
int rb_io_mode_flags _((const char*));
|
|
|
|
void rb_io_check_writable _((OpenFile*));
|
|
|
|
void rb_io_check_readable _((OpenFile*));
|
2004-04-06 22:51:05 -04:00
|
|
|
int rb_io_fptr_finalize _((OpenFile*));
|
1999-09-20 03:14:18 -04:00
|
|
|
void rb_io_synchronized _((OpenFile*));
|
1999-08-13 01:45:20 -04:00
|
|
|
void rb_io_check_closed _((OpenFile*));
|
2002-10-02 10:13:58 -04:00
|
|
|
int rb_io_wait_readable _((int));
|
|
|
|
int rb_io_wait_writable _((int));
|
2000-11-10 02:16:52 -05:00
|
|
|
|
|
|
|
VALUE rb_io_taint_check _((VALUE));
|
2004-08-11 21:56:25 -04:00
|
|
|
NORETURN(void rb_eof_error _((void)));
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2000-01-31 22:18:03 -05:00
|
|
|
void rb_read_check _((FILE*));
|
2000-01-17 03:37:53 -05:00
|
|
|
int rb_read_pending _((FILE*));
|
1999-08-13 01:45:20 -04:00
|
|
|
#endif
|