return NULL;
// Copy URL
- snprintf(transfer->url, sizeof(transfer->url) - 1, "%s", url);
+ pakfire_string_set(transfer->url, url);
// Copy path
- snprintf(transfer->path, sizeof(transfer->path) - 1, "%s", path);
-
- // Make path for the temporary file (must be on the same file system)
- snprintf(transfer->tempfile, sizeof(transfer->tempfile) - 1, "%s.XXXXXX", path);
+ pakfire_string_set(transfer->path, path);
// Keep a reference to the mirrorlist
if (mirrors)
// Open a temporary file to write the output to
if (!transfer->f) {
+ // Make path for the temporary file (must be on the same file system)
+ int r = pakfire_string_format(transfer->tempfile, "%s.XXXXXX", transfer->path);
+ if (r < 0)
+ return 1;
+
transfer->f = pakfire_mktemp(transfer->tempfile);
if (!transfer->f) {
ERROR(downloader->pakfire, "Could not create temporary file for download %s: %s\n",
#include <pakfire/types.h>
-#define pakfire_string_set(s, value) snprintf(s, sizeof(s) - 1, "%s", value)
+#define pakfire_string_format(s, fmt, ...) snprintf(s, sizeof(s) - 1, fmt, __VA_ARGS__)
+#define pakfire_string_set(s, value) pakfire_string_format(s, "%s", value)
int pakfire_string_startswith(const char* s, const char* prefix);
int pakfire_string_endswith(const char* s, const char* suffix);