version 1.7, 2014/07/19 23:50:38 |
version 1.8, 2014/07/20 06:24:19 |
|
|
* |
* |
*/ |
*/ |
typedef struct { |
typedef struct { |
unsigned char *consume, /* where data comes out of */ |
unsigned char *consume; /* where data comes out of */ |
*supply, /* where data comes in to */ |
unsigned char *supply; /* where data comes in to */ |
*bottom, /* lowest address in buffer */ |
unsigned char *bottom; /* lowest address in buffer */ |
*top, /* highest address+1 in buffer */ |
unsigned char *top; /* highest address+1 in buffer */ |
*mark; /* marker (user defined) */ |
unsigned char *mark; /* marker (user defined) */ |
int size; /* size in bytes of buffer */ |
int size; /* size in bytes of buffer */ |
u_long consumetime, /* help us keep straight full, empty, etc. */ |
u_long consumetime; /* help us keep straight full, empty, etc. */ |
supplytime; |
u_long supplytime; |
} Ring; |
} Ring; |
|
|
/* Here are some functions and macros to deal with the ring buffer */ |
/* Here are some functions and macros to deal with the ring buffer */ |
|
|
/* Initialization routine */ |
/* Initialization routine */ |
extern int |
void ring_init(Ring *ring, unsigned char *buffer, int size); |
ring_init(Ring *ring, unsigned char *buffer, int count); |
|
|
|
/* Data movement routines */ |
/* Data movement routines */ |
extern void |
void ring_supply_data(Ring *ring, unsigned char *buffer, int count); |
ring_supply_data(Ring *ring, unsigned char *buffer, int count); |
|
|
|
/* Buffer state transition routines */ |
/* Buffer state transition routines */ |
extern void |
void ring_supplied(Ring *ring, int count); |
ring_supplied(Ring *ring, int count), |
void ring_consumed(Ring *ring, int count); |
ring_consumed(Ring *ring, int count); |
|
|
|
/* Buffer state query routines */ |
/* Buffer state query routines */ |
extern int |
int ring_empty_count(Ring *ring); |
ring_empty_count(Ring *ring), |
int ring_empty_consecutive(Ring *ring); |
ring_empty_consecutive(Ring *ring), |
int ring_full_count(Ring *ring); |
ring_full_count(Ring *ring), |
int ring_full_consecutive(Ring *ring); |
ring_full_consecutive(Ring *ring); |
|
|
|
extern void |
/* Buffer urgent data handling */ |
ring_clear_mark(Ring *), |
void ring_clear_mark(Ring *); |
ring_mark(Ring *); |
void ring_mark(Ring *); |
|
int ring_at_mark(Ring *); |
|
|
|
|
extern int |
|
ring_at_mark(Ring *); |
|