stream.cpp revision 949b061fb44b5917da2062c60971d0e33f866e00
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * IPRT - I/O Stream.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * available from http://www.virtualbox.org. This file is free software;
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * you can redistribute it and/or modify it under the terms of the GNU
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * General Public License (GPL) as published by the Free Software
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * The contents of this file may alternatively be used under the terms
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * of the Common Development and Distribution License Version 1.0
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * VirtualBox OSE distribution, in which case the provisions of the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * CDDL are applicable instead of those of the GPL.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * You may elect to license modified versions of this file under the
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * terms and conditions of either the GPL or the CDDL or both.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * additional information or have any questions.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync/*******************************************************************************
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync* Header Files *
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync*******************************************************************************/
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync#if defined(RT_OS_LINUX) /* PORTME: check for the _unlocked functions in stdio.h */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync/*******************************************************************************
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync* Structures and Typedefs *
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync*******************************************************************************/
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync * File stream.
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsynctypedef struct RTSTREAM
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Magic value used to validate the stream. (RTSTREAM_MAGIC) */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** File stream error. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Pointer to the LIBC file stream. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync /** Critical section for serializing access to the stream. */
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync/*******************************************************************************
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync* Global Variables *
61cb83a8ccd1dd7f671f31fa93c9d8b7be09b4ccvboxsync*******************************************************************************/
#ifndef HAVE_FWRITE_UNLOCKED
, NULL
#ifndef HAVE_FWRITE_UNLOCKED
, NULL
#ifndef HAVE_FWRITE_UNLOCKED
, NULL
#ifndef HAVE_FWRITE_UNLOCKED
if (!pCritSect)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
if (pCritSect)
return rc;
#ifdef HAVE_FWRITE_UNLOCKED
#ifdef HAVE_FWRITE_UNLOCKED
return VERR_INVALID_PARAMETER;
if (!pszFilename)
return VERR_INVALID_PARAMETER;
bool fOk = true;
switch (*pszMode)
fOk = false;
fOk = false;
fOk = false;
if (!fOk)
return VINF_SUCCESS;
if (pStream)
return VINF_SUCCESS;
return VERR_NO_MEMORY;
RTR3DECL(int) RTStrmOpenFV(const char *pszMode, PRTSTREAM *ppStream, const char *pszFilenameFmt, va_list args)
int rc;
return rc;
RTR3DECL(int) RTStrmOpenF(const char *pszMode, PRTSTREAM *ppStream, const char *pszFilenameFmt, ...)
return rc;
#ifndef HAVE_FWRITE_UNLOCKED
return VINF_SUCCESS;
return VERR_INVALID_PARAMETER;
int rc;
return rc;
int rc;
return rc;
int rc;
errno = 0;
return rc;
int rc;
if (pcbRead)
return VINF_SUCCESS;
if (*pcbRead)
return VINF_EOF;
return VINF_SUCCESS;
return rc;
RTR3DECL(int) RTStrmWriteEx(PRTSTREAM pStream, const void *pvBuf, size_t cbWrite, size_t *pcbWritten)
int rc;
if (pcbWritten)
return VINF_SUCCESS;
return VINF_SUCCESS;
return rc;
unsigned char ch;
return ch;
int rc;
#ifdef HAVE_FWRITE_UNLOCKED /** @todo darwin + freebsd(?) has fgetc_unlocked but not fwrite_unlocked, optimize... */
#ifdef HAVE_FWRITE_UNLOCKED
#ifdef HAVE_FWRITE_UNLOCKED
if (--cchString <= 0)
return rc;
return VINF_SUCCESS;
if (cchChars)
#ifdef HAVE_FWRITE_UNLOCKED
return cchChars;
int rc;
return rc;
return rc;
return rc;