view release on metacpan or search on metacpan
src/libmemcached/example/byteorder.h view on Meta::CPAN
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
uint64_t example_ntohll(uint64_t);
uint64_t example_htonll(uint64_t);
#ifdef __cplusplus
}
#endif
src/libmemcached/libmemcached/byteorder.h view on Meta::CPAN
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
uint64_t memcached_ntohll(uint64_t);
uint64_t memcached_htonll(uint64_t);
#ifdef __cplusplus
}
#endif
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
header->request.opcode == PROTOCOL_BINARY_CMD_ADD)
{
/* Send a positive request */
protocol_binary_response_no_extras response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_ADD,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(cas)
}
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
{
rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
memcached_binary_protocol_raw_response_handler response_handler)
{
(void)response_handler;
protocol_binary_response_status rval;
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.decrement != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
protocol_binary_request_decr *request= (void*)header;
uint64_t init= memcached_ntohll(request->message.body.initial);
uint64_t delta= memcached_ntohll(request->message.body.delta);
uint32_t timeout= ntohl(request->message.body.expiration);
void *key= request->bytes + sizeof(request->bytes);
uint64_t result;
uint64_t cas;
rval= client->root->callback->interface.v1.decrement(cookie, key, keylen,
delta, init, timeout,
&result, &cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_DECREMENT)
{
/* Send a positive request */
protocol_binary_response_decr response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_DECREMENT,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(cas),
.bodylen= htonl(8)
},
.body.value= memcached_htonll(result)
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
{
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
memcached_binary_protocol_raw_response_handler response_handler)
{
(void)response_handler;
protocol_binary_response_status rval;
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.delete_object != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
void *key= (header +1);
uint64_t cas= memcached_ntohll(header->request.cas);
rval= client->root->callback->interface.v1.delete_object(cookie, key, keylen, cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_DELETE)
{
/* Send a positive request */
protocol_binary_response_no_extras response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_DELETE,
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
memcached_binary_protocol_raw_response_handler response_handler)
{
(void)response_handler;
protocol_binary_response_status rval;
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.increment != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
protocol_binary_request_incr *request= (void*)header;
uint64_t init= memcached_ntohll(request->message.body.initial);
uint64_t delta= memcached_ntohll(request->message.body.delta);
uint32_t timeout= ntohl(request->message.body.expiration);
void *key= request->bytes + sizeof(request->bytes);
uint64_t cas;
uint64_t result;
rval= client->root->callback->interface.v1.increment(cookie, key, keylen,
delta, init, timeout,
&result, &cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENT)
{
/* Send a positive request */
protocol_binary_response_incr response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_INCREMENT,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(cas),
.bodylen= htonl(8)
},
.body.value= memcached_htonll(result)
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
(void)response_handler;
protocol_binary_response_status rval;
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.append != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
uint32_t datalen= ntohl(header->request.bodylen) - keylen;
char *key= (void*)(header +1);
char *data= key +keylen;
uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.append(cookie, key, keylen,
data, datalen, cas,
&result_cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_APPEND)
{
/* Send a positive request */
protocol_binary_response_no_extras response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_APPEND,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(result_cas),
},
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
{
rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
(void)response_handler;
protocol_binary_response_status rval;
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.prepend != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
uint32_t datalen= ntohl(header->request.bodylen) - keylen;
char *key= (char*)(header + 1);
char *data= key + keylen;
uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.prepend(cookie, key, keylen,
data, datalen, cas,
&result_cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_PREPEND)
{
/* Send a positive request */
protocol_binary_response_no_extras response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_PREPEND,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(result_cas),
},
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
{
rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.replace != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8;
protocol_binary_request_replace *request= (void*)header;
uint32_t flags= ntohl(request->message.body.flags);
uint32_t timeout= ntohl(request->message.body.expiration);
char *key= ((char*)header) + sizeof(*header) + 8;
char *data= key + keylen;
uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.replace(cookie, key, keylen,
data, datalen, flags,
timeout, cas,
&result_cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE)
{
/* Send a positive request */
protocol_binary_response_no_extras response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_REPLACE,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(result_cas),
},
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
{
rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}
src/libmemcached/libmemcachedprotocol/binary_handler.c view on Meta::CPAN
memcached_protocol_client_st *client= (void*)cookie;
if (client->root->callback->interface.v1.set != NULL)
{
uint16_t keylen= ntohs(header->request.keylen);
uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8;
protocol_binary_request_replace *request= (void*)header;
uint32_t flags= ntohl(request->message.body.flags);
uint32_t timeout= ntohl(request->message.body.expiration);
char *key= ((char*)header) + sizeof(*header) + 8;
char *data= key + keylen;
uint64_t cas= memcached_ntohll(header->request.cas);
uint64_t result_cas;
rval= client->root->callback->interface.v1.set(cookie, key, keylen,
data, datalen, flags,
timeout, cas, &result_cas);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS &&
header->request.opcode == PROTOCOL_BINARY_CMD_SET)
{
/* Send a positive request */
protocol_binary_response_no_extras response= {
.message= {
.header.response= {
.magic= PROTOCOL_BINARY_RES,
.opcode= PROTOCOL_BINARY_CMD_SET,
.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
.opaque= header->request.opaque,
.cas= memcached_ntohll(result_cas),
},
}
};
rval= response_handler(cookie, header, (void*)&response);
}
}
else
{
rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}