]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/LibC/Stdio/fputws.c
Add device abstraction code for the UEFI Console and UEFI Shell-based file systems.
[mirror_edk2.git] / StdLib / LibC / Stdio / fputws.c
CommitLineData
53e1e5c6 1/*\r
2 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
3 This program and the accompanying materials are licensed and made available\r
4 under the terms and conditions of the BSD License that accompanies this\r
5 distribution. The full text of the license may be found at\r
6 http://opensource.org/licenses/bsd-license.\r
7\r
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
2aa62f2b 10\r
2aa62f2b 11 * Copyright (c) 2002 Tim J. Robbins.\r
12 * All rights reserved.\r
13 *\r
14 * Redistribution and use in source and binary forms, with or without\r
15 * modification, are permitted provided that the following conditions\r
16 * are met:\r
17 * 1. Redistributions of source code must retain the above copyright\r
18 * notice, this list of conditions and the following disclaimer.\r
19 * 2. Redistributions in binary form must reproduce the above copyright\r
20 * notice, this list of conditions and the following disclaimer in the\r
21 * documentation and/or other materials provided with the distribution.\r
22 *\r
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
33 * SUCH DAMAGE.\r
34 *\r
35 * Original version ID:\r
36 * FreeBSD: src/lib/libc/stdio/fputws.c,v 1.4 2002/09/20 13:25:40 tjr Exp\r
53e1e5c6 37 NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp\r
38*/\r
2aa62f2b 39#include <LibConfig.h>\r
40#include <sys/EfiCdefs.h>\r
2aa62f2b 41\r
42#include <assert.h>\r
43#include <errno.h>\r
44#include <stdio.h>\r
45#include <wchar.h>\r
46#include "reentrant.h"\r
47#include "local.h"\r
48\r
49int\r
50fputws(\r
51 const wchar_t * __restrict ws,\r
52 FILE * __restrict fp\r
53 )\r
54{\r
55 _DIAGASSERT(fp != NULL);\r
56 _DIAGASSERT(ws != NULL);\r
53e1e5c6 57 if(fp == NULL) {\r
58 errno = EINVAL;\r
59 return (EOF);\r
60 }\r
2aa62f2b 61\r
62 FLOCKFILE(fp);\r
63 _SET_ORIENTATION(fp, 1);\r
64\r
65 while (*ws != '\0') {\r
66 if (__fputwc_unlock(*ws++, fp) == WEOF) {\r
67 FUNLOCKFILE(fp);\r
68 return (-1);\r
69 }\r
70 }\r
71 FUNLOCKFILE(fp);\r
72\r
73 return (0);\r
74}\r