Mercurial > audlegacy
annotate Plugins/Input/wma/libffwma/file.c @ 255:ad1e65c6a854 trunk
[svn] Create some proper headers and include them. No more implicit declarations.
author | chainsaw |
---|---|
date | Sun, 04 Dec 2005 07:37:06 -0800 |
parents | 0bea7509d6ba |
children | f4a57eac3ba3 |
rev | line source |
---|---|
137 | 1 /* |
2 * Buffered file io for ffmpeg system | |
3 * Copyright (c) 2001 Fabrice Bellard | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 #include "avformat.h" | |
255
ad1e65c6a854
[svn] Create some proper headers and include them. No more implicit declarations.
chainsaw
parents:
218
diff
changeset
|
20 #include "cutils.h" |
137 | 21 #include <fcntl.h> |
22 #include <unistd.h> | |
23 #include <sys/ioctl.h> | |
24 #include <sys/time.h> | |
25 | |
26 /* standard file protocol */ | |
27 | |
28 static int file_open(URLContext *h, const char *filename, int flags) | |
29 { | |
30 int access; | |
31 int fd; | |
32 | |
33 strstart(filename, "file:", &filename); | |
34 | |
35 if (flags & URL_WRONLY) { | |
36 access = O_CREAT | O_TRUNC | O_WRONLY; | |
37 } else { | |
38 access = O_RDONLY; | |
39 } | |
218
0bea7509d6ba
[svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents:
210
diff
changeset
|
40 |
137 | 41 fd = open(filename, access, 0666); |
42 if (fd < 0) | |
43 return -ENOENT; | |
44 h->priv_data = (void *)fd; | |
45 return 0; | |
46 } | |
47 | |
48 static int file_read(URLContext *h, unsigned char *buf, int size) | |
49 { | |
50 int fd = (int)h->priv_data; | |
51 return read(fd, buf, size); | |
52 } | |
53 | |
54 static int file_write(URLContext *h, unsigned char *buf, int size) | |
55 { | |
56 int fd = (int)h->priv_data; | |
57 return write(fd, buf, size); | |
58 } | |
59 | |
60 /* XXX: use llseek */ | |
61 static offset_t file_seek(URLContext *h, offset_t pos, int whence) | |
62 { | |
63 int fd = (int)h->priv_data; | |
64 return lseek(fd, pos, whence); | |
65 } | |
66 | |
67 static int file_close(URLContext *h) | |
68 { | |
69 int fd = (int)h->priv_data; | |
70 return close(fd); | |
71 } | |
72 | |
73 URLProtocol file_protocol = { | |
74 "file", | |
75 file_open, | |
76 file_read, | |
77 file_write, | |
78 file_seek, | |
79 file_close, | |
80 }; | |
81 | |
82 /* pipe protocol */ | |
83 | |
84 static int pipe_open(URLContext *h, const char *filename, int flags) | |
85 { | |
86 int fd; | |
87 | |
88 if (flags & URL_WRONLY) { | |
89 fd = 1; | |
90 } else { | |
91 fd = 0; | |
92 } | |
93 h->priv_data = (void *)fd; | |
94 return 0; | |
95 } | |
96 | |
97 static int pipe_read(URLContext *h, unsigned char *buf, int size) | |
98 { | |
99 int fd = (int)h->priv_data; | |
100 return read(fd, buf, size); | |
101 } | |
102 | |
103 static int pipe_write(URLContext *h, unsigned char *buf, int size) | |
104 { | |
105 int fd = (int)h->priv_data; | |
106 return write(fd, buf, size); | |
107 } | |
108 | |
109 static int pipe_close(URLContext *h) | |
110 { | |
111 return 0; | |
112 } | |
113 | |
114 URLProtocol pipe_protocol = { | |
115 "pipe", | |
116 pipe_open, | |
117 pipe_read, | |
118 pipe_write, | |
119 NULL, | |
120 pipe_close, | |
121 }; |