]> pd.if.org Git - pdclib/blob - functions/stdio/tmpnam.c
Almost done on tmpfile / tmpnam.
[pdclib] / functions / stdio / tmpnam.c
1 /* $Id$ */
2
3 /* tmpnam( char * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10
11 #ifndef REGTEST
12
13 #include <string.h>
14 #include <_PDCLIB_glue.h>
15
16 char * tmpnam( char * s )
17 {
18     static char filename[ L_tmpnam ];
19     FILE * file = tmpfile();
20     if ( s == NULL )
21     {
22         s = filename;
23     }
24     strcpy( s, file->filename );
25     fclose( file );
26     return s;
27 }
28
29 #endif
30
31 #ifdef TEST
32 #include <_PDCLIB_test.h>
33
34 #include <string.h>
35
36 int main( void )
37 {
38     TESTCASE( strlen( tmpnam( NULL ) ) < L_tmpnam );
39     return TEST_RESULTS;
40 }
41
42 #endif
43