summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-08-30 02:42:34 +0000
committermidipix <writeonce@midipix.org>2019-08-30 03:02:03 +0000
commitb85b1f5d35413312c08e7670dd4db67b7e088d91 (patch)
tree1be04be1b6f6aff303965a440c37e4be8d9c5599
parentda2149d3136a05b9adb98b0811f706fef15bb95f (diff)
downloadmmglue-b85b1f5d35413312c08e7670dd4db67b7e088d91.tar.bz2
mmglue-b85b1f5d35413312c08e7670dd4db67b7e088d91.tar.xz
glue layer: introduced <sys/cmd.h>, implemented associated interfaces.
-rw-r--r--include/sys/cmd.h45
-rw-r--r--project/arch.mk1
-rw-r--r--src/arch/nt32/cmd.c10
-rw-r--r--src/arch/nt64/cmd.c10
4 files changed, 66 insertions, 0 deletions
diff --git a/include/sys/cmd.h b/include/sys/cmd.h
new file mode 100644
index 0000000..eb3cbfc
--- /dev/null
+++ b/include/sys/cmd.h
@@ -0,0 +1,45 @@
+#ifndef _SYS_CMD_H
+#define _SYS_CMD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_size_t
+
+#include <bits/alltypes.h>
+
+/***************************************************************************/
+/* int (*cmd_args_to_argv)( */
+/* const char * args, */
+/* char * argbuf, size_t buflen, */
+/* char ** argv, size_t nptrs); */
+/* */
+/* arguments: */
+/* args: command to parse */
+/* argbuf: buffer to receive the corresponding sequence of */
+/* null-terminated arguments. */
+/* buflen: size of argbuf, including final null-terminator. */
+/* argv: argument vector to receive pointers to the above */
+/* null-terminated arguments. */
+/* nptrs: number of available argv pointers, including */
+/* including the terminating null pointer. */
+/* */
+/* return value: */
+/* zero upon successful parsing and buffer initialization */
+/* negative value returned upon failure, which is the actual value */
+/* returned by the underlying system call; accordingly, errno */
+/* is _not_ set by the above interface. */
+/* */
+/* implementation: */
+/* the above interface is async-safe, thread-safe, and re-entrant. */
+/* */
+/***************************************************************************/
+
+int __cmd_args_to_argv(const char *, char *, size_t, char **, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/project/arch.mk b/project/arch.mk
index 5a5b967..5203888 100644
--- a/project/arch.mk
+++ b/project/arch.mk
@@ -23,6 +23,7 @@ LDFLAGS_CONFIG += -Wl,--exclude-symbols=_IO_putc_unlocked
LDFLAGS_CONFIG += -Wl,--exclude-symbols=___errno_location
TARGET_SYS_HEADERS = \
+ $(PROJECT_DIR)/include/sys/cmd.h \
$(PROJECT_DIR)/include/sys/debug.h \
$(PROJECT_DIR)/include/sys/fs.h \
$(PROJECT_DIR)/include/sys/ldso.h \
diff --git a/src/arch/nt32/cmd.c b/src/arch/nt32/cmd.c
new file mode 100644
index 0000000..a5def88
--- /dev/null
+++ b/src/arch/nt32/cmd.c
@@ -0,0 +1,10 @@
+#include <sys/cmd.h>
+#include "syscall.h"
+
+int __cmd_args_to_argv(
+ const char * args,
+ char * argbuf, size_t buflen,
+ char ** argv, size_t nptrs)
+{
+ return __syscall(SYS_cmd_args_to_argv,args,argbuf,buflen,argv,nptrs);
+}
diff --git a/src/arch/nt64/cmd.c b/src/arch/nt64/cmd.c
new file mode 100644
index 0000000..a5def88
--- /dev/null
+++ b/src/arch/nt64/cmd.c
@@ -0,0 +1,10 @@
+#include <sys/cmd.h>
+#include "syscall.h"
+
+int __cmd_args_to_argv(
+ const char * args,
+ char * argbuf, size_t buflen,
+ char ** argv, size_t nptrs)
+{
+ return __syscall(SYS_cmd_args_to_argv,args,argbuf,buflen,argv,nptrs);
+}