This commit is contained in:
Kelvin Sherlock 2018-04-01 15:45:56 -04:00
parent 875690e00d
commit 1840352173
3 changed files with 127 additions and 77 deletions

View File

@ -54,7 +54,7 @@ static CreateRecGS CreateDCB = {4, (GSString255Ptr)&folderPath, 0xe3, 0x0f, 0};
} }
if (t == fileNotFound) // file doesn't exist, create if (t == fileNotFound) // file doesn't exist, create
{ {
CreateResourceFile(0,0,0,(Pointer)&filePath); CreateResourceFile(0,0x5A,0,(Pointer)&filePath);
if (_toolErr) return 0; if (_toolErr) return 0;
} }
else if (t) return 0; else if (t) return 0;

View File

@ -3,7 +3,7 @@
CFLAGS += $(DEFINES) -v #-O CFLAGS += $(DEFINES) -v #-O
LDLIBS += -l /usr/local/lib/libk LDLIBS += -l /usr/local/lib/libk
OBJS = qserver.o macroman.o common.o marinetti.o config.o OBJS = qserver.o macroman.o common.o config.o
CFLAGS += -I /usr/local/include/ CFLAGS += -I /usr/local/include/
qserver: $(OBJS) qserver.r qserver: $(OBJS) qserver.r

200
qserver.c
View File

@ -81,7 +81,7 @@ void fixstats(void)
static char stats[16]; static char stats[16];
Word i; Word i;
i = ksprintf(stats + 1, "%d : %d", current, total); i = ksprintf(stats + 1, "%D : %D", current, total);
stats[0] = i; // pascal string stats[0] = i; // pascal string
SetInfoRefCon((LongWord)stats, MyWindow); SetInfoRefCon((LongWord)stats, MyWindow);
@ -119,7 +119,8 @@ enum
STATE_NULL = 0, STATE_NULL = 0,
STATE_ESTABLISH, // waiting to establish STATE_ESTABLISH, // waiting to establish
STATE_QUOTE, // send the quote... STATE_QUOTE, // send the quote...
STATE_SEND // waiting for data to send STATE_SEND, // waiting for data to send
STATE_CLOSE
}; };
void QServer(void) void QServer(void)
@ -139,6 +140,25 @@ int i;
if (!ipid) continue; if (!ipid) continue;
TCPIPStatusTCP(ipid, &srBuffer); TCPIPStatusTCP(ipid, &srBuffer);
if (_toolErr)
{
queue[i].ipid = 0;
queue[i].state = 0;
current--;
delta = true;
continue;
}
if (srBuffer.srState == TCPSCLOSED)
{
TCPIPLogout(ipid);
queue[i].ipid = 0;
queue[i].state = 0;
current--;
delta = true;
continue;
}
switch (queue[i].state) switch (queue[i].state)
{ {
@ -173,14 +193,10 @@ int i;
if (srBuffer.srSndQueued == 0) if (srBuffer.srSndQueued == 0)
{ {
queue[i].ipid = 0;
queue[i].state = 0;
TCPIPCloseTCP(ipid); TCPIPCloseTCP(ipid);
current--; queue[i].state = STATE_CLOSE;
delta = true;
} }
break; break;
} }
} }
@ -218,7 +234,7 @@ int i;
TCPIPConvertIPToASCII(srBuffer.srDestIP, TCPIPConvertIPToASCII(srBuffer.srDestIP,
buffer, 0); buffer, 0);
j = ksprintf(line, "%p:%d\r", j = ksprintf(line, "%p:%D\r",
buffer, srBuffer.srDestPort); buffer, srBuffer.srDestPort);
InsertString(j, line); InsertString(j, line);
@ -293,6 +309,8 @@ static char err[256];
fixstats(); fixstats();
HUnlock(rPath); HUnlock(rPath);
InsertString(16, "QServer started\r");
return true; return true;
} }
@ -309,7 +327,8 @@ int i;
ipid = queue[i].ipid; ipid = queue[i].ipid;
if (ipid) if (ipid)
{ {
TCPIPCloseTCP(ipid); TCPIPAbortTCP(ipid);
TCPIPLogout(ipid);
queue[i].ipid = 0; queue[i].ipid = 0;
} }
} }
@ -326,9 +345,11 @@ int i;
CloseResourceFile(rFile); CloseResourceFile(rFile);
SetInfoRefCon((LongWord)"\pQuote Server stopped", MyWindow); SetInfoRefCon((LongWord)"\pServer stopped", MyWindow);
DrawInfoBar(MyWindow); DrawInfoBar(MyWindow);
InsertString(16, "QServer stopped\r");
return true; return true;
} }
@ -407,6 +428,7 @@ pascal void MarinettiCallback(char *str)
DrawInfoBar(MyWindow); DrawInfoBar(MyWindow);
} }
} }
#pragma databank 0
pascal void DrawInfo(void *rect, const char *str, GrafPortPtr w) pascal void DrawInfo(void *rect, const char *str, GrafPortPtr w)
{ {
@ -425,49 +447,119 @@ void DrawWindow(void)
} }
// returns 1 on success, 0 on error. // returns 1 on success, 0 on error.
Word LoadNDATools(void) Word LoadNDATools(Word MyID)
{ {
if (!QDAuxStatus() || _toolErr) if (!QDAuxStatus() || _toolErr)
{ {
LoadOneTool(0x12,0); LoadOneTool(0x12,0);
if (_toolErr) return 0; if (!_toolErr) QDAuxStartUp();
QDAuxStartUp(); if (_toolErr)
{
AlertWindow(awCString, NULL,
(Ref)"24~Unable to start QuickDraw Aux.~^Too Bad");
return 0;
}
FlagQDAux = true; FlagQDAux = true;
} }
if (!FMStatus() || _toolErr) if (!FMStatus() || _toolErr)
{ {
Handle h; Handle h;
LoadOneTool(0x1b, 0); LoadOneTool(0x1b, 0);
if (_toolErr) return 0; if (!_toolErr) HandleFM = NewHandle(0x0100, MyID, 0xc005, 0);
HandleFM = NewHandle(MyID, 0x0100, 0xc005, 0); if (!_toolErr) FMStartUp(MyID, (Word)*HandleFM);
if (_toolErr) return 0; if (_toolErr)
FMStartUp(MyID, (Word)*HandleFM); {
if (HandleFM) DisposeHandle(HandleFM);
AlertWindow(awCString, NULL,
(Ref)"24~Unable to start Font Manager.~^Too Bad");
return 0;
}
FlagFM = true; FlagFM = true;
} }
if (!TEStatus() || _toolErr) if (!TEStatus() || _toolErr)
{ {
LoadOneTool(0x22,0x0); LoadOneTool(0x22,0x0);
if (_toolErr) return 0; if (!_toolErr) HandleTE = NewHandle(0x0100, MyID, 0xc005, 0);
HandleTE = NewHandle(MyID, 0x0100, 0xc005, 0); if (!_toolErr) TEStartUp(MyID, (Word)*HandleTE);
if (_toolErr) return 0; if (_toolErr)
TEStartUp(MyID, (Word)*HandleTE); {
FlagTE = true; if (HandleTE) DisposeHandle(HandleTE);
AlertWindow(awCString, NULL,
(Ref)"24~Unable to start Text Edit.~^Too Bad");
return 0;
}
FlagTE = true;
} }
if (!SFStatus() || _toolErr) if (!SFStatus() || _toolErr)
{ {
LoadOneTool(0x17,0); LoadOneTool(0x17,0);
if (_toolErr) return 0; if (!_toolErr) HandleSF = NewHandle(0x0100, MyID, 0xc005, 0);
HandleSF = NewHandle(MyID, 0x0100, 0xc005, 0); if (!_toolErr) SFStartUp(MyID, (Word)*HandleSF);
if (_toolErr) return 0; if (_toolErr)
SFStartUp(MyID, (Word)*HandleSF); {
FlagSF = true; if (HandleSF) DisposeHandle(HandleSF);
AlertWindow(awCString, NULL,
(Ref)"24~Unable to start Standard Filer.~^Too Bad");
return 0;
}
FlagSF = true;
} }
if (!TCPIPStatus() || _toolErr)
{
LoadOneTool(0x36,0x0200);
if (!_toolErr) TCPIPStartUp();
if (_toolErr)
{
AlertWindow(awCString, NULL,
(Ref)"24~Unable to start Marinetti.~^Too Bad");
return 0;
}
FlagLoadTCP = true;
}
return 1;
} }
#pragma databank 0 void UnloadNDATools(void)
{
if (FlagLoadTCP && !TCPIPGetConnectStatus())
{
TCPIPShutDown();
UnloadOneTool(0x36);
}
if (FlagSF)
{
SFShutDown();
UnloadOneTool(0x17);
DisposeHandle(HandleSF);
}
if (FlagTE)
{
TEShutDown();
UnloadOneTool(0x22);
DisposeHandle(HandleTE);
}
if (FlagFM)
{
FMShutDown();
UnloadOneTool(0x1b);
DisposeHandle(HandleFM);
}
if (FlagQDAux)
{
QDAuxShutDown();
UnloadOneTool(0x12);
}
}
GrafPortPtr NDAOpen(void) GrafPortPtr NDAOpen(void)
@ -475,19 +567,12 @@ GrafPortPtr NDAOpen(void)
Boolean ok = true; Boolean ok = true;
const char *err = NULL; const char *err = NULL;
if (!LoadNDATools()) if (!LoadNDATools(MyID)) return NULL;
{
AlertWindow(awCString, NULL,
(Ref)"24~Unable to load required tools.~^Too Bad");
return NULL;
}
LoadConfig(MyID); LoadConfig(MyID);
// Check if Marinetti Active. // Check if Marinetti Active.
if (!TCPIPStatus() || _toolErr) FlagTCP = TCPIPGetConnectStatus();
FlagTCP = false;
else FlagTCP = TCPIPGetConnectStatus();
if (ok) if (ok)
@ -585,35 +670,7 @@ void NDAInit(Word code)
} }
else else
{ {
if (FlagLoadTCP && !TCPIPGetConnectStatus()) UnloadNDATools();
{
TCPIPShutDown();
UnloadOneTool(0x36);
}
if (FlagTE)
{
TEShutDown();
UnloadOneTool(0x22);
DisposeHandle(HandleTE);
}
if (FlagFM)
{
FMShutDown();
UnloadOneTool(0x1b);
DisposeHandle(HandleFM);
}
if (FlagQDAux)
{
QDAuxShutDown();
UnloadOneTool(0x12);
}
if (FlagSF)
{
SFShutDown();
UnloadOneTool(0x17);
DisposeHandle(HandleSF);
}
} }
} }
@ -648,13 +705,6 @@ static word counter = 0;
/* start marinetti */ /* start marinetti */
case CtrlStartM: case CtrlStartM:
// //
// 1 load marinetti if need be.
if (!TCPIPStatus() || _toolErr)
{
LoadOneTool(0x36,0x0200);
TCPIPStartUp();
FlagLoadTCP = true;
}
if (TCPIPGetConnectStatus()) if (TCPIPGetConnectStatus())
{ {
FlagTCP = true; FlagTCP = true;