A function to parse options meant for the helpers out of a the command
line is added. This parse function picks up options altering the behaviour
of the helpers out of the command line. Other options are reject.
No helper options are definied (yet).

Signed-off-by: Christophe Milard <christophe.mil...@linaro.org>
---
 helper/include/odp/helper/linux.h | 13 +++++++++++++
 helper/linux.c                    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/helper/include/odp/helper/linux.h 
b/helper/include/odp/helper/linux.h
index 7a6504f..c6736a0 100644
--- a/helper/include/odp/helper/linux.h
+++ b/helper/include/odp/helper/linux.h
@@ -130,6 +130,19 @@ int odph_linux_process_fork_n(odph_linux_process_t 
*proc_tbl,
 int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num);
 
 
+/**
+ * Parse linux helper options
+ *
+ * Parse the command line options. Pick up options meant for the helper itself.
+ *
+ * @param argc argument count
+ * @param argv argument values
+ *
+ * @return On success: 0
+ *        On failure: -1 (failure occurs only if a value passed for a helper
+ *                        option is invalid. callers cannot have own options)
+ */
+int odph_parse_options(int argc, char *argv[]);
 #ifdef __cplusplus
 }
 #endif
diff --git a/helper/linux.c b/helper/linux.c
index 24e243b..5dbc2da 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <getopt.h>
 
 #include <odp_api.h>
 #include <odp/helper/linux.h>
@@ -236,3 +237,32 @@ int odph_linux_process_wait_n(odph_linux_process_t 
*proc_tbl, int num)
 
        return 0;
 }
+
+/*
+ * Parse command line options to extract options affecting helpers.
+ */
+int odph_parse_options(int argc, char *argv[])
+{
+       int c;
+
+       static struct option long_options[] = {
+               /* These options set a flag. */
+               {0, 0, 0, 0}
+               };
+
+       while (1) {
+               /* getopt_long stores the option index here. */
+               int option_index = 0;
+
+               c = getopt_long (argc, argv, "",
+                                long_options, &option_index);
+
+               /* Detect the end of the options. */
+               if (c == -1)
+                       break;
+       }
+
+       optind = 0; /* caller expects this to be zero if it parses too*/
+
+       return 0;
+}
-- 
2.5.0

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to