1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#include <stdlib.h>
29#include <string.h>
30#include <stdio.h>
31
32#include "containers/containers.h"
33#include "containers/core/containers_common.h"
34#include "containers/core/containers_io.h"
35#include "containers/core/containers_uri.h"
36
37VC_CONTAINER_STATUS_T vc_container_io_null_open( VC_CONTAINER_IO_T *, const char *,
38 VC_CONTAINER_IO_MODE_T );
39
40/*****************************************************************************/
41static VC_CONTAINER_STATUS_T io_null_close( VC_CONTAINER_IO_T *p_ctx )
42{
43 VC_CONTAINER_PARAM_UNUSED(p_ctx);
44 return VC_CONTAINER_SUCCESS;
45}
46
47/*****************************************************************************/
48static size_t io_null_read(VC_CONTAINER_IO_T *p_ctx, void *buffer, size_t size)
49{
50 VC_CONTAINER_PARAM_UNUSED(p_ctx);
51 VC_CONTAINER_PARAM_UNUSED(buffer);
52 VC_CONTAINER_PARAM_UNUSED(size);
53 return size;
54}
55
56/*****************************************************************************/
57static size_t io_null_write(VC_CONTAINER_IO_T *p_ctx, const void *buffer, size_t size)
58{
59 VC_CONTAINER_PARAM_UNUSED(p_ctx);
60 VC_CONTAINER_PARAM_UNUSED(buffer);
61 VC_CONTAINER_PARAM_UNUSED(size);
62 return size;
63}
64
65/*****************************************************************************/
66static VC_CONTAINER_STATUS_T io_null_seek(VC_CONTAINER_IO_T *p_ctx, int64_t offset)
67{
68 VC_CONTAINER_PARAM_UNUSED(p_ctx);
69 VC_CONTAINER_PARAM_UNUSED(offset);
70 return VC_CONTAINER_SUCCESS;
71}
72
73/*****************************************************************************/
74VC_CONTAINER_STATUS_T vc_container_io_null_open( VC_CONTAINER_IO_T *p_ctx,
75 const char *unused, VC_CONTAINER_IO_MODE_T mode )
76{
77 VC_CONTAINER_PARAM_UNUSED(unused);
78 VC_CONTAINER_PARAM_UNUSED(mode);
79
80 /* Check the URI */
81 if (!vc_uri_scheme(p_ctx->uri_parts) ||
82 (strcasecmp(vc_uri_scheme(p_ctx->uri_parts), "null") &&
83 strcasecmp(vc_uri_scheme(p_ctx->uri_parts), "null")))
84 return VC_CONTAINER_ERROR_FORMAT_NOT_SUPPORTED;
85
86 p_ctx->pf_close = io_null_close;
87 p_ctx->pf_read = io_null_read;
88 p_ctx->pf_write = io_null_write;
89 p_ctx->pf_seek = io_null_seek;
90 return VC_CONTAINER_SUCCESS;
91}
92