Add flag controlling whether to use cache.

This commit is contained in:
Stephen Heumann 2018-10-01 22:42:33 -05:00
parent 55b199f83b
commit 1ce645ec0d
5 changed files with 33 additions and 4 deletions

14
cdev.c
View File

@ -34,6 +34,7 @@
#define mountBtn 1
//#define optionsPopUp 6
//#define trianglePic 7
#define useCacheChk 8
#define netDiskMissingError 3000
#define mountURLError 3001
@ -46,6 +47,8 @@ char urlBuf[257];
WindowPtr wPtr = NULL;
Boolean useCache;
struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)};
void DoMount(void)
@ -83,6 +86,11 @@ void DoMount(void)
TCPIPConnect(NULL);
mountURLRec.result = NETDISK_NOT_PRESENT;
mountURLRec.flags = 0;
if (useCache) {
mountURLRec.flags |= flgUseCache;
}
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
(Long)&mountURLRec, NULL);
@ -108,14 +116,13 @@ void DoMount(void)
void DoHit(long ctlID, CtlRecHndl ctlHandle)
{
CtlRecHndl oldMenuBar;
Word menuItem;
if (!wPtr) /* shouldn't happen */
return;
if (ctlID == mountBtn) {
DoMount();
} else if (ctlID == useCacheChk) {
useCache = !useCache;
}
return;
@ -179,6 +186,7 @@ void DoCreate(WindowPtr windPtr)
wPtr = windPtr;
mode = (GetMasterSCB() & scbColorMode) ? 640 : 320;
NewControl2(wPtr, resourceToResource, mode);
useCache = TRUE;
}
LongWord cdevMain (LongWord data2, LongWord data1, Word message)

View File

@ -87,6 +87,7 @@ resource rIcon (1) {
#define mountBtn 1
//#define optionsPopUp 6
//#define trianglePic 7
#define useCacheChk 8
#define helpTxt 5
@ -98,6 +99,7 @@ resource rControlList (640) {
{
cdevWindow+imageURLTxt,
cdevWindow+urlLine,
cdevWindow+useCacheChk,
cdevWindow+mountBtn,
//cdevWindow+trianglePic,
//cdevWindow+optionsPopUp
@ -108,6 +110,7 @@ resource rControlList (320) {
{
cdevWindow+imageURLTxt,
cdevWindow+urlLine,
cdevWindow+useCacheChk,
cdevWindow+mountBtn,
//cdevWindow+trianglePic+320,
//cdevWindow+optionsPopUp+320
@ -158,6 +161,19 @@ resource rControlTemplate (cdevWindow+mountBtn) {
resource rPString(cdevWindow+mountBtn) { "Mount Disk Image" };
resource rControlTemplate (cdevWindow+useCacheChk) {
useCacheChk,
{37,10,0,0},
CheckControl {{
$0000,
$1002,
0,
cdevWindow+useCacheChk, /* Title ref */
1 /* initial value */
}};
};
resource rPString (cdevWindow+useCacheChk) {"Use Disk Cache"};
#if 0
/* Options menu pop-up -- separate versions for 640 mode and 320 mode */
resource rControlTemplate (cdevWindow+optionsPopUp) {

View File

@ -251,7 +251,7 @@ static Word DoMountURL(struct GSOSDP *dp) {
mountURLRec->result = OUT_OF_MEMORY;
return drvrNoResrc;
}
sess->useCache = TRUE;
sess->useCache = (mountURLRec->flags & flgUseCache);
err = SetURL(sess, mountURLRec->url, TRUE, FALSE);
if (err != OPERATION_SUCCESSFUL) {

View File

@ -11,6 +11,7 @@ int main(int argc, char **argv) {
struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)};
mountURLRec.result = NETDISK_NOT_PRESENT;
mountURLRec.url = argv[1];
mountURLRec.flags = flgUseCache;
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
(Long)&mountURLRec, NULL);

View File

@ -8,10 +8,14 @@
#define NETDISK_REQUEST_NAME "\pSTH~NetDisk~"
/* Bits in flags */
#define flgUseCache 0x0001
struct MountURLRec {
Word byteCount;
enum NetDiskError result; /* output value */
char *url; /* C-string; will be modified */
Word flags;
Word devNum; /* output value: device number */
};