2 * pANS stdio -- freopen
6 * Open the named file with the given mode, using the given FILE
7 * Legal modes are given below, `additional characters may follow these sequences':
9 * w wb open to write, truncating
10 * a ab open to write positioned at eof, creating if non-existant
11 * r+ r+b rb+ open to read and write, creating if non-existant
12 * w+ w+b wb+ open to read and write, truncating
13 * a+ a+b ab+ open to read and write, positioned at eof, creating if non-existant.
15 FILE *freopen(const char *name, const char *mode, FILE *f){
20 /* premature; fall through and see what happens */
33 f->fd=open(name, (*mode == '+'? ORDWR: OREAD));
36 f->fd=create(name, (*mode == '+'? ORDWR: OWRITE), 0666);
39 m = (*mode == '+'? ORDWR: OWRITE);
42 f->fd=create(name, m, 0666);
49 f->flags=(mode[0]=='a')? APPEND : 0;