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.
This commit is contained in:
Mario Fetka
2026-05-29 12:27:02 +02:00
parent 8f8ce00093
commit f3e77819d8
5 changed files with 5 additions and 55 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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") ||

View File

@@ -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
*

View File

@@ -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);