Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | #include |
||
8 | |||
9 | FILE * |
||
10 | tmpfile(void) |
||
11 | { |
||
12 | FILE *f; |
||
13 | char *temp_name; |
||
14 | char *n_t_r; |
||
15 | |||
16 | temp_name = tmpnam(0); |
||
17 | if (temp_name == 0) |
||
18 | return 0; |
||
19 | |||
20 | n_t_r = (char *)malloc(strlen(temp_name)+1); |
||
21 | if (!n_t_r) |
||
22 | return 0; |
||
23 | |||
24 | f = fopen(temp_name, (_fmode & O_TEXT) ? "wt+" : "wb+"); |
||
25 | if (f) |
||
26 | { |
||
27 | f->_flag |= _IORMONCL; |
||
28 | f->_name_to_remove = n_t_r; |
||
29 | strcpy(f->_name_to_remove, temp_name); |
||
30 | } |
||
31 | return f; |
||
32 | } |