trustee: use shared tool helpers for generic path handling
Remove generic wrapper helpers from trustee.c and switch GRANT/REMOVE/REVOKE callers to the shared tools.c helpers directly. Keep trustee.c focused on Trustee/Rights-specific behavior such as option parsing, rights parsing/formatting, object lookup and trustee path handling. The generic string, current directory handle, uppercase and path helper logic now lives in tools.c where it can be reused by other DOS utilities.
This commit is contained in:
34
remove.c
34
remove.c
@@ -53,7 +53,7 @@ static void remove_header_path(char *out, char *path, int max)
|
||||
{
|
||||
char *p;
|
||||
|
||||
trustee_header_path(out, path, max);
|
||||
tool_header_path(out, path, max);
|
||||
|
||||
/* Novell REMOVE displays server and volume as SERVER/SYS: while
|
||||
* RIGHTS uses SERVER\SYS:. Keep the rest of the path with DOS
|
||||
@@ -127,12 +127,12 @@ static int remove_subdirs_inner(char *path, uint16 dhandle, uint32 object_id,
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
trustee_join_path(pattern, path, "*.*", sizeof(pattern));
|
||||
tool_join_path(pattern, path, "*.*", sizeof(pattern));
|
||||
|
||||
if (_dos_findfirst(pattern, _A_SUBDIR, &ff) == 0) {
|
||||
do {
|
||||
if ((ff.attrib & _A_SUBDIR) && !trustee_is_dot_dir(ff.name)) {
|
||||
trustee_join_path(child, path, ff.name, sizeof(child));
|
||||
if ((ff.attrib & _A_SUBDIR) && !tool_is_dot_dir(ff.name)) {
|
||||
tool_join_path(child, path, ff.name, sizeof(child));
|
||||
if (remove_subdirs_inner(child, dhandle, object_id, objtype, objname,
|
||||
count, 1))
|
||||
rc = 1;
|
||||
@@ -165,8 +165,8 @@ static int remove_files(char *path, uint16 dhandle, uint32 object_id,
|
||||
if (trustee_path_is_dir(path)) {
|
||||
strmaxcpy(dir, path, sizeof(dir) - 1);
|
||||
strmaxcpy(pat, "*.*", sizeof(pat) - 1);
|
||||
} else if (trustee_path_has_wildcards(path)) {
|
||||
trustee_parent_pattern(dir, pat, path, sizeof(dir), sizeof(pat));
|
||||
} else if (tool_has_wildcards(path)) {
|
||||
tool_parent_pattern(dir, pat, path, sizeof(dir), sizeof(pat));
|
||||
} else {
|
||||
if (remove_one(path, dhandle, object_id, objtype, objname, 1) == 0)
|
||||
(*count)++;
|
||||
@@ -175,11 +175,11 @@ static int remove_files(char *path, uint16 dhandle, uint32 object_id,
|
||||
return(rc);
|
||||
}
|
||||
|
||||
trustee_join_path(spec, dir, pat, sizeof(spec));
|
||||
tool_join_path(spec, dir, pat, sizeof(spec));
|
||||
if (_dos_findfirst(spec, _A_NORMAL | _A_HIDDEN | _A_SYSTEM | _A_ARCH, &ff) == 0) {
|
||||
do {
|
||||
if (!(ff.attrib & _A_SUBDIR)) {
|
||||
trustee_join_path(target, dir, ff.name, sizeof(target));
|
||||
tool_join_path(target, dir, ff.name, sizeof(target));
|
||||
if (remove_one(target, dhandle, object_id, objtype, objname, 1) == 0)
|
||||
(*count)++;
|
||||
else
|
||||
@@ -209,7 +209,7 @@ int func_remove(int argc, char *argv[], int mode)
|
||||
|
||||
(void)mode;
|
||||
|
||||
if (argc < 2 || trustee_is_help(argv[1])) {
|
||||
if (argc < 2 || tool_is_help_arg(argv[1])) {
|
||||
if (argc < 2) {
|
||||
remove_usage_after_error();
|
||||
return(1);
|
||||
@@ -218,18 +218,18 @@ int func_remove(int argc, char *argv[], int mode)
|
||||
return(argc < 2 ? 1 : 0);
|
||||
}
|
||||
|
||||
if (i < argc && trustee_same(argv[i], "USER")) {
|
||||
if (i < argc && tool_strsame(argv[i], "USER")) {
|
||||
/* Novell treats "REMOVE USER FROM path" as an object lookup for
|
||||
* USER, not as a grammar error. */
|
||||
if ((i + 1) < argc && trustee_same(argv[i + 1], "FROM")) {
|
||||
if ((i + 1) < argc && tool_strsame(argv[i + 1], "FROM")) {
|
||||
objtype_given = 0;
|
||||
} else {
|
||||
objtype = TRUSTEE_BINDERY_USER;
|
||||
objtype_given = 1;
|
||||
i++;
|
||||
}
|
||||
} else if (i < argc && trustee_same(argv[i], "GROUP")) {
|
||||
if ((i + 1) < argc && trustee_same(argv[i + 1], "FROM")) {
|
||||
} else if (i < argc && tool_strsame(argv[i], "GROUP")) {
|
||||
if ((i + 1) < argc && tool_strsame(argv[i + 1], "FROM")) {
|
||||
objtype_given = 0;
|
||||
} else {
|
||||
objtype = TRUSTEE_BINDERY_GROUP;
|
||||
@@ -245,7 +245,7 @@ int func_remove(int argc, char *argv[], int mode)
|
||||
|
||||
objname = argv[i++];
|
||||
|
||||
if (i < argc && trustee_same(argv[i], "FROM")) {
|
||||
if (i < argc && tool_strsame(argv[i], "FROM")) {
|
||||
i++;
|
||||
if (i >= argc) {
|
||||
remove_usage_after_error();
|
||||
@@ -255,7 +255,7 @@ int func_remove(int argc, char *argv[], int mode)
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
if (!trustee_is_option(argv[i])) {
|
||||
if (!tool_is_option(argv[i])) {
|
||||
remove_usage_after_error();
|
||||
return(1);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ int func_remove(int argc, char *argv[], int mode)
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (trustee_current_dhandle(&connid, &dhandle)) {
|
||||
if (tool_current_dhandle(&connid, &dhandle)) {
|
||||
fprintf(stdout, "Error: Drive not mapped to network.\n");
|
||||
return(1);
|
||||
}
|
||||
@@ -297,7 +297,7 @@ int func_remove(int argc, char *argv[], int mode)
|
||||
return(1);
|
||||
}
|
||||
|
||||
trustee_upcopy(objprint, objname, sizeof(objprint));
|
||||
tool_upcopy(objprint, objname, sizeof(objprint));
|
||||
|
||||
if (use_subdirs)
|
||||
rc = remove_subdirs(path, (uint16)dhandle, object_id, objtype, objprint, &count);
|
||||
|
||||
Reference in New Issue
Block a user