Merge pull request #140 from hussainnaqvee/patch-1
[awesomized/libmemcached] / src / bin / common / options.hpp
index 70be59039d877b713c88e3a7ff11de29b70b812b..93275b338f949fd753fd34cfec46a6fcd76122f6 100644 (file)
@@ -1,6 +1,6 @@
 /*
     +--------------------------------------------------------------------+
-    | libmemcached - C/C++ Client Library for memcached                  |
+    | libmemcached-awesome - C/C++ Client Library for memcached          |
     +--------------------------------------------------------------------+
     | Redistribution and use in source and binary forms, with or without |
     | modification, are permitted under the terms of the BSD license.    |
@@ -9,7 +9,7 @@
     | the terms online at: https://opensource.org/licenses/BSD-3-Clause  |
     +--------------------------------------------------------------------+
     | Copyright (c) 2006-2014 Brian Aker   https://datadifferential.com/ |
-    | Copyright (c) 2020 Michael Wallner   <mike@php.net>                |
+    | Copyright (c) 2020-2021 Michael Wallner        https://awesome.co/ |
     +--------------------------------------------------------------------+
 */
 
 #include <cstdint>
 #include <climits>
 #include <functional>
-#include <getopt.h>
 #include <iostream>
 #include <string>
 #include <vector>
 
 #include "libmemcached/common.h"
+#include "p9y/getopt.hpp"
 
 class client_options {
 public:
@@ -94,13 +94,14 @@ 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
+          (void) memc;
           if (!opt.isset("quiet")) {
             std::cerr
-                << "SASL username was supplied, but binary was not built with SASL support.\n";
-            return false;
+                << "SASL username '" << username << "' was supplied, but binary was not built with SASL support.\n";
           }
-        }
+          return false;
+#else
         if (memc) {
           if (MEMCACHED_SUCCESS
               != memcached_set_sasl_auth_data(memc, username, opt.argof("password"))) {
@@ -110,6 +111,7 @@ public:
             return false;
           }
         }
+#endif
       }
       return true;
     };