#ifndef UTILITY_H_
#define UTILITY_H_
-#define UTILITY_H_CVSID "$Id: utility.h,v 1.43 2006/04/12 14:54:28 ballen4705 Exp $\n"
+#define UTILITY_H_CVSID "$Id: utility.h,v 1.46 2006/08/25 06:06:25 sxzzsf Exp $\n"
#include <time.h>
#include <sys/types.h> // for regex.h (according to POSIX)
#ifndef __GNUC__
#define __attribute__(x) /* nothing */
#endif
-void pout(char *fmt, ...)
+void pout(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
// replacement for perror() with redirected output.
void *Calloc(size_t nmemb, size_t size);
// Utility function to free memory
-void *FreeNonZero(void* address, int size, int whatline, const char* file);
+void *FreeNonZero1(void* address, int size, int whatline, const char* file);
+
+// Typesafe version of above
+template <class T>
+inline T * FreeNonZero(T * address, int size, int whatline, const char* file)
+ { return (T *)FreeNonZero1((void *)address, size, whatline, file); }
// A custom version of strdup() that keeps track of how much memory is
// being allocated. If mustexist is set, it also throws an error if we
// To help with memory checking. Use when it is known that address is
// NOT null.
-void *CheckFree(void *address, int whatline, const char* file);
+void *CheckFree1(void *address, int whatline, const char* file);
+
+// Typesafe version of above
+template <class T>
+inline T * CheckFree(T * address, int whatline, const char* file)
+ { return (T *)CheckFree1((void *)address, whatline, file); }
// This function prints either to stdout or to the syslog as needed
// values. This means the objects of type char or short int (whether
// signed or not) are promoted to either int or unsigned int, as
// appropriate.]
-void PrintOut(int priority,char *fmt, ...);
+void PrintOut(int priority, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
// run time, determine byte ordering
int isbigendian();
#define CONTROLLER_3WARE_9000_CHAR 0x05 // set by guess_device_type()
#define CONTROLLER_3WARE_678K_CHAR 0x06 // set by guess_device_type()
#define CONTROLLER_MARVELL_SATA 0x07 // SATA drives behind Marvell controllers
-
+#define CONTROLLER_SAT 0x08 // SATA device behind a SCSI ATA Translation (SAT) layer
+#define CONTROLLER_HPT 0x09 // SATA drives behind HighPoint Raid controllers
#endif