mirror of
https://github.com/sheumann/DiskBrowser.git
synced 2024-11-21 22:31:13 +00:00
Check for presence of NetDisk and Marinetti, and bail out if they're missing.
This commit is contained in:
parent
b3b9eea27e
commit
8c7ef2e331
@ -14,6 +14,8 @@
|
|||||||
#include <gsos.h>
|
#include <gsos.h>
|
||||||
#include <orca.h>
|
#include <orca.h>
|
||||||
#include <finder.h>
|
#include <finder.h>
|
||||||
|
#include <tcpip.h>
|
||||||
|
#include "mounturl.h"
|
||||||
|
|
||||||
static char menuTitle[] = "\pArchive.org Disk Browser\xC9";
|
static char menuTitle[] = "\pArchive.org Disk Browser\xC9";
|
||||||
static char windowTitle[] = "\p Archive.org Disk Browser ";
|
static char windowTitle[] = "\p Archive.org Disk Browser ";
|
||||||
@ -59,6 +61,8 @@ struct diskListEntry {
|
|||||||
|
|
||||||
struct diskListEntry diskList[DISK_LIST_LENGTH];
|
struct diskListEntry diskList[DISK_LIST_LENGTH];
|
||||||
|
|
||||||
|
static struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)};
|
||||||
|
|
||||||
/* Record about our system window, to support processing by Desk Manager. */
|
/* Record about our system window, to support processing by Desk Manager. */
|
||||||
/* See Prog. Ref. for System 6.0, page 20. */
|
/* See Prog. Ref. for System 6.0, page 20. */
|
||||||
static NDASysWindRecord sysWindRecord;
|
static NDASysWindRecord sysWindRecord;
|
||||||
@ -365,6 +369,21 @@ static pascal Word requestProc(Word reqCode, Long dataIn, void *dataOut) {
|
|||||||
#pragma toolparms 0
|
#pragma toolparms 0
|
||||||
#pragma databank 0
|
#pragma databank 0
|
||||||
|
|
||||||
|
boolean NetDiskPresent(void)
|
||||||
|
{
|
||||||
|
mountURLRec.result = NETDISK_NOT_PRESENT;
|
||||||
|
mountURLRec.url = "";
|
||||||
|
mountURLRec.flags = flgUseCache;
|
||||||
|
|
||||||
|
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
||||||
|
(Long)&mountURLRec, NULL);
|
||||||
|
|
||||||
|
if (mountURLRec.result == NETDISK_NOT_PRESENT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
myUserID = MMStartUp(); //userid() & 0xF0FF;
|
myUserID = MMStartUp(); //userid() & 0xF0FF;
|
||||||
@ -373,5 +392,10 @@ int main(void) {
|
|||||||
ResourceStartUp(myUserID);
|
ResourceStartUp(myUserID);
|
||||||
SetCurResourceApp(origResourceApp);
|
SetCurResourceApp(origResourceApp);
|
||||||
|
|
||||||
|
/* Bail out if NetDisk or Marinetti is not present */
|
||||||
|
if (!NetDiskPresent() || !TCPIPStatus() || toolerror()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
AcceptRequests(diskbrowserRequestName, myUserID, &requestProc);
|
AcceptRequests(diskbrowserRequestName, myUserID, &requestProc);
|
||||||
}
|
}
|
||||||
|
31
mounturl.h
Normal file
31
mounturl.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef MOUNTURL_H
|
||||||
|
#define MOUNTURL_H
|
||||||
|
|
||||||
|
#include "netdiskerror.h"
|
||||||
|
|
||||||
|
/* Custom DControl code and request code for MountURL operation */
|
||||||
|
#define MountURL 0x8080
|
||||||
|
|
||||||
|
#define NETDISK_REQUEST_NAME "\pSTH~NetDisk~"
|
||||||
|
|
||||||
|
/* Bits in flags */
|
||||||
|
#define flgUseCache 0x0001
|
||||||
|
|
||||||
|
enum DiskImageFormat {
|
||||||
|
formatAutoDetect = 0,
|
||||||
|
format2mg,
|
||||||
|
formatRaw,
|
||||||
|
formatDOSOrder,
|
||||||
|
formatDiskCopy42
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MountURLRec {
|
||||||
|
Word byteCount;
|
||||||
|
enum NetDiskError result; /* output value */
|
||||||
|
char *url; /* C-string; will be modified */
|
||||||
|
Word flags;
|
||||||
|
enum DiskImageFormat format; /* input/output value */
|
||||||
|
Word devNum; /* output value: device number */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
53
netdiskerror.h
Normal file
53
netdiskerror.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef NETDISKERROR_H
|
||||||
|
#define NETDISKERROR_H
|
||||||
|
|
||||||
|
enum NetDiskError {
|
||||||
|
OPERATION_SUCCESSFUL = 0,
|
||||||
|
|
||||||
|
NETDISK_NOT_PRESENT = 100,
|
||||||
|
DISK_ALREADY_MOUNTED,
|
||||||
|
NO_DIBS_AVAILABLE,
|
||||||
|
OUT_OF_MEMORY,
|
||||||
|
|
||||||
|
/* SetURL errors */
|
||||||
|
URL_TOO_LONG = 200,
|
||||||
|
INVALID_CHARACTER_IN_URL,
|
||||||
|
BAD_URL_SYNTAX,
|
||||||
|
UNSUPPORTED_URL_SCHEME,
|
||||||
|
AUTHENTICATION_NOT_SUPPORTED,
|
||||||
|
FRAGMENT_NOT_SUPPORTED,
|
||||||
|
INVALID_PORT_NUMBER,
|
||||||
|
NO_HOST_SPECIFIED,
|
||||||
|
IPV6_NOT_SUPPORTED,
|
||||||
|
HOSTNAME_TOO_LONG,
|
||||||
|
NAME_LOOKUP_FAILED,
|
||||||
|
|
||||||
|
/* StartTCPConnection and DoHTTPRequest errors */
|
||||||
|
NETWORK_ERROR = 300,
|
||||||
|
NO_RESPONSE,
|
||||||
|
INVALID_RESPONSE,
|
||||||
|
EXCESSIVE_REDIRECTS,
|
||||||
|
UNSUPPORTED_RESPONSE,
|
||||||
|
UNSUPPORTED_HEADER_VALUE,
|
||||||
|
REDIRECT_ERROR,
|
||||||
|
NOT_DESIRED_CONTENT,
|
||||||
|
DIFFERENT_LENGTH,
|
||||||
|
|
||||||
|
/* Error values of 4xx and 5xx mean we got the corresponding HTTP error */
|
||||||
|
HTTP_ERROR = 400,
|
||||||
|
|
||||||
|
/* File format errors */
|
||||||
|
UNSUPPORTED_2IMG_FILE = 600,
|
||||||
|
NOT_MULTIPLE_OF_BLOCK_SIZE,
|
||||||
|
NOT_SPECIFIED_IMAGE_TYPE
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a string describing the error. It may contain the substitution
|
||||||
|
* string "*0", which should be replaced by the error number.
|
||||||
|
*/
|
||||||
|
char *ErrorString(enum NetDiskError err);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user