2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
16 #include "libmemcachedutil/common.h"
19 struct local_context
{
20 uint8_t major_version
;
21 uint8_t minor_version
;
22 uint8_t micro_version
;
27 static memcached_return_t
28 check_server_version(const memcached_st
*, const memcached_instance_st
*instance
, void *context
) {
30 struct local_context
*check
= (struct local_context
*) context
;
32 if (memcached_server_major_version(instance
) != UINT8_MAX
) {
35 sv
= memcached_server_micro_version(instance
) | memcached_server_minor_version(instance
) << 8
36 | memcached_server_major_version(instance
) << 16;
37 cv
= check
->micro_version
| check
->minor_version
<< 8 | check
->major_version
<< 16;
40 return MEMCACHED_SUCCESS
;
46 return MEMCACHED_FAILURE
;
49 bool libmemcached_util_version_check(memcached_st
*memc
, uint8_t major_version
,
50 uint8_t minor_version
, uint8_t micro_version
) {
51 if (memcached_failed(memcached_version(memc
))) {
55 struct local_context check
= {major_version
, minor_version
, micro_version
, true};
57 memcached_server_fn callbacks
[1];
58 callbacks
[0] = check_server_version
;
59 memcached_server_cursor(memc
, callbacks
, (void *) &check
, 1);