From 0f870f29388a36d32ec9ffaabe9ffe03edc038c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20G=C3=B6hler?= Date: Fri, 12 Sep 2014 01:05:12 +0200 Subject: [PATCH] sorted some includes + added version number --- include/mdp.h | 10 ++++++++++ include/viewer.h | 1 + markdown.c | 1 - mdp.c | 29 ++++++++++++++++++----------- viewer.c | 1 - 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 include/mdp.h diff --git a/include/mdp.h b/include/mdp.h new file mode 100644 index 0000000..a1d2e0e --- /dev/null +++ b/include/mdp.h @@ -0,0 +1,10 @@ +#if !defined( MDP_H ) +#define MDP_H + +#include "parser.h" +#include "viewer.h" + +#define MAJOR_VERSION 0 +#define MINOR_VERSION 1 + +#endif // !defined( MDP_H ) diff --git a/include/viewer.h b/include/viewer.h index c4f4175..c5f4530 100644 --- a/include/viewer.h +++ b/include/viewer.h @@ -3,6 +3,7 @@ #include +#include "parser.h" #include "cstack.h" #define CP_WHITE 1 // 255 diff --git a/markdown.c b/markdown.c index 9c358d4..762df34 100644 --- a/markdown.c +++ b/markdown.c @@ -1,7 +1,6 @@ #include #include -#include "include/cstring.h" #include "include/markdown.h" line_t *new_line() { diff --git a/mdp.c b/mdp.c index 0671ab6..b12ea97 100644 --- a/mdp.c +++ b/mdp.c @@ -4,34 +4,41 @@ #include #include -#include "include/parser.h" -#include "include/viewer.h" +#include "include/mdp.h" void usage() { - fprintf(stderr, "Usage: mdp [OPTION]... [FILE]\n"); - fprintf(stderr, "A command-line based markdown presentation tool.\n\n"); - fprintf(stderr, " -d, --debug enable debug messages on STDERR\n"); - fprintf(stderr, " add it multiple times to increases debug level\n\n"); - fprintf(stderr, " -h, --help display this help and exit\n"); - fprintf(stderr, "\nWith no FILE, or when FILE is -, read standard input.\n\n"); + fprintf(stderr, "%s", "Usage: mdp [OPTION]... [FILE]\n"); + fprintf(stderr, "%s", "A command-line based markdown presentation tool.\n\n"); + fprintf(stderr, "%s", " -d, --debug enable debug messages on STDERR\n"); + fprintf(stderr, "%s", " add it multiple times to increases debug level\n\n"); + fprintf(stderr, "%s", " -h, --help display this help and exit\n"); + fprintf(stderr, "%s", "\nWith no FILE, or when FILE is -, read standard input.\n\n"); exit(EXIT_FAILURE); } +void version() { + printf("mdp %d.%d\n", MAJOR_VERSION, MINOR_VERSION); + //TODO add copyright, license, written by + exit(EXIT_SUCCESS); +} + int main(int argc, char *argv[]) { // define command-line options struct option longopts[] = { - { "debug", no_argument, 0, 'd' }, - { "help", no_argument, 0, 'h' }, + { "debug", no_argument, 0, 'd' }, + { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; // parse command-line options int opt, debug = 0; - while ((opt = getopt_long(argc, argv, ":dh", longopts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, ":dhv", longopts, NULL)) != -1) { switch(opt) { case 'd': debug += 1; break; case 'h': usage(); break; + case 'v': version(); break; case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break; case '?': default : fprintf(stderr, "%s: option '%c' is invalid\n", argv[0], optopt); usage(); break; diff --git a/viewer.c b/viewer.c index 2d64b4e..d31fa71 100644 --- a/viewer.c +++ b/viewer.c @@ -3,7 +3,6 @@ #include // strchr #include -#include "include/parser.h" #include "include/viewer.h" static short white_ramp[24] = { 16, 232, 233, 234, 235, 236, -- 2.20.1