ncpcalls: use descriptive names for NCP wrapper functions

Rename the low-level NCP wrapper functions in ncpcall.c and net.h to include
both the NCP function/subfunction number and the operation they perform.

This keeps the numeric protocol reference visible for comparison with SDK
documentation and MARS-NWE logs, while making call sites easier to understand.
Update all callers to use the new names.

No behavior change.
This commit is contained in:
Mario Fetka
2026-05-29 09:55:33 +02:00
parent 19afe23651
commit 53e28c6bfe
12 changed files with 54 additions and 54 deletions

View File

@@ -132,10 +132,10 @@ static uint32 lookup_object_id(char *name)
strmaxcpy(namebuf, name, sizeof(namebuf) - 1);
upstr(namebuf);
id = ncp_17_35(namebuf, BINDERY_USER);
id = ncp17_35_get_bindery_object_id(namebuf, BINDERY_USER);
if (id)
return(id);
id = ncp_17_35(namebuf, BINDERY_GROUP);
id = ncp17_35_get_bindery_object_id(namebuf, BINDERY_GROUP);
return(id);
}

View File

@@ -416,7 +416,7 @@ int func_grant(int argc, char *argv[], int mode)
strmaxcpy(namebuf, objname, sizeof(namebuf) - 1);
upstr(namebuf);
object_id = ncp_17_35(namebuf, objtype);
object_id = ncp17_35_get_bindery_object_id(namebuf, objtype);
if (!object_id) {
char header[300];

22
login.c
View File

@@ -631,8 +631,8 @@ static int do_change_object_passwd(char *name,
{
uint8 key[8];
if (!ncp_17_17(key)) {
uint32 objid = ncp_17_35(name, objtyp);
if (!ncp17_17_get_encryption_key(key)) {
uint32 objid = ncp17_35_get_bindery_object_id(name, objtyp);
if (objid) {
uint8 oldpwd[16]; /* old passwd as stored by server */
uint8 newpwd[16]; /* new passwd as stored by server */
@@ -663,7 +663,7 @@ static int do_change_object_passwd(char *name,
if (newlen > 63) newlen = 63;
passwdx = (uint8)(((newlen ^ oldpwd[0] ^ oldpwd[1]) & 0x7f) | 0x40);
if (!ncp_17_4b(cryptkey, name, objtyp, passwdx, newpwd)) {
if (!ncp17_4b_keyed_change_password(cryptkey, name, objtyp, passwdx, newpwd)) {
;;
return(0);
}
@@ -674,7 +674,7 @@ static int do_change_object_passwd(char *name,
* Fallback for old servers/requesters where Get Encryption Key is not
* available. Keep the original unencrypted behavior as fallback only.
*/
if (!ncp_17_40(name, objtyp, oldpassword, newpassword)) {
if (!ncp17_40_change_password_unencrypted(name, objtyp, oldpassword, newpassword)) {
;;
return(0);
}
@@ -685,8 +685,8 @@ static int do_change_object_passwd(char *name,
static int do_object_login(char *name, uint16 objtyp, char *password, int option)
{
uint8 key[8];
if (!(option & 1) && !ncp_17_17(key)) {
uint32 objid = ncp_17_35(name, objtyp);
if (!(option & 1) && !ncp17_17_get_encryption_key(key)) {
uint32 objid = ncp17_35_get_bindery_object_id(name, objtyp);
if (objid) {
uint8 buff[128];
uint8 encrypted[8];
@@ -694,13 +694,13 @@ static int do_object_login(char *name, uint16 objtyp, char *password, int option
U32_TO_BE32(objid, tmpid);
shuffle(tmpid, password, strlen(password), buff);
nw_encrypt(key, buff, encrypted);
if (!ncp_17_18(encrypted, name, objtyp)) {
if (!ncp17_18_keyed_object_login(encrypted, name, objtyp)) {
;;
return(0);
}
}
} else { /* now we use old unencrypted algorithmus */
if (!ncp_17_14(name, objtyp, password)) {
if (!ncp17_14_login_object_unencrypted(name, objtyp, password)) {
return(0);
}
}
@@ -926,7 +926,7 @@ int func_passwd(int argc, char *argv[], int mode)
uint8 upasswd[130];
uint32 my_obj_id;
if (ncp_14_46(&my_obj_id) < 0 || my_obj_id == MAX_U32 || !my_obj_id) {
if (ncp17_46_get_bindery_access_level(&my_obj_id) < 0 || my_obj_id == MAX_U32 || !my_obj_id) {
fprintf(stderr, "Cannot get actual user id\n");
result = -1;
}
@@ -935,14 +935,14 @@ int func_passwd(int argc, char *argv[], int mode)
uint32 obj_id;
strmaxcpy(uname, argv[1], sizeof(uname) -1);
upstr(uname);
obj_id = ncp_17_35(uname, 1);
obj_id = ncp17_35_get_bindery_object_id(uname, 1);
if (!obj_id) {
fprintf(stderr, "Unkwown user: %s\n", uname);
return(-1);
}
} else if (!result) {
uint16 obj_typ;
if (ncp_17_36(my_obj_id, uname, &obj_typ) || obj_typ != 1) {
if (ncp17_36_get_bindery_object_name(my_obj_id, uname, &obj_typ) || obj_typ != 1) {
fprintf(stderr, "Cannot get actual username\n");
result=-1;
}

View File

@@ -26,7 +26,7 @@
#include "net.h"
/* ---------------- 0x16 ----------------------------------- */
int ncp_16_02(int dirhandle,
int ncp16_02_get_directory_entry(int dirhandle,
uint8 *path,
int *sub_dir,
uint8 *resultpath,
@@ -68,7 +68,7 @@ int ncp_16_02(int dirhandle,
}
/* ---------------- 0x17 ----------------------------------- */
int ncp_17_02(int module, int debuglevel)
int ncp17_02_set_debug_level(int module, int debuglevel)
/* debuglevel fuer module setzen */
{
struct {
@@ -89,7 +89,7 @@ int ncp_17_02(int module, int debuglevel)
return((int) repl.olddebug);
}
int ncp_17_14(uint8 *objname, uint16 objtyp, uint8 *password)
int ncp17_14_login_object_unencrypted(uint8 *objname, uint16 objtyp, uint8 *password)
/* login unencreypted */
{
struct {
@@ -116,7 +116,7 @@ int ncp_17_14(uint8 *objname, uint16 objtyp, uint8 *password)
return(0);
}
int ncp_17_17(uint8 *key)
int ncp17_17_get_encryption_key(uint8 *key)
/* get crypt key */
{
struct {
@@ -138,7 +138,7 @@ int ncp_17_17(uint8 *key)
}
}
int ncp_17_18(uint8 *cryptkey, uint8 *objname, uint16 objtyp)
int ncp17_18_keyed_object_login(uint8 *cryptkey, uint8 *objname, uint16 objtyp)
/* keyed login */
{
struct {
@@ -163,7 +163,7 @@ int ncp_17_18(uint8 *cryptkey, uint8 *objname, uint16 objtyp)
return(0);
}
uint32 ncp_17_35(uint8 *objname, uint16 objtyp)
uint32 ncp17_35_get_bindery_object_id(uint8 *objname, uint16 objtyp)
/* get bindery object id */
{
struct {
@@ -191,7 +191,7 @@ uint32 ncp_17_35(uint8 *objname, uint16 objtyp)
return(GET_BE32(repl.object_id));
}
int ncp_17_36(uint32 obj_id, uint8 *objname, uint16 *objtyp)
int ncp17_36_get_bindery_object_name(uint32 obj_id, uint8 *objname, uint16 *objtyp)
/* get bindery object name */
{
struct {
@@ -217,7 +217,7 @@ int ncp_17_36(uint32 obj_id, uint8 *objname, uint16 *objtyp)
}
int ncp_17_40(uint8 *objname, uint16 objtyp,
int ncp17_40_change_password_unencrypted(uint8 *objname, uint16 objtyp,
uint8 *password, uint8 *newpassword)
/* change password unencreypted */
{
@@ -249,7 +249,7 @@ int ncp_17_40(uint8 *objname, uint16 objtyp,
return(0);
}
int ncp_14_46(uint32 *obj_id)
int ncp17_46_get_bindery_access_level(uint32 *obj_id)
/* get bindery access level & actual ID */
{
struct {
@@ -273,7 +273,7 @@ int ncp_14_46(uint32 *obj_id)
}
int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
int ncp17_4b_keyed_change_password(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
int passwx, uint8 *newpassword)
/* keyed change password */
{
@@ -304,7 +304,7 @@ int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
}
int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
int ncp17_37_scan_bindery_object(uint32 last_id, uint16 objtyp, uint8 *pattern,
BINDERY_OBJECT *target)
/* scan bindery object */
{
@@ -356,7 +356,7 @@ int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
return(0);
}
int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
int ncp17_3d_read_property_value(uint16 objtyp, uint8 *objname, int segment,
uint8 *propname, NW_PROPERTY *target)
/* read bindery property value */
{

4
ndir.c
View File

@@ -421,7 +421,7 @@ static void ndir_format_owner(uint32 objid, char *out, int max)
uint16 objtyp;
uint8 objname[50];
if (objid && !ncp_17_36(objid, objname, &objtyp)) {
if (objid && !ncp17_36_get_bindery_object_name(objid, objname, &objtyp)) {
strmaxcpy(out, (char *)objname, max - 1);
return;
}
@@ -637,7 +637,7 @@ static void ndir_effective_rights(char *path, char *out)
if (usepath[0]) {
int subdir = 1;
int r = ncp_16_02(dhandle, (uint8 *)usepath, &subdir,
int r = ncp16_02_get_directory_entry(dhandle, (uint8 *)usepath, &subdir,
NULL, NULL, NULL);
if (r >= 0)
ndir_old_rights_string((uint8)r, out);

24
net.h
View File

@@ -255,24 +255,24 @@ extern int get_search_drive_vektor(SEARCH_VECTOR_ENTRY *vec);
extern int set_search_drive_vektor(SEARCH_VECTOR_ENTRY *vec);
/********* ncpcall.h ***********/
extern int ncp_16_02(int dirhandle,
extern int ncp16_02_get_directory_entry(int dirhandle,
uint8 *path,
int *sub_dir,
uint8 *resultpath,
uint32 *creattime,
uint32 *owner_id);
extern int ncp_14_46(uint32 *obj_id);
extern int ncp_17_02(int module, int debuglevel);
extern int ncp_17_14(uint8 *objname, uint16 objtyp, uint8 *password);
extern int ncp_17_17(uint8 *key);
extern int ncp_17_18(uint8 *cryptkey, uint8 *objname, uint16 objtyp);
extern uint32 ncp_17_35(uint8 *objname, uint16 objtyp);
extern int ncp_17_36(uint32 obj_id, uint8 *objname, uint16 *objtyp);
extern int ncp_17_40(uint8 *objname, uint16 objtyp, uint8 *password,
extern int ncp17_46_get_bindery_access_level(uint32 *obj_id);
extern int ncp17_02_set_debug_level(int module, int debuglevel);
extern int ncp17_14_login_object_unencrypted(uint8 *objname, uint16 objtyp, uint8 *password);
extern int ncp17_17_get_encryption_key(uint8 *key);
extern int ncp17_18_keyed_object_login(uint8 *cryptkey, uint8 *objname, uint16 objtyp);
extern uint32 ncp17_35_get_bindery_object_id(uint8 *objname, uint16 objtyp);
extern int ncp17_36_get_bindery_object_name(uint32 obj_id, uint8 *objname, uint16 *objtyp);
extern int ncp17_40_change_password_unencrypted(uint8 *objname, uint16 objtyp, uint8 *password,
uint8 *newpassword);
extern int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
extern int ncp17_4b_keyed_change_password(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
int passwx, uint8 *newpassword);
/* map.c */
@@ -315,8 +315,8 @@ extern int func_creator(int argc, char *argv[], int mode);
extern int func_ncopy (int argc, char *argv[], int mode);
extern int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
extern int ncp17_37_scan_bindery_object(uint32 last_id, uint16 objtyp, uint8 *pattern,
BINDERY_OBJECT *target);
extern int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
extern int ncp17_3d_read_property_value(uint16 objtyp, uint8 *objname, int segment,
uint8 *propname, NW_PROPERTY *target);

View File

@@ -47,7 +47,7 @@ int func_debug(int argc, char *argv[], int mode)
else return(usage());
level = atoi(argv[2]);
if (level < 0 || level > 99) return(usage());
result = ncp_17_02(module, level);
result = ncp17_02_set_debug_level(module, level);
if (result < 0) {
fprintf(stderr, "set debug failed\n");
fprintf(stderr, "perhaps you did not enable FUNC_17_02_IS_DEBUG\n");

View File

@@ -2506,10 +2506,10 @@ static int tests_effright(char *path)
{
int access_level;
access_level = ncp_14_46(&my_obj_id);
access_level = ncp17_46_get_bindery_access_level(&my_obj_id);
my_obj_name[0] = '\0';
if (access_level >= 0 && my_obj_id) {
ncp_17_36(my_obj_id, my_obj_name, &my_obj_type);
ncp17_36_get_bindery_object_name(my_obj_id, my_obj_name, &my_obj_type);
fprintf(stdout, "Current object: %08lX type=%04X access=%02X name=%s\n\n",
(unsigned long)my_obj_id, my_obj_type,
(unsigned)access_level, my_obj_name);
@@ -2586,7 +2586,7 @@ static int tests_effright(char *path)
if (usepath[0]) {
int subdir = 1;
int r = ncp_16_02(dhandle, (uint8 *)usepath, &subdir,
int r = ncp16_02_get_directory_entry(dhandle, (uint8 *)usepath, &subdir,
NULL, NULL, NULL);
if (r >= 0)
tests_print_eff_row("ncp16_02 parent", 0, (uint8)r, (uint16)r, 1);

View File

@@ -191,7 +191,7 @@ static int rights_effective_mask(char *path, int is_dir, uint8 *mask)
if (newhandle < 0) {
if (usepath[0]) {
int subdir = 1;
int r = ncp_16_02(dhandle, (uint8 *)usepath, &subdir,
int r = ncp16_02_get_directory_entry(dhandle, (uint8 *)usepath, &subdir,
NULL, NULL, NULL);
if (r >= 0) {
eff = (uint8)r;

View File

@@ -93,7 +93,7 @@ int func_slist(int argc, char *argv[], int mode)
upstr(pattern);
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
while ((result = ncp17_37_scan_bindery_object(last_id, NCP_BINDERY_FSERVER,
pattern, &obj)) == 0) {
NW_PROPERTY prop;
@@ -109,7 +109,7 @@ int func_slist(int argc, char *argv[], int mode)
fprintf(stdout, "%-47s", obj.object_name);
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
if (!ncp17_3d_read_property_value(NCP_BINDERY_FSERVER, obj.object_name,
1, "NET_ADDRESS", &prop)) {
print_net_node_status(prop.value, found == 1);
}

View File

@@ -129,16 +129,16 @@ uint32 trustee_lookup_object(char *name, uint16 *objtype, int objtype_given)
upstr(namebuf);
if (objtype_given) {
return(ncp_17_35(namebuf, *objtype));
return(ncp17_35_get_bindery_object_id(namebuf, *objtype));
}
*objtype = TRUSTEE_BINDERY_USER;
object_id = ncp_17_35(namebuf, TRUSTEE_BINDERY_USER);
object_id = ncp17_35_get_bindery_object_id(namebuf, TRUSTEE_BINDERY_USER);
if (object_id)
return(object_id);
*objtype = TRUSTEE_BINDERY_GROUP;
object_id = ncp_17_35(namebuf, TRUSTEE_BINDERY_GROUP);
object_id = ncp17_35_get_bindery_object_id(namebuf, TRUSTEE_BINDERY_GROUP);
return(object_id);
}

View File

@@ -187,7 +187,7 @@ static int who_print_prop_objects(uint8 *username, uint16 usertype,
NW_PROPERTY prop;
int i;
if (ncp_17_3d(usertype, username, segment, propname, &prop))
if (ncp17_3d_read_property_value(usertype, username, segment, propname, &prop))
break;
for (i = 0; i < 128; i += 4) {
@@ -202,7 +202,7 @@ static int who_print_prop_objects(uint8 *username, uint16 usertype,
continue;
name[0] = '\0';
if (ncp_17_36(oid, name, &typ))
if (ncp17_36_get_bindery_object_name(oid, name, &typ))
continue;
if (with_type)
@@ -375,9 +375,9 @@ int func_whoami(int argc, char *argv[], int mode)
}
obj_name[0] = '\0';
ncp_14_46(&obj_id);
ncp17_46_get_bindery_access_level(&obj_id);
if (obj_id)
ncp_17_36(obj_id, obj_name, &obj_type);
ncp17_36_get_bindery_object_name(obj_id, obj_name, &obj_type);
memset(&logged_obj, 0, sizeof(logged_obj));
memset(&login_time, 0, sizeof(login_time));