static void scrot_parse_option_array(int argc, char **argv) { static char stropts[] = "bcd:e:hmq:st:v+:"; static struct option lopts[] = { /* actions */ {"help", 0, 0, 'h'}, /* okay */ {"version", 0, 0, 'v'}, /* okay */ {"count", 0, 0, 'c'}, {"select", 0, 0, 's'}, {"border", 0, 0, 'b'}, {"multidisp", 0, 0, 'm'}, /* toggles */ {"thumb", 1, 0, 't'}, {"quality", 1, 0, 'q'}, {"exec", 1, 0, 'e'}, {"debug-level", 1, 0, '+'}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; /* Now to pass some optionarinos */ while ((optch = getopt_long(argc, argv, stropts, lopts, &cmdx)) != EOF) { switch (optch) { case 0: break; case 'h': show_usage(); break; case 'v': show_version(); break; case 'b': opt.border = 1; break; case 'e': opt.exec = gib_estrdup(optarg); break; case 'm': opt.multidisp = 1; break; case 'q': opt.quality = atoi(optarg); break; case 's': opt.select = 1; break; case '+': opt.debug_level = atoi(optarg); break; case 'c': opt.countdown = 1; break; case 't': options_parse_thumbnail(optarg); break; default: break; } } /* Now the leftovers, which must be files */ if (optind < argc) { while (optind < argc) { /* If recursive is NOT set, but the only argument is a directory name, we grab all the files in there, but not subdirs */ if (!opt.output_file) { opt.output_file = argv[optind++]; if (opt.thumb) opt.thumb_file = name_thumbnail(opt.output_file); } else gib_weprintf("unrecognised option %s\n", argv[optind++]); } } /* So that we can safely be called again */ optind = 1; }
int gib_imlib_load_image(Imlib_Image * im, char *filename) { Imlib_Load_Error err; imlib_context_set_progress_function(NULL); if (!filename) return (0); *im = imlib_load_image_with_error_return(filename, &err); if ((err) || (!im)) { /* Check error code */ switch (err) { case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: gib_weprintf("%s - File does not exist", filename); break; case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: gib_weprintf("%s - Directory specified for image filename", filename); break; case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: gib_weprintf("%s - No read access to directory", filename); break; case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: gib_weprintf("%s - No Imlib2 loader for that file format", filename); break; case IMLIB_LOAD_ERROR_PATH_TOO_LONG: gib_weprintf("%s - Path specified is too long", filename); break; case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: gib_weprintf("%s - Path component does not exist", filename); break; case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: gib_weprintf("%s - Path component is not a directory", filename); break; case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: gib_weprintf("%s - Path points outside address space", filename); break; case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: gib_weprintf("%s - Too many levels of symbolic links", filename); break; case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: gib_eprintf("While loading %s - Out of memory", filename); break; case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS: gib_eprintf("While loading %s - Out of file descriptors", filename); break; case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: gib_weprintf("%s - Cannot write to directory", filename); break; case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: gib_weprintf("%s - Cannot write - out of disk space", filename); break; case IMLIB_LOAD_ERROR_UNKNOWN: default: gib_weprintf ("While loading %s - Unknown error. Attempting to continue", filename); break; } return (0); } return (1); }