.TL Netpbm subroutine library: pm_tmpfile() function .SH 1 pm_tmpfile() .LP Updated: 22 July 2004 .br .SH 2 NAME .LP pm_tmpfile() - tempfile creation routine using TMPFILE .SH 2 SYNOPSIS .LP .DS L #include FILE * pm_tmpfile(void); .DE .SH 2 EXAMPLE .LP .LP This simple example creates a temporary file, writes "hello world" to it, then reads back and prints those contents. .DS L #include FILE * myfile; myfile = pm_tmpfile(); fprintf(myfile, "hello world\n"); fseek(myfile, 0, SEEK_SET); fread(buffer, sizeof(buffer), 1, myfile); fprintf(STDOUT, "temp file contains '%s'\n", buffer); fclose(myfile); .DE .SH 2 DESCRIPTION .LP .LP This library function is part of Netpbm. .LP \fBpm_tmpfile()\fR creates and opens an unnamed temporary file. It is basically the same thing as the standard C library \fBtmpfile()\fR function, except that it uses the \fBTMPFILE\fR environment variable to decide where to create the temporary file. If \fBTMPFILE\fR is not set or is set to something unusable (e.g. too long), \fBpm_tmpfile()\fR falls back to the value of the standard C library symbol \fBP_tmpdir\fR, just like \fBtmpfile()\fR. .LP Unlike \fBtmpfile()\fR, \fBpm_tmpfile()\fR never returns NULL. If it fails, it issues a message to Standard Error and aborts the program, like most libnetpbm routines do. .SH 2 HISTORY .LP \fBpm_tmpfile()\fR was introduced in Netpbm 10.20 (January 2004).