summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2019-10-11 17:20:47 +0200
committerKim Woelders <kim@woelders.dk>2019-10-13 16:12:28 +0200
commitab918a65acf8d8ebd0c7211123a1ccd93dccd5fb (patch)
tree3fe55b033ba36f3e6b627ae8dd3f3e993d7b7f64
parentcb1b2482a3f8005237772c597813ce53e974f21f (diff)
downloadimlib2-ab918a65acf8d8ebd0c7211123a1ccd93dccd5fb.tar.gz
Miscellaneous imlib_test_load tweaks
- Error messages to stdout (not stderr). - Check progress call. - Break on error option.
-rw-r--r--src/bin/imlib2_test_load.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/bin/imlib2_test_load.c b/src/bin/imlib2_test_load.c
index 81519ec..263b200 100644
--- a/src/bin/imlib2_test_load.c
+++ b/src/bin/imlib2_test_load.c
@@ -9,6 +9,9 @@
#define PROG_NAME "imlib2_test_load"
+static char progress_called;
+static char break_on_error;
+
static void
usage(int exit_status)
{
@@ -19,15 +22,46 @@ usage(int exit_status)
exit(exit_status);
}
+static int
+progress(Imlib_Image im, char percent, int update_x, int update_y,
+ int update_w, int update_h)
+{
+ progress_called = 1;
+ return 1; /* Continue */
+}
+
int
main(int argc, char **argv)
{
+ const char *s;
Imlib_Image im;
Imlib_Load_Error lerr;
+ break_on_error = 0;
+
+ for (;;)
+ {
+ argv++;
+ argc--;
+ if (argc <= 0)
+ break;
+ s = argv[0];
+ if (*s++ != '-')
+ break;
+ switch (*s++)
+ {
+ case 'e':
+ break_on_error += 1;
+ break;
+ }
+ }
+
if (argc <= 1)
usage(0);
+ imlib_context_set_progress_function(progress);
+ imlib_context_set_progress_granularity(10);
+
for (;;)
{
argc--;
@@ -35,16 +69,25 @@ main(int argc, char **argv)
if (argc <= 0)
break;
+ progress_called = 0;
+
printf("Loading image: '%s'\n", argv[0]);
im = imlib_load_image_with_error_return(argv[0], &lerr);
if (!im)
{
- fprintf(stderr, PROG_NAME ": Error %d loading image: %s\n", lerr,
- argv[0]);
+ printf("*** Error %d loading image: %s\n", lerr, argv[0]);
+ if (break_on_error & 2)
+ break;
continue;
}
imlib_context_set_image(im);
imlib_free_image_and_decache();
+ if (!progress_called)
+ {
+ printf("*** No progress during image load\n");
+ if (break_on_error & 1)
+ break;
+ }
}
return 0;