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:
27
flagdir.c
27
flagdir.c
@@ -56,29 +56,6 @@
|
||||
|
||||
|
||||
|
||||
static int fd_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);
|
||||
}
|
||||
|
||||
static int fd_ncp22_1e_obtain_attrs(char *name, uint32 *attrs)
|
||||
{
|
||||
struct {
|
||||
@@ -104,7 +81,7 @@ static int fd_ncp22_1e_obtain_attrs(char *name, uint32 *attrs)
|
||||
memset(&req, 0, sizeof(req));
|
||||
memset(&repl, 0, sizeof(repl));
|
||||
|
||||
if (fd_copy_ncp22_name(req.name, name, &namlen))
|
||||
if (tool_copy_ncp22_name(req.name, name, &namlen))
|
||||
return(-1);
|
||||
|
||||
req.func = 0x1e; /* Scan directory */
|
||||
@@ -163,7 +140,7 @@ static int fd_ncp22_25_modify_attrs(char *name, uint32 attrs)
|
||||
U32_TO_32(FD_DM_ATTRIBUTES, req.change_bits);
|
||||
tool_put_dword_lh(req.attributes, attrs);
|
||||
|
||||
if (fd_copy_ncp22_name(req.name, name, &req.namlen))
|
||||
if (tool_copy_ncp22_name(req.name, name, &req.namlen))
|
||||
return(-1);
|
||||
|
||||
req.len = sizeof(req) - sizeof(req.len);
|
||||
|
||||
Reference in New Issue
Block a user