Пример #1
0
/* Write the value c (cast to unsigned char) to the given stream.
   Returns c if successful, EOF otherwise.
   If a write error occurs, the error indicator of the stream is set.
*/
int fputc( int c, struct _PDCLIB_file_t * stream )
{
    if ( _PDCLIB_prepwrite( stream ) == EOF )
    {
        return EOF;
    }
    stream->buffer[stream->bufidx++] = (char)c;
    if ( ( stream->bufidx == stream->bufsize )                   /* _IOFBF */
           || ( ( stream->status & _IOLBF ) && ( (char)c == '\n' ) ) /* _IOLBF */
           || ( stream->status & _IONBF )                        /* _IONBF */
    )
    {
        /* buffer filled, unbuffered stream, or end-of-line. */
        return ( _PDCLIB_flushbuffer( stream ) == 0 ) ? c : EOF;
    }
    return c;
}
Пример #2
0
int _PDCLIB_fsetpos_unlocked( FILE * stream, 
                      const _PDCLIB_fpos_t * pos )
{
    if ( stream->status & _PDCLIB_FWRITE )
    {
        if ( _PDCLIB_flushbuffer( stream ) == EOF )
        {
            return EOF;
        }
    }
    if ( _PDCLIB_seek( stream, pos->offset, SEEK_SET ) == EOF )
    {
        return EOF;
    }
    stream->pos.mbs = pos->mbs;
    
    return 0;
}
Пример #3
0
int _PDCLIB_fseek_unlocked( FILE * stream, long loffset, int whence )
{
    _PDCLIB_int64_t offset = loffset;
    if ( stream->status & _PDCLIB_FWRITE )
    {
        if ( _PDCLIB_flushbuffer( stream ) == EOF )
        {
            return EOF;
        }
    }
    stream->status &= ~ _PDCLIB_EOFFLAG;
    if ( stream->status & _PDCLIB_FRW )
    {
        stream->status &= ~ ( _PDCLIB_FREAD | _PDCLIB_FWRITE );
    }

    if ( whence == SEEK_CUR )
    {
        whence  = SEEK_SET;
        offset += _PDCLIB_ftell64_unlocked( stream );
    }

    return ( _PDCLIB_seek( stream, offset, whence ) != EOF ) ? 0 : EOF;
}