1 /* 2 * pANS stdio -- sopenr 3 */ 4 #include "iolib.h" 5 sopenr(const char * s)6FILE *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 } 23