Mercurial > libavformat.hg
comparison file.c @ 6238:7f0042585fe4 libavformat
Add #ifdefs around code specific to file and pipe protocols
author | mru |
---|---|
date | Tue, 06 Jul 2010 14:28:32 +0000 |
parents | 9be5a847f59c |
children |
comparison
equal
deleted
inserted
replaced
6237:f0263543b617 | 6238:7f0042585fe4 |
---|---|
31 #include "os_support.h" | 31 #include "os_support.h" |
32 | 32 |
33 | 33 |
34 /* standard file protocol */ | 34 /* standard file protocol */ |
35 | 35 |
36 static int file_read(URLContext *h, unsigned char *buf, int size) | |
37 { | |
38 int fd = (intptr_t) h->priv_data; | |
39 return read(fd, buf, size); | |
40 } | |
41 | |
42 static int file_write(URLContext *h, const unsigned char *buf, int size) | |
43 { | |
44 int fd = (intptr_t) h->priv_data; | |
45 return write(fd, buf, size); | |
46 } | |
47 | |
48 static int file_get_handle(URLContext *h) | |
49 { | |
50 return (intptr_t) h->priv_data; | |
51 } | |
52 | |
53 #if CONFIG_FILE_PROTOCOL | |
54 | |
36 static int file_open(URLContext *h, const char *filename, int flags) | 55 static int file_open(URLContext *h, const char *filename, int flags) |
37 { | 56 { |
38 int access; | 57 int access; |
39 int fd; | 58 int fd; |
40 | 59 |
55 return AVERROR(errno); | 74 return AVERROR(errno); |
56 h->priv_data = (void *) (intptr_t) fd; | 75 h->priv_data = (void *) (intptr_t) fd; |
57 return 0; | 76 return 0; |
58 } | 77 } |
59 | 78 |
60 static int file_read(URLContext *h, unsigned char *buf, int size) | |
61 { | |
62 int fd = (intptr_t) h->priv_data; | |
63 return read(fd, buf, size); | |
64 } | |
65 | |
66 static int file_write(URLContext *h, const unsigned char *buf, int size) | |
67 { | |
68 int fd = (intptr_t) h->priv_data; | |
69 return write(fd, buf, size); | |
70 } | |
71 | |
72 /* XXX: use llseek */ | 79 /* XXX: use llseek */ |
73 static int64_t file_seek(URLContext *h, int64_t pos, int whence) | 80 static int64_t file_seek(URLContext *h, int64_t pos, int whence) |
74 { | 81 { |
75 int fd = (intptr_t) h->priv_data; | 82 int fd = (intptr_t) h->priv_data; |
76 if (whence == AVSEEK_SIZE) { | 83 if (whence == AVSEEK_SIZE) { |
85 { | 92 { |
86 int fd = (intptr_t) h->priv_data; | 93 int fd = (intptr_t) h->priv_data; |
87 return close(fd); | 94 return close(fd); |
88 } | 95 } |
89 | 96 |
90 static int file_get_handle(URLContext *h) | |
91 { | |
92 return (intptr_t) h->priv_data; | |
93 } | |
94 | |
95 URLProtocol file_protocol = { | 97 URLProtocol file_protocol = { |
96 "file", | 98 "file", |
97 file_open, | 99 file_open, |
98 file_read, | 100 file_read, |
99 file_write, | 101 file_write, |
100 file_seek, | 102 file_seek, |
101 file_close, | 103 file_close, |
102 .url_get_file_handle = file_get_handle, | 104 .url_get_file_handle = file_get_handle, |
103 }; | 105 }; |
104 | 106 |
105 /* pipe protocol */ | 107 #endif /* CONFIG_FILE_PROTOCOL */ |
108 | |
109 #if CONFIG_PIPE_PROTOCOL | |
106 | 110 |
107 static int pipe_open(URLContext *h, const char *filename, int flags) | 111 static int pipe_open(URLContext *h, const char *filename, int flags) |
108 { | 112 { |
109 int fd; | 113 int fd; |
110 char *final; | 114 char *final; |
131 pipe_open, | 135 pipe_open, |
132 file_read, | 136 file_read, |
133 file_write, | 137 file_write, |
134 .url_get_file_handle = file_get_handle, | 138 .url_get_file_handle = file_get_handle, |
135 }; | 139 }; |
140 | |
141 #endif /* CONFIG_PIPE_PROTOCOL */ |