tools: add shared NCP22 name helper
Move the common NCP22 DOS name buffer helper into tools.c and declare it in net.h. Replace the local copy/uppercase implementations in CREATOR, FLAG, FLAGDIR, NDIR and NWTESTS with tool_copy_ncp22_name(). The helper keeps the existing behavior: uppercase conversion, path separator rejection and the 1..12 byte DOS name length limit. NCOPY is intentionally left untouched while its NCP copy path remains under investigation.
This commit is contained in:
31
tools.c
31
tools.c
@@ -127,6 +127,37 @@ uint32 tool_get_dword_hl(uint8 *p)
|
||||
(uint32)p[3]);
|
||||
}
|
||||
|
||||
/*
|
||||
* tool_copy_ncp22_name
|
||||
*
|
||||
* Purpose:
|
||||
* Converts one DOS filename component into the uppercase NCP22 name format.
|
||||
* The helper rejects paths and keeps the historical 12-byte DOS namespace
|
||||
* component limit used by the old directory-entry NCPs.
|
||||
*/
|
||||
int tool_copy_ncp22_name(uint8 *dst, char *src, uint8 *len_out)
|
||||
{
|
||||
char tmp[260];
|
||||
int len;
|
||||
|
||||
if (!dst || !len_out)
|
||||
return(-1);
|
||||
if (!src)
|
||||
src = "";
|
||||
|
||||
tool_upcopy(tmp, src, sizeof(tmp));
|
||||
if (strchr(tmp, '\\') || strchr(tmp, '/') || strchr(tmp, ':'))
|
||||
return(-1);
|
||||
|
||||
len = strlen(tmp);
|
||||
if (len < 1 || len > 12)
|
||||
return(-1);
|
||||
|
||||
memcpy(dst, tmp, len);
|
||||
*len_out = (uint8)len;
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/*
|
||||
* Borland C compatibility wrappers used by the historical mars-nwe DOS tools.
|
||||
|
||||
Reference in New Issue
Block a user