File: cbuf.h

package info (click to toggle)
tsdecrypt 8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,084 kB
  • sloc: ansic: 13,568; makefile: 248; sh: 183
file content (41 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (4)
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
/*
 * Circular buffer header file
 * Copyright (C) 2010 Unix Solutions Ltd.
 *
 * Released under MIT license.
 * See LICENSE-MIT.txt for license terms.
 */
#ifndef CBUF_H
#define CBUF_H

#include <netdb.h>

// Circular buffer
typedef struct {
	pthread_mutex_t *lock;
	char *name;
	int size;			/* Buffer size, must be (bufsize % 1316) == 0 */
	int pos;			/* Up to where the buffer is filled */
	int writepos;		/* Up to where the buffer is get */
	void *buffer;		/* The buffer data */
	uint64_t input;
	uint64_t output;
	int pos_wrapped;
	int debug_get;
} CBUF;

CBUF *cbuf_init(int buffer_size, char *name);
void cbuf_free(CBUF **buffer);

int  cbuf_fill(CBUF *b, uint8_t *data, int datasize);
void *cbuf_get(CBUF *b, int size, int *ret_datasize);
void *cbuf_peek(CBUF *b, int size, int *ret_datasize);
void cbuf_copy(CBUF *src, CBUF *dest);

int cbuf_data_size(CBUF *b);

void cbuf_poison(CBUF *b, char poison_byte);

void cbuf_dump(CBUF *b);

#endif