diff options
-rw-r--r-- | src/shh-portable-utils/chmod.c | 27 | ||||
-rw-r--r-- | src/shh-portable-utils/shhfuncs.h | 28 |
2 files changed, 29 insertions, 26 deletions
diff --git a/src/shh-portable-utils/chmod.c b/src/shh-portable-utils/chmod.c index 0995419..40091e6 100644 --- a/src/shh-portable-utils/chmod.c +++ b/src/shh-portable-utils/chmod.c @@ -11,32 +11,9 @@ #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> -#define USAGE "chmod [-R] mode file..." - -#define S_ISALL (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) - -struct chmod_directive_s { - mode_t who; - int action; - mode_t perm; - int permcopy; - int dir_x; -}; - -typedef struct chmod_directive_s chmod_directive; - -#define CHMOD_DIRECTIVE_ZERO { 0, 0, 0, 0, 0 } +#include "shhfuncs.h" -mode_t parse_octal(char const*); - -void parse_symbolic(char const*, genalloc*); - -/* - * Algorithm for chmod mode parsing was inspired by sbase's chmod - * implementation (https://core.suckless.org/sbase), so let's credit them here. - */ - -int change_mode(char const*, mode_t, genalloc*, mode_t); +#define USAGE "chmod [-R] mode file..." int traverse_dir(stralloc*, mode_t, genalloc*, mode_t); diff --git a/src/shh-portable-utils/shhfuncs.h b/src/shh-portable-utils/shhfuncs.h index 7558149..dd13f7c 100644 --- a/src/shh-portable-utils/shhfuncs.h +++ b/src/shh-portable-utils/shhfuncs.h @@ -1,12 +1,38 @@ #include <sys/types.h> #include <skalibs/stralloc.h> +#include <skalibs/genalloc.h> #include <skalibs/buffer.h> +#define S_ISALL (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX) + +struct chmod_directive_s { + mode_t who; + int action; + mode_t perm; + int permcopy; + int dir_x; +}; + +typedef struct chmod_directive_s chmod_directive; + +#define CHMOD_DIRECTIVE_ZERO { 0, 0, 0, 0, 0 } + +mode_t parse_octal(char const*); +void parse_symbolic(char const*, genalloc*); + +/* + * Algorithm for chmod mode parsing was inspired by sbase's chmod + * implementation (https://core.suckless.org/sbase), so let's credit them here. + */ + +int change_mode(char const*, mode_t, genalloc*, mode_t); + + size_t byte_notin(char const *s, size_t n, char const *sep, size_t len); int shhgetln(buffer *b, stralloc *sa, char sep); -uid_t parse_user(char const*); +uid_t parse_user(char const*); gid_t parse_group(char const*); |