<commit_before>/*
 * omcache_cdef.h - bare c function definitions
 * for omcache.h and python cffi
 *
 * Copyright (c) 2013-2014, <NAME> <<EMAIL>>
 * All rights reserved.
 *
 * This file is under the Apache License, Version 2.0.
 * See the file `LICENSE` for details.
 *
 */

// Note: some of these numbers try to match the identifiers used by the
// memcached binary protocol
typedef enum omcache_ret_e {
  OMCACHE_OK = 0x00,               ///< Success
  OMCACHE_NOT_FOUND = 0x01,        ///< Key not found from memcached
  OMCACHE_KEY_EXISTS = 0x02,       ///< Conflicting key exists in memcached
  OMCACHE_TOO_LARGE_VALUE = 0x03,  ///< Value size exceeds maximum
  OMCACHE_NOT_STORED = 0x05,       ///< Append or prepend value not stored
  OMCACHE_DELTA_BAD_VALUE = 0x06,  ///< Existing value can not be
                                   ///  incremented or decremented
  OMCACHE_FAIL = 0x0FFF,           ///< Command failed in memcached
  OMCACHE_AGAIN = 0x1001,          ///< Call would block, try again
  OMCACHE_INVALID,                 ///< Invalid parameters
  OMCACHE_BUFFERED,                ///< Data buffered in OMcache
  OMCACHE_BUFFER_FULL,             ///< Buffer full, command dropped
  OMCACHE_NO_SERVERS,              ///< No server available
  OMCACHE_SERVER_FAILURE,          ///< Failure communicating to server
} omcache_ret_t;

typedef struct omcache_s omcache_t;

typedef struct omcache_req_s {
    int server_index;           ///< Opaque integer identifying the server to
                                ///  use when the request type does not use
                                ///  a key (NOOP, VERSION and STATS).
                                ///  -1 when server is selected by key.
    struct omcache_req_header_s {
        uint8_t magic;          ///< Always PROTOCOL_BINARY_REQ (0x80),
                                ///  set by OMcache
        uint8_t opcode;         ///< Command type
        uint16_t keylen;        ///< Length of key, in network byte order
        uint8_t extlen;         ///< Length of structured extra data
        uint8_t datatype;       ///< Always PROTOCOL_BINARY_RAW_BYTES (0x00),
                                ///  set by OMcache
        uint16_t reserved;      ///< Reserved, do not set
        uint32_t bodylen;       ///< Request body length, in network byte
                                ///  order, includes extra, key and data
        uint32_t opaque;        ///< Request identifier, set by OMcache
        uint64_t cas;           ///< CAS value for synchronization
    } header;                   ///< Memcache binary protocol header struct
    void *extra;                ///< Extra structured data sent for some
                                ///  request types
    const unsigned char *key;   ///< Object key
    const unsigned char *data;  ///< Object value
} omcache_req_t;

typedef struct omcache_value_s {
    int status;                 ///< Response status (omcache_ret_t)
    const unsigned char *key;   ///< Response key (if any)
    size_t key_len;             ///< Response key length
    const unsigned char *data;  ///< Response data (if any)
    size_t data_len;            ///< Response data length
    uint32_t flags;             ///< Flags associated with the object
    uint64_t cas;               ///< CAS value for synchronization
    uint64_t delta_value;       ///< Value returned in delta operations
} omcache_value_t;

// OMcache -object

/**
 * Create a new OMcache handle.
 * @return A new OMcache handle that can be used with other functions.
 */
omcache_t *omcache_init(void);

/**
 * Free an OMcache handle and its resources.
 * @param mc OMcache handle.<commit_msg>omcache_cdef.h: make 'extra' const in omcache_req_t<commit_after>/*
 * omcache_cdef.h - bare c function definitions
 * for omcache.h and python cffi
 *
 * Copyright (c) 2013-2014, <NAME> <<EMAIL>>
 * All rights reserved.
 *
 * This file is under the Apache License, Version 2.0.
 * See the file `LICENSE` for details.
 *
 */

// Note: some of these numbers try to match the identifiers used by the
// memcached binary protocol
typedef enum omcache_ret_e {
  OMCACHE_OK = 0x00,               ///< Success
  OMCACHE_NOT_FOUND = 0x01,        ///< Key not found from memcached
  OMCACHE_KEY_EXISTS = 0x02,       ///< Conflicting key exists in memcached
  OMCACHE_TOO_LARGE_VALUE = 0x03,  ///< Value size exceeds maximum
  OMCACHE_NOT_STORED = 0x05,       ///< Append or prepend value not stored
  OMCACHE_DELTA_BAD_VALUE = 0x06,  ///< Existing value can not be
                                   ///  incremented or decremented
  OMCACHE_FAIL = 0x0FFF,           ///< Command failed in memcached
  OMCACHE_AGAIN = 0x1001,          ///< Call would block, try again
  OMCACHE_INVALID,                 ///< Invalid parameters
  OMCACHE_BUFFERED,                ///< Data buffered in OMcache
  OMCACHE_BUFFER_FULL,             ///< Buffer full, command dropped
  OMCACHE_NO_SERVERS,              ///< No server available
  OMCACHE_SERVER_FAILURE,          ///< Failure communicating to server
} omcache_ret_t;

typedef struct omcache_s omcache_t;

typedef struct omcache_req_s {
    int server_index;           ///< Opaque integer identifying the server to
                                ///  use when the request type does not use
                                ///  a key (NOOP, VERSION and STATS).
                                ///  -1 when server is selected by key.
    struct omcache_req_header_s {
        uint8_t magic;          ///< Always PROTOCOL_BINARY_REQ (0x80),
                                ///  set by OMcache
        uint8_t opcode;         ///< Command type
        uint16_t keylen;        ///< Length of key, in network byte order
        uint8_t extlen;         ///< Length of structured extra data
        uint8_t datatype;       ///< Always PROTOCOL_BINARY_RAW_BYTES (0x00),
                                ///  set by OMcache
        uint16_t reserved;      ///< Reserved, do not set
        uint32_t bodylen;       ///< Request body length, in network byte
                                ///  order, includes extra, key and data
        uint32_t opaque;        ///< Request identifier, set by OMcache
        uint64_t cas;           ///< CAS value for synchronization
    } header;                   ///< Memcache binary protocol header struct
    const void *extra;          ///< Extra structured data sent for some
                                ///  request types
    const unsigned char *key;   ///< Object key
    const unsigned char *data;  ///< Object value
} omcache_req_t;

typedef struct omcache_value_s {
    int status;                 ///< Response status (omcache_ret_t)
    const unsigned char *key;   ///< Response key (if any)
    size_t key_len;             ///< Response key length
    const unsigned char *data;  ///< Response data (if any)
    size_t data_len;            ///< Response data length
    uint32_t flags;             ///< Flags associated with the object
    uint64_t cas;               ///< CAS value for synchronization
    uint64_t delta_value;       ///< Value returned in delta operations
} omcache_value_t;

// OMcache -object

/**
 * Create a new OMcache handle.
 * @return A new OMcache handle that can be used with other functions.
 */
omcache_t *omcache_init(void);

/**
 * Free an OMcache handle and its resources.
 * @param mc OMcache handle.
{'fraction_non_alphanumeric': 0.08608554412560909, 'fraction_numerical': 0.016783974011911208, 'mean_word_length': 1.763275991024682, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7410942', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2051, 'n_words': 711}