change license header library name to libmemcached-awesome
[awesomized/libmemcached] / src / libmemcached / initialize_query.cc
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached-awesome - 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-2021 Michael Wallner https://awesome.co/ |
13 +--------------------------------------------------------------------+
14 */
15
16 #include "libmemcached/common.h"
17
18 memcached_return_t initialize_query(Memcached *self, bool increment_query_id) {
19 if (self == NULL) {
20 return MEMCACHED_INVALID_ARGUMENTS;
21 }
22
23 if (increment_query_id) {
24 self->query_id++;
25 }
26
27 if (self->state.is_time_for_rebuild) {
28 memcached_reset(self);
29 }
30
31 if (memcached_server_count(self) == 0) {
32 return memcached_set_error(*self, MEMCACHED_NO_SERVERS, MEMCACHED_AT);
33 }
34
35 memcached_error_free(*self);
36 memcached_result_reset(&self->result);
37
38 return MEMCACHED_SUCCESS;
39 }
40
41 memcached_return_t initialize_const_query(const Memcached *self) {
42 if (self == NULL) {
43 return MEMCACHED_INVALID_ARGUMENTS;
44 }
45
46 if (memcached_server_count(self) == 0) {
47 return MEMCACHED_NO_SERVERS;
48 }
49
50 return MEMCACHED_SUCCESS;
51 }