date and time created 87/10/10 12:39:07 by minshall
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Sun, 11 Oct 1987 04:39:07 +0000 (20:39 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Sun, 11 Oct 1987 04:39:07 +0000 (20:39 -0800)
SCCS-vsn: usr.bin/telnet/ring.h 1.1

usr/src/usr.bin/telnet/ring.h [new file with mode: 0644]

diff --git a/usr/src/usr.bin/telnet/ring.h b/usr/src/usr.bin/telnet/ring.h
new file mode 100644 (file)
index 0000000..fc8c9a0
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * This defines a structure for a receive or send ring buffer.
+ *
+ * The circular buffer actually has three parts:
+ *(((
+ *     full, sent, not acked:  [ack, send)
+ *     full, not sent:         [send, add)
+ *     empty:                  [add, ack)
+ *]]]
+ *
+ * Any given byte will go through "empty" -> "send" -> "ack" -> "empty"
+ * as data is moved through it.  The transition from "ack" to "empty"
+ * may occur instantaneously (as in the case of sending data up to another
+ * process).
+ */
+typedef struct {
+    char       *ack,           /* where you can't add at */
+               *send,          /* where data comes out of */
+               *add,           /* where data comes in to */
+               *bottom,        /* lowest address in buffer */
+               *top;           /* highest address+1 in buffer */
+    int                size;           /* size in bytes of buffer */
+    u_long     acktime,        /* the relations between these clocks */
+               sendtime,       /* help us keep straight full, empty, etc. */
+               addtime;
+} Ring;
+
+/* Here are some functions and macros to deal with the ring buffer */
+
+
+#if    defined(LINT_ARGS)
+
+/* Data movement routines */
+extern void
+       ring_add_data(Ring *ring, char *buffer, int count),
+       ring_send_data(Ring *ring, char *buffer, int count);
+
+/* Buffer state transition routines */
+extern void
+       ring_added(Ring *ring, int count),
+       ring_sent(Ring *ring, int count),
+       ring_acked(Ring *ring, int count);
+
+/* Buffer state query routines */
+extern int
+       ring_empty_count(Ring *ring),
+       ring_empty_consecutive(Ring *ring),
+       ring_unsent_count(Ring *ring),
+       ring_unsent_consecutive(Ring *ring),
+       ring_unacked_count(Ring *ring);
+
+#endif /* defined(LINT_ARGS) */