]> git.proxmox.com Git - mirror_smartmontools-debian.git/blobdiff - dev_interface.cpp
Refreshed patches
[mirror_smartmontools-debian.git] / dev_interface.cpp
index f19aff7ef218dd01147040723f3250fe2882968a..a14f47cedfc8a36191850f1be74c9762f823dc8f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Home page of code is: http://smartmontools.sourceforge.net
  *
- * Copyright (C) 2008 Christian Franke <smartmontools-support@lists.sourceforge.net>
+ * Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 #include <stdexcept>
 
-const char * dev_interface_cpp_cvsid = "$Id: dev_interface.cpp,v 1.5 2009/01/30 18:34:55 chrfranke Exp $"
+const char * dev_interface_cpp_cvsid = "$Id: dev_interface.cpp 2971 2009-10-26 22:05:54Z chrfranke $"
   DEV_INTERFACE_H_CVSID;
 
 /////////////////////////////////////////////////////////////////////////////
@@ -217,29 +217,27 @@ void tunnelled_device_base::release(const smart_device * dev)
 // Pointer to (usually singleton) interface object returned by ::smi()
 smart_interface * smart_interface::s_instance;
 
-const char * smart_interface::get_os_version_str()
+std::string smart_interface::get_os_version_str()
 {
   return SMARTMONTOOLS_BUILD_HOST;
 }
 
-const char * smart_interface::get_valid_dev_types_str()
+std::string smart_interface::get_valid_dev_types_str()
 {
-  static std::string buf;
-  if (!buf.empty())
-    return buf.c_str();
   // default
-  buf = "ata, scsi, sat[,N][+TYPE]";
+  std::string s =
+    "ata, scsi, sat[,N][+TYPE], usbcypress[,X], usbjmicron[,x][,N], usbsunplus";
   // append custom
-  const char * add = get_valid_custom_dev_types_str();
-  if (!add || !*add)
-    return buf.c_str();
-  buf += ", "; buf += add;
-  return buf.c_str();
+  std::string s2 = get_valid_custom_dev_types_str();
+  if (!s2.empty()) {
+    s += ", "; s += s2;
+  }
+  return s;
 }
 
-const char * smart_interface::get_app_examples(const char * /*appname*/)
+std::string smart_interface::get_app_examples(const char * /*appname*/)
 {
-  return 0;
+  return "";
 }
 
 void smart_interface::set_err(int no, const char * msg, ...)
@@ -303,29 +301,22 @@ smart_device * smart_interface::get_smart_device(const char * name, const char *
     // Recurse to allocate base device, default is standard SCSI
     if (!*basetype)
       basetype = "scsi";
-    dev = get_smart_device(name, basetype);
-    if (!dev) {
+    smart_device_auto_ptr basedev( get_smart_device(name, basetype) );
+    if (!basedev) {
       set_err(EINVAL, "Type '%s+...': %s", sattype.c_str(), get_errmsg());
       return 0;
     }
     // Result must be SCSI
-    if (!dev->is_scsi()) {
-      delete dev;
+    if (!basedev->is_scsi()) {
       set_err(EINVAL, "Type '%s+...': Device type '%s' is not SCSI", sattype.c_str(), basetype);
       return 0;
     }
     // Attach SAT tunnel
-    try {
-      ata_device * satdev = get_sat_device(sattype.c_str(), dev->to_scsi());
-      if (!satdev) {
-        delete dev;
-        return 0;
-      }
-      return satdev;
-    }
-    catch (...) {
-      delete dev; throw;
-    }
+    ata_device * satdev = get_sat_device(sattype.c_str(), basedev->to_scsi());
+    if (!satdev)
+      return 0;
+    basedev.release();
+    return satdev;
   }
 
   else {
@@ -342,7 +333,7 @@ smart_device * smart_interface::get_custom_smart_device(const char * /*name*/, c
   return 0;
 }
 
-const char * smart_interface::get_valid_custom_dev_types_str()
+std::string smart_interface::get_valid_custom_dev_types_str()
 {
-  return 0;
+  return "";
 }