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:
Mario Fetka
2026-05-29 09:38:08 +02:00
parent 5fa36cc6f4
commit b3cec8eecf
4 changed files with 24 additions and 64 deletions

View File

@@ -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, &regs, &regs);
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);