Skip to content

Commit 03eab53

Browse files
committed
Add missing function.
1 parent b9f7054 commit 03eab53

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Embedded/np_embed.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,17 @@ NP_DECL(int) np_close(int fd) {
326326
return 0;
327327
}
328328

329+
NP_DECL(EFILE*) np_freopen(const char *filename, const char *mode, void *stream) {
330+
if (NP_FOREIGN_PTR) {
331+
return freopen(filename, mode, (FILE*)stream);
332+
}
333+
if (((EFILE*)e)->handle_type == EHANDLE_NATIVE) {
334+
return freopen(filename, mode, ((EFILE*)stream)->f);
335+
}
336+
337+
return NULL;
338+
}
339+
329340
NP_DECL(EFILE*) np_tmpfile() {
330341
FILE* f = tmpfile();
331342
if (f == NULL)

Include/np_embed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ NP_DECL(ssize_t) np_read(int fd, void *buf, size_t count);
298298
NP_DECL(ssize_t) np_pread(int fd, void *buf, size_t count, off_t offset);
299299
NP_DECL(int) np_fgetpos(void* e, fpos_t* pos);
300300
/* File Opening and Closing */
301-
NP_DECL(EFILE*) np_freopen(const char *filename, const char *mode, EFILE *stream);
301+
NP_DECL(EFILE*) np_freopen(const char *filename, const char *mode, void *stream);
302302
NP_DECL(EFILE*) np_fdopen(int fd, const char *mode);
303303

304304
/* File Input Functions */

0 commit comments

Comments
 (0)