LIBTMPFILE(3)

πŸ“¦
version 11.13.03 Β· 2 versions
  • 11.13.03 Β· centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 10.86.51 Β· arch rolling
, in centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– LIBTMPFILE(3) β€” aka the pm_tmpfile() glow-up πŸ’–

okay bestie, welcome to the Netpbm sub...) function(3) page, straight out of the Library Functions Manual ✨ this one's short, sweet, and lowkey iconic, so let's get into it 🫢


✨ NAME ✨

pm_tmpfile() β€” create a temporary unnamed file πŸŽ€


🌸 SYNOPSIS 🌸

#include <netpbm/pm.h>

FILE *
pm_tmpfile(void);

like. that's it. that's the whole vibe. πŸ’…


πŸ¦‹ EXAMPLE πŸ¦‹

okay so here's a lil baby example that literally does the most: it makes a temp file, writes "hello world" into it, then reads it right back and prints what it found. main character behavior fr fr ✨

#include <netpbm/pm.h>

FILE * myfileP;

myfile = pm_tmpfile();

fprintf(myfile, "hello world\n");

fseek(myfileP, 0, SEEK_SET);

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

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

fclose(myfileP);

(and yes bestie, we are printing it exactly as the page has it, typos and all β€” not my job to fix the lore πŸ’€)


πŸ’œ DESCRIPTION πŸ’œ

so this library function is part of Netpbm(1) 🫢

pm_tmpfile() creates and opens an unnamed temporary file. it's basically the same thing as the standard C library tmpfile() function β€” same energy, same fit β€” except that it uses the TMPFILE environment variable to decide where to create the temporary file πŸ‘‘

if TMPFILE is not set, or it's set to something unusable (e.g. too long 😭), then pm_tmpfile() falls back to the value of the standard C library symbol P_tmpdir, just like tmpfile() does. no cap, that's the fallback plan.

🚨 but here's the plot twist, and it's the good kind: unlike tmpfile(), pm_tmpfile() never returns NULL. if it fails, it issues a message to Standard Error and aborts the program, like most libnetpbm routines do. so like, it doesn't ghost you β€” it either shows up or it full-on ends the show πŸ’€

if you need to refer to the temporary file by name, use pm_make_tmpfile() instead. that's the one for that job, bestie ✨


🌈 HISTORY 🌈

pm_tmpfile() was introduced in Netpbm 10.20 (January 2004) πŸŽ‚ a true elder icon, we respect her.


πŸŽ€ 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/libtmpfile.html

netpbm documentation Β· 22 July 2004 Β· Netpbm sub...) function(3) β€” ok that's the whole page bestie, you ate that, go forth and make ur unnamed temp files πŸ’…πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ«Ά

πŸ“¦ where this page comes from