map via redir
This commit is contained in:
49
map.c
49
map.c
@@ -80,19 +80,41 @@ static void do_map(int drive, NWPATH *nwp)
|
||||
static int do_map(int drive, NWPATH *nwp, int delete)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
if (drive > -1 && drive < 32) {
|
||||
uint8 connid;
|
||||
uint8 dhandle;
|
||||
uint8 flags;
|
||||
if (!delete ||
|
||||
(!get_drive_info(drive, &connid, &dhandle, &flags) && flags && connid)){
|
||||
uint8 nmdrive[3];
|
||||
nmdrive[0] = drive+'A';
|
||||
nmdrive[1] = ':';
|
||||
nmdrive[2] = '\0';
|
||||
result = redir_device_drive(delete ? -1 : 0x4, nmdrive, nwp->path);
|
||||
uint8 connid = 0;
|
||||
uint8 dhandle = 0;
|
||||
uint8 flags = 0;
|
||||
|
||||
if (delete) {
|
||||
if (!get_drive_info(drive, &connid, &dhandle, &flags)
|
||||
&& flags && !(flags & 0x80) && connid) {
|
||||
result = dealloc_dir_handle(dhandle);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* The old mars-dosutils MAP used DOS redirector INT 21h AX=5F03h.
|
||||
* NetWare Client32 returns AX=0001 for that call, while Novell MAP
|
||||
* works. Use the NetWare shell/NCP "Allocate Permanent Directory
|
||||
* Handle" path instead; this is what the surrounding code already
|
||||
* provides via alloc_permanent_dir_handle().
|
||||
*/
|
||||
if (!get_drive_info(drive, &connid, &dhandle, &flags)
|
||||
&& flags && !(flags & 0x80) && connid) {
|
||||
(void)dealloc_dir_handle(dhandle);
|
||||
}
|
||||
|
||||
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'A', NULL);
|
||||
|
||||
/*
|
||||
* Some requesters historically accepted lowercase drive letters in
|
||||
* this call. Keep this only as compatibility fallback.
|
||||
*/
|
||||
if (result < 0)
|
||||
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'a', NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -173,11 +195,8 @@ int func_map(int argc, char *argv[], int mode)
|
||||
if (!ipx_init()) argc = 1;
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
||||
if (*(nwpath.path) || mode==1) {
|
||||
{
|
||||
int rc = do_map(*drvstr - 'A', &nwpath, mode);
|
||||
if (rc < 0)
|
||||
fprintf(stderr, "MAP Error rc=%d\n", rc);
|
||||
}
|
||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||
fprintf(stderr, "MAP Error\n");
|
||||
}
|
||||
if (mode != 1)
|
||||
show_map(drvstr);
|
||||
|
||||
Reference in New Issue
Block a user