mirror of
https://github.com/ksherlock/gopher.git
synced 2024-05-28 00:48:28 +00:00
inc busy /dec busy code.
This commit is contained in:
parent
7d31bafffc
commit
caa54a0f3e
10
common.c
10
common.c
|
@ -26,13 +26,17 @@ int read_binary(Word ipid, FILE *file)
|
||||||
rrBuff rb;
|
rrBuff rb;
|
||||||
Word count;
|
Word count;
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
rv = TCPIPReadTCP(ipid, 0, (Ref)buffer, 512, &rb);
|
rv = TCPIPReadTCP(ipid, 0, (Ref)buffer, 512, &rb);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
count = rb.rrBuffCount;
|
count = rb.rrBuffCount;
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
if (rv) break;
|
if (rv) break;
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +63,11 @@ int ConnectLoop(char *host, Word port, Connection *connection)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Connection timed out.\n");
|
fprintf(stderr, "Connection timed out.\n");
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
TCPIPAbortTCP(connection->ipid);
|
TCPIPAbortTCP(connection->ipid);
|
||||||
TCPIPLogout(connection->ipid);
|
TCPIPLogout(connection->ipid);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
gopher.c
20
gopher.c
|
@ -45,8 +45,10 @@ static int gopher_text(Word ipid, FILE *file)
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
Word lastTerm = 0;
|
Word lastTerm = 0;
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
Word count;
|
Word count;
|
||||||
|
@ -62,7 +64,10 @@ static int gopher_text(Word ipid, FILE *file)
|
||||||
if (rv < 0) break; // eof
|
if (rv < 0) break; // eof
|
||||||
if (rv == 0) // no data available (yet)
|
if (rv == 0) // no data available (yet)
|
||||||
{
|
{
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,11 +151,17 @@ static int gopher_dir(Word ipid, FILE *file)
|
||||||
if (rv < 0) break;
|
if (rv < 0) break;
|
||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
{
|
{
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!rb.moreFlag) TCPIPPoll();
|
if (!rb.moreFlag)
|
||||||
|
{
|
||||||
|
IncBusy();
|
||||||
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
|
}
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
|
@ -351,6 +362,8 @@ int do_gopher(const char *url, URLComponents *components)
|
||||||
|
|
||||||
// path is /[type][resource]
|
// path is /[type][resource]
|
||||||
// where [type] is 1 char and the leading / is ignored.
|
// where [type] is 1 char and the leading / is ignored.
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
|
|
||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
|
@ -370,6 +383,7 @@ int do_gopher(const char *url, URLComponents *components)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
TCPIPWriteTCP(connection.ipid, "\r\n", 2, true, false);
|
TCPIPWriteTCP(connection.ipid, "\r\n", 2, true, false);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
17
http.c
17
http.c
|
@ -49,9 +49,9 @@ static int do_http_0_9(
|
||||||
char *cp;
|
char *cp;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
TCPIPWriteTCP(ipid, "GET ", 4, false, false);
|
TCPIPWriteTCP(ipid, "GET ", 4, false, false);
|
||||||
|
|
||||||
length = components->pathAndQuery.length;
|
length = components->pathAndQuery.length;
|
||||||
cp = url + components->pathAndQuery.location;
|
cp = url + components->pathAndQuery.location;
|
||||||
|
|
||||||
|
@ -61,9 +61,11 @@ static int do_http_0_9(
|
||||||
cp = "/";
|
cp = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TCPIPWriteTCP(ipid, cp, length, false, false);
|
TCPIPWriteTCP(ipid, cp, length, false, false);
|
||||||
|
|
||||||
TCPIPWriteTCP(ipid, "\r\n", 2, true, false);
|
TCPIPWriteTCP(ipid, "\r\n", 2, true, false);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
ok = read_binary(ipid, file);
|
ok = read_binary(ipid, file);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -90,7 +92,9 @@ static int parseHeaders(Word ipid, FILE *file, Handle dict)
|
||||||
|
|
||||||
line = 0;
|
line = 0;
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -103,7 +107,9 @@ static int parseHeaders(Word ipid, FILE *file, Handle dict)
|
||||||
|
|
||||||
if (ok == 0)
|
if (ok == 0)
|
||||||
{
|
{
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
|
DecBusy();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,9 +294,10 @@ int read_response(Word ipid, FILE *file, Handle dict)
|
||||||
{
|
{
|
||||||
LongWord count = 256;
|
LongWord count = 256;
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
TCPIPPoll();
|
TCPIPPoll();
|
||||||
TCPIPStatusTCP(ipid, &sr);
|
TCPIPStatusTCP(ipid, &sr);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
count = sr.srRcvQueued;
|
count = sr.srRcvQueued;
|
||||||
if (count > contentSize) count = contentSize;
|
if (count > contentSize) count = contentSize;
|
||||||
|
@ -300,7 +307,9 @@ int read_response(Word ipid, FILE *file, Handle dict)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IncBusy();
|
||||||
terr = TCPIPReadTCP(ipid, 2, (Ref)0, count, &rr);
|
terr = TCPIPReadTCP(ipid, 2, (Ref)0, count, &rr);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
if (_toolErr) break;
|
if (_toolErr) break;
|
||||||
|
|
||||||
|
@ -375,6 +384,7 @@ static int do_http_1_1(
|
||||||
|
|
||||||
// send the request.
|
// send the request.
|
||||||
// GET path HTTP/version\r\n
|
// GET path HTTP/version\r\n
|
||||||
|
IncBusy();
|
||||||
|
|
||||||
if (flags._I)
|
if (flags._I)
|
||||||
TCPIPWriteTCP(ipid, "HEAD ", 5, false, false);
|
TCPIPWriteTCP(ipid, "HEAD ", 5, false, false);
|
||||||
|
@ -416,6 +426,7 @@ static int do_http_1_1(
|
||||||
|
|
||||||
// end headers and push.
|
// end headers and push.
|
||||||
TCPIPWriteTCP(ipid, "\r\n", 2, true, false);
|
TCPIPWriteTCP(ipid, "\r\n", 2, true, false);
|
||||||
|
DecBusy();
|
||||||
|
|
||||||
DisposeHandle(dict);
|
DisposeHandle(dict);
|
||||||
dict = NULL;
|
dict = NULL;
|
||||||
|
|
11
prototypes.h
11
prototypes.h
|
@ -3,6 +3,17 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define IncBusy() asm { jsl 0xE10064 }
|
||||||
|
#define DecBusy() asm { jsl 0xE10068 }
|
||||||
|
#define Resched() asm { cop 0x7f }
|
||||||
|
|
||||||
|
#define BusyFlag ((byte *)0xE100FFl)
|
||||||
|
|
||||||
|
#define SEI() asm { sei }
|
||||||
|
#define CLI() asm { cli }
|
||||||
|
|
||||||
|
|
||||||
int read_binary(unsigned ipid, FILE *file);
|
int read_binary(unsigned ipid, FILE *file);
|
||||||
|
|
||||||
int setfiletype(const char *filename);
|
int setfiletype(const char *filename);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user