@@ 163,8 163,21 @@ get_absolute_url(char *url, char *base_url)
int
-main()
+main(int argc, char *argv[])
{
+ /* Must have exactly one argument */
+ if (argc != 2) {
+ fprintf(stderr, "Usage: gemlogger /path/to/config/file.gmi");
+ return 1;
+ }
+
+ /* Open config file */
+ FILE *config_fp = fopen(argv[1], "r");
+ if (!config_fp) {
+ fprintf(stderr, "Failed to access config file %s.\n", argv[1]);
+ return 1;
+ }
+
/* Setup for using gmni */
struct addrinfo hints = {0};
struct gemini_options opts = {
@@ 177,13 190,6 @@ main()
opts.ssl_ctx = SSL_CTX_new(TLS_method());
gemini_tofu_init(&cfg.tofu, opts.ssl_ctx, &tofu_callback, &cfg);
- /* Open config file */
- const char *config_path = "/home/callum/gemlogger-test.gmi";
- FILE *config_fp = fopen(config_path, "r");
- if (!config_fp) {
- fprintf(stderr, "Failed to access config file %s.\n", config_path);
- goto finish;
- }
/* Make a gmni response from the config file */
BIO *file = BIO_new_fp(config_fp, BIO_CLOSE);
struct gemini_response config_resp;
@@ 237,7 243,6 @@ main()
gemini_token_finish(&config_tok);
gemini_parser_finish(&config_parser);
gemini_response_finish(&config_resp);
-finish:
gemini_tofu_finish(&cfg.tofu);
SSL_CTX_free(opts.ssl_ctx);
return 0;