mirror of
https://github.com/sheumann/NetDisk.git
synced 2025-01-17 09:29:58 +00:00
Enhance mounturl command-line utility.
It now accepts a flag "-c" to disable caching, and can also print meaningful error messages.
This commit is contained in:
parent
1ce645ec0d
commit
92649e33ee
2
Makefile
2
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_OBJS = httptest.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a
|
||||||
HTTPTEST_PROG = httptest
|
HTTPTEST_PROG = httptest
|
||||||
|
|
||||||
MOUNTURL_OBJS = mounturl.a
|
MOUNTURL_OBJS = mounturl.a netdiskerror.a
|
||||||
MOUNTURL_PROG = mounturl
|
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
|
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
|
||||||
|
13
httptest.c
13
httptest.c
@ -13,14 +13,6 @@
|
|||||||
#include "tcpconnection.h"
|
#include "tcpconnection.h"
|
||||||
#include "readtcp.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];
|
char buf[512];
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@ -37,7 +29,10 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
Session sess = {0};
|
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);
|
enum NetDiskError result = SetURL(&sess, url, TRUE, FALSE);
|
||||||
|
|
||||||
|
39
mounturl.c
39
mounturl.c
@ -3,21 +3,48 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <locator.h>
|
#include <locator.h>
|
||||||
#include "mounturl.h"
|
#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) {
|
int main(int argc, char **argv) {
|
||||||
if (argc < 2)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
struct MountURLRec mountURLRec = {sizeof(struct MountURLRec)};
|
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.result = NETDISK_NOT_PRESENT;
|
||||||
mountURLRec.url = argv[1];
|
mountURLRec.url = argv[i];
|
||||||
mountURLRec.flags = flgUseCache;
|
mountURLRec.flags = flags;
|
||||||
|
|
||||||
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
SendRequest(MountURL, sendToName|stopAfterOne, (Long)NETDISK_REQUEST_NAME,
|
||||||
(Long)&mountURLRec, NULL);
|
(Long)&mountURLRec, NULL);
|
||||||
|
|
||||||
if (mountURLRec.result != OPERATION_SUCCESSFUL) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user