X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Foptions%2Fcontext.h;h=d65f8ede53ce8659367a37c06cbbf1a078a9b6ab;hb=de161b27e5e394ea0ae4a88e58fc9ebb21e821d0;hp=e650b5ee582c290681f98490b059312b78218dc6;hpb=aa6d65c93cadc9869623af385919db1394116934;p=m6w6%2Flibmemcached diff --git a/libmemcached/options/context.h b/libmemcached/options/context.h index e650b5ee..d65f8ede 100644 --- a/libmemcached/options/context.h +++ b/libmemcached/options/context.h @@ -49,8 +49,10 @@ public: pos(0), memc(NULL), rc(rc_arg), + _is_server(false), _end(false) { + _hostname[0]= 0; buf= option_string; length= option_string_length; memc= memc_arg; @@ -63,12 +65,43 @@ public: return _end; } + void start(); + void set_end() { rc= MEMCACHED_SUCCESS; _end= true; } + void set_server() + { + _is_server= true; + } + + void unset_server() + { + _is_server= false; + } + + bool is_server() + { + return _is_server; + } + + const char *set_hostname(const char *str, size_t size) + { + size_t copy_length= std::min((size_t)NI_MAXHOST, size); + memcpy(_hostname, str, copy_length); + _hostname[copy_length]= 0; + + return _hostname; + } + + const char *hostname() + { + return _hostname; + } + ~Context() { destroy_scanner(); @@ -87,5 +120,7 @@ protected: void destroy_scanner(); private: + bool _is_server; bool _end; + char _hostname[NI_MAXHOST]; };