fix includes
[awesomized/libmemcached] / src / bin / common / options.hpp
index fbcd10f6eb7b210022b617ec8539c28c17d0df3e..980ca38dc39ab8865a498002e98d6f334d4c2814 100644 (file)
 #include <cstdint>
 #include <climits>
 #include <functional>
-#include <getopt.h>
 #include <iostream>
 #include <string>
 #include <vector>
 
 #include "libmemcached/common.h"
 
+#ifdef HAVE_GETOPT_H
+#  include <getopt.h>
+#elif defined _MSC_VER
+#  include "win32/getopt.h"
+#endif
+
 class client_options {
 public:
 
@@ -94,13 +99,13 @@ public:
     def("username", 'u', required_argument, "SASL username.")
         .apply = [](const client_options &opt, const extended_option &ext, memcached_st *memc) {
       if (auto username = ext.arg) {
-        if (!LIBMEMCACHED_WITH_SASL_SUPPORT) {
+#if !LIBMEMCACHED_WITH_SASL_SUPPORT
           if (!opt.isset("quiet")) {
             std::cerr
                 << "SASL username was supplied, but binary was not built with SASL support.\n";
-            return false;
           }
-        }
+          return false;
+#else
         if (memc) {
           if (MEMCACHED_SUCCESS
               != memcached_set_sasl_auth_data(memc, username, opt.argof("password"))) {
@@ -110,6 +115,7 @@ public:
             return false;
           }
         }
+#endif
       }
       return true;
     };
@@ -310,13 +316,13 @@ public:
     }
   }
 
-  const char *argof(const std::string &name) const {
+  char *argof(const std::string &name) const {
     if (has(name)) {
       return get(name).arg;
     }
     return nullptr;
   }
-  const char *argof(int c) const {
+  char *argof(int c) const {
     if (has(c)) {
       return get(c).arg;
     }
@@ -341,9 +347,6 @@ private:
   using const_iterator = std::vector<extended_option>::const_iterator;
   using predicate = std::function<bool(const extended_option &ext)>;
 
-  static option null_opt;
-  static const extended_option null_ext_opt;
-
   const_iterator find(const predicate &pred) const {
     return std::find_if(options.cbegin(), options.cend(), pred);
   }