|
| 1 | +/**************************************************************************** |
| 2 | + * libs/libc/stdio/lib_putwc.c |
| 3 | + * |
| 4 | + * Copyright © 2005-2014 Rich Felker, et al. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | + * a copy of this software and associated documentation files (the |
| 8 | + * "Software"), to deal in the Software without restriction, including |
| 9 | + * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | + * distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | + * permit persons to whom the Software is furnished to do so, subject to |
| 12 | + * the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be |
| 15 | + * included in all copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 | + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 | + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 | + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | + * |
| 25 | + ****************************************************************************/ |
| 26 | + |
| 27 | +/**************************************************************************** |
| 28 | + * Included Files |
| 29 | + ****************************************************************************/ |
| 30 | + |
| 31 | +#include <wchar.h> |
| 32 | +#include <stdio.h> |
| 33 | + |
| 34 | +#ifdef CONFIG_FILE_STREAM |
| 35 | + |
| 36 | +/**************************************************************************** |
| 37 | + * Public Functions |
| 38 | + ****************************************************************************/ |
| 39 | + |
| 40 | +/**************************************************************************** |
| 41 | + * Name: putwc_unlocked |
| 42 | + * |
| 43 | + * Description: |
| 44 | + * Write wide character to stream without lock the stream |
| 45 | + * |
| 46 | + * Input Parameters: |
| 47 | + * c - the wide character to write |
| 48 | + * f - the FILE object that identifies an output stream |
| 49 | + * |
| 50 | + * Returned Value: |
| 51 | + * Return the wide character that written in to the stream on success, |
| 52 | + * return WEOF on fail write to the stream |
| 53 | + * |
| 54 | + ****************************************************************************/ |
| 55 | + |
| 56 | +wint_t putwc_unlocked(wchar_t c, FAR FILE *f) |
| 57 | +{ |
| 58 | + return fputwc_unlocked(c, f); |
| 59 | +} |
| 60 | + |
| 61 | +/**************************************************************************** |
| 62 | + * Name: putwc |
| 63 | + * |
| 64 | + * Description: |
| 65 | + * Write wide character to stream |
| 66 | + * |
| 67 | + * Input Parameters: |
| 68 | + * c - the wide character to write |
| 69 | + * f - the FILE object that identifies an output stream |
| 70 | + * |
| 71 | + * Returned Value: |
| 72 | + * Return the wide character that written in to the stream on success, |
| 73 | + * return WEOF on fail write to the stream |
| 74 | + * |
| 75 | + ****************************************************************************/ |
| 76 | + |
| 77 | +wint_t putwc(wchar_t c, FAR FILE *f) |
| 78 | +{ |
| 79 | + flockfile(f); |
| 80 | + c = putwc_unlocked(c, f); |
| 81 | + funlockfile(f); |
| 82 | + return c; |
| 83 | +} |
| 84 | + |
| 85 | +#endif /* CONFIG_FILE_STREAM */ |
0 commit comments