From 53e28c6bfebcabdcf74398454619080b95ad9c62 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Fri, 29 May 2026 09:55:33 +0200 Subject: [PATCH] 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. --- creator.c | 4 ++-- grant.c | 2 +- login.c | 22 +++++++++++----------- ncpcall.c | 24 ++++++++++++------------ ndir.c | 4 ++-- net.h | 24 ++++++++++++------------ nwdebug.c | 2 +- nwtests.c | 6 +++--- rights.c | 2 +- slist.c | 4 ++-- trustee.c | 6 +++--- whoami.c | 8 ++++---- 12 files changed, 54 insertions(+), 54 deletions(-) diff --git a/creator.c b/creator.c index a5bb743..504acf0 100644 --- a/creator.c +++ b/creator.c @@ -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); } diff --git a/grant.c b/grant.c index a976f9d..d3ade76 100644 --- a/grant.c +++ b/grant.c @@ -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]; diff --git a/login.c b/login.c index a8c911a..8f87402 100644 --- a/login.c +++ b/login.c @@ -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; } diff --git a/ncpcall.c b/ncpcall.c index 4b79704..ae21a81 100644 --- a/ncpcall.c +++ b/ncpcall.c @@ -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 */ { diff --git a/ndir.c b/ndir.c index bf46bc8..a64ca38 100644 --- a/ndir.c +++ b/ndir.c @@ -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); diff --git a/net.h b/net.h index e7da7d6..b02d6e6 100644 --- a/net.h +++ b/net.h @@ -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); diff --git a/nwdebug.c b/nwdebug.c index f592626..d5f377f 100644 --- a/nwdebug.c +++ b/nwdebug.c @@ -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"); diff --git a/nwtests.c b/nwtests.c index ba5f3ee..b54fbb9 100644 --- a/nwtests.c +++ b/nwtests.c @@ -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); diff --git a/rights.c b/rights.c index 2440568..d655d0f 100644 --- a/rights.c +++ b/rights.c @@ -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; diff --git a/slist.c b/slist.c index 53d75b7..a66b21b 100644 --- a/slist.c +++ b/slist.c @@ -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); } diff --git a/trustee.c b/trustee.c index 0196040..4de06e9 100644 --- a/trustee.c +++ b/trustee.c @@ -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); } diff --git a/whoami.c b/whoami.c index 9008246..1d2e61e 100644 --- a/whoami.c +++ b/whoami.c @@ -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));