projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Add test cases for add server for NULL cases.
[m6w6/libmemcached]
/
clients
/
utilities.cc
diff --git
a/clients/utilities.cc
b/clients/utilities.cc
index ca109adcfa66bd1229e0dbaa9ee0640356451d1d..8be59abb4e9cc12f12e29935ab7c2c3fe9ecc490 100644
(file)
--- a/
clients/utilities.cc
+++ b/
clients/utilities.cc
@@
-127,10
+127,12
@@
void process_hash_option(memcached_st *memc, char *opt_hash)
}
}
}
}
-#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+
static char *username;
static char *passwd;
static char *username;
static char *passwd;
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+
static int get_username(void *context, int id, const char **result, unsigned int *len)
{
(void)context;
static int get_username(void *context, int id, const char **result, unsigned int *len)
{
(void)context;
@@
-139,7
+141,9
@@
static int get_username(void *context, int id, const char **result, unsigned int
*result= username;
if (len)
*result= username;
if (len)
+ {
*len= (username == NULL) ? 0 : (unsigned int)strlen(username);
*len= (username == NULL) ? 0 : (unsigned int)strlen(username);
+ }
return SASL_OK;
}
return SASL_OK;
}
@@
-181,44
+185,55
@@
static sasl_callback_t sasl_callbacks[] = {
{ SASL_CB_PASS, (local_sasl_fn)get_password, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};
{ SASL_CB_PASS, (local_sasl_fn)get_password, NULL },
{ SASL_CB_LIST_END, NULL, NULL }
};
+
#endif
bool initialize_sasl(memcached_st *memc, char *user, char *password)
{
#endif
bool initialize_sasl(memcached_st *memc, char *user, char *password)
{
-#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+ if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ {
+ return false;
+ }
+
+ if (memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)true) == 0)
+ {
+ return false;
+ }
+
if (user != NULL && password != NULL)
{
username= user;
passwd= password;
if (user != NULL && password != NULL)
{
username= user;
passwd= password;
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
if (sasl_client_init(NULL) != SASL_OK)
{
fprintf(stderr, "Failed to initialize sasl library!\n");
return false;
}
memcached_set_sasl_callbacks(memc, sasl_callbacks);
if (sasl_client_init(NULL) != SASL_OK)
{
fprintf(stderr, "Failed to initialize sasl library!\n");
return false;
}
memcached_set_sasl_callbacks(memc, sasl_callbacks);
- }
#else
#else
- (void)memc;
- (void)user;
- (void)password;
+ (void)memc;
#endif
#endif
+ }
return true;
}
void shutdown_sasl(void)
{
return true;
}
void shutdown_sasl(void)
{
-#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
- if (username != NULL || passwd != NULL)
+ if (username or passwd)
+ {
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
sasl_done();
#endif
sasl_done();
#endif
+ }
}
void initialize_sockets(void)
{
/* Define the function for all platforms to avoid #ifdefs in each program */
}
void initialize_sockets(void)
{
/* Define the function for all platforms to avoid #ifdefs in each program */
-#if
def
WIN32
+#if
defined(WIN32) &&
WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0)
{
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0)
{