Create a gist now

Instantly share code, notes, and snippets.

anonymous /fopen.c
Created Jul 11, 2017

What would you like to do?
/* 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