tools: add shared current directory handle helper
Add tool_current_dhandle_only() as a small wrapper for callers that only need the current NetWare directory handle. Replace the local creator_current_dhandle() and tests_current_dhandle() implementations in CREATOR and NWTESTS with the shared helper. This removes duplicate requester-current-directory code without changing behavior.
This commit is contained in:
25
creator.c
25
creator.c
@@ -90,29 +90,6 @@ static void creator_usage(void)
|
||||
fprintf(stdout, " CREATOR F:\\CIXTEST\\SUP\\S_SUP.TXT /ARCHIVE MARIO\n");
|
||||
}
|
||||
|
||||
static int creator_get_current_drive(void)
|
||||
{
|
||||
REGS regs;
|
||||
|
||||
regs.h.ah = 0x19;
|
||||
int86(0x21, ®s, ®s);
|
||||
return((int)regs.h.al);
|
||||
}
|
||||
|
||||
static int creator_current_dhandle(uint8 *dhandle)
|
||||
{
|
||||
uint8 connid = 0;
|
||||
uint8 flags = 0;
|
||||
int drive;
|
||||
|
||||
drive = creator_get_current_drive();
|
||||
if (get_drive_info((uint8)drive, &connid, dhandle, &flags))
|
||||
return(-1);
|
||||
if (!connid || (flags & 0x80))
|
||||
return(-1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int hex_value(int c)
|
||||
{
|
||||
if (c >= '0' && c <= '9') return(c - '0');
|
||||
@@ -516,7 +493,7 @@ int func_creator(int argc, char *argv[], int mode)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (creator_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "CREATOR: current drive is not a network drive\n");
|
||||
if (oldcwd[0]) chdir(oldcwd);
|
||||
return(1);
|
||||
|
||||
1
net.h
1
net.h
@@ -183,6 +183,7 @@ extern int tool_is_files_option(char *s);
|
||||
extern int tool_is_subdirs_option(char *s);
|
||||
extern int tool_get_current_drive(void);
|
||||
extern int tool_current_dhandle(uint8 *connid, uint8 *dhandle);
|
||||
extern int tool_current_dhandle_only(uint8 *dhandle);
|
||||
extern int tool_current_prefix(char *out, int max);
|
||||
extern int tool_is_current_path(char *path);
|
||||
extern void tool_upcopy(char *dst, char *src, int max);
|
||||
|
||||
55
nwtests.c
55
nwtests.c
@@ -62,31 +62,6 @@ static void tests_usage(void)
|
||||
fprintf(stdout, " TESTS NCP23MAP path (probe NCP23/F4 then F3 layouts; see server debug log)\n");
|
||||
}
|
||||
|
||||
static int tests_get_current_drive(void)
|
||||
{
|
||||
REGS regs;
|
||||
|
||||
regs.h.ah = 0x19;
|
||||
int86(0x21, ®s, ®s);
|
||||
return((int)regs.h.al);
|
||||
}
|
||||
|
||||
static int tests_current_dhandle(uint8 *dhandle)
|
||||
{
|
||||
uint8 connid = 0;
|
||||
uint8 flags = 0;
|
||||
int drive;
|
||||
|
||||
drive = tests_get_current_drive();
|
||||
if (get_drive_info((uint8)drive, &connid, dhandle, &flags))
|
||||
return(-1);
|
||||
|
||||
if (!connid || (flags & 0x80))
|
||||
return(-1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static uint8 tests_map_ncp_mask(uint16 ncp_rights)
|
||||
{
|
||||
uint8 mask = 0;
|
||||
@@ -438,7 +413,7 @@ static int tests_ncp2225miss(char *path)
|
||||
if (!path || !*path)
|
||||
path = "NO22_25.$$$";
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225MISS failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -467,7 +442,7 @@ static int tests_ncp2225attr(char *path, char *attr_arg)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225ATTR failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -983,7 +958,7 @@ static int tests_ncp221einfo(char *path)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP221EINFO failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1109,7 +1084,7 @@ static int tests_ncp2225time(char *path, char *date_arg, char *time_arg)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225TIME failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1200,7 +1175,7 @@ static int tests_ncp2225adate(char *path, char *date_arg)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225ADATE failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1296,7 +1271,7 @@ static int tests_ncp2225maxspace(char *path, char *space_arg)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225MAXSPACE failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1354,7 +1329,7 @@ static int tests_ncp2225modid(char *path, char *id_arg)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225MODID failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1447,7 +1422,7 @@ static int tests_ncp2225create(char *path, char *date_arg, char *time_arg, char
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225CREATE failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1557,7 +1532,7 @@ static int tests_ncp2225arch(char *path, char *date_arg, char *time_arg, char *i
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP2225ARCH failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1794,7 +1769,7 @@ static int tests_ncp22ren(char *src, char *dst)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP22REN failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1835,7 +1810,7 @@ static int tests_ncp22rendir(char *parent)
|
||||
if (!parent || !*parent)
|
||||
parent = ".";
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP22RENDIR failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1884,7 +1859,7 @@ static int tests_ncp22s4(char *path, char *mask_arg)
|
||||
if (!path)
|
||||
path = ".";
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP22S4 failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -1930,7 +1905,7 @@ static int tests_ncp87c32attr(void)
|
||||
uint16 handle_hi = 0;
|
||||
int rc;
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP87C32ATTR failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -2193,7 +2168,7 @@ static int tests_ncp23map(char *path)
|
||||
if (!path)
|
||||
path = ".";
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "NCP23MAP failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -2520,7 +2495,7 @@ static int tests_effright(char *path)
|
||||
if (!path)
|
||||
path = ".";
|
||||
|
||||
if (tests_current_dhandle(&dhandle)) {
|
||||
if (tool_current_dhandle_only(&dhandle)) {
|
||||
fprintf(stdout, "EFFRIGHT failed: current drive is not a network drive\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user