From b6782ccf1fa9e0f1778b79bdaf2367c8a84a1d6c Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 25 Aug 2017 10:23:25 -0700 Subject: Silence warnings --- src/imlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index ecc44b5..cdc4fe7 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1262,7 +1262,7 @@ void feh_draw_actions(winwidget w) int i = 0; int num_actions = 0; int cur_action = 0; - char index[2]; + char index[3]; char *line; /* Count number of defined actions. This method sucks a bit since it needs -- cgit v1.2.3 From 72cafcccdeabe56809d26e0afac5de6d3c331150 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 5 Sep 2017 18:14:56 +0200 Subject: Work around ImageMagick bug when converting to file descriptors (#323) --- src/imlib.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index cdc4fe7..71b0a81 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -283,7 +283,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) static char *feh_magick_load_image(char *filename) { - char argv_fd[12]; + char *argv_fn; char *basename; char *tmpname; char *sfn; @@ -310,10 +310,17 @@ static char *feh_magick_load_image(char *filename) fd = mkstemp(sfn); - if (fd == -1) + if (fd == -1) { + free(sfn); return NULL; + } - snprintf(argv_fd, sizeof(argv_fd), "png:fd:%d", fd); + /* + * We could use png:fd:(whatever mkstemp returned) as target filename + * for convert, but this seems to be broken in some ImageMagick versions. + * So we resort to png:(sfn) instead. + */ + argv_fn = estrjoin(":", "png", sfn, NULL); if ((childpid = fork()) < 0) { weprintf("%s: Can't load with imagemagick. Fork failed:", filename); @@ -336,7 +343,7 @@ static char *feh_magick_load_image(char *filename) */ setpgid(0, 0); - execlp("convert", "convert", filename, argv_fd, NULL); + execlp("convert", "convert", filename, argv_fn, NULL); _exit(1); } else { @@ -369,6 +376,7 @@ static char *feh_magick_load_image(char *filename) childpid = 0; } + free(argv_fn); return sfn; } -- cgit v1.2.3 From 9b4341e12c6be32b654478cdf3a4e8a631c4e31f Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Mon, 25 Sep 2017 18:54:24 +0200 Subject: Remove unused variable --- src/imlib.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 71b0a81..290ec8f 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -207,10 +207,6 @@ int feh_load_image(Imlib_Image * im, feh_file * file) char *tmpname = NULL; char *real_filename = NULL; -#ifdef HAVE_LIBEXIF - ExifEntry *entry; -#endif - D(("filename is %s, image is %p\n", file->filename, im)); if (!file || !file->filename) -- cgit v1.2.3 From f49f0879e651d8c92468f232febe143db2cbcd36 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 26 Sep 2017 21:34:56 +0200 Subject: Fix dead code The check if buffer == NULL is always false, since buffer is an autoamtic variable allocated when entering the function. What we instead want to do is to check if the string is empty after the call to exif_get_info(), since that means we could not read any exif information. When the code once more is enabled, I discovered that we need to copy the information string into info_buf as well as into buffer, since it is the former that is used to print the exif information on top of the picture. Without this change, imlib warns about trying to write NULL strings. --- src/imlib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 290ec8f..dfb79aa 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -679,11 +679,12 @@ void feh_draw_exif(winwidget w) fn = feh_load_font(w); - if (buffer == NULL) + if (buffer[0] == '\0') { snprintf(buffer, EXIF_MAX_DATA, "%s", estrdup("Failed to run exif command")); - gib_imlib_get_text_size(fn, &buffer[0], NULL, &width, &height, IMLIB_TEXT_TO_RIGHT); - no_lines = 1; + gib_imlib_get_text_size(fn, buffer, NULL, &width, &height, IMLIB_TEXT_TO_RIGHT); + info_buf[no_lines] = estrdup(buffer); + no_lines++; } else { -- cgit v1.2.3 From ed0dd5a474117f337baecb2c5210ec464d120696 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Mon, 30 Oct 2017 00:09:11 +0100 Subject: imlib: Look up CA certificates by $CURL_CA_BUNDLE. Similar to the `curl` command-line tool. --- src/imlib.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index dfb79aa..82a9865 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -429,6 +429,10 @@ static char *feh_http_load_image(char *url) if (opt.insecure_ssl) { curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); + } else { + // Allow the user to specify custom CA certificates. + curl_easy_setopt(curl, CURLOPT_CAINFO, + getenv("CURL_CA_BUNDLE")); } res = curl_easy_perform(curl); -- cgit v1.2.3 From f6642257096c6fe0f78984d989790a3d9e1056fe Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 7 Nov 2017 07:52:52 +0100 Subject: Fix ~/.fehbg no longer being source-able (closes #342) --- ChangeLog | 6 ++++++ src/imlib.c | 2 +- src/wallpaper.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/imlib.c') diff --git a/ChangeLog b/ChangeLog index b5b814a..752b29d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue, 07 Nov 2017 07:51:48 +0100 + +* Release v2.22.1 + * Allow ~/.fehbg to be sourced (instead of executed) from other shell + scripts again (broken in 2.22) + Sat, 04 Nov 2017 14:55:38 +0100 Daniel Friesel * Release v2.22 diff --git a/src/imlib.c b/src/imlib.c index 82a9865..abdef4e 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -467,7 +467,7 @@ static char *feh_http_load_image(char *url) char *feh_http_load_image(char *url) { weprintf( - "Cannot load image %s\n Please recompile with libcurl support", + "Cannot load image %s\nPlease recompile feh with libcurl support", url ); return NULL; diff --git a/src/wallpaper.c b/src/wallpaper.c index 2a4743f..c9a3a05 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -436,7 +436,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, if ((fp = fopen(path, "w")) == NULL) { weprintf("Can't write to %s", path); } else { - fputs("#!/bin/sh\nexec ", fp); + fputs("#!/bin/sh\n", fp); if (use_filelist) { for (int i = 0; i < cmdargc; i++) { fputs(shell_escape(cmdargv[i]), fp); -- cgit v1.2.3 From edac0d1d056180ad7821ac21e09b2b53725b49f2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 7 Nov 2017 10:36:20 +0100 Subject: Only set CURLOPT_CAINFO if CURL_CA_BUNDLE is set --- src/imlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index abdef4e..5b96e8a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -429,7 +429,7 @@ static char *feh_http_load_image(char *url) if (opt.insecure_ssl) { curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); - } else { + } else if (getenv("CURL_CA_BUNDLE") != NULL) { // Allow the user to specify custom CA certificates. curl_easy_setopt(curl, CURLOPT_CAINFO, getenv("CURL_CA_BUNDLE")); -- cgit v1.2.3 From 0a006ed6767e42bbc1608400faf0fa9e008ff49c Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 27 Dec 2017 19:03:03 +0100 Subject: Add option to change the imlib cache size This option allows you to change the default imlib2 image cache size of 4 MiB. --- src/help.raw | 1 + src/imlib.c | 2 ++ src/options.c | 10 ++++++++++ src/options.h | 3 +++ 4 files changed, 16 insertions(+) (limited to 'src/imlib.c') diff --git a/src/help.raw b/src/help.raw index 2bc5986..37e0e71 100644 --- a/src/help.raw +++ b/src/help.raw @@ -94,6 +94,7 @@ OPTIONS --min-dimension WxH Only show images with width >= W and height >= H --max-dimension WxH Only show images with width <= W and height <= H --scroll-step COUNT scroll COUNT pixels when movement key is pressed + --cache-size NUM imlib cache size in mebibytes (0 .. 2048) MONTAGE MODE OPTIONS -X, --ignore-aspect Set thumbnail to specified width/height without diff --git a/src/imlib.c b/src/imlib.c index 5b96e8a..48808a1 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -131,6 +131,8 @@ void init_x_and_imlib(void) imlib_context_set_operation(IMLIB_OP_COPY); wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False); + imlib_set_cache_size(opt.cache_size * 1024 * 1024); + /* Initialise random numbers */ srand(getpid() * time(NULL) % ((unsigned int) -1)); diff --git a/src/options.c b/src/options.c index 1ed5b54..c874832 100644 --- a/src/options.c +++ b/src/options.c @@ -68,6 +68,7 @@ void init_parse_options(int argc, char **argv) opt.jump_on_resort = 1; opt.screen_clip = 1; + opt.cache_size = 4; #ifdef HAVE_LIBXINERAMA /* if we're using xinerama, then enable it by default */ opt.xinerama = 1; @@ -410,6 +411,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"xinerama-index", 1, 0, 239}, {"insecure" , 0, 0, 240}, {"no-recursive" , 0, 0, 241}, + {"cache-size" , 1, 0, 243}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; @@ -772,6 +774,14 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) break; case 241: opt.recursive = 0; + break; + case 243: + opt.cache_size = atoi(optarg); + if (opt.cache_size < 0) + opt.cache_size = 0; + if (opt.cache_size > 2048) + opt.cache_size = 2048; + break; default: break; } diff --git a/src/options.h b/src/options.h index 4e2703e..c6959c8 100644 --- a/src/options.h +++ b/src/options.h @@ -117,6 +117,9 @@ struct __fehoptions { /* signed in case someone wants to invert scrolling real quick */ int scroll_step; + // imlib cache size in mebibytes + int cache_size; + unsigned int min_width, min_height, max_width, max_height; unsigned char mode; -- cgit v1.2.3 From 91b331f0fa6999dff69fa1da90a8816b8d855ccc Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 28 Dec 2017 19:04:20 +0100 Subject: Always check file modification time before loading images from cache --- src/imlib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 48808a1..73b7039 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -256,6 +256,16 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(0); } + /* + * By default, Imlib2 unconditionally loads a cached file without checking + * if it was modified on disk. However, feh (or rather its users) should + * expect image changes to appear at the next reload. So we tell Imlib2 to + * always check the file modification time and only use a cached image if + * the mtime was not changed. The performance penalty is usually negligible. + */ + imlib_context_set_image(*im); + imlib_image_set_changes_on_disk(); + #ifdef HAVE_LIBEXIF int orientation = 0; ExifData *exifData = exif_data_new_from_file(file->filename); -- cgit v1.2.3 From 394517d1c66783c4e1d044f79df9ef1703a6f5db Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 20 Jan 2018 11:25:09 +0100 Subject: Fix the --magick-timeout handling * Prevents nasty loading loops * Prevents zombie subprocesses * Fixes the conversion timeout detection routine --- src/imlib.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 73b7039..6de6bdb 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -231,7 +231,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if ((image_source != SRC_IMLIB) && tmpname) { *im = imlib_load_image_with_error_return(tmpname, &err); - if (im) { + if (!err && im) { real_filename = file->filename; file->filename = tmpname; feh_file_info_load(file, *im); @@ -240,7 +240,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) file->ed = exif_get_data(tmpname); #endif } - if ((image_source == SRC_MAGICK) || !opt.keep_http) + if ((image_source != SRC_HTTP) || !opt.keep_http) unlink(tmpname); free(tmpname); @@ -357,30 +357,17 @@ static char *feh_magick_load_image(char *filename) else { alarm(opt.magick_timeout); waitpid(childpid, &status, 0); - alarm(0); - if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { - close(fd); + kill(childpid, SIGKILL); + if (opt.magick_timeout > 0 && !alarm(0)) { unlink(sfn); free(sfn); sfn = NULL; if (!opt.quiet) { - if (WIFSIGNALED(status)) - weprintf("%s - Conversion took too long, skipping", - filename); + weprintf("%s - Conversion took too long, skipping", filename); } - - /* - * Reap child. The previous waitpid call was interrupted by - * alarm, but convert doesn't terminate immediately. - * XXX - * normally, if (WIFSIGNALED(status)) waitpid(childpid, &status, 0); - * would suffice. However, as soon as feh has its own window, - * this doesn't work anymore and the following workaround is - * required. Hm. - */ - waitpid(-1, &status, 0); } + close(fd); childpid = 0; } -- cgit v1.2.3 From 5e75b5ef3e7d0270913c04645398bc3596c2a90a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 14 Feb 2018 22:33:38 +0100 Subject: Only check image dimensions on the fly in multiwindow and slideshow mode This introduces a new feh_should_ignore_image function which is called at appropriate places in those modes to skip images which are loadable but undesired. --- src/feh.h | 1 + src/filelist.c | 12 +++++++++++- src/imlib.c | 12 ++++++++++++ src/options.c | 2 ++ src/options.h | 1 + src/slideshow.c | 14 ++++++-------- src/winwidget.c | 2 +- 7 files changed, 34 insertions(+), 10 deletions(-) (limited to 'src/imlib.c') diff --git a/src/feh.h b/src/feh.h index bfd71db..60baade 100644 --- a/src/feh.h +++ b/src/feh.h @@ -133,6 +133,7 @@ void init_list_mode(void); void init_loadables_mode(void); void init_unloadables_mode(void); void feh_clean_exit(void); +int feh_should_ignore_image(Imlib_Image * im); int feh_load_image(Imlib_Image * im, feh_file * file); void show_mini_usage(void); void slideshow_change_image(winwidget winwid, int change, int render); diff --git a/src/filelist.c b/src/filelist.c index 0066efd..9a4af27 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -464,7 +464,17 @@ int feh_cmp_format(void *file1, void *file2) void feh_prepare_filelist(void) { - if (opt.list || opt.preload || opt.customlist || (opt.sort > SORT_MTIME)) { + /* + * list and customlist mode as well as the somewhat more fancy sort modes + * need access to file infos. Preloading them is also useful for + * list/customlist as --min-dimension/--max-dimension may filter images + * which should not be processed. + * Finally, if --min-dimension/--max-dimension (-> opt.filter_by_dimensions) + * is set and we're in thumbnail mode, we need to filter images first so + * we can create a properly sized thumbnail list. + */ + if (opt.list || opt.preload || opt.customlist || (opt.sort > SORT_MTIME) + || (opt.filter_by_dimensions && (opt.index || opt.collage || opt.thumbs || opt.bgmode))) { /* For these sort options, we have to preload images */ filelist = feh_file_info_preload(filelist); if (!gib_list_length(filelist)) diff --git a/src/imlib.c b/src/imlib.c index 6de6bdb..d9c5cd0 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -139,6 +139,18 @@ void init_x_and_imlib(void) return; } +int feh_should_ignore_image(Imlib_Image * im) +{ + if (opt.filter_by_dimensions) { + unsigned int w = gib_imlib_image_get_width(im); + unsigned int h = gib_imlib_image_get_height(im); + if (w < opt.min_width || w > opt.max_width || h < opt.min_height || h > opt.max_height) { + return 1; + } + } + return 0; +} + int feh_load_image_char(Imlib_Image * im, char *filename) { feh_file *file; diff --git a/src/options.c b/src/options.c index bf5c67c..76d70c5 100644 --- a/src/options.c +++ b/src/options.c @@ -433,6 +433,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.debug = 1; break; case '<': + opt.filter_by_dimensions = 1; XParseGeometry(optarg, &discard, &discard, &opt.max_width, &opt.max_height); if (opt.max_width == 0) opt.max_width = UINT_MAX; @@ -440,6 +441,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.max_height = UINT_MAX; break; case '>': + opt.filter_by_dimensions = 1; XParseGeometry(optarg, &discard, &discard, &opt.min_width, &opt.min_height); break; case '.': diff --git a/src/options.h b/src/options.h index c6959c8..9bf2763 100644 --- a/src/options.h +++ b/src/options.h @@ -75,6 +75,7 @@ struct __fehoptions { unsigned char no_fehbg; unsigned char keep_zoom_vp; unsigned char insecure_ssl; + unsigned char filter_by_dimensions; char *output_file; char *output_dir; diff --git a/src/slideshow.c b/src/slideshow.c index 6ab56fa..d56c1b6 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -361,17 +361,15 @@ void slideshow_change_image(winwidget winwid, int change, int render) } if (winwidget_loadimage(winwid, FEH_FILE(current_file->data))) { - unsigned int w = gib_imlib_image_get_width(winwid->im); - unsigned int h = gib_imlib_image_get_height(winwid->im); - if (opt.min_width || opt.min_height || (opt.max_width != UINT_MAX) || (opt.max_height != UINT_MAX)) { - if (w < opt.min_width || w > opt.max_width || h < opt.min_height || h > opt.max_height) { - last = current_file; - continue; - } + int w = gib_imlib_image_get_width(winwid->im); + int h = gib_imlib_image_get_height(winwid->im); + if (feh_should_ignore_image(winwid->im)) { + last = current_file; + continue; } winwid->mode = MODE_NORMAL; winwid->file = current_file; - if ((winwid->im_w != (int)w) || (winwid->im_h != (int)h)) + if ((winwid->im_w != w) || (winwid->im_h != h)) winwid->had_resize = 1; winwidget_reset_image(winwid); winwid->im_w = w; diff --git a/src/winwidget.c b/src/winwidget.c index 3311383..9600465 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -115,7 +115,7 @@ winwidget winwidget_create_from_file(gib_list * list, char type) ret->file = list; ret->type = type; - if (winwidget_loadimage(ret, file) == 0) { + if ((winwidget_loadimage(ret, file) == 0) || feh_should_ignore_image(ret->im)) { winwidget_destroy(ret); return(NULL); } -- cgit v1.2.3 From 05e745a519248c1907340c7f5b0b7bc65f0409eb Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 19 Jan 2018 12:22:09 +0100 Subject: Utilize dcraw to preview RAW files Uses the camera-generated thumbnail to display RAW images that could otherwise not be loaded. --- src/imlib.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- src/options.c | 5 +++ src/options.h | 1 + 3 files changed, 108 insertions(+), 8 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index d9c5cd0..b6041fc 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -61,7 +61,9 @@ int num_xinerama_screens; int childpid = 0; +static int feh_file_is_raw(char *filename); static char *feh_http_load_image(char *url); +static char *feh_dcraw_load_image(char *filename); static char *feh_magick_load_image(char *filename); #ifdef HAVE_LIBXINERAMA @@ -216,8 +218,7 @@ void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err) int feh_load_image(Imlib_Image * im, feh_file * file) { Imlib_Load_Error err = IMLIB_LOAD_ERROR_NONE; - enum { SRC_IMLIB, SRC_HTTP, SRC_MAGICK } image_source = - SRC_IMLIB; + enum { SRC_IMLIB, SRC_HTTP, SRC_MAGICK, SRC_DCRAW } image_source = SRC_IMLIB; char *tmpname = NULL; char *real_filename = NULL; @@ -232,16 +233,23 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if ((tmpname = feh_http_load_image(file->filename)) == NULL) err = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; } + else if (opt.dcraw_timeout >= 0 && feh_file_is_raw(file->filename)) { + image_source = SRC_DCRAW; + tmpname = feh_dcraw_load_image(file->filename); + if (!tmpname) + err = IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT; + } else *im = imlib_load_image_with_error_return(file->filename, &err); - if ((err == IMLIB_LOAD_ERROR_UNKNOWN) - || (err == IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT)) { + if (opt.magick_timeout >= 0 && ( + (err == IMLIB_LOAD_ERROR_UNKNOWN) || + (err == IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT))) { image_source = SRC_MAGICK; tmpname = feh_magick_load_image(file->filename); } - if ((image_source != SRC_IMLIB) && tmpname) { + if (tmpname) { *im = imlib_load_image_with_error_return(tmpname, &err); if (!err && im) { real_filename = file->filename; @@ -301,6 +309,95 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(1); } +static int feh_file_is_raw(char *filename) +{ + childpid = fork(); + if (childpid == -1) { + perror("fork"); + return 0; + } + + if (childpid == 0) { + if (opt.quiet) { + int devnull = open("/dev/null", O_WRONLY); + dup2(devnull, 1); + dup2(devnull, 2); + } + execlp("dcraw", "dcraw", "-i", filename, NULL); + _exit(1); + } else { + int status; + do { + waitpid(childpid, &status, WUNTRACED); + if (WIFEXITED(status)) { + return !WEXITSTATUS(status); + } + } while (!WIFEXITED(status) && !WIFSIGNALED(status)); + } + + return 0; +} + +static char *feh_dcraw_load_image(char *filename) +{ + char *basename; + char *tmpname; + char *sfn; + int fd = -1; + + basename = strrchr(filename, '/'); + + if (basename == NULL) + basename = filename; + else + basename++; + + tmpname = feh_unique_filename("/tmp/", basename); + + if (strlen(tmpname) > (NAME_MAX-6)) + tmpname[NAME_MAX-7] = '\0'; + + sfn = estrjoin("_", tmpname, "XXXXXX", NULL); + free(tmpname); + + fd = mkstemp(sfn); + + if (fd == -1) { + free(sfn); + return NULL; + } + + childpid = fork(); + if (childpid == -1) { + weprintf("%s: Can't load with dcraw. Fork failed:", filename); + unlink(sfn); + free(sfn); + close(fd); + return NULL; + } else if (childpid == 0) { + + close(1); + dup(fd); + close(fd); + + alarm(opt.dcraw_timeout); + execlp("dcraw", "dcraw", "-c", "-e", filename, NULL); + _exit(1); + } + + int status; + waitpid(-1, &status, 0); + if (WIFSIGNALED(status)) { + unlink(sfn); + free(sfn); + sfn = NULL; + if (!opt.quiet) + weprintf("%s - Conversion took too long, skipping", filename); + } + + return sfn; +} + static char *feh_magick_load_image(char *filename) { char *argv_fn; @@ -310,9 +407,6 @@ static char *feh_magick_load_image(char *filename) int fd = -1, devnull = -1; int status; - if (opt.magick_timeout < 0) - return NULL; - basename = strrchr(filename, '/'); if (basename == NULL) diff --git a/src/options.c b/src/options.c index 3d11482..29ce836 100644 --- a/src/options.c +++ b/src/options.c @@ -55,6 +55,7 @@ void init_parse_options(int argc, char **argv) opt.display = 1; opt.aspect = 1; opt.slideshow_delay = 0.0; + opt.dcraw_timeout = -1; opt.magick_timeout = -1; opt.thumb_w = 60; opt.thumb_h = 60; @@ -415,6 +416,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"insecure" , 0, 0, 240}, {"no-recursive" , 0, 0, 241}, {"cache-size" , 1, 0, 243}, + {"dcraw-timeout" , 1, 0, 245}, {"version-sort" , 0, 0, 246}, {0, 0, 0, 0} }; @@ -781,6 +783,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) if (opt.cache_size > 2048) opt.cache_size = 2048; break; + case 245: + opt.dcraw_timeout = atoi(optarg); + break; case 246: opt.version_sort = 1; break; diff --git a/src/options.h b/src/options.h index d4de3c5..88121e6 100644 --- a/src/options.h +++ b/src/options.h @@ -129,6 +129,7 @@ struct __fehoptions { double slideshow_delay; + signed short dcraw_timeout; signed short magick_timeout; Imlib_Font menu_fn; -- cgit v1.2.3 From f8640490308f29de951b7b59f07be8b744f6e895 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 10 Mar 2018 10:03:39 +0100 Subject: Only set random seed once Fixes non-random behaviour when randomizing file lists several times per second. Closes #349 --- src/gib_list.c | 1 - src/imlib.c | 3 --- src/main.c | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/imlib.c') diff --git a/src/gib_list.c b/src/gib_list.c index 281f528..5384d98 100644 --- a/src/gib_list.c +++ b/src/gib_list.c @@ -360,7 +360,6 @@ gib_list_randomize(gib_list * list) { farray[i] = f; } - srand(getpid() * time(NULL) % ((unsigned int) -1)); for (i = 0; i < len - 1; i++) { r = i + rand() / (RAND_MAX / (len - i) + 1 ); diff --git a/src/imlib.c b/src/imlib.c index d9c5cd0..baaa64a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -133,9 +133,6 @@ void init_x_and_imlib(void) imlib_set_cache_size(opt.cache_size * 1024 * 1024); - /* Initialise random numbers */ - srand(getpid() * time(NULL) % ((unsigned int) -1)); - return; } diff --git a/src/main.c b/src/main.c index 840919f..534b89e 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,8 @@ int main(int argc, char **argv) { atexit(feh_clean_exit); + srand(getpid() * time(NULL) % ((unsigned int) -1)); + setup_signal_handlers(); init_parse_options(argc, argv); -- cgit v1.2.3 From e28fb4e9d5723c46b8c3c91e94e9c5789b609d80 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 11 May 2018 15:03:24 +0200 Subject: Use custom temporary directory for ImageMagick calls and clean it up afterwards --- man/feh.pre | 15 --------------- src/imlib.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 16 deletions(-) (limited to 'src/imlib.c') diff --git a/man/feh.pre b/man/feh.pre index a6b76ef..a358714 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -489,11 +489,6 @@ of zero causes to try indefinitely. By default, magick support is disabled. . -Note that feh may clutter -.Pa /tmp -with temporary files created by ImageMagick for each failed conversion attempt. -This is a known bug. -. .It Cm --max-dimension Ar width No x Ar height . Only show images with width <= @@ -1916,16 +1911,6 @@ as it could be. does not take window decorations into account and may therefore make the window slightly too large. . -.Pp -. -When enabled, -.Cm --magick-timeout -may clutter -.Pa /tmp -with temporary files produced by ImageMagick. -This happens whenever an image is not loaded due to the conversion taking -longer than the specified timeout. -. .Ss REPORTING BUGS . If you find a bug, please report it to diff --git a/src/imlib.c b/src/imlib.c index baaa64a..28dc1a6 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -304,8 +304,10 @@ static char *feh_magick_load_image(char *filename) char *basename; char *tmpname; char *sfn; + char tempdir[] = "/tmp/.feh-magick-tmp-XXXXXX"; int fd = -1, devnull = -1; int status; + char created_tempdir = 0; if (opt.magick_timeout < 0) return NULL; @@ -339,6 +341,22 @@ static char *feh_magick_load_image(char *filename) */ argv_fn = estrjoin(":", "png", sfn, NULL); + /* + * By default, ImageMagick saves (occasionally lots of) temporary files + * in /tmp. It doesn't remove them if it runs into a timeout and is killed + * by us, no matter whether we use SIGINT, SIGTERM or SIGKILL. So, unless + * MAGICK_TMPDIR has already been set by the user, we create our own + * temporary directory for ImageMagick and remove its contents at the end of + * this function. + */ + if (getenv("MAGICK_TMPDIR") == NULL) { + if (mkdtemp(tempdir) == NULL) { + weprintf("%s: ImageMagick may leave temporary files in /tmp. mkdtemp failed:", filename); + } else { + created_tempdir = 1; + } + } + if ((childpid = fork()) < 0) { weprintf("%s: Can't load with imagemagick. Fork failed:", filename); unlink(sfn); @@ -360,6 +378,11 @@ static char *feh_magick_load_image(char *filename) */ setpgid(0, 0); + if (created_tempdir) { + // no error checking - this is a best-effort code path + setenv("MAGICK_TMPDIR", tempdir, 0); + } + execlp("convert", "convert", filename, argv_fn, NULL); _exit(1); } @@ -373,13 +396,39 @@ static char *feh_magick_load_image(char *filename) sfn = NULL; if (!opt.quiet) { - weprintf("%s - Conversion took too long, skipping", filename); + weprintf("%s: Conversion took too long, skipping", filename); } } close(fd); childpid = 0; } + if (created_tempdir) { + DIR *dir; + struct dirent *de; + if ((dir = opendir(tempdir)) == NULL) { + weprintf("%s: Cannot remove temporary ImageMagick files from %s:", filename, tempdir); + } else { + while ((de = readdir(dir)) != NULL) { + if (de->d_name[0] != '.') { + char *temporary_file_name = estrjoin("/", tempdir, de->d_name, NULL); + /* + * We assume that ImageMagick only creates temporary files and + * not directories. + */ + if (unlink(temporary_file_name) == -1) { + weprintf("unlink %s:", temporary_file_name); + } + free(temporary_file_name); + } + } + if (rmdir(tempdir) == -1) { + weprintf("rmdir %s:", tempdir); + } + } + closedir(dir); + } + free(argv_fn); return sfn; } -- cgit v1.2.3 From 3c675a64a5842f0fe824a22bc9d3af025c1d17fe Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 11 May 2018 20:51:24 +0200 Subject: Update copyright notice --- man/feh.pre | 2 +- src/collage.c | 2 +- src/debug.h | 2 +- src/events.c | 2 +- src/feh.h | 2 +- src/filelist.c | 2 +- src/imlib.c | 2 +- src/index.c | 2 +- src/index.h | 2 +- src/keyevents.c | 2 +- src/list.c | 2 +- src/main.c | 2 +- src/menu.c | 2 +- src/menu.h | 2 +- src/options.c | 2 +- src/options.h | 2 +- src/signals.c | 2 +- src/slideshow.c | 2 +- src/structs.h | 2 +- src/thumbnail.c | 2 +- src/thumbnail.h | 2 +- src/timers.c | 2 +- src/wallpaper.c | 2 +- src/wallpaper.h | 2 +- src/winwidget.c | 2 +- src/winwidget.h | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/imlib.c') diff --git a/man/feh.pre b/man/feh.pre index a358714..d2c2cea 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -1943,7 +1943,7 @@ Make zoom options more intuitive . Copyright (C) 1999, 2000 by Paul Duncan. Copyright (C) 1999, 2000 by Tom Gilbert (and various contributors). -Copyright (C) 2010-2016 by Daniel Friesel (and even more contributors). +Copyright (C) 2010-2018 by Daniel Friesel (and even more contributors). . .Pp . diff --git a/src/collage.c b/src/collage.c index 431d3b6..2a4d9f9 100644 --- a/src/collage.c +++ b/src/collage.c @@ -1,7 +1,7 @@ /* collage.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/debug.h b/src/debug.h index eb929e3..38cf83f 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1,7 +1,7 @@ /* debug.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/events.c b/src/events.c index 947e69f..4a24935 100644 --- a/src/events.c +++ b/src/events.c @@ -1,7 +1,7 @@ /* events.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/feh.h b/src/feh.h index 3e0cdda..009f45b 100644 --- a/src/feh.h +++ b/src/feh.h @@ -1,7 +1,7 @@ /* feh.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/filelist.c b/src/filelist.c index 08da331..eb8e294 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -1,7 +1,7 @@ /* filelist.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/imlib.c b/src/imlib.c index 28dc1a6..5be0539 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -1,7 +1,7 @@ /* imlib.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/index.c b/src/index.c index c8c34c5..ca1664b 100644 --- a/src/index.c +++ b/src/index.c @@ -1,7 +1,7 @@ /* index.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/index.h b/src/index.h index 08ab337..b022f1a 100644 --- a/src/index.h +++ b/src/index.h @@ -1,6 +1,6 @@ /* index.h -Copyright (C) 2011 Daniel Friesel. +Copyright (C) 2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/keyevents.c b/src/keyevents.c index 12a8eb9..689aebd 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -1,7 +1,7 @@ /* keyevents.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/list.c b/src/list.c index 09b23f4..2f6cf76 100644 --- a/src/list.c +++ b/src/list.c @@ -1,7 +1,7 @@ /* list.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/main.c b/src/main.c index 534b89e..f1fca24 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ /* main.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/menu.c b/src/menu.c index ddb2db1..2f8875d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,7 +1,7 @@ /* menu.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/menu.h b/src/menu.h index 403728f..b53b32f 100644 --- a/src/menu.h +++ b/src/menu.h @@ -1,7 +1,7 @@ /* menu.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/options.c b/src/options.c index bc95604..8ddf2fa 100644 --- a/src/options.c +++ b/src/options.c @@ -1,7 +1,7 @@ /* options.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/options.h b/src/options.h index ed8641a..61de5dc 100644 --- a/src/options.h +++ b/src/options.h @@ -1,7 +1,7 @@ /* options.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/signals.c b/src/signals.c index 8a3a8f7..c08d5df 100644 --- a/src/signals.c +++ b/src/signals.c @@ -1,6 +1,6 @@ /* signals.c -Copyright (C) 2010 by Daniel Friesel +Copyright (C) 2010-2018 by Daniel Friesel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/slideshow.c b/src/slideshow.c index 7bad2c9..0e560d8 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -1,7 +1,7 @@ /* slideshow.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/structs.h b/src/structs.h index 3942bc0..ce30eb9 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,7 +1,7 @@ /* structs.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/thumbnail.c b/src/thumbnail.c index 3e99bfb..cf38cfc 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -1,7 +1,7 @@ /* thumbnail.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/thumbnail.h b/src/thumbnail.h index f22ff77..09cd771 100644 --- a/src/thumbnail.h +++ b/src/thumbnail.h @@ -1,7 +1,7 @@ /* thumbnail.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/timers.c b/src/timers.c index 1cac94b..95fc9f8 100644 --- a/src/timers.c +++ b/src/timers.c @@ -1,7 +1,7 @@ /* timers.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/wallpaper.c b/src/wallpaper.c index 6aa5c6d..7cf2468 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -1,7 +1,7 @@ /* wallpaper.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/wallpaper.h b/src/wallpaper.h index 0921129..02a6997 100644 --- a/src/wallpaper.h +++ b/src/wallpaper.h @@ -1,7 +1,7 @@ /* wallpaper.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/winwidget.c b/src/winwidget.c index 7aae191..cd5a745 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -1,7 +1,7 @@ /* winwidget.c Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff --git a/src/winwidget.h b/src/winwidget.h index dd8489a..3d998b4 100644 --- a/src/winwidget.h +++ b/src/winwidget.h @@ -1,7 +1,7 @@ /* winwidget.h Copyright (C) 1999-2003 Tom Gilbert. -Copyright (C) 2010-2011 Daniel Friesel. +Copyright (C) 2010-2018 Daniel Friesel. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to -- cgit v1.2.3 From 607374d4c7f7a133d3d1c5c012a6a5af9e2e60bf Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 5 Aug 2018 13:57:45 +0200 Subject: Merge --dcraw-timeout and --magick-timeout into --conversion-timeout --- src/filelist.c | 8 ++++---- src/imlib.c | 10 +++++----- src/options.c | 10 +++++----- src/options.h | 3 +-- 4 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src/imlib.c') diff --git a/src/filelist.c b/src/filelist.c index eb8e294..b492965 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -574,7 +574,7 @@ gib_list *feh_read_filelist(char *filename) Imlib_Load_Error err = IMLIB_LOAD_ERROR_NONE; Imlib_Image tmp_im; struct stat st; - signed short tmp_magick_timeout; + signed short tmp_conversion_timeout; if (!filename) return(NULL); @@ -582,8 +582,8 @@ gib_list *feh_read_filelist(char *filename) /* * feh_load_image will fail horribly if filename is not seekable */ - tmp_magick_timeout = opt.magick_timeout; - opt.magick_timeout = -1; + tmp_conversion_timeout = opt.conversion_timeout; + opt.conversion_timeout = -1; if (!stat(filename, &st) && S_ISREG(st.st_mode)) { tmp_im = imlib_load_image_with_error_return(filename, &err); if (err == IMLIB_LOAD_ERROR_NONE) { @@ -594,7 +594,7 @@ gib_list *feh_read_filelist(char *filename) return NULL; } } - opt.magick_timeout = tmp_magick_timeout; + opt.conversion_timeout = tmp_conversion_timeout; errno = 0; diff --git a/src/imlib.c b/src/imlib.c index 2d1b47a..f41cdcd 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -230,7 +230,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if ((tmpname = feh_http_load_image(file->filename)) == NULL) err = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; } - else if (opt.dcraw_timeout >= 0 && feh_file_is_raw(file->filename)) { + else if (opt.conversion_timeout >= 0 && feh_file_is_raw(file->filename)) { image_source = SRC_DCRAW; tmpname = feh_dcraw_load_image(file->filename); if (!tmpname) @@ -239,7 +239,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) else *im = imlib_load_image_with_error_return(file->filename, &err); - if (opt.magick_timeout >= 0 && ( + if (opt.conversion_timeout >= 0 && ( (err == IMLIB_LOAD_ERROR_UNKNOWN) || (err == IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT))) { image_source = SRC_MAGICK; @@ -377,7 +377,7 @@ static char *feh_dcraw_load_image(char *filename) dup(fd); close(fd); - alarm(opt.dcraw_timeout); + alarm(opt.conversion_timeout); execlp("dcraw", "dcraw", "-c", "-e", filename, NULL); _exit(1); } @@ -481,10 +481,10 @@ static char *feh_magick_load_image(char *filename) _exit(1); } else { - alarm(opt.magick_timeout); + alarm(opt.conversion_timeout); waitpid(childpid, &status, 0); kill(childpid, SIGKILL); - if (opt.magick_timeout > 0 && !alarm(0)) { + if (opt.conversion_timeout > 0 && !alarm(0)) { unlink(sfn); free(sfn); sfn = NULL; diff --git a/src/options.c b/src/options.c index b0d67cd..af0f07d 100644 --- a/src/options.c +++ b/src/options.c @@ -55,8 +55,7 @@ void init_parse_options(int argc, char **argv) opt.display = 1; opt.aspect = 1; opt.slideshow_delay = 0.0; - opt.dcraw_timeout = -1; - opt.magick_timeout = -1; + opt.conversion_timeout = -1; opt.thumb_w = 60; opt.thumb_h = 60; opt.thumb_redraw = 10; @@ -416,7 +415,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"insecure" , 0, 0, 240}, {"no-recursive" , 0, 0, 241}, {"cache-size" , 1, 0, 243}, - {"dcraw-timeout" , 1, 0, 245}, + {"conversion-timeout" , 1, 0, 245}, {"version-sort" , 0, 0, 246}, {"offset" , 1, 0, 247}, {0, 0, 0, 0} @@ -695,7 +694,8 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.index_info = estrdup(optarg); break; case 208: - opt.magick_timeout = atoi(optarg); + weprintf("--magick-timeout is deprecated, please use --conversion-timeout instead"); + opt.conversion_timeout = atoi(optarg); break; case 209: opt.actions[1] = estrdup(optarg); @@ -786,7 +786,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.cache_size = 2048; break; case 245: - opt.dcraw_timeout = atoi(optarg); + opt.conversion_timeout = atoi(optarg); break; case 246: opt.version_sort = 1; diff --git a/src/options.h b/src/options.h index 741b0c7..936b4bd 100644 --- a/src/options.h +++ b/src/options.h @@ -133,8 +133,7 @@ struct __fehoptions { double slideshow_delay; - signed short dcraw_timeout; - signed short magick_timeout; + signed int conversion_timeout; Imlib_Font menu_fn; }; -- cgit v1.2.3