scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#include <errno.h>
 2#include <stdio.h>
 3
 4#include "../libc.h"
 5
 6#undef fopen
 7
 8FILE *
 9fopen(const char * restrict name, const char * restrict mode)
10{
11	FILE *fp;
12
13	for (fp = __iob; fp < &__iob[FOPEN_MAX]; ++fp) {
14		if ((fp->flags & (_IOREAD | _IOWRITE | _IORW)) == 0)
15			break;
16	}
17	if (fp == &__iob[FOPEN_MAX]) {
18		errno = ENOMEM;
19		return NULL;
20	}
21
22	return _fpopen(name, mode, fp);
23}