Changeset 777832e in mainline for uspace/lib/posix/src/stdio.c


Ignore:
Timestamp:
2018-06-21T12:27:09Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
296890f3
Parents:
7d7bc09
git-author:
Jiri Svoboda <jiri@…> (2018-06-20 19:26:46)
git-committer:
Jiri Svoboda <jiri@…> (2018-06-21 12:27:09)
Message:

fgetpos, fsetpos, perror.

File:
1 edited

Legend:

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

    r7d7bc09 r777832e  
    169169
    170170/**
    171  * Write error messages to standard error.
    172  *
    173  * @param s Error message.
    174  */
    175 void perror(const char *s)
    176 {
    177         if (s == NULL || s[0] == '\0') {
    178                 fprintf(stderr, "%s\n", strerror(errno));
    179         } else {
    180                 fprintf(stderr, "%s: %s\n", s, strerror(errno));
    181         }
    182 }
    183 
    184 /** Restores stream a to position previously saved with fgetpos().
    185  *
    186  * @param stream Stream to restore
    187  * @param pos Position to restore
    188  * @return Zero on success, non-zero (with errno set) on failure
    189  */
    190 int fsetpos(FILE *stream, const fpos_t *pos)
    191 {
    192         return fseek64(stream, pos->offset, SEEK_SET);
    193 }
    194 
    195 /** Saves the stream's position for later use by fsetpos().
    196  *
    197  * @param stream Stream to save
    198  * @param pos Place to store the position
    199  * @return Zero on success, non-zero (with errno set) on failure
    200  */
    201 int fgetpos(FILE *restrict stream, fpos_t *restrict pos)
    202 {
    203         off64_t ret = ftell64(stream);
    204         if (ret != -1) {
    205                 pos->offset = ret;
    206                 return 0;
    207         } else {
    208                 return -1;
    209         }
    210 }
    211 
    212 /**
    213171 * Reposition a file-position indicator in a stream.
    214172 *
Note: See TracChangeset for help on using the changeset viewer.