aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs6f/s6f_equote.c
diff options
context:
space:
mode:
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 ;
+}