~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to include/ruby/io.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
 
 
3
  rubyio.h -
 
4
 
 
5
  $Author: matz $
 
6
  $Date: 2007-08-25 12:29:39 +0900 (土, 25  8月 2007) $
 
7
  created at: Fri Nov 12 16:47:09 JST 1993
 
8
 
 
9
  Copyright (C) 1993-2007 Yukihiro Matsumoto
 
10
 
 
11
**********************************************************************/
 
12
 
 
13
#ifndef RUBY_IO_H
 
14
#define RUBY_IO_H 1
 
15
 
 
16
#if defined(__cplusplus)
 
17
extern "C" {
 
18
#if 0
 
19
} /* satisfy cc-mode */
 
20
#endif
 
21
#endif
 
22
 
 
23
#include <stdio.h>
 
24
#include <errno.h>
 
25
#include "ruby/encoding.h"
 
26
 
 
27
#if defined(HAVE_STDIO_EXT_H)
 
28
#include <stdio_ext.h>
 
29
#endif
 
30
 
 
31
typedef struct rb_io_t {
 
32
    int fd;                     /* file descriptor */
 
33
    FILE *stdio_file;           /* stdio ptr for read/write if available */
 
34
    int mode;                   /* mode flags */
 
35
    rb_pid_t pid;               /* child's pid (for pipes) */
 
36
    int lineno;                 /* number of lines read */
 
37
    char *path;                 /* pathname for file */
 
38
    void (*finalize)(struct rb_io_t*,int); /* finalize proc */
 
39
    long refcnt;
 
40
    char *wbuf;                 /* wbuf_off + wbuf_len <= wbuf_capa */
 
41
    int wbuf_off;
 
42
    int wbuf_len;
 
43
    int wbuf_capa;
 
44
    char *rbuf;                 /* rbuf_off + rbuf_len <= rbuf_capa */
 
45
    int rbuf_off;
 
46
    int rbuf_len;
 
47
    int rbuf_capa;
 
48
    rb_encoding *enc;
 
49
} rb_io_t;
 
50
 
 
51
#define HAVE_RB_IO_T 1
 
52
 
 
53
#define FMODE_READABLE  1
 
54
#define FMODE_WRITABLE  2
 
55
#define FMODE_READWRITE 3
 
56
#define FMODE_APPEND   64
 
57
#define FMODE_CREATE  128
 
58
#define FMODE_BINMODE   4
 
59
#define FMODE_SYNC      8
 
60
#define FMODE_TTY      16
 
61
#define FMODE_DUPLEX   32
 
62
#define FMODE_WSPLIT  0x200
 
63
#define FMODE_WSPLIT_INITIALIZED  0x400
 
64
 
 
65
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
 
66
 
 
67
#define MakeOpenFile(obj, fp) do {\
 
68
    if (RFILE(obj)->fptr) {\
 
69
        rb_io_close(obj);\
 
70
        free(RFILE(obj)->fptr);\
 
71
        RFILE(obj)->fptr = 0;\
 
72
    }\
 
73
    fp = 0;\
 
74
    fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
 
75
    fp->fd = -1;\
 
76
    fp->stdio_file = NULL;\
 
77
    fp->mode = 0;\
 
78
    fp->pid = 0;\
 
79
    fp->lineno = 0;\
 
80
    fp->path = NULL;\
 
81
    fp->finalize = 0;\
 
82
    fp->refcnt = 1;\
 
83
    fp->wbuf = NULL;\
 
84
    fp->wbuf_off = 0;\
 
85
    fp->wbuf_len = 0;\
 
86
    fp->wbuf_capa = 0;\
 
87
    fp->rbuf = NULL;\
 
88
    fp->rbuf_off = 0;\
 
89
    fp->rbuf_len = 0;\
 
90
    fp->rbuf_capa = 0;\
 
91
} while (0)
 
92
 
 
93
FILE *rb_io_stdio_file(rb_io_t *fptr);
 
94
 
 
95
FILE *rb_fopen(const char*, const char*);
 
96
FILE *rb_fdopen(int, const char*);
 
97
int  rb_io_mode_flags(const char*);
 
98
int  rb_io_modenum_flags(int);
 
99
void rb_io_check_writable(rb_io_t*);
 
100
void rb_io_check_readable(rb_io_t*);
 
101
int rb_io_fptr_finalize(rb_io_t*);
 
102
void rb_io_synchronized(rb_io_t*);
 
103
void rb_io_check_initialized(rb_io_t*);
 
104
void rb_io_check_closed(rb_io_t*);
 
105
int rb_io_wait_readable(int);
 
106
int rb_io_wait_writable(int);
 
107
void rb_io_set_nonblock(rb_io_t *fptr);
 
108
 
 
109
VALUE rb_io_taint_check(VALUE);
 
110
NORETURN(void rb_eof_error(void));
 
111
 
 
112
void rb_io_read_check(rb_io_t*);
 
113
int rb_io_read_pending(rb_io_t*);
 
114
void rb_read_check(FILE*);
 
115
 
 
116
DEPRECATED(int rb_getc(FILE*));
 
117
DEPRECATED(long rb_io_fread(char *, long, FILE *));
 
118
DEPRECATED(long rb_io_fwrite(const char *, long, FILE *));
 
119
DEPRECATED(int rb_read_pending(FILE*));
 
120
 
 
121
#if defined(__cplusplus)
 
122
#if 0
 
123
{ /* satisfy cc-mode */
 
124
#endif
 
125
}  /* extern "C" { */
 
126
#endif
 
127
 
 
128
#endif /* RUBY_IO_H */