]> www.infradead.org Git - users/mchehab/edactool.git/commitdiff
Add a basic mainfile skeleton for the edactool
authorMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 25 Feb 2013 19:11:49 +0000 (16:11 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 25 Feb 2013 19:18:08 +0000 (16:18 -0300)
For now, it does nothing.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Makefile [new file with mode: 0644]
edactool.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..ffb694b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+CC=gcc
+CFLAGS = -Wall
+FILES = edactool
+
+default: $(FILES)
+
+
+edactool: edactool.o
+
+clean:
+       rm edactool edactool.o
diff --git a/edactool.c b/edactool.c
new file mode 100644 (file)
index 0000000..af9190d
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2013 Mauro Carvalho Chehab <mchehab@redhat.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of Red Hat
+ * not be used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.  Red
+ * Hat makes no representations about the suitability of this software
+ * for any purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <argp.h>
+#include <string.h>
+
+#define VERSION "0.1.0"
+#define TOOL_NAME "edactool"
+#define TOOL_DESCRIPTION "Ancillary tool to control the Error Detect And Correction - EDAC subsystem."
+#define ARGS_DOC "<options>"
+
+const char *argp_program_version = TOOL_NAME " " VERSION;
+const char *argp_program_bug_address = "Mauro Carvalho Chehab <mchehab@redhat.com>";
+
+struct arguments {
+       int device_mode;
+};
+
+static error_t parse_opt(int k, char *arg, struct argp_state *state)
+{
+       struct arguments *args = state->input;
+
+       switch (k) {
+       case 'd':
+               args->device_mode++;
+               break;
+       default:
+               return ARGP_ERR_UNKNOWN;
+       }
+       return 0;
+}
+
+int main(int argc, char *argv[])
+{
+       struct arguments args;
+       int idx = -1;
+       const struct argp_option options[] = {
+               {"device", 'd', 0, 0, "use alternative device show mode", 0},
+               { 0, 0, 0, 0, 0, 0 }
+       };
+       const struct argp argp = {
+               .options = options,
+               .parser = parse_opt,
+               .doc = TOOL_DESCRIPTION,
+               .args_doc = ARGS_DOC,
+
+       };
+       memset (&args, 0, sizeof(args));
+
+       argp_parse(&argp, argc, argv, 0,  &idx, &args);
+
+       if (idx < 0) {
+               argp_help(&argp, stderr, ARGP_HELP_STD_HELP, TOOL_NAME);
+               return -1;
+       }
+
+
+       return 0;
+}