]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - utility.h
Updated changelog
[mirror_smartmontools-debian.git] / utility.h
index f2d081ffc022751ca6a69fbd10b9c8c8ec6b267c..5635655f408b7351fe6fd6418c32ecf1fecda679 100644 (file)
--- a/utility.h
+++ b/utility.h
@@ -26,7 +26,7 @@
 #ifndef UTILITY_H_
 #define UTILITY_H_
 
-#define UTILITY_H_CVSID "$Id: utility.h 3285 2011-03-04 22:08:49Z chrfranke $"
+#define UTILITY_H_CVSID "$Id: utility.h 3475 2011-11-10 21:43:40Z chrfranke $"
 
 #include <time.h>
 #include <sys/types.h> // for regex.h (according to POSIX)
 #include <string.h>
 #include <string>
 
-#if !defined(__GNUC__) && !defined(__attribute__)
-#define __attribute__(x)  /**/
+#ifndef __GNUC__
+#define __attribute_format_printf(x, y)  /**/
+#elif defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO
+// Check format of __mingw_*printf() instead of MSVCRT.DLL:*printf()
+#define __attribute_format_printf(x, y)  __attribute__((format (gnu_printf, x, y)))
+#define HAVE_WORKING_SNPRINTF 1
+#else
+#define __attribute_format_printf(x, y)  __attribute__((format (printf, x, y)))
 #endif
 
 // Make version information string
@@ -45,13 +51,13 @@ std::string format_version_info(const char * prog_name, bool full = false);
 
 // return (v)sprintf() formated std::string
 std::string strprintf(const char * fmt, ...)
-    __attribute__ ((format (printf, 1, 2)));
+    __attribute_format_printf(1, 2);
 std::string vstrprintf(const char * fmt, va_list ap);
 
 #ifndef HAVE_WORKING_SNPRINTF
 // Substitute by safe replacement functions
 int safe_snprintf(char *buf, int size, const char *fmt, ...)
-    __attribute__ ((format (printf, 3, 4)));
+    __attribute_format_printf(3, 4);
 int safe_vsnprintf(char *buf, int size, const char *fmt, va_list ap);
 #define snprintf  safe_snprintf
 #define vsnprintf safe_vsnprintf
@@ -75,7 +81,7 @@ void dateandtimezoneepoch(char *buffer, time_t tval);
 // itself is defined differently in smartctl and smartd.  So the
 // function definition(s) are in smartd.c and in smartctl.c.
 void pout(const char *fmt, ...)  
-     __attribute__ ((format (printf, 1, 2)));
+    __attribute_format_printf(1, 2);
 
 // replacement for perror() with redirected output.
 void syserror(const char *message);
@@ -173,6 +179,14 @@ void FixGlibcTimeZoneBug();
 // convert time in msec to a text string
 void MsecToText(unsigned int msec, char *txt);
 
+// Format integer with thousands separator
+const char * format_with_thousands_sep(char * str, int strsize, uint64_t val,
+                                       const char * thousands_sep = 0);
+
+// Format capacity with SI prefixes
+const char * format_capacity(char * str, int strsize, uint64_t val,
+                             const char * decimal_point = 0);
+
 // Wrapper class for a raw data buffer
 class raw_buffer
 {