2000-05-01 13:42:38 +04:00
|
|
|
/**********************************************************************
|
1999-08-13 09:45:20 +04:00
|
|
|
|
|
|
|
rubyio.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
created at: Fri Nov 12 16:47:09 JST 1993
|
|
|
|
|
2000-01-05 07:41:21 +03:00
|
|
|
Copyright (C) 1993-2000 Yukihiro Matsumoto
|
1999-08-13 09:45:20 +04:00
|
|
|
|
2000-05-01 13:42:38 +04:00
|
|
|
**********************************************************************/
|
1999-08-13 09:45:20 +04:00
|
|
|
|
|
|
|
#ifndef IO_H
|
|
|
|
#define IO_H
|
|
|
|
|
|
|
|
#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 */
|
|
|
|
void (*finalize)(); /* finalize proc */
|
|
|
|
} OpenFile;
|
|
|
|
|
|
|
|
#define FMODE_READABLE 1
|
|
|
|
#define FMODE_WRITABLE 2
|
|
|
|
#define FMODE_READWRITE 3
|
|
|
|
#define FMODE_BINMODE 4
|
|
|
|
#define FMODE_SYNC 8
|
|
|
|
|
|
|
|
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(obj)->fptr)
|
|
|
|
|
|
|
|
#define MakeOpenFile(obj, fp) do {\
|
2000-03-23 11:37:35 +03:00
|
|
|
fp = 0;\
|
1999-08-13 09: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;\
|
|
|
|
} 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*));
|
|
|
|
int rb_io_mode_flags _((const char*));
|
|
|
|
void rb_io_check_writable _((OpenFile*));
|
|
|
|
void rb_io_check_readable _((OpenFile*));
|
|
|
|
void rb_io_fptr_finalize _((OpenFile*));
|
1999-09-20 11:14:18 +04:00
|
|
|
void rb_io_synchronized _((OpenFile*));
|
1999-08-13 09:45:20 +04:00
|
|
|
void rb_io_check_closed _((OpenFile*));
|
|
|
|
void rb_eof_error _((void));
|
|
|
|
|
2000-02-01 06:18:03 +03:00
|
|
|
void rb_read_check _((FILE*));
|
2000-01-17 11:37:53 +03:00
|
|
|
int rb_read_pending _((FILE*));
|
1999-08-13 09:45:20 +04:00
|
|
|
#endif
|