MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsTempFd

Function cupsTempFd

cups/tempfile.c:35–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 */
34
35int /* O - New file descriptor or -1 on error */
36cupsTempFd(char *filename, /* I - Pointer to buffer */
37 int len) /* I - Size of buffer */
38{
39 int fd; /* File descriptor for temp file */
40 int tries; /* Number of tries */
41 const char *tmpdir; /* TMPDIR environment var */
42#if (defined(__APPLE__) && defined(_CS_DARWIN_USER_TEMP_DIR)) || defined(_WIN32)
43 char tmppath[1024]; /* Temporary directory */
44#endif /* (__APPLE__ && _CS_DARWIN_USER_TEMP_DIR) || _WIN32 */
45#ifdef _WIN32
46 DWORD curtime; /* Current time */
47#else
48 struct timeval curtime; /* Current time */
49#endif /* _WIN32 */
50
51
52 /*
53 * See if TMPDIR is defined...
54 */
55
56#ifdef _WIN32
57 if ((tmpdir = getenv("TEMP")) == NULL)
58 {
59 GetTempPathA(sizeof(tmppath), tmppath);
60 tmpdir = tmppath;
61 }
62
63#elif defined(__APPLE__)
64 /*
65 * On macOS and iOS, the TMPDIR environment variable is not always the best
66 * location to place temporary files due to sandboxing. Instead, the confstr
67 * function should be called to get the proper per-user, per-process TMPDIR
68 * value.
69 */
70
71 if ((tmpdir = getenv("TMPDIR")) != NULL && access(tmpdir, W_OK))
72 tmpdir = NULL;
73
74 if (!tmpdir)
75 {
76#ifdef _CS_DARWIN_USER_TEMP_DIR
77 if (confstr(_CS_DARWIN_USER_TEMP_DIR, tmppath, sizeof(tmppath)))
78 tmpdir = tmppath;
79 else
80#endif /* _CS_DARWIN_USER_TEMP_DIR */
81 tmpdir = "/private/tmp"; /* OS X 10.4 and earlier */
82 }
83
84#else
85 /*
86 * Previously we put root temporary files in the default CUPS temporary
87 * directory under /var/spool/cups. However, since the scheduler cleans
88 * out temporary files there and runs independently of the user apps, we
89 * don't want to use it unless specifically told to by cupsd.
90 */
91
92 if ((tmpdir = getenv("TMPDIR")) == NULL)

Callers 15

pdf_to_psFunction · 0.85
get_job_fileFunction · 0.85
recv_print_jobFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
cgi_initialize_multipartFunction · 0.85
do_am_printerFunction · 0.85
do_config_serverFunction · 0.85
mainFunction · 0.85
get_cupsd_confFunction · 0.85
cups_get_urlFunction · 0.85
cupsTempFile2Function · 0.85

Calls

no outgoing calls

Tested by 1

make_raster_fileFunction · 0.68