summary refs log tree commit diff
path: root/libtmpfile.html
blob: dca1f472007de329435af9fdf203b4293ead0aa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html> <head>
<title>Netpbm subroutine library: pm_tmpfile() function</title>
<meta name="manual_section" content="3">
</head>

<body>
<h1>pm_tmpfile()</h1>
Updated: 22 July 2004
<br>
<h2>NAME</h2>

pm_tmpfile() - create a temporary unnamed file

<h2>SYNOPSIS</h2>

<pre>
#include &lt;netpbm/pm.h&gt;

FILE *
pm_tmpfile(void);
</pre>

<h2>EXAMPLE</h2>

<p>This simple example creates a temporary file, writes &quot;hello
world&quot; to it, then reads back and prints those contents.

<pre>
#include &lt;netpbm/pm.h&gt;

FILE * myfileP;

myfile = pm_tmpfile();

fprintf(myfile, &quot;hello world\n&quot;);

fseek(myfileP, 0, SEEK_SET);

fread(buffer, sizeof(buffer), 1, myfileP);

fprintf(STDOUT, &quot;temp file contains '%s'\n&quot;, buffer);

fclose(myfileP);

</pre>

<h2>DESCRIPTION</H2>

<p>This library function is part of <a href="index.html">Netpbm</a>.

<p><b>pm_tmpfile()</b> creates and opens an unnamed temporary file.
It is basically the same thing as the standard C library
<b>tmpfile()</b> function, except that it uses the <b>TMPFILE</B>
environment variable to decide where to create the temporary file.
If <b>TMPFILE</b> is not set or is set to something unusable (e.g.
too long), <b>pm_tmpfile()</b> falls back to the value of the
standard C library symbol <b>P_tmpdir</b>, just like <b>tmpfile()</b>.

<p>Unlike <b>tmpfile()</b>, <b>pm_tmpfile()</b> never returns NULL.
If it fails, it issues a message to Standard Error and aborts the
program, like most libnetpbm routines do.

<p>If you need to refer to the temporary file by name, use
<b>pm_make_tmpfile()</b> instead.

<h2>HISTORY</h2>

<p><b>pm_tmpfile()</b> was introduced in Netpbm 10.20 (January 2004).

</body>
</html>