]> pd.if.org Git - pdclib.old/blobdiff - functions/stdio/fgets.c
PDCLIB-8: First phase of intergation of new I/O backend system (with minimal
[pdclib.old] / functions / stdio / fgets.c
index 1afd79f6ed7ed50426dadd32414d3a5c1f851df3..04510583ad29e82b46671106b81caac76399594e 100644 (file)
 
 #ifndef REGTEST
 
-#define _PDCLIB_GLUE_H _PDCLIB_GLUE_H
 #include <_PDCLIB_glue.h>
 
-char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+char * fgets_unlocked( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
 {
     if ( size == 0 )
     {
@@ -47,6 +46,15 @@ char * fgets( char * _PDCLIB_restrict s, int size, struct _PDCLIB_file_t * _PDCL
     return ( dest == s ) ? NULL : s;
 }
 
+char * fgets( char * _PDCLIB_restrict s, int size, 
+              struct _PDCLIB_file_t * _PDCLIB_restrict stream )
+{
+    flockfile( stream );
+    char* r = fgets_unlocked( s, size, stream );
+    funlockfile( stream );
+    return r;
+}
+
 #endif
 
 #ifdef TEST
@@ -82,7 +90,7 @@ int main( void )
     TESTCASE( fgets( buffer, 2, fh ) == NULL );
     TESTCASE( feof( fh ) );
     TESTCASE( fclose( fh ) == 0 );
-    remove( testfile );
+    TESTCASE( remove( testfile ) == 0 );
     return TEST_RESULTS;
 }