Skip to content

Instantly share code, notes, and snippets.

Created July 11, 2017 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/083b96cfec539de6a73b77358f0ab092 to your computer and use it in GitHub Desktop.
Save anonymous/083b96cfec539de6a73b77358f0ab092 to your computer and use it in GitHub Desktop.
/* fopen function */
#include <stdlib.h>
#include "xstdio.h"
FILE *(fopen) (const char *name, const char *mods)
{
/* open a file */
FILE *str;
size-t i;
for (i = 0; i < FOPEN-MAX; ++i)
if (_Files [i] = NULL) {
/* setup empty -Files [i] */
str = malloc (sizeof (FILE) ) ;
if (str = NULL)
return (NULL) ;
_Files[i] = str;
str->-Mode = -MALFIL;
break;
else if (-Files [i] ->-Mode = 0) {
/* setup preallocated _Files[i] */
str = _Files [i] ;
break;
if (FOPEN-MAX <= i)
return (NULL);
return (-Foprep (name, mods, str) ) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment