From f3e77819d87f6734839c6e5f04454a119198b38d Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Fri, 29 May 2026 12:27:02 +0200 Subject: [PATCH] dosutils: use shared option helper functions Replace small local option helper wrappers with the shared tools.c helpers. SLIST now uses tool_is_help_arg() directly, and REMOVE/REVOKE use tool_is_files_option() and tool_is_subdirs_option() instead of Trustee-specific wrappers. This keeps trustee.c focused on Rights/Trustee behavior and leaves generic command-line option handling in tools.c. No behavior change. --- remove.c | 4 ++-- revoke.c | 4 ++-- slist.c | 8 +------- trustee.c | 42 ------------------------------------------ trustee.h | 2 -- 5 files changed, 5 insertions(+), 55 deletions(-) diff --git a/remove.c b/remove.c index 658ced5..2d6d22f 100644 --- a/remove.c +++ b/remove.c @@ -260,13 +260,13 @@ int func_remove(int argc, char *argv[], int mode) return(1); } - if (trustee_is_files_option(argv[i])) { + if (tool_is_files_option(argv[i])) { use_files = 1; i++; continue; } - if (trustee_is_subdirs_option(argv[i])) { + if (tool_is_subdirs_option(argv[i])) { use_subdirs = 1; i++; continue; diff --git a/revoke.c b/revoke.c index 9038bce..34511a1 100644 --- a/revoke.c +++ b/revoke.c @@ -315,13 +315,13 @@ int func_revoke(int argc, char *argv[], int mode) return(1); } - if (trustee_is_files_option(argv[i])) { + if (tool_is_files_option(argv[i])) { use_files = 1; i++; continue; } - if (trustee_is_subdirs_option(argv[i])) { + if (tool_is_subdirs_option(argv[i])) { use_subdirs = 1; i++; continue; diff --git a/slist.c b/slist.c index a66b21b..6f619c7 100644 --- a/slist.c +++ b/slist.c @@ -34,12 +34,6 @@ static int usage(void) return(0); } -static int is_help_arg(char *s) -{ - if (!s) return(0); - return(tool_strsame(s, "/?") || tool_strsame(s, "-?") || tool_strsame(s, "?")); -} - static unsigned long node_to_number(uint8 *addr) { unsigned long n = 0; @@ -76,7 +70,7 @@ int func_slist(int argc, char *argv[], int mode) strcpy(pattern, "*"); for (i = 1; i < argc; i++) { - if (is_help_arg(argv[i])) return(usage()); + if (tool_is_help_arg(argv[i])) return(usage()); if (argv[i][0] == '/' || argv[i][0] == '-') { if (tool_strsame(argv[i], "/C") || tool_strsame(argv[i], "/CONTINUE") || diff --git a/trustee.c b/trustee.c index 510d3f7..2327c7b 100644 --- a/trustee.c +++ b/trustee.c @@ -31,48 +31,6 @@ #define S_IFDIR 0040000 #endif -/* - * trustee_is_subdirs_option - * - * Purpose: - * Recognizes the GRANT/REMOVE/REVOKE option variants that request - * recursive processing of subdirectories. - * - * Parameters: - * s - command-line token to test. - * - * Returns: - * Non-zero when the token is a /SUBDIRS, /SUBDIRECTORIES or /S option, - * otherwise zero. - */ -int trustee_is_subdirs_option(char *s) -{ - if (!s) return(0); - return(tool_strsame(s, "/SUBDIRS") || tool_strsame(s, "-SUBDIRS") || - tool_strsame(s, "/SUBDIRECTORIES") || tool_strsame(s, "-SUBDIRECTORIES") || - tool_strsame(s, "/S") || tool_strsame(s, "-S")); -} - -/* - * trustee_is_files_option - * - * Purpose: - * Recognizes the option variants that request file entries in addition to - * directories for trustee operations. - * - * Parameters: - * s - command-line token to test. - * - * Returns: - * Non-zero for /FILES or /F variants, otherwise zero. - */ -int trustee_is_files_option(char *s) -{ - if (!s) return(0); - return(tool_strsame(s, "/FILES") || tool_strsame(s, "-FILES") || - tool_strsame(s, "/F") || tool_strsame(s, "-F")); -} - /* * trustee_parse_right_word * diff --git a/trustee.h b/trustee.h index 9d6d1e9..20147f5 100644 --- a/trustee.h +++ b/trustee.h @@ -43,8 +43,6 @@ TRUSTEE_RIGHT_DELETE | TRUSTEE_RIGHT_MODIFY | \ TRUSTEE_RIGHT_SEARCH | TRUSTEE_RIGHT_OWNER) -int trustee_is_subdirs_option(char *s); -int trustee_is_files_option(char *s); int trustee_parse_right_word(char *s, uint16 *rights); void trustee_rights_bracket(uint16 rights, char *out); uint32 trustee_lookup_object(char *name, uint16 *objtype, int objtype_given);