From 2ab70fbaff33cda1d79aea65b91bd146a82644d1 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Fri, 11 May 2012 21:21:29 -0400 Subject: [PATCH] use Debug flag --- mattach.c | 8 ++++++++ mconnect.c | 18 ++++++++++++++++-- mread.c | 22 ++++++++++++++++++++-- mselect.c | 8 ++++++++ mwrite.c | 5 +++++ table.c | 10 ++++++---- 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/mattach.c b/mattach.c index 9c98eb7..1701a61 100644 --- a/mattach.c +++ b/mattach.c @@ -3,6 +3,7 @@ #include #include +#include "s16debug.h" #pragma noroot #pragma optimize 79 @@ -17,6 +18,13 @@ int mattach(int type, void *p1, void *p2, void *p3, void *p4, void *p5) // p2 = selwakeup. int protocol = *(int *)p3; + if (Debug > 0) + { + s16_debug_printf("socket type = %d protocol = %d", + type, protocol); + } + + if (type != SOCK_STREAM) return ESOCKTNOSUPPORT; //if (protocol != 6) return EPROTONOSUPPORT; // TODO -- check protocol? 6 = tcp, 1 = icmp, 17 = udp. diff --git a/mconnect.c b/mconnect.c index 12b13f2..4784bf3 100644 --- a/mconnect.c +++ b/mconnect.c @@ -2,11 +2,19 @@ #include #include #include + #include "s16debug.h" #pragma noroot #pragma optimize 79 +union split { + + LongWord i32; + Word i16[2]; + Byte i8[4]; +}; + int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) { Word port; @@ -29,6 +37,14 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) sta 0) + { + union split s; + s.i32 = sin->sin_addr; + s16_debug_printf("connect address = %d.%d.%d.%d port = %d", + s.i8[0], s.i8[1], s.i8[2], s.i8[3], port); + } + // check if already connected. IncBusy(); terr = TCPIPStatusTCP(e->ipid, &e->sr); @@ -77,8 +93,6 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) xerrno = queue_command(e, kCommandConnect, 0, timeout); - s16_debug_printf("mconnect: %d - %d - %d", - e->semaphore, xerrno, e->command); // hmmm .. should these abort? if (xerrno == EINTR) diff --git a/mread.c b/mread.c index 2f46110..acfd9a9 100644 --- a/mread.c +++ b/mread.c @@ -4,6 +4,8 @@ #include +#include "s16debug.h" + #pragma noroot #pragma optimize 79 @@ -22,7 +24,11 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) LongWord nbytes = *(LongWord *)p2; *(LongWord *)p2 = 0; - + if (Debug > 0) + { + s16_debug_printf("read nbytes = %ld", nbytes); + } + count = e->_RCVLOWAT; if (count > nbytes) count = nbytes; @@ -53,7 +59,13 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) DecBusy(); if (t) terr = t; - *(LongWord *)p2 = rr.rrBuffCount; + *(LongWord *)p2 = rr.rrBuffCount; + + if (Debug > 1) + { + s16_debug_dump(buffer, (Word)rr.rrBuffCount); + } + } return 0; } @@ -100,6 +112,12 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) DecBusy(); *(LongWord *)p2 = rr.rrBuffCount; + + if (Debug > 1) + { + s16_debug_dump(buffer, (Word)rr.rrBuffCount); + } + } return 0; } diff --git a/mselect.c b/mselect.c index 79cdc23..7855c80 100644 --- a/mselect.c +++ b/mselect.c @@ -2,6 +2,8 @@ #include #include +#include "s16debug.h" + #pragma noroot #pragma optimize 79 @@ -75,6 +77,12 @@ int mselect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) *(int *)p3 = 0; + + if (Debug > 0) + { + s16_debug_printf("select pid = %5d flag = %d", pid, flag); + } + IncBusy(); terr = TCPIPStatusTCP(e->ipid, &e->sr); t = _toolErr; diff --git a/mwrite.c b/mwrite.c index 81714fa..7b42a8d 100644 --- a/mwrite.c +++ b/mwrite.c @@ -3,6 +3,7 @@ #include #include +#include "s16debug.h" #pragma noroot #pragma optimize 79 @@ -19,6 +20,10 @@ int mwrite(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) *(LongWord *)p2 = 0; + if (Debug > 0) + { + s16_debug_printf("write nbytes = %ld", nbytes); + } // todo -- queue up if pending >= _SNDLOWAT? // todo -- push? diff --git a/table.c b/table.c index 226c121..8d2448b 100644 --- a/table.c +++ b/table.c @@ -155,11 +155,13 @@ void process_table(void) if (t) terr = t; e->terr = terr; - s16_debug_printf("process: %04x : %04x : expired: %d", - e->ipid, command, expired); + if (Debug > 2) + { + s16_debug_printf("- ipid: %d command %d", + e->ipid, command); - s16_debug_srbuff(&e->sr); - + s16_debug_srbuff(&e->sr); + } state = e->sr.srState; sig = 0;