4 /* output byte stream handling */
6 typedef INT64 offset_t
;
11 struct URLProtocol
*prot
;
13 int is_streamed
; /* true if streamed (no seek possible), default = false */
14 int max_packet_size
; /* if non zero, the stream is packetized with this max packet size */
18 typedef struct URLContext URLContext
;
20 typedef struct URLPollEntry
{
30 int url_open(URLContext
**h
, const char *filename
, int flags
);
31 int url_read(URLContext
*h
, unsigned char *buf
, int size
);
32 int url_write(URLContext
*h
, unsigned char *buf
, int size
);
33 offset_t
url_seek(URLContext
*h
, offset_t pos
, int whence
);
34 int url_close(URLContext
*h
);
35 int url_exist(const char *filename
);
36 offset_t
url_filesize(URLContext
*h
);
37 int url_get_max_packet_size(URLContext
*h
);
39 int url_poll(URLPollEntry
*poll_table
, int n
, int timeout
);
41 typedef struct URLProtocol
{
43 int (*url_open
)(URLContext
*h
, const char *filename
, int flags
);
44 int (*url_read
)(URLContext
*h
, unsigned char *buf
, int size
);
45 int (*url_write
)(URLContext
*h
, unsigned char *buf
, int size
);
46 offset_t (*url_seek
)(URLContext
*h
, offset_t pos
, int whence
);
47 int (*url_close
)(URLContext
*h
);
48 struct URLProtocol
*next
;
51 extern URLProtocol
*first_protocol
;
53 int register_protocol(URLProtocol
*protocol
);
56 unsigned char *buffer
;
58 unsigned char *buf_ptr
, *buf_end
;
60 int (*read_packet
)(void *opaque
, UINT8
*buf
, int buf_size
);
61 void (*write_packet
)(void *opaque
, UINT8
*buf
, int buf_size
);
62 int (*seek
)(void *opaque
, offset_t offset
, int whence
);
63 offset_t pos
; /* position in the file of the current buffer */
64 int must_flush
; /* true if the next seek should flush */
65 int eof_reached
; /* true if eof reached */
66 int write_flag
; /* true if open for writing */
71 int init_put_byte(ByteIOContext
*s
,
72 unsigned char *buffer
,
76 int (*read_packet
)(void *opaque
, UINT8
*buf
, int buf_size
),
77 void (*write_packet
)(void *opaque
, UINT8
*buf
, int buf_size
),
78 int (*seek
)(void *opaque
, offset_t offset
, int whence
));
80 void put_byte(ByteIOContext
*s
, int b
);
81 void put_buffer(ByteIOContext
*s
, unsigned char *buf
, int size
);
82 void put_le64(ByteIOContext
*s
, UINT64 val
);
83 void put_be64(ByteIOContext
*s
, UINT64 val
);
84 void put_le32(ByteIOContext
*s
, unsigned int val
);
85 void put_be32(ByteIOContext
*s
, unsigned int val
);
86 void put_le16(ByteIOContext
*s
, unsigned int val
);
87 void put_be16(ByteIOContext
*s
, unsigned int val
);
88 void put_tag(ByteIOContext
*s
, char *tag
);
90 offset_t
url_fseek(ByteIOContext
*s
, offset_t offset
, int whence
);
91 void url_fskip(ByteIOContext
*s
, offset_t offset
);
92 offset_t
url_ftell(ByteIOContext
*s
);
93 int url_feof(ByteIOContext
*s
);
96 int url_fgetc(ByteIOContext
*s
);
97 int url_fprintf(ByteIOContext
*s
, const char *fmt
, ...);
98 char *url_fgets(ByteIOContext
*s
, char *buf
, int buf_size
);
100 void put_flush_packet(ByteIOContext
*s
);
102 int get_buffer(ByteIOContext
*s
, unsigned char *buf
, int size
);
103 int get_byte(ByteIOContext
*s
);
104 unsigned int get_le32(ByteIOContext
*s
);
105 UINT64
get_le64(ByteIOContext
*s
);
106 unsigned int get_le16(ByteIOContext
*s
);
108 unsigned int get_be16(ByteIOContext
*s
);
109 unsigned int get_be32(ByteIOContext
*s
);
110 UINT64
get_be64(ByteIOContext
*s
);
112 static inline int url_is_streamed(ByteIOContext
*s
)
114 return s
->is_streamed
;
117 int url_fdopen(ByteIOContext
*s
, URLContext
*h
);
118 int url_setbufsize(ByteIOContext
*s
, int buf_size
);
119 int url_fopen(ByteIOContext
*s
, const char *filename
, int flags
);
120 int url_fclose(ByteIOContext
*s
);
121 URLContext
*url_fileno(ByteIOContext
*s
);
122 int url_fget_max_packet_size(ByteIOContext
*s
);
124 int url_open_buf(ByteIOContext
*s
, UINT8
*buf
, int buf_size
, int flags
);
125 int url_close_buf(ByteIOContext
*s
);
127 int url_open_dyn_buf(ByteIOContext
*s
);
128 int url_open_dyn_packet_buf(ByteIOContext
*s
, int max_packet_size
);
129 int url_close_dyn_buf(ByteIOContext
*s
, UINT8
**pbuffer
);
132 extern URLProtocol file_protocol
;
133 extern URLProtocol pipe_protocol
;
136 extern URLProtocol udp_protocol
;
137 int udp_set_remote_url(URLContext
*h
, const char *uri
);
138 int udp_get_local_port(URLContext
*h
);
139 int udp_get_file_handle(URLContext
*h
);
142 extern URLProtocol tcp_protocol
;
145 extern URLProtocol http_protocol
;