LIBMAKETMPFILEFD(3)
β¨ LIBMAKETMPFILEFD(3) β¨
okay bestie, we're in the Netpbm corner of the library functions manual, and today's main character is pm_make_tmpfile_fd() π yes it's a library function, yes it lives in section 3, and yes it's about to be your new fave for making temp files. sit down, grab a strawberry π, let's go.
π NAME π
pm_make_tmpfile_fd() β create a temporary named file π¦
literally that's the whole job. make a temp file. give it a name. slay.
πΈ SYNOPSIS πΈ
#include <netpbm/pm.h>
pm_make_tmpfile(int * fdP,
const char ** filenameP);
that's the whole vibe, no cap. π«Ά
β¨ EXAMPLE β¨
okay so this simple example creates a temporary file, writes "hello world" to it, then writes some search patterns to it, then uses it as input to grep. iconic behaviour honestly π
#include <netpbm/pm.h>
int fd;
const char * myfilename;
pm_make_tmpfile_fd(&fdP, &myfilename);
write(fd, "^account:\\s.*\n", 16);
fprintf(fd, "^name:\\s.*\n", 13);
close(fd);
asprintfN(&grepCommand, "grep --file='%s' /tmp/infile >/tmp/outfile");
system(grepCommand);
strfree(grepCommand);
unlink(myfilename);
strfree(myfilename);
not me reading this and being like "okay yes, clean up after yourself, queen" π§Ήβ¨ unlink the file, strfree the name, periodt.
π DESCRIPTION π
so this library function is part of Netpbm(1). yes, that Netpbm. the whole family. π
pm_make_tmpfile_fd() is analogous to pm_make_tmpfile()(1). the only difference is that it opens the file as a low level file, the way open() would, rather than as a stream, the way fopen() would. that's it. that's the whole plot twist π₯
if you don't actually need to access the file by name, bestie, usepm_tmpfile_fd()instead, because it's cleaner. withpm_tmpfile_fd(), the operating system always deletes the temporary file when your program exits, even if your program failed to clean up after itself. main character energy from the OS fr fr π
π¦ HISTORY π¦
pm_tmpfile() was introduced in Netpbm 10.42 (March 2008). so it's a little vintage, a little classic, still serving. β
π DOCUMENT SOURCE π
this manual page was generated by the Netpbm tool makeman from HTML source. the master documentation lives at:
http://netpbm.sourceforge.net/doc/libmaketmpfilefd.html
go peek if you want the source of truth, iykyk π
and that's the whole page, bestie!! π«Ά brought to you by the netpbm documentation, dated 31 December 2007, closing out this Netpbm section 3 library function manual like the absolute icon it is. mwah π β¨
π¦ where this page comes from
- centos-stream 10: netpbm-devel 11.09.00-1.el10 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- centos-stream 9: netpbm-devel 10.95.00-3.el9 Β· BSD and GPLv2 and IJG and MIT and Public Domain
- centos-stream 9: netpbm-devel 10.95.00-3.el9 Β· BSD and GPLv2 and IJG and MIT and Public Domain
- debian trixie: libnetpbm-dev 2:11.10.02-1 Β· MIT
- fedora 43: netpbm-devel 11.10.00-2.fc43 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- fedora 43: netpbm-devel 11.10.00-2.fc43 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- fedora 43: netpbm-devel 11.13.00-1.fc43 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- fedora 43: netpbm-devel 11.13.00-1.fc43 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- fedora 44: netpbm-devel 11.13.00-2.fc44 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- fedora 44: netpbm-devel 11.13.00-2.fc44 Β· BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
- ubuntu noble: libnetpbm-dev 2:11.05.02-1.1build1 Β· MIT
- ubuntu resolute: libnetpbm-dev 2:11.10.02-1build1 Β· MIT
- ubuntu stonking: libnetpbm-dev 2:11.13.03+ds-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms