/* * Program name: shim * Version: 1.1 beta * Source file: shim_func.h (function prototypes, included in shim.c) * Description: A simple command line utility to show graphical images * of various formats. Use for more information. * * Comments: In general functions return -1 on failure and 0 on success. * * Copyright (C) 2005-2007 Jeroen van Aart * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * holds data used in multiple functions */ struct Shim_Data { SDL_Surface *screen; /* main surface */ SDL_Surface *image; /* will hold the image to be displayed */ char *name; /* the name of the image file to be loaded */ int fullscreen; /* if 0 then display in window, if 1 then display fullscreen */ int slideshow; /* if 0 then no slideshow, if 1 then slideshow, decided by option -s */ int always; /* if 0 then do not continue forever with slideshow, if 1 then do so, decided by option -a in combination with -s */ int sec; /* amount of seconds between image displays in slideshow mode */ int msec; /* amount of miliseconds calculated from amount of seconds */ int angle; /* holds the angle of rotation, 0=no rotation, 90, 270 */ double zoom; /* if set to 0.5 image will be zoomed to half size, if 2 it will be zoomed to double size */ int smooth; /* if set to 1 anti-aliasing is used with zooming/rotating */ int output; /* if set to 1 images will be saved to a file instead of displayed */ }; /* graciously exit the program */ void cleanened ( struct Shim_Data *shimdata ); /* calls checkevent inside a loop */ void eventloop ( struct Shim_Data *shimdata ); /* shows an image, returns -1 on failure and 0 on success */ int showimage ( struct Shim_Data *shimdata, char *name ); /* shows an image when the -s option(slideshow) has been used */ void showimage_slide ( struct Shim_Data *shimdata, int argc, char **argv ); /* * shos an image possibly zoomed and/or rotated * return 0 on success, -1 on failure */ int showimage_zoom ( struct Shim_Data *shimdata, double zoom, int angle ); /* process the arguments given at program startup, if any */ void process_arguments ( struct Shim_Data *shimdata, int arg, char **argv ); /* handles the -h(help) argument */ void print_help ( char *name ); /* when program is started without any arguments this will print a short help text */ void print_shorthelp ( char *name ); /* during msec amount of time this function repeatedely calls checkevent_poll and then waits for a while using delay, used with -s option(slideshow) */ void do_delay ( struct Shim_Data *shimdata, int msec ); /* show version information when -v option(version) has been given */ void do_version ( void ); /* check the arguments given with the -s option(slideshow) */ int process_s ( int argc, char **argv ); /* Checks if the given string has only numeric values or not, returns -1 if string contains more than just numeric values, else 0 */ int checkifnum ( int l, char **argv ); /* setup and prepare SDL for usage */ int setupsdl ( void ); /* waits for an event to happen and acts accordingly */ int checkevent ( struct Shim_Data *shimdata ); /* polls for an event which may have happened and acts accordingly */ int checkevent_poll ( struct Shim_Data *shimdata );