diff options
-rw-r--r-- | crypto/compat/posix_win.c | 14 | ||||
-rw-r--r-- | include/compat/stdio.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 0dcc046..c6ff924 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
@@ -38,6 +38,20 @@ posix_fopen(const char *path, const char *mode) | |||
38 | return fopen(path, mode); | 38 | return fopen(path, mode); |
39 | } | 39 | } |
40 | 40 | ||
41 | char * | ||
42 | posix_fgets(char *s, int size, FILE *stream) | ||
43 | { | ||
44 | char *ret = fgets(s, size, stream); | ||
45 | if (ret != NULL) { | ||
46 | size_t end = strlen(ret); | ||
47 | if (end >= 2 && ret[end - 2] == '\r' && ret[end - 1] == '\n') { | ||
48 | ret[end - 2] = '\n'; | ||
49 | ret[end - 1] = '\0'; | ||
50 | } | ||
51 | } | ||
52 | return ret; | ||
53 | } | ||
54 | |||
41 | int | 55 | int |
42 | posix_rename(const char *oldpath, const char *newpath) | 56 | posix_rename(const char *oldpath, const char *newpath) |
43 | { | 57 | { |
diff --git a/include/compat/stdio.h b/include/compat/stdio.h index 4b96b8b..a0dda6f 100644 --- a/include/compat/stdio.h +++ b/include/compat/stdio.h | |||
@@ -28,11 +28,13 @@ int asprintf(char **str, const char *fmt, ...); | |||
28 | 28 | ||
29 | void posix_perror(const char *s); | 29 | void posix_perror(const char *s); |
30 | FILE * posix_fopen(const char *path, const char *mode); | 30 | FILE * posix_fopen(const char *path, const char *mode); |
31 | char * posix_fgets(char *s, int size, FILE *stream); | ||
31 | int posix_rename(const char *oldpath, const char *newpath); | 32 | int posix_rename(const char *oldpath, const char *newpath); |
32 | 33 | ||
33 | #ifndef NO_REDEF_POSIX_FUNCTIONS | 34 | #ifndef NO_REDEF_POSIX_FUNCTIONS |
34 | #define perror(errnum) posix_perror(errnum) | 35 | #define perror(errnum) posix_perror(errnum) |
35 | #define fopen(path, mode) posix_fopen(path, mode) | 36 | #define fopen(path, mode) posix_fopen(path, mode) |
37 | #define fgets(s, size, stream) posix_fgets(s, size, stream) | ||
36 | #define rename(oldpath, newpath) posix_rename(oldpath, newpath) | 38 | #define rename(oldpath, newpath) posix_rename(oldpath, newpath) |
37 | #endif | 39 | #endif |
38 | 40 | ||