From e7acb77a45d3163e2e1b1da0558d50b7b28f9d8f Mon Sep 17 00:00:00 2001 From: Joursoir Date: Mon, 17 May 2021 07:28:28 +0000 Subject: ctimeline: use sub-module 'ui-common', remove handling command-line arguments --- ctimeline.c | 58 ++++++++++------------------------------------------------ 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/ctimeline.c b/ctimeline.c index c6f99d5..6ecbca3 100644 --- a/ctimeline.c +++ b/ctimeline.c @@ -4,6 +4,7 @@ #include #include "ctimeline.h" +#include "ui-common.h" #define COMMENT_CHAR '#' #define INIT_CAPACITY_LIST 8 @@ -151,56 +152,17 @@ void parse_config_file(FILE *f) string_release(value); } -void usage() -{ - printf("Usage: ctimeline [-h, --help | -i, --stdin]\n" - "Copyright (C) 2021 Aleksandr D. Goncharov (Joursoir)\n" - "Version: %s\n" - "License: GNU GPL version 3 + X11 License\n" - "This is free software: you are free to change and redistribute it.\n" - "This program comes with ABSOLUTELY NO WARRANTY.\n", APP_VERSION); -} - int main(int argc, char **argv) { - FILE *config; - if(argc < 2) { - config = fopen(CONFIG_PATH, "r"); - if(!config) { - perror(CONFIG_PATH); - return 1; - } - } - else if(strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { - usage(); - return 0; - } - else if(strcmp(argv[1], "--stdin") == 0 || strcmp(argv[1], "-i") == 0) - config = stdin; - else { - usage(); - return 1; - } + prepare_context(); + parse_config_file(CTIMELINE_CONFIG); + + print_http_headers(); + print_document_start(); + print_document_header(); + print_timelines(); + print_document_end(); - parse_config_file(config); - fclose(config); - - sort_branches_by_age(); - - printf("Content-type: text/html\n" - "\n" - "\n" - "\n" - " ctimeline\n" - " \n" - "\n" - "" - "\n" - "
\n"); - printf("
\n" - "\n" - "\n"); - - free(branches.list); + forget_context(); return 0; } -- cgit v1.2.3-18-g5258