summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/stdio/sopenr.c
blob: 279ec726b38270e9211870f393708b6cc9ec48c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * pANS stdio -- sopenr
 */
#include "iolib.h"
#include <string.h>

FILE *_IO_sopenr(const char *s){
	FILE *f;
	for(f=_IO_stream;f!=&_IO_stream[FOPEN_MAX];f++) if(f->state==CLOSED) break;
	if(f==&_IO_stream[FOPEN_MAX]) return NULL;
	f->buf=f->rp=(char *)s;	/* what an annoyance const is */
	f->bufl=strlen(s);
	f->wp=f->buf+f->bufl;
	f->state=RD;
	f->flags=STRING;
	f->fd=-1;
	return f;
}