aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpetershh <petershh@disroot.org>2022-07-31 14:38:46 +0300
committerPeter <santurysim@gmail.com>2022-08-03 00:37:07 +0300
commit209e0fd80abba905559c8542bf4adfcde2c4445d (patch)
treefd712ada030e94e28df0a70cd5fb49ba3d4b9aa3
parentb096cc58572143359a638b6d10748ddd4edd7a9c (diff)
downloadshh-portable-utils-209e0fd80abba905559c8542bf4adfcde2c4445d.tar.xz
Begin separating chmod-related functions to their own files
-rw-r--r--src/shh-portable-utils/chmod.c27
-rw-r--r--src/shh-portable-utils/shhfuncs.h28
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*);