aboutsummaryrefslogtreecommitdiffstats
path: root/src/u_utils.c
diff options
context:
space:
mode:
authorjozan <jozan@noemail.net>2020-11-08 00:27:27 +0000
committerjozan <jozan@noemail.net>2020-11-08 00:27:27 +0000
commit538efe3fc1e62a231fa10cd3071c2c7a69c7d281 (patch)
treea7ed803d4becaeea6a84b36def84952a9601e4da /src/u_utils.c
parentMerging branch 'go-full-stack' into 'trunk' (diff)
downloadunixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.gz
unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.bz2
unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.xz
unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.zst
unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.zip
Added relative path nice
FossilOrigin-Name: 9cca594d1c68d5b68ea84412f2d2809e337d6b9cd1d0b0ef034feec55a8c2ae0
Diffstat (limited to 'src/u_utils.c')
-rw-r--r--src/u_utils.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/u_utils.c b/src/u_utils.c
index e352eb6..65b59a3 100644
--- a/src/u_utils.c
+++ b/src/u_utils.c
@@ -43,6 +43,8 @@
* 2020-11-05 19:27
*/
+#include <sys/param.h>
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -177,3 +179,39 @@ u_get_nargv(struct opts_s* opts)
}
return (nargv);
}
+
+void
+u_increase_subpath
+(char subp[],
+ const char newp[])
+{
+ strlcpy(
+ subp + strlen(subp),
+ newp,
+ MAXPATHLEN - strlen(subp) - 1
+ );
+ subp[strlen(subp) + 1] = 0x00;
+ subp[strlen(subp)] = '/';
+}
+
+void
+u_decrease_subpath(char subp[])
+{
+ char* p;
+
+ p = subp;
+ p += strlen(subp);
+ if (p == 0) {
+ return;
+ }
+ p -= 2;
+ while (subp - p != 0 && *p != '/') {
+ p--;
+ }
+ if (*p == '/') {
+ *(p + 1) = 0x00;
+ }
+ else if (subp - p == 0) {
+ *p = 0x00;
+ }
+}