Rename Or Move (old) 0x2222 22 46
All checks were successful
Source release / source-package (push) Successful in 36s
All checks were successful
Source release / source-package (push) Successful in 36s
This commit is contained in:
85
src/nwconn.c
85
src/nwconn.c
@@ -117,6 +117,41 @@ static void ncp23_debug_dump(char *what, uint8 *data, int len)
|
||||
what, len, n, hex, asc));
|
||||
}
|
||||
|
||||
static int ncp22_component_path_to_dos(uint8 *src, int count,
|
||||
uint8 *dst, int maxlen,
|
||||
int *used_out)
|
||||
{
|
||||
int used = 0;
|
||||
int out = 0;
|
||||
int i;
|
||||
|
||||
if (used_out)
|
||||
*used_out = 0;
|
||||
|
||||
if (!dst || maxlen < 1 || count < 0)
|
||||
return(-0x9c);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int len = (int)src[used++];
|
||||
|
||||
if (len < 0 || len > 255)
|
||||
return(-0x9c);
|
||||
if (out + len + ((i > 0) ? 1 : 0) >= maxlen)
|
||||
return(-0x9c);
|
||||
|
||||
if (i > 0)
|
||||
dst[out++] = '\\';
|
||||
memcpy(dst + out, src + used, len);
|
||||
out += len;
|
||||
used += len;
|
||||
}
|
||||
|
||||
dst[out] = '\0';
|
||||
if (used_out)
|
||||
*used_out = used;
|
||||
return(out);
|
||||
}
|
||||
|
||||
#if !CALL_NWCONN_OVER_SOCKET
|
||||
static char* nwconn_state; /* shared memory segment will be
|
||||
* attached to this pointer */
|
||||
@@ -1278,8 +1313,54 @@ static int handle_ncp_serv(void)
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x2e : { /* rename file */
|
||||
completition = 0xfb; /* TODO: !!! */
|
||||
case 0x2e : { /* Rename or Move (old) */
|
||||
/*
|
||||
* NCP 22 / subfunction 46 (0x2e): Rename Or Move (old)
|
||||
*
|
||||
* Request:
|
||||
* byte source directory handle
|
||||
* byte search attributes
|
||||
* byte source path component count
|
||||
* source path components: byte len + bytes, repeated
|
||||
* byte destination directory handle
|
||||
* byte destination path component count
|
||||
* destination path components: byte len + bytes, repeated
|
||||
*
|
||||
* No reply data. This old call uses component-counted
|
||||
* paths, unlike the plain length-prefixed NCP 69 rename.
|
||||
*/
|
||||
uint8 srcpath[256];
|
||||
uint8 dstpath[256];
|
||||
int src_handle = (int)*(p+1);
|
||||
int searchattr = (int)*(p+2);
|
||||
int src_count = (int)*(p+3);
|
||||
int used = 0;
|
||||
int srclen;
|
||||
int dstlen;
|
||||
int result;
|
||||
uint8 *q;
|
||||
|
||||
srclen = ncp22_component_path_to_dos(p+4, src_count,
|
||||
srcpath, sizeof(srcpath),
|
||||
&used);
|
||||
if (srclen < 0) {
|
||||
completition = (uint8)(-srclen);
|
||||
break;
|
||||
}
|
||||
|
||||
q = p + 4 + used;
|
||||
dstlen = ncp22_component_path_to_dos(q+2, (int)*(q+1),
|
||||
dstpath, sizeof(dstpath),
|
||||
NULL);
|
||||
if (dstlen < 0) {
|
||||
completition = (uint8)(-dstlen);
|
||||
break;
|
||||
}
|
||||
|
||||
result = nw_mv_files(searchattr,
|
||||
src_handle, srcpath, srclen,
|
||||
(int)*q, dstpath, dstlen);
|
||||
if (result < 0) completition = (uint8)(-result);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user