diff --git a/Makefile b/Makefile index e565188..9c2d6c4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CFLAGS = -w-1 -O-1 HTTPTEST_OBJS = httptest.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a HTTPTEST_PROG = httptest -MOUNTURL_OBJS = mounturl.a +MOUNTURL_OBJS = mounturl.a netdiskerror.a MOUNTURL_PROG = mounturl NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a driver.a installdriver.a asmglue.a driverwrapper.a session.a systemservices.a diff --git a/httptest.c b/httptest.c index d96ec68..e07c72b 100644 --- a/httptest.c +++ b/httptest.c @@ -13,14 +13,6 @@ #include "tcpconnection.h" #include "readtcp.h" -/* -http://archive.org/download/a2gs_System_1.0_1986_Apple_FW/System_1.0_1986_Apple_FW.2mg -redirects to: -http://ia800505.us.archive.org/16/items/a2gs_System_1.0_1986_Apple_FW/System_1.0_1986_Apple_FW.2mg -*/ - -char *defaultURL = "http://archive.org/download/a2gs_System_1.0_1986_Apple_FW/System_1.0_1986_Apple_FW.2mg"; - char buf[512]; int main(int argc, char **argv) { @@ -37,7 +29,10 @@ int main(int argc, char **argv) { Session sess = {0}; - char *url = (argc > 1) ? argv[1] : defaultURL; + if (argc < 2) + goto exit; + + char *url = argv[1]; enum NetDiskError result = SetURL(&sess, url, TRUE, FALSE); diff --git a/mounturl.c b/mounturl.c index 0abd8ee..1e2eeca 100644 --- a/mounturl.c +++ b/mounturl.c @@ -3,21 +3,48 @@ #include #include #include "mounturl.h" +#include "netdiskerror.h" + +static void usage(void) { + fprintf(stderr, "Usage: mounturl [-c] url\n"); + exit(EXIT_FAILURE); +} + int main(int argc, char **argv) { - if (argc < 2) - return -1; - struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)}; + int i = 1; + int flags = flgUseCache; + + while (i < argc && argv[i][0] == '-') { + switch(argv[i][1]) { + case 'c': + flags &= ~flgUseCache; + break; + + default: + usage(); + } + i++; + } + + if (i >= argc) + usage(); + mountURLRec.result = NETDISK_NOT_PRESENT; - mountURLRec.url = argv[1]; - mountURLRec.flags = flgUseCache; + mountURLRec.url = argv[i]; + mountURLRec.flags = flags; SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME, (Long)&mountURLRec, NULL); if (mountURLRec.result != OPERATION_SUCCESSFUL) { - fprintf(stderr, "MountURL error %u\n", mountURLRec.result); + char *errString = ErrorString(mountURLRec.result); + if (strchr(errString, '*') == NULL) { + fprintf(stderr, "%s\n", errString); + } else { + fprintf(stderr, "NetDisk error %u.\n", mountURLRec.result); + } return 1; }