]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libstdio/sopenr.c
ndb/dns: lookup *all* entries in dblookup(), v4 and v6 queries in parallel, remove...
[plan9front.git] / sys / src / libstdio / sopenr.c
1 /*
2  * pANS stdio -- sopenr
3  */
4 #include "iolib.h"
5
6 FILE *sopenr(const char *s){
7         FILE *f;
8         qlock(&_stdiolk);
9         for(f=_IO_stream;f!=&_IO_stream[FOPEN_MAX];f++) if(f->state==CLOSED) break;
10         if(f==&_IO_stream[FOPEN_MAX]) {
11                 qunlock(&_stdiolk);
12                 return NULL;
13         }
14         f->buf=f->rp=(char *)s; /* what an annoyance const is */
15         f->bufl=strlen(s);
16         f->wp=f->buf+f->bufl;
17         f->state=RD;
18         f->flags=STRING;
19         f->fd=-1;
20         qunlock(&_stdiolk);
21         return f;
22 }