mirror of
https://github.com/ksherlock/qserver.git
synced 2024-09-07 06:54:24 +00:00
clang-format
This commit is contained in:
parent
828ee953ac
commit
3ea20b057c
242
common.c
242
common.c
@ -2,9 +2,9 @@
|
||||
#pragma lint -1
|
||||
#pragma optimize -1
|
||||
|
||||
#include <IntMath.h>
|
||||
#include <Memory.h>
|
||||
#include <Resources.h>
|
||||
#include <IntMath.h>
|
||||
#include <texttool.h>
|
||||
|
||||
#include "macroman.h"
|
||||
@ -23,160 +23,148 @@ char tmp[6];
|
||||
}
|
||||
#endif
|
||||
|
||||
extern pascal Word Random(void) inline(0x8604, dispatcher);
|
||||
|
||||
extern pascal Word Random(void) inline(0x8604,dispatcher);
|
||||
Handle LoadQuote(word mID, Word rFile) {
|
||||
Word oFile;
|
||||
Word oDepth;
|
||||
|
||||
Handle LoadQuote(word mID, Word rFile)
|
||||
{
|
||||
Word oFile;
|
||||
Word oDepth;
|
||||
int rID;
|
||||
Word rCount;
|
||||
|
||||
int rID;
|
||||
Word rCount;
|
||||
Handle rHandle;
|
||||
Handle h;
|
||||
|
||||
Handle rHandle;
|
||||
Handle h;
|
||||
h = NULL;
|
||||
|
||||
oFile = GetCurResourceFile();
|
||||
SetCurResourceFile(rFile);
|
||||
oDepth = SetResourceFileDepth(1);
|
||||
rCount = CountResources(rTextForLETextBox2);
|
||||
|
||||
h = NULL;
|
||||
// printint("rCount: ", rCount);
|
||||
|
||||
oFile = GetCurResourceFile();
|
||||
SetCurResourceFile(rFile);
|
||||
oDepth = SetResourceFileDepth(1);
|
||||
rCount = CountResources(rTextForLETextBox2);
|
||||
if (rCount) {
|
||||
WordDivRec wdr;
|
||||
longword index;
|
||||
|
||||
//printint("rCount: ", rCount);
|
||||
wdr = UDivide(Random(), (word)rCount);
|
||||
|
||||
if (rCount)
|
||||
{
|
||||
WordDivRec wdr;
|
||||
longword index;
|
||||
// printint("remainder: ", wdr.remainder);
|
||||
|
||||
wdr = UDivide(Random(), (word)rCount);
|
||||
index = GetIndResource(rTextForLETextBox2, wdr.remainder + 1);
|
||||
|
||||
//printint("remainder: ", wdr.remainder);
|
||||
// todo - repeat above until index out of range
|
||||
// printint("index: ", index);
|
||||
|
||||
index = GetIndResource(rTextForLETextBox2, wdr.remainder + 1);
|
||||
rHandle = LoadResource(rTextForLETextBox2, index);
|
||||
// printint("loadres: ", _toolErr);
|
||||
if (!_toolErr) {
|
||||
word oldLen;
|
||||
word newLen;
|
||||
char *newText;
|
||||
char *oldText;
|
||||
|
||||
// todo - repeat above until index out of range
|
||||
//printint("index: ", index);
|
||||
word len;
|
||||
word i;
|
||||
|
||||
oldLen = (word)GetHandleSize(rHandle);
|
||||
// printint("oldLen: ", oldLen);
|
||||
|
||||
rHandle = LoadResource(rTextForLETextBox2, index);
|
||||
//printint("loadres: ", _toolErr);
|
||||
if (!_toolErr)
|
||||
{
|
||||
word oldLen;
|
||||
word newLen;
|
||||
char *newText;
|
||||
char *oldText;
|
||||
h = NewHandle(oldLen << 2 + 2, mID, 0, NULL);
|
||||
if (!_toolErr) {
|
||||
HLock(h);
|
||||
HLock(rHandle);
|
||||
|
||||
word len;
|
||||
word i;
|
||||
oldText = *rHandle;
|
||||
newText = *h;
|
||||
newLen = 0;
|
||||
|
||||
oldLen = (word)GetHandleSize(rHandle);
|
||||
//printint("oldLen: ", oldLen);
|
||||
i = 0;
|
||||
while (i < oldLen) {
|
||||
char c;
|
||||
|
||||
h = NewHandle(oldLen << 2 + 2, mID, 0, NULL);
|
||||
if (!_toolErr)
|
||||
{
|
||||
HLock(h);
|
||||
HLock(rHandle);
|
||||
c = *oldText++;
|
||||
i++;
|
||||
|
||||
oldText = *rHandle;
|
||||
newText = *h;
|
||||
newLen = 0;
|
||||
if (c == '\r') {
|
||||
*((Word *)newText) = 0x0A0D;
|
||||
newText += 2;
|
||||
newLen += 2;
|
||||
continue;
|
||||
|
||||
i = 0;
|
||||
while (i < oldLen)
|
||||
{
|
||||
char c;
|
||||
//*newText++ = '\r';
|
||||
//*newText++ = '\n';
|
||||
// newLen += 2;
|
||||
// continue;
|
||||
}
|
||||
if (c == 0x01) // formatting codes.
|
||||
{
|
||||
c = *oldText;
|
||||
switch (c) {
|
||||
case 'F': // font
|
||||
oldText += 5;
|
||||
i += 5;
|
||||
break;
|
||||
|
||||
c = *oldText++;
|
||||
i++;
|
||||
case 'S': // set style
|
||||
oldText += 5;
|
||||
i += 4;
|
||||
break;
|
||||
|
||||
if (c == '\r')
|
||||
{
|
||||
*((Word *)newText) = 0x0A0D;
|
||||
newText += 2;
|
||||
newLen += 2;
|
||||
continue;
|
||||
case 'C': // fore color
|
||||
case 'B': // back color
|
||||
case 'J': // justify
|
||||
case 'L': // left margin
|
||||
case 'R': // right margin
|
||||
case 'X': // extra space
|
||||
oldText += 3;
|
||||
i += 3;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c & 0x80) // macroman encoding.
|
||||
{
|
||||
int j;
|
||||
c &= 0x7f;
|
||||
j = macroman[c].length;
|
||||
|
||||
//*newText++ = '\r';
|
||||
//*newText++ = '\n';
|
||||
//newLen += 2;
|
||||
//continue;
|
||||
}
|
||||
if (c == 0x01) // formatting codes.
|
||||
{
|
||||
c = *oldText;
|
||||
switch (c)
|
||||
{
|
||||
case 'F': // font
|
||||
oldText += 5;
|
||||
i += 5;
|
||||
break;
|
||||
if (j == 0)
|
||||
continue;
|
||||
|
||||
case 'S': // set style
|
||||
oldText += 5;
|
||||
i += 4;
|
||||
break;
|
||||
if (j > 1) {
|
||||
char *cp;
|
||||
cp = macroman[c].cp;
|
||||
|
||||
case 'C': // fore color
|
||||
case 'B': // back color
|
||||
case 'J': // justify
|
||||
case 'L': // left margin
|
||||
case 'R': // right margin
|
||||
case 'X': // extra space
|
||||
oldText += 3;
|
||||
i += 3;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c & 0x80) // macroman encoding.
|
||||
{
|
||||
int j;
|
||||
c &= 0x7f;
|
||||
j = macroman[c].length;
|
||||
newLen += j;
|
||||
do {
|
||||
*newText++ = *cp++;
|
||||
} while (--j);
|
||||
|
||||
if (j == 0) continue;
|
||||
continue;
|
||||
} else
|
||||
c = (char)macroman[c].cp;
|
||||
}
|
||||
|
||||
if (j > 1)
|
||||
{
|
||||
char *cp;
|
||||
cp = macroman[c].cp;
|
||||
newLen++;
|
||||
*newText++ = c;
|
||||
}
|
||||
|
||||
newLen += j;
|
||||
do
|
||||
{
|
||||
*newText++ = *cp++;
|
||||
}
|
||||
while (--j);
|
||||
//*newText++ = '\r';
|
||||
//*newText++ = '\n';
|
||||
*((Word *)newText) = 0x0A0D;
|
||||
newLen += 2;
|
||||
HUnlock(h);
|
||||
SetHandleSize(newLen, h);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else c = (char)macroman[c].cp;
|
||||
}
|
||||
HUnlock(rHandle);
|
||||
ReleaseResource(0, rTextForLETextBox2, index);
|
||||
}
|
||||
}
|
||||
SetCurResourceFile(oFile);
|
||||
SetResourceFileDepth(oDepth);
|
||||
|
||||
newLen++;
|
||||
*newText++ = c;
|
||||
}
|
||||
|
||||
//*newText++ = '\r';
|
||||
//*newText++ = '\n';
|
||||
*((Word *)newText) = 0x0A0D;
|
||||
newLen += 2;
|
||||
HUnlock(h);
|
||||
SetHandleSize(newLen, h);
|
||||
}
|
||||
|
||||
HUnlock(rHandle);
|
||||
ReleaseResource(0, rTextForLETextBox2, index);
|
||||
}
|
||||
}
|
||||
SetCurResourceFile(oFile);
|
||||
SetResourceFileDepth(oDepth);
|
||||
|
||||
return h;
|
||||
return h;
|
||||
}
|
||||
|
155
config.c
155
config.c
@ -14,7 +14,6 @@
|
||||
|
||||
#include "qserver.h"
|
||||
|
||||
|
||||
extern Handle rPath;
|
||||
|
||||
static Word fd;
|
||||
@ -24,42 +23,43 @@ static Word fd;
|
||||
* return 0 on failure, anything else on success.
|
||||
*/
|
||||
//
|
||||
Word LoadConfig(Word MyID)
|
||||
{
|
||||
Word t;
|
||||
Word oFile;
|
||||
Word oDepth;
|
||||
Word LoadConfig(Word MyID) {
|
||||
Word t;
|
||||
Word oFile;
|
||||
Word oDepth;
|
||||
|
||||
static GSString32 filePath = {28, "*:System:Preferences:QServer"};
|
||||
static GSString32 folderPath = {21, "*:System:Preferences:"};
|
||||
static GSString32 filePath = {28, "*:System:Preferences:QServer"};
|
||||
static GSString32 folderPath = {21, "*:System:Preferences:"};
|
||||
|
||||
static FileInfoRecGS InfoDCB = {12, (GSString255Ptr)&filePath};
|
||||
static CreateRecGS CreateDCB = {4, (GSString255Ptr)&folderPath, 0xe3, 0x0f, 0};
|
||||
|
||||
static FileInfoRecGS InfoDCB = {12, (GSString255Ptr)&filePath};
|
||||
static CreateRecGS CreateDCB = {4, (GSString255Ptr)&folderPath, 0xe3, 0x0f,
|
||||
0};
|
||||
|
||||
// 1 - check if file exists
|
||||
// 2 - if no, create the folder and file
|
||||
// 3 - load up the data
|
||||
// 4 - if data doesn't exist, store a default value.
|
||||
// 1 - check if file exists
|
||||
// 2 - if no, create the folder and file
|
||||
// 3 - load up the data
|
||||
// 4 - if data doesn't exist, store a default value.
|
||||
|
||||
fd = 0;
|
||||
|
||||
GetFileInfoGS(&InfoDCB);
|
||||
t = _toolErr;
|
||||
if (_toolErr == pathNotFound)
|
||||
{
|
||||
if (_toolErr == pathNotFound) {
|
||||
CreateGS(&CreateDCB);
|
||||
if (!_toolErr) t = fileNotFound;
|
||||
if (!_toolErr)
|
||||
t = fileNotFound;
|
||||
}
|
||||
if (t == fileNotFound) // file doesn't exist, create
|
||||
{
|
||||
CreateResourceFile(0,0x5A,0xe3,(Pointer)&filePath);
|
||||
if (_toolErr) return 0;
|
||||
}
|
||||
else if (t) return 0;
|
||||
CreateResourceFile(0, 0x5A, 0xe3, (Pointer)&filePath);
|
||||
if (_toolErr)
|
||||
return 0;
|
||||
} else if (t)
|
||||
return 0;
|
||||
|
||||
fd = OpenResourceFile(readWriteEnable, NULL, (Pointer)&filePath);
|
||||
if (_toolErr) return 0;
|
||||
if (_toolErr)
|
||||
return 0;
|
||||
|
||||
// make sure we're the only resource file...
|
||||
oFile = GetCurResourceFile();
|
||||
@ -69,13 +69,11 @@ static CreateRecGS CreateDCB = {4, (GSString255Ptr)&folderPath, 0xe3, 0x0f, 0};
|
||||
// load the quote path.
|
||||
|
||||
rPath = LoadResource(rC1InputString, 1);
|
||||
if (_toolErr)
|
||||
{
|
||||
static GSString255 defPath = { 34, "*/system/CDEVs/Twilight/QuotesFile"};
|
||||
if (_toolErr) {
|
||||
static GSString255 defPath = {34, "*/system/CDEVs/Twilight/QuotesFile"};
|
||||
|
||||
rPath = NewHandle(36, MyID, 0, NULL);
|
||||
if (rPath)
|
||||
{
|
||||
if (rPath) {
|
||||
PtrToHand((Pointer)defPath, rPath, 36);
|
||||
AddResource(rPath, 0, rC1InputString, 1);
|
||||
}
|
||||
@ -89,9 +87,9 @@ static CreateRecGS CreateDCB = {4, (GSString255Ptr)&folderPath, 0xe3, 0x0f, 0};
|
||||
return 1;
|
||||
}
|
||||
|
||||
void UnloadConfig(void)
|
||||
{
|
||||
if (fd) CloseResourceFile(fd);
|
||||
void UnloadConfig(void) {
|
||||
if (fd)
|
||||
CloseResourceFile(fd);
|
||||
fd = 0;
|
||||
}
|
||||
|
||||
@ -99,19 +97,17 @@ void UnloadConfig(void)
|
||||
* callback from SFGetFile2. only allows if resource fork found.
|
||||
*/
|
||||
#pragma toolparms 1
|
||||
Word SFFilter(DirEntryRecGS *file)
|
||||
{
|
||||
if (file->flags & 0x8000) return displaySelect;
|
||||
Word SFFilter(DirEntryRecGS *file) {
|
||||
if (file->flags & 0x8000)
|
||||
return displaySelect;
|
||||
return noSelect;
|
||||
}
|
||||
#pragma toolparms 0
|
||||
|
||||
|
||||
static void SetText(WindowPtr win, Word id, void *data)
|
||||
{
|
||||
GSString255 * gstr = (GSString255 *)data;
|
||||
CtlRecHndl CtrlHand;
|
||||
Rect r;
|
||||
static void SetText(WindowPtr win, Word id, void *data) {
|
||||
GSString255 *gstr = (GSString255 *)data;
|
||||
CtlRecHndl CtrlHand;
|
||||
Rect r;
|
||||
|
||||
CtrlHand = GetCtlHandleFromID(win, id);
|
||||
|
||||
@ -124,27 +120,26 @@ Rect r;
|
||||
SetCtlTitle(gstr->text, (Handle)CtrlHand);
|
||||
} else {
|
||||
SetCtlValue(0, CtrlHand);
|
||||
SetCtlTitle("", (Handle)CtrlHand);
|
||||
SetCtlTitle("", (Handle)CtrlHand);
|
||||
}
|
||||
}
|
||||
|
||||
void DoConfig(Word MyID)
|
||||
{
|
||||
static EventRecord event;
|
||||
void DoConfig(Word MyID) {
|
||||
static EventRecord event;
|
||||
|
||||
WindowPtr win;
|
||||
Word control;
|
||||
Word ok;
|
||||
GrafPortPtr oldPort;
|
||||
Handle newPath = NULL;
|
||||
WindowPtr win;
|
||||
Word control;
|
||||
Word ok;
|
||||
GrafPortPtr oldPort;
|
||||
Handle newPath = NULL;
|
||||
|
||||
oldPort = GetPort();
|
||||
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.wmTaskMask = 0x001f0004;
|
||||
|
||||
win = NewWindow2(NULL, NULL, NULL, NULL,
|
||||
refIsResource, (long)rConfigWindow, rWindParam1);
|
||||
win = NewWindow2(NULL, NULL, NULL, NULL, refIsResource, (long)rConfigWindow,
|
||||
rWindParam1);
|
||||
|
||||
SetPort(win);
|
||||
// set the current path text...
|
||||
@ -155,58 +150,49 @@ Handle newPath = NULL;
|
||||
SetText(win, CtrlPath, NULL);
|
||||
}
|
||||
|
||||
for (ok = true; ok;)
|
||||
{
|
||||
for (ok = true; ok;) {
|
||||
control = (Word)DoModalWindow(&event, NULL, NULL, NULL, 0x0008);
|
||||
|
||||
switch(control)
|
||||
{
|
||||
switch (control) {
|
||||
case CtrlCancel:
|
||||
case CtrlOk:
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case CtrlBrowse:
|
||||
{
|
||||
case CtrlBrowse: {
|
||||
SFReplyRec2 myReply;
|
||||
|
||||
myReply.nameRefDesc = refIsNewHandle;
|
||||
myReply.pathRefDesc = refIsNewHandle;
|
||||
myReply.nameRefDesc = refIsNewHandle;
|
||||
myReply.pathRefDesc = refIsNewHandle;
|
||||
|
||||
SFGetFile2(
|
||||
10, 35,
|
||||
refIsPointer,
|
||||
(Ref)"\pSelect quotation file.",
|
||||
(WordProcPtr)SFFilter, /* filter proc */
|
||||
NULL, /* type list */
|
||||
&myReply);
|
||||
if (myReply.good)
|
||||
{
|
||||
Handle h;
|
||||
Word size;
|
||||
SFGetFile2(10, 35, refIsPointer, (Ref) "\pSelect quotation file.",
|
||||
(WordProcPtr)SFFilter, /* filter proc */
|
||||
NULL, /* type list */
|
||||
&myReply);
|
||||
if (myReply.good) {
|
||||
Handle h;
|
||||
Word size;
|
||||
|
||||
h = (Handle)myReply.pathRef;
|
||||
HLock(h);
|
||||
size = GetHandleSize(h) - 2;
|
||||
BlockMove(*h + 2, *h, size);
|
||||
ReAllocHandle(size, MyID, 0x8000, NULL, h);
|
||||
h = (Handle)myReply.pathRef;
|
||||
HLock(h);
|
||||
size = GetHandleSize(h) - 2;
|
||||
BlockMove(*h + 2, *h, size);
|
||||
ReAllocHandle(size, MyID, 0x8000, NULL, h);
|
||||
|
||||
SetText(win, CtrlPath, *h);
|
||||
SetText(win, CtrlPath, *h);
|
||||
|
||||
if (newPath) DisposeHandle(newPath);
|
||||
newPath = h;
|
||||
if (newPath)
|
||||
DisposeHandle(newPath);
|
||||
newPath = h;
|
||||
|
||||
DisposeHandle((Handle)myReply.nameRef);
|
||||
}
|
||||
DisposeHandle((Handle)myReply.nameRef);
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
if (control == CtrlOk) // update the config file.
|
||||
{
|
||||
if (newPath)
|
||||
{
|
||||
if (newPath) {
|
||||
Word size = (Word)GetHandleSize(newPath);
|
||||
|
||||
ReAllocHandle(size, MyID, 0, NULL, rPath);
|
||||
@ -220,5 +206,4 @@ Handle newPath = NULL;
|
||||
SetPort(oldPort);
|
||||
|
||||
HUnlock(rPath);
|
||||
|
||||
}
|
||||
|
272
macroman.c
272
macroman.c
@ -3,148 +3,150 @@
|
||||
|
||||
#include "macroman.h"
|
||||
|
||||
#define ONECHAR(x) { 1, (char *)x }
|
||||
#define ONECHAR(x) \
|
||||
{ 1, (char *)x }
|
||||
|
||||
#define MULTICHAR(x) { sizeof(x) -1, x }
|
||||
#define MULTICHAR(x) \
|
||||
{ sizeof(x) - 1, x }
|
||||
|
||||
#define BLANK { 0, (char *)0 }
|
||||
#define BLANK \
|
||||
{ 0, (char *)0 }
|
||||
|
||||
struct charmap macroman[128] =
|
||||
{
|
||||
ONECHAR('A'), // 0x80
|
||||
ONECHAR('A'),
|
||||
ONECHAR('C'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('N'),
|
||||
ONECHAR('O'),
|
||||
ONECHAR('U'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('c'),
|
||||
ONECHAR('e'),
|
||||
ONECHAR('e'),
|
||||
struct charmap macroman[128] = {
|
||||
ONECHAR('A'), // 0x80
|
||||
ONECHAR('A'),
|
||||
ONECHAR('C'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('N'),
|
||||
ONECHAR('O'),
|
||||
ONECHAR('U'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('a'),
|
||||
ONECHAR('c'),
|
||||
ONECHAR('e'),
|
||||
ONECHAR('e'),
|
||||
|
||||
ONECHAR('e'), // 0x90
|
||||
ONECHAR('e'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('n'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('e'), // 0x90
|
||||
ONECHAR('e'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('i'),
|
||||
ONECHAR('n'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('o'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('u'),
|
||||
ONECHAR('u'),
|
||||
|
||||
BLANK, // 0xA0
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('*'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("(r)"),
|
||||
MULTICHAR("(c)"),
|
||||
MULTICHAR("tm"),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("AE"),
|
||||
ONECHAR('O'),
|
||||
BLANK, // 0xA0
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('*'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("(r)"),
|
||||
MULTICHAR("(c)"),
|
||||
MULTICHAR("tm"),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("AE"),
|
||||
ONECHAR('O'),
|
||||
|
||||
BLANK, // 0xB0
|
||||
BLANK,
|
||||
MULTICHAR("<="),
|
||||
MULTICHAR(">="),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("ae"),
|
||||
ONECHAR('o'),
|
||||
BLANK, // 0xB0
|
||||
BLANK,
|
||||
MULTICHAR("<="),
|
||||
MULTICHAR(">="),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("ae"),
|
||||
ONECHAR('o'),
|
||||
|
||||
ONECHAR('?'), // 0xC0
|
||||
ONECHAR('!'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('f'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("<<"),
|
||||
MULTICHAR(">>"),
|
||||
MULTICHAR("..."),
|
||||
ONECHAR(' '),
|
||||
ONECHAR('A'),
|
||||
ONECHAR('A'),
|
||||
ONECHAR('O'),
|
||||
MULTICHAR("OE"),
|
||||
MULTICHAR("oe"),
|
||||
|
||||
MULTICHAR("--"), // 0xD0
|
||||
MULTICHAR("---"),
|
||||
ONECHAR('"'),
|
||||
ONECHAR('"'),
|
||||
ONECHAR('\''),
|
||||
ONECHAR('\''),
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('y'),
|
||||
ONECHAR('Y'),
|
||||
ONECHAR('/'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("fi"),
|
||||
MULTICHAR("fl"),
|
||||
ONECHAR('?'), // 0xC0
|
||||
ONECHAR('!'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('f'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("<<"),
|
||||
MULTICHAR(">>"),
|
||||
MULTICHAR("..."),
|
||||
ONECHAR(' '),
|
||||
ONECHAR('A'),
|
||||
ONECHAR('A'),
|
||||
ONECHAR('O'),
|
||||
MULTICHAR("OE"),
|
||||
MULTICHAR("oe"),
|
||||
|
||||
BLANK, // 0xE0
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('A'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('A'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('O'),
|
||||
ONECHAR('O'),
|
||||
|
||||
ONECHAR('?'), // 0xF0
|
||||
ONECHAR('O'),
|
||||
ONECHAR('U'),
|
||||
ONECHAR('U'),
|
||||
ONECHAR('U'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("--"), // 0xD0
|
||||
MULTICHAR("---"),
|
||||
ONECHAR('"'),
|
||||
ONECHAR('"'),
|
||||
ONECHAR('\''),
|
||||
ONECHAR('\''),
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('y'),
|
||||
ONECHAR('Y'),
|
||||
ONECHAR('/'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
MULTICHAR("fi"),
|
||||
MULTICHAR("fl"),
|
||||
|
||||
BLANK, // 0xE0
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
ONECHAR('A'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('A'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('E'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('I'),
|
||||
ONECHAR('O'),
|
||||
ONECHAR('O'),
|
||||
|
||||
ONECHAR('?'), // 0xF0
|
||||
ONECHAR('O'),
|
||||
ONECHAR('U'),
|
||||
ONECHAR('U'),
|
||||
ONECHAR('U'),
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
BLANK,
|
||||
|
||||
};
|
||||
|
@ -1,10 +1,9 @@
|
||||
#ifndef __MACROMAN_H__
|
||||
#define __MACROMAN_H__
|
||||
|
||||
struct charmap
|
||||
{
|
||||
int length;
|
||||
char *cp;
|
||||
struct charmap {
|
||||
int length;
|
||||
char *cp;
|
||||
};
|
||||
|
||||
extern struct charmap macroman[128];
|
||||
|
59
marinetti.c
59
marinetti.c
@ -10,45 +10,42 @@
|
||||
#define FLAG_CONNECTED 4
|
||||
#define FLAG_ERROR 0xffff
|
||||
|
||||
void stopMarinetti(int flag)
|
||||
{
|
||||
if (flag == FLAG_ERROR) return;
|
||||
if (flag == 0) return;
|
||||
if (flag & FLAG_CONNECTED)
|
||||
{
|
||||
void stopMarinetti(int flag) {
|
||||
if (flag == FLAG_ERROR)
|
||||
return;
|
||||
if (flag == 0)
|
||||
return;
|
||||
if (flag & FLAG_CONNECTED) {
|
||||
TCPIPDisconnect(0, 0);
|
||||
if (_toolErr) return;
|
||||
if (_toolErr)
|
||||
return;
|
||||
}
|
||||
if (flag & FLAG_STARTED) TCPIPShutDown();
|
||||
if (flag & FLAG_LOADED) UnloadOneTool(0x36);
|
||||
if (flag & FLAG_STARTED)
|
||||
TCPIPShutDown();
|
||||
if (flag & FLAG_LOADED)
|
||||
UnloadOneTool(0x36);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* do the various steps to start up marinetti.
|
||||
*/
|
||||
int startMarinetti(void)
|
||||
{
|
||||
int flag = 0;
|
||||
int startMarinetti(void) {
|
||||
int flag = 0;
|
||||
|
||||
TCPIPStatus();
|
||||
if (_toolErr)
|
||||
{
|
||||
LoadOneTool(0x36, 0x0200); //load Marinetti
|
||||
if (_toolErr) return FLAG_ERROR;
|
||||
if (_toolErr) {
|
||||
LoadOneTool(0x36, 0x0200); // load Marinetti
|
||||
if (_toolErr)
|
||||
return FLAG_ERROR;
|
||||
flag |= FLAG_LOADED;
|
||||
}
|
||||
if (!TCPIPStatus())
|
||||
{
|
||||
if (!TCPIPStatus()) {
|
||||
TCPIPStartUp();
|
||||
flag |= FLAG_STARTED;
|
||||
}
|
||||
if (!TCPIPGetConnectStatus())
|
||||
{
|
||||
if (!TCPIPGetConnectStatus()) {
|
||||
TCPIPConnect(0);
|
||||
if (_toolErr)
|
||||
{
|
||||
if (_toolErr) {
|
||||
stopMarinetti(flag);
|
||||
return FLAG_ERROR;
|
||||
}
|
||||
@ -57,17 +54,3 @@ int flag = 0;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
630
qserver.c
630
qserver.c
@ -1,36 +1,33 @@
|
||||
#pragma nda NDAOpen NDAClose NDAAction NDAInit 30 0xffff "--Quote Server\\H**"
|
||||
#pragma nda NDAOpen NDAClose NDAAction NDAInit 30 0xffff "--Quote Server\\H**"
|
||||
#pragma lint -1
|
||||
#pragma optimize -1
|
||||
|
||||
#include <Types.h>
|
||||
#include <GSOS.h>
|
||||
#include <Memory.h>
|
||||
#include <Locator.h>
|
||||
#include <Loader.h>
|
||||
#include <Control.h>
|
||||
#include <Desk.h>
|
||||
#include <Event.h>
|
||||
#include <Window.h>
|
||||
#include <Control.h>
|
||||
#include <Resources.h>
|
||||
#include <Quickdraw.h>
|
||||
#include <QDAux.h>
|
||||
#include <Font.h>
|
||||
#include <stdfile.h>
|
||||
#include <TextEdit.h>
|
||||
#include <intmath.h>
|
||||
#include <GSOS.h>
|
||||
#include <Loader.h>
|
||||
#include <Locator.h>
|
||||
#include <Memory.h>
|
||||
#include <QDAux.h>
|
||||
#include <Quickdraw.h>
|
||||
#include <Resources.h>
|
||||
#include <TCPIP.h>
|
||||
#include <TextEdit.h>
|
||||
#include <Types.h>
|
||||
#include <Window.h>
|
||||
#include <intmath.h>
|
||||
#include <misctool.h>
|
||||
#include <stdfile.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "qserver.h"
|
||||
|
||||
|
||||
unsigned NDAStartUpTools(Word memID, StartStopRecord *ssRef);
|
||||
void NDAShutDownTools(StartStopRecord *ssRef);
|
||||
|
||||
|
||||
|
||||
typedef struct NDAResourceCookie {
|
||||
Word oldPrefs;
|
||||
Word oldRApp;
|
||||
@ -41,15 +38,12 @@ void NDAResourceRestore(NDAResourceCookie *cookie);
|
||||
void NDAResourceShutDown(NDAResourceCookie *cookie);
|
||||
Word NDAResourceStartUp(Word memID, Word access, NDAResourceCookie *cookie);
|
||||
|
||||
|
||||
|
||||
Handle LoadQuote(word mID, Word rfile);
|
||||
|
||||
Word LoadConfig(Word MemID);
|
||||
void UnloadConfig(void);
|
||||
void DoConfig(Word MemID);
|
||||
|
||||
|
||||
const char *ReqName = "\pTCP/IP~kelvin~qserver~";
|
||||
|
||||
/*
|
||||
@ -64,16 +58,14 @@ Boolean ToolsLoaded;
|
||||
Word MyID;
|
||||
Word Ipid;
|
||||
|
||||
|
||||
word rFile;
|
||||
Handle rPath;
|
||||
word rCount;
|
||||
|
||||
struct qentry
|
||||
{
|
||||
Word ipid;
|
||||
Word state;
|
||||
Longword tick;
|
||||
struct qentry {
|
||||
Word ipid;
|
||||
Word state;
|
||||
Longword tick;
|
||||
};
|
||||
|
||||
#define QSIZE 16
|
||||
@ -82,11 +74,9 @@ struct qentry queue[QSIZE];
|
||||
word total;
|
||||
word current;
|
||||
|
||||
|
||||
void fixstats(void)
|
||||
{
|
||||
static char stats[16];
|
||||
Word i;
|
||||
void fixstats(void) {
|
||||
static char stats[16];
|
||||
Word i;
|
||||
|
||||
i = sprintf(stats + 1, "%u : %u", current, total);
|
||||
stats[0] = i; // pascal string
|
||||
@ -95,282 +85,247 @@ Word i;
|
||||
DrawInfoBar(MyWindow);
|
||||
}
|
||||
|
||||
void InsertString(word length, char *cp) {
|
||||
Handle handle;
|
||||
TERecord **temp;
|
||||
longword oldStart, oldEnd;
|
||||
|
||||
void InsertString(word length, char *cp)
|
||||
{
|
||||
Handle handle;
|
||||
TERecord **temp;
|
||||
longword oldStart, oldEnd;
|
||||
handle = (Handle)GetCtlHandleFromID(MyWindow, CtrlTE);
|
||||
temp = (TERecord **)handle;
|
||||
|
||||
handle = (Handle)GetCtlHandleFromID(MyWindow, CtrlTE);
|
||||
temp = (TERecord **)handle;
|
||||
(**temp).textFlags &= (~fReadOnly);
|
||||
|
||||
(**temp).textFlags &= (~fReadOnly);
|
||||
TEGetSelection((pointer)&oldStart, (pointer)&oldEnd, handle);
|
||||
|
||||
TEGetSelection((pointer)&oldStart, (pointer)&oldEnd, handle);
|
||||
TESetSelection((Pointer)-1, (Pointer)-1, handle);
|
||||
TEInsert(teDataIsTextBlock, (Ref)cp, length, NULL, NULL, /* no style info */
|
||||
handle);
|
||||
|
||||
TESetSelection((Pointer)-1, (Pointer)-1, handle);
|
||||
TEInsert(teDataIsTextBlock, (Ref)cp, length,
|
||||
NULL, NULL, /* no style info */
|
||||
handle);
|
||||
|
||||
(**temp).textFlags |= fReadOnly;
|
||||
|
||||
TESetSelection((Pointer)oldStart, (Pointer)oldEnd, handle);
|
||||
(**temp).textFlags |= fReadOnly;
|
||||
|
||||
TESetSelection((Pointer)oldStart, (Pointer)oldEnd, handle);
|
||||
}
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
STATE_NULL = 0,
|
||||
STATE_ESTABLISH, // waiting to establish
|
||||
STATE_QUOTE, // send the quote...
|
||||
STATE_SEND, // waiting for data to send
|
||||
STATE_CLOSE
|
||||
enum {
|
||||
STATE_NULL = 0,
|
||||
STATE_ESTABLISH, // waiting to establish
|
||||
STATE_QUOTE, // send the quote...
|
||||
STATE_SEND, // waiting for data to send
|
||||
STATE_CLOSE
|
||||
};
|
||||
|
||||
void QServer(void)
|
||||
{
|
||||
static srBuff srBuffer;
|
||||
word delta;
|
||||
int i;
|
||||
void QServer(void) {
|
||||
static srBuff srBuffer;
|
||||
word delta;
|
||||
int i;
|
||||
|
||||
delta = false;
|
||||
delta = false;
|
||||
|
||||
TCPIPPoll();
|
||||
for (i = 0; i < QSIZE; i++)
|
||||
{
|
||||
word ipid;
|
||||
TCPIPPoll();
|
||||
for (i = 0; i < QSIZE; i++) {
|
||||
word ipid;
|
||||
|
||||
ipid = queue[i].ipid;
|
||||
if (!ipid) continue;
|
||||
ipid = queue[i].ipid;
|
||||
if (!ipid)
|
||||
continue;
|
||||
|
||||
TCPIPStatusTCP(ipid, &srBuffer);
|
||||
if (_toolErr)
|
||||
{
|
||||
queue[i].ipid = 0;
|
||||
queue[i].state = 0;
|
||||
current--;
|
||||
delta = true;
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (srBuffer.srState == TCPSCLOSED) {
|
||||
TCPIPLogout(ipid);
|
||||
queue[i].ipid = 0;
|
||||
queue[i].state = 0;
|
||||
current--;
|
||||
delta = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (queue[i].state) {
|
||||
case STATE_ESTABLISH:
|
||||
if (srBuffer.srState != TCPSESTABLISHED)
|
||||
break;
|
||||
|
||||
switch (queue[i].state)
|
||||
{
|
||||
case STATE_ESTABLISH:
|
||||
if (srBuffer.srState != TCPSESTABLISHED)
|
||||
break;
|
||||
queue[i].state = STATE_QUOTE;
|
||||
// drop through and send the quote.
|
||||
|
||||
queue[i].state = STATE_QUOTE;
|
||||
// drop through and send the quote.
|
||||
case STATE_QUOTE: {
|
||||
Handle h;
|
||||
h = LoadQuote(MyID, rFile);
|
||||
if (h) {
|
||||
HLock(h);
|
||||
TCPIPWriteTCP(ipid, *h, GetHandleSize(h), false, false);
|
||||
DisposeHandle(h);
|
||||
} else {
|
||||
TCPIPWriteTCP(ipid, "Your quote here!\r\n", 18, false, false);
|
||||
}
|
||||
}
|
||||
queue[i].state = STATE_SEND;
|
||||
break;
|
||||
|
||||
case STATE_QUOTE:
|
||||
{
|
||||
Handle h;
|
||||
h = LoadQuote(MyID, rFile);
|
||||
if (h)
|
||||
{
|
||||
HLock(h);
|
||||
TCPIPWriteTCP(ipid, *h,
|
||||
GetHandleSize(h), false, false);
|
||||
DisposeHandle(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
TCPIPWriteTCP(ipid, "Your quote here!\r\n",
|
||||
18, false, false);
|
||||
}
|
||||
}
|
||||
queue[i].state = STATE_SEND;
|
||||
break;
|
||||
|
||||
case STATE_SEND:
|
||||
case STATE_SEND:
|
||||
|
||||
if (srBuffer.srSndQueued == 0)
|
||||
{
|
||||
TCPIPCloseTCP(ipid);
|
||||
queue[i].state = STATE_CLOSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (srBuffer.srSndQueued == 0) {
|
||||
TCPIPCloseTCP(ipid);
|
||||
queue[i].state = STATE_CLOSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// check for a new connection.
|
||||
if (current < QSIZE) {
|
||||
word child;
|
||||
int i;
|
||||
child = TCPIPAcceptTCP(Ipid, 0);
|
||||
|
||||
// check for a new connection.
|
||||
if (current < QSIZE)
|
||||
{
|
||||
word child;
|
||||
int i;
|
||||
child = TCPIPAcceptTCP(Ipid, 0);
|
||||
|
||||
if (!_toolErr) for (i = 0; i < QSIZE; i++)
|
||||
{
|
||||
if (!queue[i].ipid)
|
||||
{
|
||||
static char buffer[16];
|
||||
static char line[32];
|
||||
int j;
|
||||
if (!_toolErr)
|
||||
for (i = 0; i < QSIZE; i++) {
|
||||
if (!queue[i].ipid) {
|
||||
static char buffer[16];
|
||||
static char line[32];
|
||||
int j;
|
||||
|
||||
TCPIPStatusTCP(child, &srBuffer);
|
||||
TCPIPStatusTCP(child, &srBuffer);
|
||||
|
||||
queue[i].ipid = child;
|
||||
queue[i].ipid = child;
|
||||
|
||||
if (srBuffer.srState == TCPSESTABLISHED)
|
||||
queue[i].state = STATE_SEND;
|
||||
else
|
||||
queue[i].state = STATE_ESTABLISH;
|
||||
if (srBuffer.srState == TCPSESTABLISHED)
|
||||
queue[i].state = STATE_SEND;
|
||||
else
|
||||
queue[i].state = STATE_ESTABLISH;
|
||||
|
||||
queue[i].tick = GetTick();
|
||||
queue[i].tick = GetTick();
|
||||
|
||||
current++;
|
||||
total++;
|
||||
delta = true;
|
||||
|
||||
TCPIPConvertIPToASCII(srBuffer.srDestIP,
|
||||
buffer, 0);
|
||||
current++;
|
||||
total++;
|
||||
delta = true;
|
||||
|
||||
j = sprintf(line, "%p:%u\r",
|
||||
buffer, srBuffer.srDestPort);
|
||||
|
||||
InsertString(j, line);
|
||||
TCPIPConvertIPToASCII(srBuffer.srDestIP, buffer, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delta) fixstats(); // statistics changed.
|
||||
j = sprintf(line, "%p:%u\r", buffer, srBuffer.srDestPort);
|
||||
|
||||
InsertString(j, line);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delta)
|
||||
fixstats(); // statistics changed.
|
||||
}
|
||||
|
||||
int StartServer(void) {
|
||||
int i;
|
||||
word oFile;
|
||||
word oDepth;
|
||||
static char err[256];
|
||||
GSString255 *path;
|
||||
|
||||
int StartServer(void)
|
||||
{
|
||||
int i;
|
||||
word oFile;
|
||||
word oDepth;
|
||||
static char err[256];
|
||||
GSString255 *path;
|
||||
total = current = 0;
|
||||
|
||||
total = current = 0;
|
||||
|
||||
if (!rPath)
|
||||
{
|
||||
InsertString(32, "Fatal: No quote file specified.\r");
|
||||
return false;
|
||||
}
|
||||
HLock(rPath);
|
||||
if (!rPath) {
|
||||
InsertString(32, "Fatal: No quote file specified.\r");
|
||||
return false;
|
||||
}
|
||||
HLock(rPath);
|
||||
path = *(GSString255 **)rPath;
|
||||
|
||||
rFile = OpenResourceFile(readEnable, NULL, (pointer)path);
|
||||
if (_toolErr)
|
||||
{
|
||||
/* todo */
|
||||
InsertString(sprintf(err, "Fatal: Unable to open %.*s\r", path->length, path->text),
|
||||
err);
|
||||
return false;
|
||||
}
|
||||
rFile = OpenResourceFile(readEnable, NULL, (pointer)path);
|
||||
if (_toolErr) {
|
||||
/* todo */
|
||||
InsertString(
|
||||
sprintf(err, "Fatal: Unable to open %.*s\r", path->length, path->text),
|
||||
err);
|
||||
return false;
|
||||
}
|
||||
|
||||
oFile = GetCurResourceFile();
|
||||
SetCurResourceFile(rFile);
|
||||
oDepth = SetResourceFileDepth(1);
|
||||
rCount = CountResources(rTextForLETextBox2);
|
||||
SetCurResourceFile(oFile);
|
||||
SetResourceFileDepth(oDepth);
|
||||
oFile = GetCurResourceFile();
|
||||
SetCurResourceFile(rFile);
|
||||
oDepth = SetResourceFileDepth(1);
|
||||
rCount = CountResources(rTextForLETextBox2);
|
||||
SetCurResourceFile(oFile);
|
||||
SetResourceFileDepth(oDepth);
|
||||
|
||||
if (!rCount)
|
||||
{
|
||||
/* todo */
|
||||
InsertString(sprintf(err, "Fatal: Invalid quote file %.*s\r", path->length, path->text),
|
||||
err);
|
||||
if (!rCount) {
|
||||
/* todo */
|
||||
InsertString(sprintf(err, "Fatal: Invalid quote file %.*s\r", path->length,
|
||||
path->text),
|
||||
err);
|
||||
|
||||
CloseResourceFile(rFile);
|
||||
return false;
|
||||
}
|
||||
CloseResourceFile(rFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
SetRandSeed(GetTick());
|
||||
SetRandSeed(GetTick());
|
||||
|
||||
for (i = 0; i < QSIZE; i++) {
|
||||
queue[i].ipid = 0;
|
||||
queue[i].state = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < QSIZE; i++)
|
||||
{
|
||||
queue[i].ipid = 0;
|
||||
queue[i].state = 0;
|
||||
}
|
||||
Ipid = TCPIPLogin(MyID, 0, 0, 0, 64);
|
||||
|
||||
Ipid = TCPIPLogin(MyID, 0, 0, 0, 64);
|
||||
TCPIPSetSourcePort(Ipid, PORT_QOTD);
|
||||
|
||||
TCPIPSetSourcePort(Ipid, PORT_QOTD);
|
||||
TCPIPListenTCP(Ipid);
|
||||
|
||||
TCPIPListenTCP(Ipid);
|
||||
FlagQS = true;
|
||||
|
||||
FlagQS = true;
|
||||
HiliteCtlByID(inactiveHilite, MyWindow, CtrlStartQS);
|
||||
HiliteCtlByID(noHilite, MyWindow, CtrlStopQS);
|
||||
|
||||
HiliteCtlByID(inactiveHilite, MyWindow, CtrlStartQS);
|
||||
HiliteCtlByID(noHilite, MyWindow, CtrlStopQS);
|
||||
|
||||
fixstats();
|
||||
HUnlock(rPath);
|
||||
|
||||
InsertString(16, "QServer started\r");
|
||||
return true;
|
||||
fixstats();
|
||||
HUnlock(rPath);
|
||||
|
||||
InsertString(16, "QServer started\r");
|
||||
return true;
|
||||
}
|
||||
|
||||
int StopServer(void)
|
||||
{
|
||||
int i;
|
||||
int StopServer(void) {
|
||||
int i;
|
||||
|
||||
// close any q entries
|
||||
for (i = 0; i < QSIZE; i++) {
|
||||
int ipid;
|
||||
ipid = queue[i].ipid;
|
||||
if (ipid) {
|
||||
TCPIPAbortTCP(ipid);
|
||||
TCPIPLogout(ipid);
|
||||
queue[i].ipid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// close any q entries
|
||||
for (i = 0; i < QSIZE; i++)
|
||||
{
|
||||
int ipid;
|
||||
ipid = queue[i].ipid;
|
||||
if (ipid)
|
||||
{
|
||||
TCPIPAbortTCP(ipid);
|
||||
TCPIPLogout(ipid);
|
||||
queue[i].ipid = 0;
|
||||
}
|
||||
}
|
||||
TCPIPCloseTCP(Ipid);
|
||||
TCPIPLogout(Ipid);
|
||||
|
||||
TCPIPCloseTCP(Ipid);
|
||||
TCPIPLogout(Ipid);
|
||||
FlagQS = false;
|
||||
Ipid = 0;
|
||||
|
||||
FlagQS = false;
|
||||
Ipid = 0;
|
||||
HiliteCtlByID(inactiveHilite, MyWindow, CtrlStopQS);
|
||||
HiliteCtlByID(noHilite, MyWindow, CtrlStartQS);
|
||||
|
||||
HiliteCtlByID(inactiveHilite, MyWindow, CtrlStopQS);
|
||||
HiliteCtlByID(noHilite, MyWindow, CtrlStartQS);
|
||||
CloseResourceFile(rFile);
|
||||
|
||||
CloseResourceFile(rFile);
|
||||
SetInfoRefCon((LongWord) "\pServer stopped", MyWindow);
|
||||
DrawInfoBar(MyWindow);
|
||||
|
||||
InsertString(16, "QServer stopped\r");
|
||||
|
||||
SetInfoRefCon((LongWord)"\pServer stopped", MyWindow);
|
||||
DrawInfoBar(MyWindow);
|
||||
|
||||
InsertString(16, "QServer stopped\r");
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// activate/inactivate controls based on Marinetti status
|
||||
void UpdateStatus(Boolean redraw)
|
||||
{
|
||||
void UpdateStatus(Boolean redraw) {
|
||||
if (FlagTCP) // TCP started
|
||||
{
|
||||
// deactivate
|
||||
// deactivate
|
||||
HiliteCtlByID(inactiveHilite, MyWindow, CtrlStartM);
|
||||
HiliteCtlByID(inactiveHilite, MyWindow, CtrlStopQS);
|
||||
|
||||
@ -378,11 +333,9 @@ void UpdateStatus(Boolean redraw)
|
||||
HiliteCtlByID(noHilite, MyWindow, CtrlStopM);
|
||||
HiliteCtlByID(noHilite, MyWindow, CtrlStartQS);
|
||||
|
||||
SetInfoRefCon((LongWord)"\pNetwork Connected", MyWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
// activate
|
||||
SetInfoRefCon((LongWord) "\pNetwork Connected", |