diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components.c | 4 | ||||
| -rw-r--r-- | src/config.c | 7 | ||||
| -rw-r--r-- | src/revela.c | 24 | ||||
| -rw-r--r-- | src/site.c | 5 | ||||
| -rw-r--r-- | src/tests/config.c | 1 | 
5 files changed, 20 insertions, 21 deletions
| diff --git a/src/components.c b/src/components.c index fc3bab5..aeb14b1 100644 --- a/src/components.c +++ b/src/components.c @@ -167,8 +167,8 @@ image_new(char *src, const struct stat *pstat, struct album *album)  	image->exif_data = exif_data_new_from_file(image->source);  	image->modtime = pstat->st_mtim;  	image_set_date(image, pstat); -	image->map = roscha_object_new(hmap_new_with_cap(8)); -	image->thumb = roscha_object_new(hmap_new_with_cap(4)); +	image->map = roscha_object_new(hmap_new_with_cap(16)); +	image->thumb = roscha_object_new(hmap_new_with_cap(8));  	image->modified = false;  	return image; diff --git a/src/config.c b/src/config.c index 1bc531f..a570104 100644 --- a/src/config.c +++ b/src/config.c @@ -126,12 +126,6 @@ site_config_keyvalue_handler(struct parcini_line *parsed, void *dst)  				&config->base_url)?  			KV_HANDLER_OK : KV_HANDLER_BADVALUE;  	} -	if (MATCHSK("", "max_previews", parsed)) { -		return parcini_value_handle(&parsed->value, PARCINI_VALUE_INTEGER, -				&config->max_previews)? -			KV_HANDLER_OK : KV_HANDLER_BADVALUE; -	} -  out:  	return KV_HANDLER_NOMATCH; @@ -232,7 +226,6 @@ site_config_init(void)  {  	struct site_config *config = calloc(1, sizeof *config);  	if (config != NULL) { -		config->max_previews = 10;  		config->images = (struct image_config) {  			.strip = true,  			.quality = 80, diff --git a/src/revela.c b/src/revela.c index 32867c6..e21ae02 100644 --- a/src/revela.c +++ b/src/revela.c @@ -10,13 +10,18 @@  #include "config.h"  #include "bstree.h" +#ifndef VERSION +#define VERSION "0.1.0" +#endif +  static const char *usage = -	"Usage: %s [options] [-i <input dir>] -o <output dir>\n"; +	"Usage: %s [OPTIONS] -o <output dir>\n" +	"For more information consult `man 1 revela`\n";  static struct site site = {0};  static enum log_level loglvl = LOG_DETAIL; -static void +static inline void  bad_arguments(const char *cmd)  {  	fprintf(stderr, usage, cmd); @@ -28,17 +33,23 @@ parse_arguments(int argc, char *argv[])  {  	int opt;  	char *cmd = argv[0]; -	while ((opt = getopt(argc, argv, "i:o:n")) != -1) { +	while ((opt = getopt(argc, argv, "i:o:nhV")) != -1) {  		switch (opt) {  		case 'i':  			site.root_dir = strdup(optarg);  			break;  		case 'o': -			site.output_dir = optarg; +			site.output_dir = realpath(optarg, NULL);  			break;  		case 'n':  			site.dry_run = true;  			break; +		case 'h': +			printf(usage, cmd); +			exit(0); +		case 'V': +			printf("revela "VERSION"\n"); +			exit(0);  		default:  			bad_arguments(cmd);  		} @@ -51,8 +62,6 @@ parse_arguments(int argc, char *argv[])  int  main(int argc, char *argv[])  { -	int ret = EXIT_SUCCESS; -  	parse_arguments(argc, argv);  #ifdef DEBUG @@ -61,7 +70,7 @@ main(int argc, char *argv[])  	log_set_verbosity(loglvl);  #endif -	ret = site_init(&site) && site_load(&site) && site_build(&site)  +	int ret = site_init(&site) && site_load(&site) && site_build(&site)   		? EXIT_SUCCESS : EXIT_FAILURE;  	if (site.dry_run) { @@ -69,5 +78,6 @@ main(int argc, char *argv[])  	}  	site_deinit(&site); +  	return ret;  } @@ -86,10 +86,6 @@ optimize_image(MagickWand *wand, const char *dst,  		const struct image_config *conf,   		const struct timespec *srcmtim, bool dry)  { -	int update = file_is_uptodate(dst, srcmtim); -	if (update == -1) return false; -	if (update == 1) return true; -  	log_printl(LOG_DETAIL, "Converting %s", dst);  	if (dry) goto out; @@ -413,6 +409,7 @@ site_deinit(struct site *site)  	site_config_destroy(site->config);  	free(site->content_dir);  	free(site->root_dir); +	free(site->output_dir);  	if (site->wand != NULL) {  		DestroyMagickWand(site->wand);  		DestroyMagick(); diff --git a/src/tests/config.c b/src/tests/config.c index 64a4da8..79e5358 100644 --- a/src/tests/config.c +++ b/src/tests/config.c @@ -15,7 +15,6 @@ test_site_config_read_ini(void)  	asserteq(site_config_read_ini(TESTS_DIR, config), true);  	asserteq(strcmp(config->title, "An example gallery"), 0);  	asserteq(strcmp(config->base_url, "http://www.example.com/photos"), 0); -	asserteq(config->max_previews, 20);  	asserteq(config->images.strip, false);  	asserteq(config->images.quality, 80);  	asserteq(config->images.max_width, 3000); | 
