X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=mdp.c;h=9a71cd0fd569c51362b8084c444957c4e2985353;hb=d4843ea375360f37e965709e73c0fbd68e302dca;hp=b12ea976f3db34bcec8af39352d269bac82c222f;hpb=0f870f29388a36d32ec9ffaabe9ffe03edc038c0;p=smdp.git diff --git a/mdp.c b/mdp.c index b12ea97..9a71cd0 100644 --- a/mdp.c +++ b/mdp.c @@ -1,3 +1,22 @@ +/* + * mdp -- A command-line based markdown presentation tool. + * Copyright (C) 2014 Michael Goehler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include #include #include @@ -9,35 +28,47 @@ void usage() { 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", " -d, --debug enable debug messages on STDERR\n"); + fprintf(stderr, "%s", " add it multiple times to increases debug level\n"); + fprintf(stderr, "%s", " -f, --nofade disable color fading in 256 color mode\n"); + fprintf(stderr, "%s", " -h, --help display this help and exit\n"); + fprintf(stderr, "%s", " -t, --notrans disable transparency in transparent terminal\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 + printf("Copyright (C) 2014 Michael Goehler\n"); + printf("License GPLv3+: GNU GPL version 3 or later .\n"); + printf("This is free software: you are free to change and redistribute it.\n"); + printf("There is NO WARRANTY, to the extent permitted by law.\n"); + printf("\nWritten by Michael Goehler and others, see .\n"); exit(EXIT_SUCCESS); } int main(int argc, char *argv[]) { + int notrans = 0; + int nofade = 0; // define command-line options struct option longopts[] = { { "debug", no_argument, 0, 'd' }, + { "nofade", no_argument, 0, 'f' }, { "help", no_argument, 0, 'h' }, + { "notrans", no_argument, 0, 't' }, { "version", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; // parse command-line options int opt, debug = 0; - while ((opt = getopt_long(argc, argv, ":dhv", longopts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, ":dfhtv", longopts, NULL)) != -1) { switch(opt) { case 'd': debug += 1; break; + case 'f': nofade = 1; break; case 'h': usage(); break; + case 't': notrans = 1; break; case 'v': version(); break; case ':': fprintf(stderr, "%s: '%c' requires an argument\n", argv[0], optopt); usage(); break; case '?': @@ -70,13 +101,14 @@ int main(int argc, char *argv[]) { deck_t *deck; deck = markdown_load(input); - //TODO close file + // close file + fclose(input); if(debug > 0) { markdown_debug(deck, debug); } - ncurses_display(deck, 0, 0); + ncurses_display(deck, notrans, nofade); return(EXIT_SUCCESS); }