/*\r
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available\r
under the terms and conditions of the BSD License that accompanies this\r
distribution. The full text of the license may be found at\r
NetBSD: refill.c,v 1.13 2003/08/07 16:43:30 agc Exp\r
refill.c 8.1 (Berkeley) 6/4/93\r
*/\r
-#include <Uefi.h> // REMOVE, For DEBUG only\r
-#include <Library/UefiLib.h> // REMOVE, For DEBUG only\r
-\r
#include <LibConfig.h>\r
#include <sys/EfiCdefs.h>\r
\r
if (!__sdidinit)\r
__sinit();\r
\r
-//Print(L"%a( %d)\n", __func__, fp->_file);\r
fp->_r = 0; /* largely a convenience for callers */\r
\r
/* SysV does not make this test; take it out for compatibility */\r
if (fp->_flags & __SEOF) {\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
return (EOF);\r
}\r
\r
/* if not already reading, have to be reading and writing */\r
if ((fp->_flags & __SRD) == 0) {\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
if ((fp->_flags & __SRW) == 0) {\r
errno = EBADF;\r
fp->_flags |= __SERR; //<dvm> Allows differentiation between errors and EOF\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
return (EOF);\r
}\r
/* switch to reading */\r
if (fp->_flags & __SWR) {\r
if (__sflush(fp)) {\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
return (EOF);\r
}\r
fp->_flags &= ~__SWR;\r
}\r
fp->_flags |= __SRD;\r
} else {\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
/*\r
* We were reading. If there is an ungetc buffer,\r
* we must have been reading from that. Drop it,\r
FREEUB(fp);\r
if ((fp->_r = fp->_ur) != 0) {\r
fp->_p = fp->_up;\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
return (0);\r
}\r
}\r
if (fp->_bf._base == NULL)\r
__smakebuf(fp);\r
\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
/*\r
* Before reading from a line buffered or unbuffered file,\r
* flush all line buffered output files, per the ANSI C\r
rwlock_rdlock(&__sfp_lock);\r
(void) _fwalk(lflush);\r
rwlock_unlock(&__sfp_lock);\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
}\r
fp->_p = fp->_bf._base;\r
fp->_r = (*fp->_read)(fp->_cookie, (char *)fp->_p, fp->_bf._size);\r
fp->_r = 0;\r
fp->_flags |= __SERR;\r
}\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
return (EOF);\r
}\r
-//Print(L"%a: %d\n", __func__, __LINE__);\r
return (0);\r
}\r