]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - utility.h
Imported Upstream version 5.42+svn3561
[mirror_smartmontools-debian.git] / utility.h
index 5635655f408b7351fe6fd6418c32ecf1fecda679..13d5ac9a424062338cf0a7cd136b61e08a5c2e7c 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
@@ -26,7 +26,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 3558 2012-06-05 16:42:05Z chrfranke $"
 
 #include <time.h>
 #include <sys/types.h> // for regex.h (according to POSIX)
@@ -54,6 +54,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, ...)