Add device abstraction code for the UEFI Console and UEFI Shell-based file systems.

Make argv use narrow characters instead of wide characters.
Add setenv functionality.
Add poll() system call.
Change signal names into macros – required for standards compliance.  The enums were renamed and moved to sys/signal.h and the new macros reference the enums.
Added SIGBREAK, which is required for Python.
Modify stdio functions to fail cleanly when called with a NULL File Pointer argument.
Added <sys/cdefs.h> that just includes <sys/EfiCdefs.h>.  By adding this wrapper, we improve compatibility with *nix files which assume <sys/cdefs> exists.
Add <netdb.h>
Added macros for bcopy(), bcmp() and strsep().
Modify the clock() function so that it does not hang when running under an emulation environment such as NT32.
Move TM structure specific macros from the private tzfile.h into <time.h>
Add strncasecmp function.
Add strptime function.
Add gettimeofday function.
Add getcwd function.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11908 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503
2011-06-28 02:34:10 +00:00
parent b00771f50a
commit 53e1e5c647
98 changed files with 5175 additions and 1409 deletions

View File

@@ -70,6 +70,9 @@
vprintf.c #
vsprintf.c #
snprintf.c
vsnprintf.c
# Wide character functions
fgetwc.c #
fgetws.c #

View File

@@ -1,7 +1,7 @@
/** @file
Implementation of clearerr as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -47,6 +47,7 @@
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include "reentrant.h"
#include "local.h"
@@ -55,9 +56,10 @@
void
clearerr(FILE *fp)
{
//_DIAGASSERT(fp != NULL);
_DIAGASSERT(fp != NULL);
if(fp != NULL) {
FLOCKFILE(fp);
__sclearerr(fp);
FUNLOCKFILE(fp);
}
}

View File

@@ -1,7 +1,7 @@
/** @file
Implementation of fclose as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -59,6 +59,10 @@ fclose(FILE *fp)
int r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (fp->_flags == 0) { /* not open! */
errno = EBADF;

View File

@@ -2,7 +2,7 @@
Implementation of a subroutine version of the macro feof,
as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -48,6 +48,7 @@
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include "reentrant.h"
#include "local.h"
@@ -59,6 +60,10 @@ feof(FILE *fp)
int r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
r = __sfeof(fp);

View File

@@ -2,7 +2,7 @@
Implementation of a subroutine version of the macro ferror,
as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -48,6 +48,7 @@
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include "reentrant.h"
#include "local.h"
@@ -59,6 +60,10 @@ ferror(FILE *fp)
int r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
r = __sferror(fp);

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fflush as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -87,6 +87,10 @@ __sflush(FILE *fp)
int t;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
t = fp->_flags;
if ((t & __SWR) == 0)

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fgetc as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -58,8 +58,14 @@ fgetc(FILE *fp)
_DIAGASSERT(fp != NULL);
if(fp != NULL) {
FLOCKFILE(fp);
r = __sgetc(fp);
FUNLOCKFILE(fp);
}
else {
r = EOF;
errno = ENOSTR;
}
return r;
}

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fgetpos as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -56,5 +56,10 @@ fgetpos(FILE *fp, fpos_t *pos)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(pos != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
return((*pos = (off_t)ftello(fp)) == (off_t)-1);
}

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fgets as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -48,6 +48,7 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "reentrant.h"
#include "local.h"
@@ -65,8 +66,10 @@ fgets(char *buf, int n, FILE *fp)
_DIAGASSERT(buf != NULL);
_DIAGASSERT(fp != NULL);
if (n <= 0) /* sanity check */
if ((fp == NULL) || (n <= 0)) { /* sanity check */
errno = EINVAL;
return (NULL);
}
FLOCKFILE(fp);
_SET_ORIENTATION(fp, -1);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fgetstr.c,v 1.4 2006/11/24 19:46:58 christos Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,20 +37,20 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
$NetBSD: fgetstr.c,v 1.4 2006/11/24 19:46:58 christos Exp $
fgetline.c 8.1 (Berkeley) 6/4/93
*/
/*-
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)fgetline.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: fgetstr.c,v 1.4 2006/11/24 19:46:58 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -66,6 +73,10 @@ __slbexpand(FILE *fp, size_t newsize)
++newsize;
#endif
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (-1);
}
if ((size_t)fp->_lb._size >= newsize)
return (0);
@@ -92,6 +103,10 @@ __fgetstr(FILE *fp, size_t *lenp, int sep)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(lenp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (NULL);
}
/* make sure there is input */
if (fp->_r <= 0 && __srefill(fp)) {

View File

@@ -1,4 +1,13 @@
/*-
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
* Copyright (c)2001 Citrus Project,
* All rights reserved.
*
@@ -46,6 +55,10 @@ __fgetwc_unlock(FILE *fp)
size_t size;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = ENOSTR;
return WEOF;
}
_SET_ORIENTATION(fp, 1);
wcio = WCIO_GET(fp);
@@ -91,6 +104,10 @@ fgetwc(FILE *fp)
wint_t r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (WEOF);
}
FLOCKFILE(fp);
r = __fgetwc_unlock(fp);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 2002 Tim J. Robbins.
* All rights reserved.
*
@@ -27,13 +34,11 @@
*
* Original version ID:
* FreeBSD: src/lib/libc/stdio/fgetws.c,v 1.4 2002/09/20 13:25:40 tjr Exp
*
*/
$NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIB_SCCS) && !defined(lint)
__RCSID("$NetBSD: fgetws.c,v 1.2 2006/07/03 17:06:36 tnozaki Exp $");
#endif
#include <assert.h>
#include <errno.h>
@@ -54,6 +59,10 @@ fgetws(
_DIAGASSERT(fp != NULL);
_DIAGASSERT(ws != NULL);
if(fp == NULL) {
errno = EINVAL;
return (NULL);
}
FLOCKFILE(fp);
_SET_ORIENTATION(fp, 1);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fileno.c,v 1.12 2004/05/09 17:27:53 kleink Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,16 +37,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
NetBSD: fileno.c,v 1.12 2004/05/09 17:27:53 kleink Exp
fileno.c 8.1 (Berkeley) 6/4/93
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)fileno.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: fileno.c,v 1.12 2004/05/09 17:27:53 kleink Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
@@ -63,6 +66,10 @@ _fileno(fp)
int r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
r = __sfileno(fp);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fparseln.c,v 1.5 2004/06/20 22:20:15 jmc Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,12 +34,11 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
NetBSD: fparseln.c,v 1.5 2004/06/20 22:20:15 jmc Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fparseln.c,v 1.5 2004/06/20 22:20:15 jmc Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -107,6 +113,10 @@ fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3], int flags)
char esc, con, nl, com;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (NULL);
}
len = 0;
buf = NULL;

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fprintf as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -58,6 +58,10 @@ fprintf(FILE *fp, const char *fmt, ...)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(fmt != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
va_start(ap, fmt);
ret = vfprintf(fp, fmt, ap);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fpurge.c,v 1.13 2003/08/07 16:43:24 agc Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,16 +37,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
NetBSD: fpurge.c,v 1.13 2003/08/07 16:43:24 agc Exp
fpurge.c 8.1 (Berkeley) 6/4/93
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)fpurge.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: fpurge.c,v 1.13 2003/08/07 16:43:24 agc Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
@@ -59,6 +62,10 @@ fpurge(fp)
{
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (fp->_flags == 0) {
errno = EBADF;

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fputc as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -58,8 +58,14 @@ fputc(int c, FILE *fp)
_DIAGASSERT(fp != NULL);
if(fp != NULL) {
FLOCKFILE(fp);
r = __sputc(c, fp);
FUNLOCKFILE(fp);
}
else {
r = EOF;
errno = ENOSTR;
}
return r;
}

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fputs as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -65,6 +65,10 @@ fputs(const char *s, FILE *fp)
_DIAGASSERT(s != NULL);
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (s == NULL)
s = "(null)";

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fputwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c)2001 Citrus Project,
* All rights reserved.
*
@@ -26,12 +33,11 @@
* SUCH DAMAGE.
*
* $Citrus$
*/
NetBSD: fputwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fputwc.c,v 1.4 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
@@ -53,6 +59,10 @@ __fputwc_unlock(wchar_t wc, FILE *fp)
struct __siov iov;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (WEOF);
}
/* LINTED we don't play with buf */
iov.iov_base = (void *)buf;
@@ -91,6 +101,10 @@ fputwc(wchar_t wc, FILE *fp)
wint_t r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (WEOF);
}
FLOCKFILE(fp);
r = __fputwc_unlock(wc, fp);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 2002 Tim J. Robbins.
* All rights reserved.
*
@@ -27,12 +34,10 @@
*
* Original version ID:
* FreeBSD: src/lib/libc/stdio/fputws.c,v 1.4 2002/09/20 13:25:40 tjr Exp
*/
NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $");
#endif
#include <assert.h>
#include <errno.h>
@@ -49,6 +54,10 @@ fputws(
{
_DIAGASSERT(fp != NULL);
_DIAGASSERT(ws != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
_SET_ORIENTATION(fp, 1);

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fread as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -61,6 +61,10 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
size_t total;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (0);
}
/*
* The ANSI standard requires a return value of 0 for a count
* or a size of 0. Whilst ANSI imposes no such requirements on

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of freopen as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -73,6 +73,10 @@ freopen(const char *file, const char *mode, FILE *fp)
_DIAGASSERT(file != NULL);
_DIAGASSERT(mode != NULL);
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (NULL);
}
if ((flags = __sflags(mode, &oflags)) == 0) {
(void) fclose(fp);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fseeko.c,v 1.5 2005/03/04 16:04:58 dsl Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,15 +37,14 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
NetBSD: fseeko.c,v 1.5 2005/03/04 16:04:58 dsl Exp
*/
//#include <Uefi.h> // REMOVE, For DEBUG only
//#include <Library/UefiLib.h> // REMOVE, For DEBUG only
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fseeko.c,v 1.5 2005/03/04 16:04:58 dsl Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/types.h>
@@ -72,6 +78,10 @@ fseeko(FILE *fp, off_t offset, int whence)
int havepos;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return -1;
}
#ifdef __GNUC__
/* This outrageous construct just to shut up a GCC warning. */

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fvwrite.c,v 1.16.2.1 2007/05/07 19:49:09 pavel Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,16 +37,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
NetBSD: fvwrite.c,v 1.16.2.1 2007/05/07 19:49:09 pavel Exp
fvwrite.c 8.1 (Berkeley) 6/4/93
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: fvwrite.c,v 1.16.2.1 2007/05/07 19:49:09 pavel Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
@@ -68,6 +71,10 @@ __sfvwrite(FILE *fp, struct __suio *uio)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(uio != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if ((len = uio->uio_resid) == 0)
return (0);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: fwide.c,v 1.3 2005/06/12 05:21:27 lukem Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c)2001 Citrus Project,
* All rights reserved.
*
@@ -26,14 +33,14 @@
* SUCH DAMAGE.
*
* $Citrus$
*/
NetBSD: fwide.c,v 1.3 2005/06/12 05:21:27 lukem Exp
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fwide.c,v 1.3 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <wchar.h>
#include "reentrant.h"
@@ -45,6 +52,10 @@ fwide(FILE *fp, int mode)
struct wchar_io_data *wcio;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (0);
}
/*
* this implementation use only -1, 0, 1

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of fwrite as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -64,6 +64,11 @@ fwrite(const void *buf, size_t size, size_t count, FILE *fp)
struct __siov iov;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (0);
}
/*
* SUSv2 requires a return value of 0 for a count or a size of 0.
*/

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of getc as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -63,6 +63,10 @@ getc(FILE *fp)
int r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = ENOSTR;
return (EOF);
}
FLOCKFILE(fp);
r = __sgetc(fp);
@@ -75,6 +79,10 @@ getc_unlocked(FILE *fp)
{
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = ENOSTR;
return EOF;
}
return (__sgetc(fp));
}

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of internal file buffer allocation functions.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -74,6 +74,7 @@ __smakebuf(FILE *fp)
_DIAGASSERT(fp != NULL);
if (fp != NULL) {
if (fp->_flags & __SNBF) {
fp->_bf._base = fp->_p = fp->_nbuf;
fp->_bf._size = 1;
@@ -93,6 +94,7 @@ __smakebuf(FILE *fp)
if (couldbetty || isatty(fp->_file))
flags |= __SLBF;
fp->_flags |= flags;
}
}
/*
@@ -106,6 +108,9 @@ __swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(bufsize != NULL);
_DIAGASSERT(couldbetty != NULL);
if(fp == NULL) {
return (__SNPT);
}
if (fp->_file < 0 || fstat(fp->_file, &st) < 0) {
*couldbetty = 0;

View File

@@ -2,11 +2,11 @@
Implementation of a subroutine version of the macro putc,
as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -64,6 +64,10 @@ putc(int c, FILE *fp)
int r;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
r = __sputc(c, fp);
@@ -75,6 +79,10 @@ int
putc_unlocked(int c, FILE *fp)
{
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
return (__sputc(c, fp));
}

View File

@@ -1,6 +1,13 @@
/* $NetBSD: refill.c,v 1.13 2003/08/07 16:43:30 agc Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,19 +37,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
NetBSD: refill.c,v 1.13 2003/08/07 16:43:30 agc Exp
refill.c 8.1 (Berkeley) 6/4/93
*/
#include <Uefi.h> // REMOVE, For DEBUG only
#include <Library/UefiLib.h> // REMOVE, For DEBUG only
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)refill.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: refill.c,v 1.13 2003/08/07 16:43:30 agc Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
@@ -61,7 +64,11 @@ static int
lflush(FILE *fp)
{
//_DIAGASSERT(fp != NULL);
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
return (__sflush(fp));
@@ -76,7 +83,11 @@ int
__srefill(FILE *fp)
{
//_DIAGASSERT(fp != NULL);
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
/* make sure stdio is set up */
if (!__sdidinit)

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of rewind as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -56,8 +56,10 @@ rewind(FILE *fp)
{
_DIAGASSERT(fp != NULL);
if(fp != NULL) {
FLOCKFILE(fp);
(void) fseek(fp, 0L, SEEK_SET);
__sclearerr(fp);
FUNLOCKFILE(fp);
}
}

View File

@@ -1,11 +1,11 @@
/** @file
Internal function to refill the buffer when getc() empties it.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -61,10 +61,12 @@ __srget(FILE *fp)
{
_DIAGASSERT(fp != NULL);
if(fp != NULL) {
_SET_ORIENTATION(fp, -1);
if (__srefill(fp) == 0) {
fp->_r--;
return (*fp->_p++);
}
}
return (EOF);
}

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of setvbuf as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -67,6 +67,10 @@ setvbuf(FILE *fp, char *buf, int mode, size_t size)
_DIAGASSERT(fp != NULL);
/* buf may be NULL */
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
/*
* Verify arguments. The `int' limit on `size' is due to this

View File

@@ -2,11 +2,11 @@
Small standard I/O/seek/close functions.
These maintain the `known seek offset' for seek optimisation.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -65,6 +65,10 @@ __sread(void *cookie, char *buf, int n)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(buf != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
ret = (int)read(fp->_file, buf, (size_t)n);
/* if the read succeeded, update the current offset */
@@ -82,6 +86,10 @@ __swrite(void *cookie, char const *buf, int n)
_DIAGASSERT(cookie != NULL);
_DIAGASSERT(buf != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (fp->_flags & __SAPP)
(void) lseek(fp->_file, (off_t)0, SEEK_END);
@@ -96,6 +104,10 @@ __sseek(void *cookie, fpos_t offset, int whence)
off_t ret;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
ret = lseek(fp->_file, (off_t)offset, whence);
if (ret == -1L)
@@ -112,6 +124,10 @@ __sclose(void *cookie)
{
_DIAGASSERT(cookie != NULL);
if(cookie == NULL) {
errno = EINVAL;
return (EOF);
}
return (close(((FILE *)cookie)->_file));
}

View File

@@ -68,8 +68,12 @@ tmpfile()
//(void)sigprocmask(SIG_BLOCK, &set, &oset);
fd = mkstemp(buf);
if (fd != -1)
(void)unlink(buf);
if (fd != -1) {
/* Changed from unlink(buf) because of differences between the behavior
of Unix and UEFI file systems.
*/
(void)DeleteOnClose(fd);
}
//(void)sigprocmask(SIG_SETMASK, &oset, NULL);

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of ungetc as declared in <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -67,6 +67,10 @@ __submore(FILE *fp)
unsigned char *p;
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (_UB(fp)._base == fp->_ubuf) {
/*
@@ -98,6 +102,10 @@ int
ungetc(int c, FILE *fp)
{
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (c == EOF)
return (EOF);

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of scanf internals for <stdio.h>.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -44,14 +44,12 @@
FreeBSD: src/lib/libc/stdio/vfscanf.c,v 1.41 2007/01/09 00:28:07 imp Exp
vfscanf.c 8.1 (Berkeley) 6/4/93
**/
//#include <Uefi.h> // REMOVE, For DEBUG only
//#include <Library/UefiLib.h> // REMOVE, For DEBUG only
#include <LibConfig.h>
#include "namespace.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
@@ -142,6 +140,10 @@ __svfscanf(FILE *fp, char const *fmt0, va_list ap)
{
int ret;
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
ret = __svfscanf_unlocked(fp, fmt0, ap);
FUNLOCKFILE(fp);
@@ -178,6 +180,10 @@ __svfscanf_unlocked(FILE *fp, const char *fmt0, va_list ap)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(fmt0 != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
_SET_ORIENTATION(fp, -1);
@@ -837,12 +843,12 @@ literal:
goto match_failure;
if ((flags & SUPPRESS) == 0) {
if (flags & LONGDBL) {
/*dvm*/ long double **mp = (long double **)ap;
long double **mp = (long double **)ap;
long double res = strtold(buf, &p);
/*dvm*/ *(*mp) = res;
/*dvm*/ ap += sizeof(long double *);
/*dvm*/ //*va_arg(ap, long double *) = res;
*(*mp) = res;
ap += sizeof(long double *);
/*???*/ //*va_arg(ap, long double *) = res;
} else if (flags & LONG) {
double res = strtod(buf, &p);
*va_arg(ap, double *) = res;
@@ -989,6 +995,11 @@ parsefloat(FILE *fp, char *buf, char *end)
char decpt = *localeconv()->decimal_point;
_Bool gotmantdig = 0, ishex = 0;
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
/*
* We set commit = p whenever the string we have read so far
* constitutes a valid representation of a floating point

View File

@@ -164,6 +164,10 @@ __sbprintf(FILE *fp, const CHAR_T *fmt, va_list ap)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(fmt != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
_FILEEXT_SETUP(&fake, &fakeext);
@@ -229,6 +233,10 @@ __sprint(FILE *fp, struct __suio *uio)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(uio != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
if (uio->uio_resid == 0) {
uio->uio_iovcnt = 0;
@@ -544,6 +552,10 @@ WDECL(vf,printf)(FILE * __restrict fp, const CHAR_T * __restrict fmt0, va_list a
{
int ret;
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
FLOCKFILE(fp);
ret = WDECL(__vf,printf_unlocked)(fp, fmt0, ap);
FUNLOCKFILE(fp);
@@ -801,6 +813,10 @@ WDECL(__vf,printf_unlocked)(FILE *fp, const CHAR_T *fmt0, va_list ap)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(fmt0 != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
_SET_ORIENTATION(fp, -1);

View File

@@ -54,11 +54,7 @@ __weak_alias(vsnprintf,_vsnprintf)
#endif
int
vsnprintf(str, n, fmt, ap)
char *str;
size_t n;
const char *fmt;
_BSD_VA_LIST_ ap;
vsnprintf(char *str, size_t n, const char *fmt, _BSD_VA_LIST_ ap)
{
int ret;
FILE f;
@@ -81,7 +77,7 @@ vsnprintf(str, n, fmt, ap)
f._bf._size = f._w = 0;
} else {
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n - 1;
f._bf._size = f._w = (int)(n - 1);
}
ret = __vfprintf_unlocked(&f, fmt, ap);
*f._p = 0;

View File

@@ -1,6 +1,13 @@
/* $NetBSD: wbuf.c,v 1.13 2003/08/07 16:43:35 agc Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,16 +37,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
NetBSD: wbuf.c,v 1.13 2003/08/07 16:43:35 agc Exp
wbuf.c 8.1 (Berkeley) 6/4/93
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: wbuf.c,v 1.13 2003/08/07 16:43:35 agc Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
@@ -58,6 +61,10 @@ __swbuf(int c, FILE *fp)
int n;
//_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (EOF);
}
_SET_ORIENTATION(fp, -1);

View File

@@ -1,6 +1,13 @@
/* $NetBSD: wsetup.c,v 1.11 2003/08/07 16:43:35 agc Exp $ */
/*
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,16 +37,12 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
NetBSD: wsetup.c,v 1.11 2003/08/07 16:43:35 agc Exp
wsetup.c 8.1 (Berkeley) 6/4/93
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)wsetup.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: wsetup.c,v 1.11 2003/08/07 16:43:35 agc Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
@@ -58,6 +61,10 @@ __swsetup(FILE *fp)
{
_DIAGASSERT(fp != NULL);
if(fp == NULL) {
errno = EINVAL;
return (-1);
}
/* make sure stdio is set up */
if (!__sdidinit)