AFPBridge/installcmds.c
Stephen Heumann 78a300f799 Add an option to tell the server that the GS is going to sleep after each command sent.
This tells the server to keep the session alive (typically for at least several hours) without sending or expecting tickles. This is useful in cases where our run queue procedure is not run regularly or at all, e.g. in text-mode shells.

The implementation here is geared toward compatibility with Netatalk and differs from Apple's published standards in a couple ways. It may or may not work with other servers.
2017-04-21 21:09:57 -05:00

51 lines
1.4 KiB
C

#pragma noroot
#include <types.h>
#include <AppleTalk.h>
#include "asmglue.h"
#include "cmdproc.h"
#include "installcmds.h"
typedef struct NewCmd {
Word cmdNum;
void (*cmdAddr)(void);
LongWord *jslOldCmdLocation;
} NewCmd;
NewCmd newCmds[] = {
{aspGetStatusCommand, cmdProc, NULL},
{aspOpenSessionCommand, cmdProc, NULL},
{aspCloseSessionCommand, cmdProc, NULL},
{aspCommandCommand, cmdProc, NULL},
{aspWriteCommand, cmdProc, NULL},
{nbpLookupNameCommand, nbpCmdProc, NULL},
{pfiLoginCommand, pfiLoginCmdProc, &jslOldPFILogin},
{pfiLogin2Command, pfiLogin2CmdProc, &jslOldPFILogin2},
{pfiLoginContCommand, pfiLoginContCmdProc, &jslOldPFILoginCont},
{pfiListSessions2Command, pfiListSessions2CmdProc, &jslOldPFIListSessions2},
{0, 0, 0}
};
LongWord *cmdTable = (LongWord *)0xE1D600;
LongWord oldCmds[MAX_CMD + 1]; /* holds old entries for commands we changed */
#define JSL 0x22
void installCmds(void) {
Word savedStateReg;
NewCmd *cmd;
savedStateReg = ForceLCBank2();
for (cmd = newCmds; cmd->cmdNum != 0; cmd++) {
oldCmds[cmd->cmdNum] = cmdTable[cmd->cmdNum];
cmdTable[cmd->cmdNum] =
(oldCmds[cmd->cmdNum] & 0xFF000000) | (LongWord)cmd->cmdAddr;
if (cmd->jslOldCmdLocation != NULL)
*cmd->jslOldCmdLocation = JSL | (oldCmds[cmd->cmdNum] << 8);
}
RestoreStateReg(savedStateReg);
}