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

« back to all changes in this revision

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