From: Trond Norbye Date: Fri, 6 Nov 2009 08:38:54 +0000 (+0100) Subject: Protocol interface should be an enum and not a uint64_t for type safety X-Git-Tag: 0.35~3^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=da1be05d0e6fed21a14201dcea0dc2c71498bd74;p=awesomized%2Flibmemcached Protocol interface should be an enum and not a uint64_t for type safety --- diff --git a/example/interface_v0.c b/example/interface_v0.c index 59631330..57459208 100644 --- a/example/interface_v0.c +++ b/example/interface_v0.c @@ -521,10 +521,10 @@ static protocol_binary_response_status stat_command_handler(const void *cookie, } memcached_binary_protocol_callback_st interface_v0_impl= { - .interface_version= 0, + .interface_version= MEMCACHED_PROTOCOL_HANDLER_V0, #ifdef FUTURE /* - ** There is a number of bugs in the extra options for gcc causing + ** There is a number of bugs in the extra options for gcc causing ** warning on these struct initializers. It hurts my heart to remove ** it so I'll just leave it in here so that we can enable it when ** we can drop support for the broken compilers diff --git a/example/interface_v1.c b/example/interface_v1.c index 3de38542..f52abfa2 100644 --- a/example/interface_v1.c +++ b/example/interface_v1.c @@ -393,7 +393,7 @@ static protocol_binary_response_status version_handler(const void *cookie, } memcached_binary_protocol_callback_st interface_v1_impl= { - .interface_version= 1, + .interface_version= MEMCACHED_PROTOCOL_HANDLER_V1, .interface.v1= { .add= add_handler, .append= append_handler, diff --git a/libmemcached/protocol/callback.h b/libmemcached/protocol/callback.h index 826a317d..e7efaad7 100644 --- a/libmemcached/protocol/callback.h +++ b/libmemcached/protocol/callback.h @@ -338,15 +338,28 @@ typedef struct { memcached_binary_protocol_version_response_handler response_handler); } memcached_binary_protocol_callback_v1_st; + /** - * + * The version numbers for the different callback structures. + */ +typedef enum { + /** Version 0 is a lowlevel interface that tries to maximize your freedom */ + MEMCACHED_PROTOCOL_HANDLER_V0= 0, + /** + * Version 1 abstracts more of the protocol details, and let you work at + * a logical level + */ + MEMCACHED_PROTOCOL_HANDLER_V1= 1, +} memcached_protocol_interface_version_t; + +/** + * Definition of the protocol callback structure. */ typedef struct { /** - * The interface version used (set to 0 if you don't have any specialized - * command handlers). + * The interface version you provide callbacks for. */ - uint64_t interface_version; + memcached_protocol_interface_version_t interface_version; /** * Callback fired just before the command will be executed.