2 * Copyright (C) 2010 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
8 * Summary: connect to all hosts, and make sure they meet a minimum version
12 /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */
13 #include "libmemcached/common.h"
14 #include "libmemcached/memcached_util.h"
18 uint8_t major_version
;
19 uint8_t minor_version
;
20 uint8_t micro_version
;
25 static memcached_return_t
check_server_version(const memcached_st
*ptr
__attribute__((unused
)),
26 const memcached_server_st
*instance
,
30 struct local_context
*check
= (struct local_context
*)context
;
32 if (instance
->major_version
>= check
->major_version
&&
33 instance
->minor_version
>= check
->minor_version
&&
34 instance
->micro_version
>= check
->micro_version
)
36 return MEMCACHED_SUCCESS
;
41 return MEMCACHED_FAILURE
;
44 bool libmemcached_util_version_check(memcached_st
*memc
,
45 uint8_t major_version
,
46 uint8_t minor_version
,
47 uint8_t micro_version
)
49 memcached_server_fn callbacks
[1];
50 memcached_version(memc
);
52 struct local_context check
= { .major_version
= major_version
, .minor_version
= minor_version
, .micro_version
= micro_version
, .truth
= true };
54 callbacks
[0]= check_server_version
;
55 memcached_server_cursor(memc
, callbacks
, (void *)&check
, 1);