changeset 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 f0263543b617
children d7ec9ef45438
files file.c
diffstat 1 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/file.c	Tue Jul 06 11:42:52 2010 +0000
+++ b/file.c	Tue Jul 06 14:28:32 2010 +0000
@@ -33,6 +33,25 @@
 
 /* standard file protocol */
 
+static int file_read(URLContext *h, unsigned char *buf, int size)
+{
+    int fd = (intptr_t) h->priv_data;
+    return read(fd, buf, size);
+}
+
+static int file_write(URLContext *h, const unsigned char *buf, int size)
+{
+    int fd = (intptr_t) h->priv_data;
+    return write(fd, buf, size);
+}
+
+static int file_get_handle(URLContext *h)
+{
+    return (intptr_t) h->priv_data;
+}
+
+#if CONFIG_FILE_PROTOCOL
+
 static int file_open(URLContext *h, const char *filename, int flags)
 {
     int access;
@@ -57,18 +76,6 @@
     return 0;
 }
 
-static int file_read(URLContext *h, unsigned char *buf, int size)
-{
-    int fd = (intptr_t) h->priv_data;
-    return read(fd, buf, size);
-}
-
-static int file_write(URLContext *h, const unsigned char *buf, int size)
-{
-    int fd = (intptr_t) h->priv_data;
-    return write(fd, buf, size);
-}
-
 /* XXX: use llseek */
 static int64_t file_seek(URLContext *h, int64_t pos, int whence)
 {
@@ -87,11 +94,6 @@
     return close(fd);
 }
 
-static int file_get_handle(URLContext *h)
-{
-    return (intptr_t) h->priv_data;
-}
-
 URLProtocol file_protocol = {
     "file",
     file_open,
@@ -102,7 +104,9 @@
     .url_get_file_handle = file_get_handle,
 };
 
-/* pipe protocol */
+#endif /* CONFIG_FILE_PROTOCOL */
+
+#if CONFIG_PIPE_PROTOCOL
 
 static int pipe_open(URLContext *h, const char *filename, int flags)
 {
@@ -133,3 +137,5 @@
     file_write,
     .url_get_file_handle = file_get_handle,
 };
+
+#endif /* CONFIG_PIPE_PROTOCOL */