Changeset 1916d1f in mainline for uspace/lib/posix/stdio.c


Ignore:
Timestamp:
2011-07-12T13:41:26Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
50fc490
Parents:
11809eab (diff), 6817eba (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/stdio.c

    r11809eab r1916d1f  
    8989
    9090/**
     91 * Put a string on the stream.
     92 *
     93 * @param s String to be written.
     94 * @param stream Output stream.
     95 * @return Non-negative on success, EOF on failure.
     96 */
     97int posix_fputs(const char *restrict s, FILE *restrict stream)
     98{
     99        int rc = fputs(s, stream);
     100        if (rc == 0) {
     101                return EOF;
     102        } else {
     103                return 0;
     104        }
     105}
     106
     107/**
    91108 * Push byte back into input stream.
    92109 *
     
    100117
    101118        bool can_unget =
    102                 /* Provided character is legal. */
     119            /* Provided character is legal. */
    103120            c != EOF &&
    104                 /* Stream is consistent. */
     121            /* Stream is consistent. */
    105122            !stream->error &&
    106                 /* Stream is buffered. */
     123            /* Stream is buffered. */
    107124            stream->btype != _IONBF &&
    108                 /* Last operation on the stream was a read operation. */
     125            /* Last operation on the stream was a read operation. */
    109126            stream->buf_state == _bs_read &&
    110                 /* Stream buffer is already allocated (i.e. there was already carried
    111                 * out either write or read operation on the stream). This is probably
    112                 * redundant check but let's be safe. */
     127            /* Stream buffer is already allocated (i.e. there was already carried
     128            * out either write or read operation on the stream). This is probably
     129            * redundant check but let's be safe. */
    113130            stream->buf != NULL &&
    114                 /* There is still space in the stream to retreat. POSIX demands the
    115                 * possibility to unget at least 1 character. It should be always
    116                 * possible, assuming the last operation on the stream read at least 1
    117                 * character, because the buffer is refilled in the lazily manner. */
     131            /* There is still space in the stream to retreat. POSIX demands the
     132            * possibility to unget at least 1 character. It should be always
     133            * possible, assuming the last operation on the stream read at least 1
     134            * character, because the buffer is refilled in the lazily manner. */
    118135            stream->buf_tail > stream->buf;
    119136
     
    230247 *     stream with a changed mode. NULL otherwise.
    231248 */
    232 FILE *posix_freopen(
    233     const char *restrict filename,
    234     const char *restrict mode,
    235     FILE *restrict stream)
     249FILE *posix_freopen(const char *restrict filename,
     250    const char *restrict mode, FILE *restrict stream)
    236251{
    237252        assert(mode != NULL);
     
    393408{
    394409        return (posix_off_t) ftell(stream);
     410}
     411
     412/**
     413 * Discard prefetched data or write unwritten data.
     414 *
     415 * @param stream Stream that shall be flushed.
     416 * @return Zero on success, EOF on failure.
     417 */
     418int posix_fflush(FILE *stream)
     419{
     420        int rc = fflush(stream);
     421        if (rc < 0) {
     422                errno = -rc;
     423                return EOF;
     424        } else {
     425                return 0;
     426        }
    395427}
    396428
Note: See TracChangeset for help on using the changeset viewer.