summaryrefslogtreecommitdiff
path: root/ucspi-tcp-0.88/delcr.c
diff options
context:
space:
mode:
Diffstat (limited to 'ucspi-tcp-0.88/delcr.c')
-rw-r--r--ucspi-tcp-0.88/delcr.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/ucspi-tcp-0.88/delcr.c b/ucspi-tcp-0.88/delcr.c
new file mode 100644
index 0000000..ab47860
--- /dev/null
+++ b/ucspi-tcp-0.88/delcr.c
@@ -0,0 +1,37 @@
+#include "buffer.h"
+#include "exit.h"
+
+main()
+{
+ register int n;
+ register char *x;
+ char ch;
+ register int flagcr = 0;
+
+ for (;;) {
+ n = buffer_feed(buffer_0);
+ if (n < 0) _exit(111);
+ if (!n) {
+ if (flagcr) buffer_PUTC(buffer_1,"\r"[0]);
+ buffer_flush(buffer_1);
+ _exit(0);
+ }
+ x = buffer_PEEK(buffer_0);
+ buffer_SEEK(buffer_0,n);
+
+ while (n > 0) {
+ ch = *x++; --n;
+ if (!flagcr) {
+ if (ch == '\r') { flagcr = 1; continue; }
+ buffer_PUTC(buffer_1,ch);
+ continue;
+ }
+ if (ch != '\n') {
+ buffer_PUTC(buffer_1,"\r"[0]);
+ if (ch == '\r') continue;
+ }
+ flagcr = 0;
+ buffer_PUTC(buffer_1,ch);
+ }
+ }
+}