dosutils: add creator and supporting NCP helpers
Add the CREATOR utility and wire it into the DOS tools build and NET command dispatch. Extend the client-side NCP helpers with the calls needed by the new and updated tools, including DOS namespace information and effective-rights queries. Also update MAP handling for automatic drive mappings used by the login script. This commit contains the tool/source support only. The DOS baseline test suite is kept separate and will be added in a follow-up commit.
This commit is contained in:
90
map.c
90
map.c
@@ -228,6 +228,86 @@ static void map_drive_name(char *dst, char *src)
|
||||
dst[2] = '\0';
|
||||
}
|
||||
|
||||
static int map_find_free_drive(int ordinal)
|
||||
{
|
||||
int drive;
|
||||
|
||||
if (ordinal < 1) ordinal = 1;
|
||||
|
||||
for (drive = 2; drive < 26; drive++) {
|
||||
uint8 connid = 0;
|
||||
uint8 dhandle = 0;
|
||||
uint8 flags = 0;
|
||||
|
||||
if (!get_drive_info((uint8)drive, &connid, &dhandle, &flags)) {
|
||||
if (flags) continue;
|
||||
}
|
||||
|
||||
if (--ordinal == 0) return(drive);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
static int parse_auto_map_arg(uint8 *drvstr, NWPATH *nwp, int argc, char *argv[])
|
||||
{
|
||||
char joined[512];
|
||||
char *p;
|
||||
char *q;
|
||||
int ordinal = 0;
|
||||
int drive;
|
||||
int k;
|
||||
|
||||
*drvstr = '\0';
|
||||
memset(nwp, 0, sizeof(NWPATH));
|
||||
nwp->path = nwp->buff;
|
||||
*(nwp->buff) = '\0';
|
||||
|
||||
if (argc < 2) return(1);
|
||||
|
||||
joined[0] = '\0';
|
||||
for (k = 1; k < argc; k++) {
|
||||
if (k > 1) strcat(joined, " ");
|
||||
strncat(joined, argv[k], sizeof(joined) - strlen(joined) - 1);
|
||||
}
|
||||
|
||||
p = joined;
|
||||
while (*p == ' ' || *p == '\t') p++;
|
||||
if (*p != '*') return(1);
|
||||
p++;
|
||||
|
||||
while (*p >= '0' && *p <= '9') {
|
||||
ordinal = ordinal * 10 + (*p - '0');
|
||||
p++;
|
||||
}
|
||||
|
||||
if (ordinal < 1) ordinal = 1;
|
||||
if (*p != ':') return(-1);
|
||||
p++;
|
||||
|
||||
while (*p == ' ' || *p == '\t') p++;
|
||||
if (*p != '=') return(-1);
|
||||
p++;
|
||||
while (*p == ' ' || *p == '\t') p++;
|
||||
if (!*p) return(-1);
|
||||
|
||||
drive = map_find_free_drive(ordinal);
|
||||
if (drive < 0) return(-1);
|
||||
|
||||
drvstr[0] = (uint8)(drive + 'A');
|
||||
drvstr[1] = '\0';
|
||||
|
||||
q = nwp->buff;
|
||||
while (*p && (q - nwp->buff) < (int)sizeof(nwp->buff) - 1) {
|
||||
if (*p >= 'a' && *p <= 'z') *q++ = *p++ - 0x20;
|
||||
else *q++ = *p++;
|
||||
}
|
||||
*q = '\0';
|
||||
nwp->path = nwp->buff;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int map_handle_path_command(int argc, char *argv[], int pathmode)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
@@ -311,6 +391,16 @@ int func_map(int argc, char *argv[], int mode)
|
||||
}
|
||||
}
|
||||
|
||||
if (!parse_auto_map_arg(drvstr, &nwpath, argc, argv)) {
|
||||
if (*(nwpath.path)) {
|
||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||
fprintf(stderr, "MAP Error\n");
|
||||
}
|
||||
if (mode != 1)
|
||||
show_map(drvstr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
||||
if (*(nwpath.path) || mode==1) {
|
||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||
|
||||
Reference in New Issue
Block a user