]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - utility.h
Refreshed patches and removed patches applied upstream
[mirror_smartmontools-debian.git] / utility.h
index 5635655f408b7351fe6fd6418c32ecf1fecda679..72764ee57614eed61ba2f96d55cfa811f8297b8a 100644 (file)
--- a/utility.h
+++ b/utility.h
@@ -4,7 +4,7 @@
  * Home page of code is: http://smartmontools.sourceforge.net
  *
  * Copyright (C) 2002-11 Bruce Allen <smartmontools-support@lists.sourceforge.net>
- * Copyright (C) 2008-11 Christian Franke <smartmontools-support@lists.sourceforge.net>
+ * Copyright (C) 2008-12 Christian Franke <smartmontools-support@lists.sourceforge.net>
  * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,7 @@
  * any later version.
  *
  * You should have received a copy of the GNU General Public License
- * (for example COPYING); if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
  *
  * This code was originally developed as a Senior Thesis by Michael Cornwell
  * at the Concurrent Systems Laboratory (now part of the Storage Systems
@@ -26,7 +25,7 @@
 #ifndef UTILITY_H_
 #define UTILITY_H_
 
-#define UTILITY_H_CVSID "$Id: utility.h 3475 2011-11-10 21:43:40Z chrfranke $"
+#define UTILITY_H_CVSID "$Id: utility.h 3719 2012-12-03 21:19:33Z chrfranke $"
 
 #include <time.h>
 #include <sys/types.h> // for regex.h (according to POSIX)
@@ -54,6 +53,13 @@ std::string strprintf(const char * fmt, ...)
     __attribute_format_printf(1, 2);
 std::string vstrprintf(const char * fmt, va_list ap);
 
+// Return true if STR starts with PREFIX
+inline bool str_starts_with(const char * str, const char * prefix)
+  { return !strncmp(str, prefix, strlen(prefix)); }
+
+inline bool str_starts_with(const std::string & str, const char * prefix)
+  { return !strncmp(str.c_str(), prefix, strlen(prefix)); }
+
 #ifndef HAVE_WORKING_SNPRINTF
 // Substitute by safe replacement functions
 int safe_snprintf(char *buf, int size, const char *fmt, ...)
@@ -88,8 +94,6 @@ void syserror(const char *message);
 
 // Function for processing -r option in smartctl and smartd
 int split_report_arg(char *s, int *i);
-// Function for processing -c option in smartctl and smartd
-int split_report_arg2(char *s, int *i);
 
 // Function for processing -t selective... option in smartctl
 int split_selective_arg(char *s, uint64_t *start, uint64_t *stop, int *mode);
@@ -176,9 +180,6 @@ bool nonempty(const void * data, int size);
 // needed to fix glibc bug
 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);