"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/vendor/mcmc/mcmc.h" (30 Mar 2022, 3047 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "mcmc.h": 1.6.14_vs_1.6.15.

    1 #ifndef MCMC_HEADER
    2 #define MCMC_HEADER
    3 
    4 #define MCMC_OK 0
    5 #define MCMC_ERR -1
    6 #define MCMC_NOT_CONNECTED 1
    7 #define MCMC_CONNECTED 2
    8 #define MCMC_CONNECTING 3 // nonblock mode.
    9 #define MCMC_WANT_WRITE 4
   10 #define MCMC_WANT_READ 5
   11 #define MCMC_HAS_RESULT 7
   12 // TODO: either internally set a flag for "ok" or "not ok" and use a func,
   13 // or use a bitflag here (1<<6) for "OK", (1<<5) for "FAIL", etc.
   14 // or, we directly return "OK" or "FAIL" and you can ask for specific error.
   15 #define MCMC_CODE_STORED 8
   16 #define MCMC_CODE_EXISTS 9
   17 #define MCMC_CODE_DELETED 10
   18 #define MCMC_CODE_TOUCHED 11
   19 #define MCMC_CODE_VERSION 12
   20 #define MCMC_CODE_NOT_FOUND 13
   21 #define MCMC_CODE_NOT_STORED 14
   22 #define MCMC_CODE_OK 15
   23 #define MCMC_CODE_NOP 16
   24 #define MCMC_PARSE_ERROR_SHORT 17
   25 #define MCMC_PARSE_ERROR 18
   26 #define MCMC_CODE_MISS 19 // FIXME
   27 
   28 
   29 // response types
   30 #define MCMC_RESP_GET 100
   31 #define MCMC_RESP_META 101
   32 #define MCMC_RESP_STAT 102
   33 #define MCMC_RESP_GENERIC 104
   34 #define MCMC_RESP_END 105
   35 #define MCMC_RESP_VERSION 106
   36 #define MCMC_RESP_NUMERIC 107 // for weird incr/decr syntax.
   37 
   38 #define MCMC_OPTION_BLANK 0
   39 #define MCMC_OPTION_NONBLOCK 1
   40 #define MCMC_OPTION_TCP_KEEPALIVE (1<<1)
   41 
   42 // convenience defines. if you want to save RAM you can set these smaller and
   43 // error handler will only copy what you ask for.
   44 #define MCMC_ERROR_CODE_MAX 32
   45 #define MCMC_ERROR_MSG_MAX 512
   46 
   47 typedef struct {
   48     unsigned short type;
   49     unsigned short code;
   50     char *value; // pointer to start of value in buffer.
   51     size_t reslen; // full length of the response line
   52     size_t vlen_read; // amount of value that was in supplied buffer.
   53     size_t vlen; // reslen + vlen is the full length of the response.
   54     union {
   55         // META response
   56         struct {
   57             char *rline; // start of meta response line.
   58             size_t rlen;
   59         };
   60         // GET response
   61         struct {
   62             char *key;
   63             size_t klen;
   64             uint32_t flags;
   65             uint64_t cas;
   66             // TODO: value info
   67         };
   68         // STAT response
   69         struct {
   70             char *stat;
   71             size_t slen;
   72         };
   73     };
   74 } mcmc_resp_t;
   75 
   76 int mcmc_fd(void *c);
   77 size_t mcmc_size(int options);
   78 size_t mcmc_min_buffer_size(int options);
   79 char *mcmc_read_prep(void *c, char *buf, size_t bufsize, size_t *bufremain);
   80 int mcmc_parse_buf(void *c, char *buf, size_t read, mcmc_resp_t *r);
   81 int mcmc_connect(void *c, char *host, char *port, int options);
   82 int mcmc_check_nonblock_connect(void *c, int *err);
   83 int mcmc_send_request(void *c, const char *request, int len, int count);
   84 int mcmc_request_writev(void *c, const struct iovec *iov, int iovcnt, ssize_t *sent, int count);
   85 int mcmc_read(void *c, char *buf, size_t bufsize, mcmc_resp_t *r);
   86 int mcmc_read_value(void *c, char *val, const size_t vsize, int *read);
   87 int mcmc_read_value_buf(void *c, char *val, const size_t vsize, int *read);
   88 char *mcmc_buffer_consume(void *c, int *remain);
   89 int mcmc_disconnect(void *c);
   90 void mcmc_get_error(void *c, char *code, size_t clen, char *msg, size_t mlen);
   91 
   92 #endif