If the URL specifies HTTPS or FTP, offer to use HTTP instead.

This commit is contained in:
Stephen Heumann 2018-09-30 22:47:43 -05:00
parent 10cb54df5f
commit 28fd51d175
3 changed files with 40 additions and 4 deletions

View File

@ -11,7 +11,7 @@ NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.
# NETDISKINIT_RSRC = # NETDISKINIT_RSRC =
NETDISKINIT_PROG = NetDiskInit NETDISKINIT_PROG = NetDiskInit
NETDISKCDEV_OBJS = cdev.a cdevutil.a netdiskerror.a NETDISKCDEV_OBJS = cdev.a cdevutil.a netdiskerror.a strcasecmp.a
NETDISKCDEV_RSRC = cdev.rez NETDISKCDEV_RSRC = cdev.rez
NETDISKCDEV_CDEV = NetDisk NETDISKCDEV_CDEV = NetDisk

32
cdev.c
View File

@ -3,6 +3,7 @@
#include <types.h> #include <types.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <gsos.h> #include <gsos.h>
#include <orca.h> #include <orca.h>
#include <quickdraw.h> #include <quickdraw.h>
@ -14,6 +15,7 @@
#include <locator.h> #include <locator.h>
#include <tcpip.h> #include <tcpip.h>
#include "mounturl.h" #include "mounturl.h"
#include "strcasecmp.h"
#define MachineCDEV 1 #define MachineCDEV 1
#define BootCDEV 2 #define BootCDEV 2
@ -35,6 +37,8 @@
#define netDiskMissingError 3000 #define netDiskMissingError 3000
#define mountURLError 3001 #define mountURLError 3001
#define unsupportedProtocolAlert 3002
#define yesBtn 1 /* number of "Yes" button in alert */
extern void FreeAllCDevMem(void); extern void FreeAllCDevMem(void);
@ -49,15 +53,36 @@ void DoMount(void)
char numStr[6] = ""; char numStr[6] = "";
char *subs[1] = {numStr}; char *subs[1] = {numStr};
static char alertString[200]; static char alertString[200];
enum {HTTPS, FTP, OTHER_PROTOCOL} protocol = OTHER_PROTOCOL;
WaitCursor();
GetLETextByID(wPtr, urlLine, (StringPtr)&urlBuf); GetLETextByID(wPtr, urlLine, (StringPtr)&urlBuf);
if (strncasecmp(urlBuf+1, "https://", 8) == 0) {
protocol = HTTPS;
subs[0] = "HTTPS";
strncpy(urlBuf+2, "http", 4);
mountURLRec.url = urlBuf + 2;
} else if (strncasecmp(urlBuf+1, "ftp://", 6) == 0) {
protocol = FTP;
subs[0] = "FTP";
strncpy(urlBuf, "http", 4);
mountURLRec.url = urlBuf;
} else {
protocol = OTHER_PROTOCOL;
mountURLRec.url = urlBuf + 1;
}
if (protocol == HTTPS || protocol == FTP) {
if (AlertWindow(awResource+awCString+awButtonLayout,
(Pointer)subs, unsupportedProtocolAlert) != yesBtn) {
return;
}
}
WaitCursor();
TCPIPConnect(NULL); TCPIPConnect(NULL);
mountURLRec.result = NETDISK_NOT_PRESENT; mountURLRec.result = NETDISK_NOT_PRESENT;
mountURLRec.url = urlBuf + 1;
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME, SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
(Long)&mountURLRec, NULL); (Long)&mountURLRec, NULL);
@ -68,6 +93,7 @@ void DoMount(void)
snprintf(numStr, sizeof(numStr), "%u", mountURLRec.result); snprintf(numStr, sizeof(numStr), "%u", mountURLRec.result);
snprintf(alertString, sizeof(alertString), "42~%.175s~^#0\0", snprintf(alertString, sizeof(alertString), "42~%.175s~^#0\0",
ErrorString(mountURLRec.result)); ErrorString(mountURLRec.result));
subs[0] = numStr;
AlertWindow(awPointer+awCString+awButtonLayout, (Pointer)subs, AlertWindow(awPointer+awCString+awButtonLayout, (Pointer)subs,
(Ref)alertString); (Ref)alertString);

View File

@ -262,6 +262,7 @@ resource rTextForLETextBox2 (helpWindow+helpTxt) {
#define netDiskMissingError 3000 #define netDiskMissingError 3000
#define mountURLError 3001 #define mountURLError 3001
#define unsupportedProtocolAlert 3002
resource rAlertString (netDiskMissingError) { resource rAlertString (netDiskMissingError) {
"62/" "62/"
@ -275,3 +276,12 @@ resource rAlertString (mountURLError) {
"MountURL error *0." "MountURL error *0."
":^#0\$00" ":^#0\$00"
}; };
resource rAlertString (unsupportedProtocolAlert) {
"64:"
"NetDisk does not support the *0 protocol. Do you want to try "
"connecting using unencrypted HTTP instead? (The server may "
"or may not support this.)"
":#3:^#2\$00"
};