read-responses.h 1.43 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
#ifndef __MOBJECT_READ_RESPONSE_H
#define __MOBJECT_READ_RESPONSE_H

#include "mobject-store-config.h"
#include "read-actions.h"

/**
 * This file contains a set of structures meant
 * to store responses for read_op operations in
 * a buffer. Some of these structures are self-sufficiant.
 * Some other are meant to be used as headers, and the
 * the serialized buffer actually contains additional
 * data after them.
 */
typedef enum {
	READ_RESPCODE_BASE = 0,
	READ_RESPCODE_STAT,
	READ_RESPCODE_READ,
	READ_RESPCODE_OMAP,
	_READ_RESPCODE_END_ENUM_
} read_resp_code_t;

typedef struct rd_response_BASE {
	read_resp_code_t         type;
	struct rd_response_BASE* prev;
	struct rd_response_BASE* next;
}* rd_response_base_t;

/**
 * stat response
 */
 typedef struct rd_response_STAT {
	struct rd_response_BASE base;
	uint64_t psize;
	time_t   pmtime;
	int      prval;
 }* rd_response_stat_t;

/**
 * read response
 */
typedef struct rd_response_READ {
	struct rd_response_BASE base;
	size_t bytes_read;
	int    prval;
}* rd_response_read_t;

/**
 * omap_* responses
 */
typedef struct rd_response_OMAP {
	struct rd_response_BASE   base;
	int                       prval;
	mobject_store_omap_iter_t iter;
}* rd_response_omap_t;

rd_response_base_t build_matching_read_responses(rd_action_base_t actions);
void free_read_responses(rd_response_base_t responses);

#endif