1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 #pragma once
3 
4 #include <stdint.h>
5 #include <gsl/gsl>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #ifdef WIN32
12 #undef interface
13 #endif
14     typedef struct engine_interface {
15         uint64_t interface; /**< The version number on the engine structure */
16     } ENGINE_HANDLE;
17 
18     /**
19      * Callback for any function producing stats.
20      *
21      * @param key the stat's key
22      * @param klen length of the key
23      * @param val the stat's value in an ascii form (e.g. text form of a number)
24      * @param vlen length of the value
25      * @param cookie magic callback cookie
26      */
27     typedef void (*ADD_STAT)(const char* key,
28                              const uint16_t klen,
29                              const char* val,
30                              const uint32_t vlen,
31                              gsl::not_null<const void*> cookie);
32 
33     /**
34      * Callback for adding a response backet
35      * @param key The key to put in the response
36      * @param keylen The length of the key
37      * @param ext The data to put in the extended field in the response
38      * @param extlen The number of bytes in the ext field
39      * @param body The data body
40      * @param bodylen The number of bytes in the body
41      * @param datatype This is currently not used and should be set to 0
42      * @param status The status code of the return packet (see in protocol_binary
43      *               for the legal values)
44      * @param cas The cas to put in the return packet
45      * @param cookie The cookie provided by the frontend
46      * @return true if return message was successfully created, false if an
47      *              error occured that prevented the message from being sent
48      */
49     typedef bool (*ADD_RESPONSE)(const void *key, uint16_t keylen,
50                                  const void *ext, uint8_t extlen,
51                                  const void *body, uint32_t bodylen,
52                                  uint8_t datatype, uint16_t status,
53                                  uint64_t cas, const void *cookie);
54 
55 
56 #ifdef __cplusplus
57 }
58 #endif
59