summaryrefslogtreecommitdiffstats
path: root/crypto/telnet/telnet/ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/telnet/telnet/ring.c')
-rw-r--r--crypto/telnet/telnet/ring.c103
1 files changed, 28 insertions, 75 deletions
diff --git a/crypto/telnet/telnet/ring.c b/crypto/telnet/telnet/ring.c
index 065888b..8fd14a7 100644
--- a/crypto/telnet/telnet/ring.c
+++ b/crypto/telnet/telnet/ring.c
@@ -31,14 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
/*
* This defines a structure for a ring buffer.
@@ -99,17 +98,10 @@ static u_long ring_clock = 0;
#define ring_full(d) (((d)->supply == (d)->consume) && \
((d)->supplytime > (d)->consumetime))
-
-
-
-
/* Buffer state transition routines */
- int
-ring_init(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
+int
+ring_init(Ring *ring, unsigned char *buffer, int count)
{
memset((char *)ring, 0, sizeof *ring);
@@ -132,9 +124,8 @@ ring_init(ring, buffer, count)
* Mark the most recently supplied byte.
*/
- void
-ring_mark(ring)
- Ring *ring;
+void
+ring_mark(Ring *ring)
{
ring->mark = ring_decrement(ring, ring->supply, 1);
}
@@ -143,9 +134,8 @@ ring_mark(ring)
* Is the ring pointing to the mark?
*/
- int
-ring_at_mark(ring)
- Ring *ring;
+int
+ring_at_mark(Ring *ring)
{
if (ring->mark == ring->consume) {
return 1;
@@ -158,9 +148,8 @@ ring_at_mark(ring)
* Clear any mark set on the ring.
*/
- void
-ring_clear_mark(ring)
- Ring *ring;
+void
+ring_clear_mark(Ring *ring)
{
ring->mark = 0;
}
@@ -168,10 +157,8 @@ ring_clear_mark(ring)
/*
* Add characters from current segment to ring buffer.
*/
- void
-ring_supplied(ring, count)
- Ring *ring;
- int count;
+void
+ring_supplied(Ring *ring, int count)
{
ring->supply = ring_increment(ring, ring->supply, count);
ring->supplytime = ++ring_clock;
@@ -180,10 +167,8 @@ ring_supplied(ring, count)
/*
* We have just consumed "c" bytes.
*/
- void
-ring_consumed(ring, count)
- Ring *ring;
- int count;
+void
+ring_consumed(Ring *ring, int count)
{
if (count == 0) /* don't update anything */
return;
@@ -217,9 +202,8 @@ ring_consumed(ring, count)
/* Number of bytes that may be supplied */
- int
-ring_empty_count(ring)
- Ring *ring;
+int
+ring_empty_count(Ring *ring)
{
if (ring_empty(ring)) { /* if empty */
return ring->size;
@@ -229,9 +213,8 @@ ring_empty_count(ring)
}
/* number of CONSECUTIVE bytes that may be supplied */
- int
-ring_empty_consecutive(ring)
- Ring *ring;
+int
+ring_empty_consecutive(Ring *ring)
{
if ((ring->consume < ring->supply) || ring_empty(ring)) {
/*
@@ -251,9 +234,8 @@ ring_empty_consecutive(ring)
* (but don't give more than enough to get to cross over set mark)
*/
- int
-ring_full_count(ring)
- Ring *ring;
+int
+ring_full_count(Ring *ring)
{
if ((ring->mark == 0) || (ring->mark == ring->consume)) {
if (ring_full(ring)) {
@@ -270,9 +252,8 @@ ring_full_count(ring)
* Return the number of CONSECUTIVE bytes available for consuming.
* However, don't return more than enough to cross over set mark.
*/
- int
-ring_full_consecutive(ring)
- Ring *ring;
+int
+ring_full_consecutive(Ring *ring)
{
if ((ring->mark == 0) || (ring->mark == ring->consume)) {
if ((ring->supply < ring->consume) || ring_full(ring)) {
@@ -292,11 +273,8 @@ ring_full_consecutive(ring)
/*
* Move data into the "supply" portion of of the ring buffer.
*/
- void
-ring_supply_data(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
+void
+ring_supply_data(Ring *ring, unsigned char *buffer, int count)
{
int i;
@@ -309,34 +287,9 @@ ring_supply_data(ring, buffer, count)
}
}
-#ifdef notdef
-
-/*
- * Move data from the "consume" portion of the ring buffer
- */
- void
-ring_consume_data(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
-{
- int i;
-
- while (count) {
- i = MIN(count, ring_full_consecutive(ring));
- memcpy(buffer, ring->consume, i);
- ring_consumed(ring, i);
- count -= i;
- buffer += i;
- }
-}
-#endif
-
#ifdef ENCRYPTION
- void
-ring_encrypt(ring, encryptor)
- Ring *ring;
- void (*encryptor)();
+void
+ring_encrypt(Ring *ring, void (*encryptor)(unsigned char *, int))
{
unsigned char *s, *c;
OpenPOWER on IntegriCloud