pathins fix

This commit is contained in:
Mario Fetka
2026-05-22 18:12:51 +02:00
parent 3d2e7913ad
commit 0ca6a3baaf

102
map.c
View File

@@ -297,19 +297,109 @@ static int set_search(uint8 *drvstr, NWPATH *nwp, int pathmode)
return(result);
}
static int path_slot_from_string(uint8 *s)
{
if ((*s == 'S' || *s == 's') && isdigit(s[1])) {
int n = atoi((char*)s + 1);
if (n > 0 && n < 32) return(n - 1);
}
return(-1);
}
static int path_drive_from_nwpath(NWPATH *nwp, uint8 *drvout)
{
int j;
char wanted[256];
strmaxcpy(wanted, nwp->path, sizeof(wanted) - 1);
korrpath(wanted);
upstr(wanted);
for (j = 0; j < 32; j++) {
uint8 connid = 0;
uint8 dhandle = 0;
uint8 flags = 0;
char path[256];
if (get_drive_info(j, &connid, &dhandle, &flags)) continue;
if (!flags || (flags & 0x80) || !connid) continue;
if (get_dir_path(dhandle, path)) continue;
korrpath(path);
upstr(path);
if (!strcmp(path, wanted)) {
drvout[0] = (uint8)('A' + j);
drvout[1] = ':';
drvout[2] = '\0';
return(0);
}
}
return(-1);
}
static int do_search_path_native(int slot, NWPATH *nwp, int mode)
{
uint8 dhandle = 0;
uint8 drive[3];
if (slot < 0 || slot >= 32) return(-1);
if (mode == 1) {
return(del_search_drive(slot));
}
/*
* Common login script syntax:
* MAP INS S1:=SYS:PUBLIC
* PATHINS should understand that natively, not LOGIN.
*/
if (!path_drive_from_nwpath(nwp, drive)) {
return(set_search_drive(slot, drive[0]));
}
if (!alloc_permanent_dir_handle(0, nwp->path, 0, &dhandle)) {
return(set_search_drive(slot, dhandle));
}
return(-1);
}
int func_path(int argc, char *argv[], int mode)
{
uint8 drvstr[22];
uint8 drvstr[300];
NWPATH nwpath;
if (!ipx_init()) argc = 1;
if (argc < 2) {
show_map(NULL);
return(0);
}
if (!parse_argv(drvstr, &nwpath, argc, argv, 1, mode)) {
int result=0;
if (*(nwpath.path) || mode==1)
result=set_search(drvstr, &nwpath, mode);
int slot = path_slot_from_string(drvstr);
if (slot < 0) {
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
return(0);
}
if (*(nwpath.path) || mode == 1) {
if (do_search_path_native(slot, &nwpath, mode) < 0)
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
}
if (mode != 1)
show_search(drvstr);
return(result);
return(0);
}
return(1);
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
return(0);
}
void remove_nwpathes(void)