xref: /openbsd-src/gnu/usr.bin/perl/ext/XS-Typemap/stdio.c (revision 43003dfe3ad45d1698bed8a37f2b0f5b14f20d4f)
1 
2 /* This provides a test of STDIO and emulates a library that
3    has been built outside of the PerlIO system and therefore is
4    built using FILE* rather than PerlIO * (a common occurrence
5    for XS).
6 
7    Use a separate file to make sure we are not contaminated by
8    PerlIO.
9 */
10 
11 #include <stdio.h>
12 
13 /* Open a file for write */
xsfopen(const char * path)14 FILE * xsfopen ( const char * path ) {
15   FILE * stream;
16   stream = fopen( path, "w");
17   return stream;
18 }
19 
xsfclose(FILE * stream)20 int xsfclose ( FILE * stream ) {
21   return fclose( stream );
22 }
23 
24 
xsfprintf(FILE * stream,const char * text)25 int xsfprintf ( FILE * stream, const char * text ) {
26   return fprintf( stream, "%s", text );
27 }
28 
29