aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs6f/s6f_equote.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-11-04 22:23:28 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2025-11-04 22:23:28 +0000
commit3b56d41ef579c18feafbf47d170a6ea4375beb6f (patch)
tree87d634d029dba1f786d04df4f35b75af996c74b3 /src/libs6f/s6f_equote.c
parent2ea40fd0c6b05d29edf5a3b62f4c0f1af6e8b8d8 (diff)
downloads6-frontend-3b56d41ef579c18feafbf47d170a6ea4375beb6f.tar.gz
Lots of work done, doesn't build yet, next commit will
- alias subsystem moved to s6 - config subsystem deleted - new helpers subsystem, with a s6-frontend-helper-kill program - new s6f_equote function, to execline-quote an argv - started the adaptation to the new s6-rc functions, in progress
Diffstat (limited to 'src/libs6f/s6f_equote.c')
-rw-r--r--src/libs6f/s6f_equote.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libs6f/s6f_equote.c b/src/libs6f/s6f_equote.c
new file mode 100644
index 0000000..41cef42
--- /dev/null
+++ b/src/libs6f/s6f_equote.c
@@ -0,0 +1,24 @@
+/* ISC license. */
+
+#include <string.h>
+
+#include "s6f.h"
+
+size_t s6f_equote_space (char const *const *argv, unsigned int argc)
+{
+ size_t l = 0 ;
+ for (unsigned int i = 0 ; i < argc ; i++) l += i + 2 + strlen(argv[i]) ;
+ return l ;
+}
+
+unsigned int s6f_equote (char const **newargv, char const *const *argv, unsigned int argc, char *s)
+{
+ for (unsigned int i = 0 ; i < argc ; i++)
+ {
+ newargv[i] = s ;
+ *s++ = ' ' ;
+ s = stpcpy(s, argv[i]) + 1 ;
+ }
+ newargv[argc] = "" ;
+ return argc + 1 ;
+}