1Netpbm subroutine liNbertaprbym:spLumib_brmroaaukrteyi_ntFemupnlfciitblireoa_nrfsyd:(M)apnmfu_uamnlacktei_otnm(p3f)ile_fd() function(3)
2
3
4
6 pm_make_tmpfile_fd() - create a temporary named file
7
8
10 #include <netpbm/pm.h>
11
12 pm_make_tmpfile(int * fdP,
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 int fd;
25 const char * myfilename;
26
27 pm_make_tmpfile_fd(&fdP, &myfilename);
28
29 write(fd, "^account:\\s.*\n", 16);
30 fprintf(fd, "^name:\\s.*\n", 13);
31
32 close(fd);
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_fd() is analogous to pm_make_tmpfile()[22m(1). The only
51 difference is that it opens the file as a low level file, as open()
52 would, rather than as a stream, as fopen() would.
53
54 If you don't need to access the file by name, use pm_tmpfile_fd() in‐
55 stead, because it's cleaner. With pm_tmpfile_fd(), the operating sys‐
56 tem always deletes the temporary file when your program exits, if the
57 program failed to clean up after itself.
58
59
60
62 pm_tmpfile() was introduced in Netpbm 10.42 (March 2008).
63
65 This manual page was generated by the Netpbm tool 'makeman' from HTML
66 source. The master documentation is at
67
68 http://netpbm.sourceforge.net/doc/libmaketmpfilefd.html
69
70netpbm documentationNetpbm subro3u1tiDneecelmibberrar2y0:07pm_make_tmpfile_fd() function(3)