]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - compat/tempnam.c
Source Format Enforcement (#763)
[thirdparty/squid.git] / compat / tempnam.c
index 8e61f4467164efed253a72aeea69a2c9f318f65d..12622b773d47b9e6b221ebee6d4b72c1d0a22c7a 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 /* A reasonably functional tmpnam. */
 
 /* Originally by Tom Hageman, tom@basil.icce.rug.nl */
@@ -8,7 +16,7 @@
  * temp file is written in /tmp.
  */
 
-#include "config.h"
+#include "squid.h"
 #include "compat/tempnam.h"
 
 #if HAVE_LIBC_H
 
 #undef TMP_MAX
 
-#define _tmp           "/tmp/"
-#define lengthof_tmp   5
+#define _tmp        "/tmp/"
+#define lengthof_tmp    5
 
 #ifndef LONG_BIT
-#define LONG_BIT       (CHAR_BIT * 4)  /* assume sizeof(long) == 4 */
+#define LONG_BIT    (CHAR_BIT * 4)  /* assume sizeof(long) == 4 */
 #endif
 
-#define L_tmpmin       (lengthof_tmp + 5)      /* 5 chars for pid. */
+#define L_tmpmin    (lengthof_tmp + 5)  /* 5 chars for pid. */
 
 #if (L_tmpnam > L_tmpmin)
-#if (L_tmpnam > L_tmpmin + LONG_BIT / 6)       /* base 64 */
-#define TMP_MAX        ULONG_MAX
+#if (L_tmpnam > L_tmpmin + LONG_BIT / 6)    /* base 64 */
+#define TMP_MAX ULONG_MAX
 #else
-#define TMP_MAX        ((1L << (6 * (L_tmpnam - L_tmpmin))) - 1)
+#define TMP_MAX ((1L << (6 * (L_tmpnam - L_tmpmin))) - 1)
 #endif
 #else
 #ifndef L_tmpnam
 #endif
 #endif
 
-
 static char *
 _tmpnam(void)
 {
     static const char digits[] =
 #if (L_tmpnam >= L_tmpmin + LONG_BIT / 4)
         "0123456789abcdef";
-#define TMP_BASE       16
+#define TMP_BASE    16
 #else
         "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
-#define TMP_BASE       64
+#define TMP_BASE    64
 #endif
     static unsigned long lastcount = 0;
     static char buffer[L_tmpnam + 1];
@@ -65,7 +72,7 @@ _tmpnam(void)
     pid_t pid = getpid();
 
     if (sizeof(_tmp) - 1 != lengthof_tmp)
-        abort();               /* Consistency error. */
+        abort();        /* Consistency error. */
 
     for (;;) {
         register int i = L_tmpnam;
@@ -128,3 +135,4 @@ main()
     return 1;
 }
 #endif
+