summaryrefslogtreecommitdiffstats
path: root/usr.bin/telnet/ring.c
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-11-30 22:09:10 +0000
committermarkm <markm@FreeBSD.org>2001-11-30 22:09:10 +0000
commit57acab063b3ef9760ddafee33cca79b6f179421a (patch)
tree872c39a50cab6fcadd1ac8e8806bfb0b5f2c9bd9 /usr.bin/telnet/ring.c
parentb72e252a0180e401fa4d5bd71ab4374f6f6e2735 (diff)
downloadFreeBSD-src-57acab063b3ef9760ddafee33cca79b6f179421a.zip
FreeBSD-src-57acab063b3ef9760ddafee33cca79b6f179421a.tar.gz
After running "make unifdef", commit the result. This code is now
a complete subset of the crypto (master) code.
Diffstat (limited to 'usr.bin/telnet/ring.c')
-rw-r--r--usr.bin/telnet/ring.c97
1 files changed, 26 insertions, 71 deletions
diff --git a/usr.bin/telnet/ring.c b/usr.bin/telnet/ring.c
index b414d16..ac415a9 100644
--- a/usr.bin/telnet/ring.c
+++ b/usr.bin/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);
@@ -129,9 +121,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);
}
@@ -140,9 +131,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;
@@ -155,9 +145,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;
}
@@ -165,10 +154,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;
@@ -177,10 +164,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;
@@ -205,9 +190,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;
@@ -217,9 +201,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)) {
/*
@@ -239,9 +222,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)) {
@@ -258,9 +240,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)) {
@@ -280,11 +261,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;
@@ -297,26 +275,3 @@ 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
-
OpenPOWER on IntegriCloud