1Netpbm subroutine libraNreyt:pbpLmmi_bsmruaabkrreyo_utFtmuipnnfceitlileoi(nb)srafMruaynn:cutapilmo_nm(a3k)e_tmpfile() function(3)
2
3
4
6 pm_make_tmpfile() - create a temporary named file
7
8
10 #include <netpbm/pm.h>
11
12 pm_make_tmpfile(FILE ** fileP,
13 const char ** filenameP);
14
15
16
18 This simple example creates a temporary file, writes "hello world" to
19 it, then writes some search patterns to it, then uses it as input to
20 grep:
21
22 #include <netpbm/pm.h>
23
24 FILE * myfileP;
25 const char * myfilename;
26
27 pm_make_tmpfile(&myfileP, &myfilename);
28
29 fprintf(myfile, "^account:\\s.*\n");
30 fprintf(myfile, "^name:\\s.*\n");
31
32 fclose(myFileP);
33
34 asprintfN(&grepCommand, "grep --file='%s' /tmp/infile >/tmp/outfile");
35
36 system(grepCommand);
37
38 strfree(grepCommand);
39
40 unlink(myfilename);
41
42 strfree(myfilename);
43
44
45
46
48 This library function is part of Netpbm(1).
49
50 pm_make_tmpfile() creates and opens a temporary file, returning to you
51 a stream file handle for it and its name.
52
53 pm_make_tmpfile() chooses a file name that is not already in use, with
54 proper interlocking to make sure that it actually creates a file and
55 opens the new file, as opposed to merely opening an existing file.
56
57 If you don't need to access the file by name, use pm_tmpfile() instead,
58 because it's cleaner. With pm_tmpfile(), the operating system always
59 deletes the temporary file when your program exits, if the program
60 failed to clean up after itself.
61
62 The temporary file goes in the directory named by the TMPFILE environā
63 ment variable. If TMPFILE is not set or is set to something unusable
64 (e.g. too long), pm_tmpfile() falls back to the value of the standard
65 C library symbol P_tmpdir (like the standard C library's tmpfile()).
66
67 The name of the file within that directory is like myprog_blrfx, where
68 myprog is the name of your program (arg 0) and the rest is an arbitrary
69 discriminator.
70
71 If pm_make_tmpfile() is unable to create a temporary file, it issues a
72 message to Standard Error and aborts the program.
73
74
75
77 pm_tmpfile() was introduced in Netpbm 10.27 (March 2005).
78
80 This manual page was generated by the Netpbm tool 'makeman' from HTML
81 source. The master documentation is at
82
83 http://netpbm.sourceforge.net/doc/libmaketmpfile.html
84
85netpbm documentation Netpbm su1b0roNuotvienmebelrib2r0a0r7y: pm_make_tmpfile() function(3)