From 330d6544f9ea7299ca6c6e303972955011befd5b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 25 Feb 2013 16:11:49 -0300 Subject: [PATCH] Add a basic mainfile skeleton for the edactool For now, it does nothing. Signed-off-by: Mauro Carvalho Chehab --- Makefile | 11 ++++++++ edactool.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Makefile create mode 100644 edactool.c diff --git a/Makefile b/Makefile new file mode 100644 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 index 0000000..af9190d --- /dev/null +++ b/edactool.c @@ -0,0 +1,80 @@ +/* + * Copyright © 2013 Mauro Carvalho Chehab + * + * 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 +#include +#include + +#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 "" + +const char *argp_program_version = TOOL_NAME " " VERSION; +const char *argp_program_bug_address = "Mauro Carvalho Chehab "; + +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; +} -- 2.50.1