gifsicle  1.92
About: Gifsicle is a UNIX command-line tool for creating, editing, and getting information about GIF images and animations.
  Fossies Dox: gifsicle-1.92.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

gifview.c File Reference
#include <config.h>
#include <lcdfgif/gifx.h>
#include <lcdf/clp.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
Include dependency graph for gifview.c:

Go to the source code of this file.

Data Structures

struct  Gt_Viewer
 

Macros

#define EXTERN   extern
 
#define MICRO_PER_SEC   1000000
 
#define xwADDTIME(result, a, b)
 
#define xwSUBTIME(result, a, b)
 
#define xwSETMINTIME(a, b)
 
#define xwTIMEGEQ(a, b)
 
#define xwTIMEGT(a, b)
 
#define xwTIMELEQ0(a)   ((a).tv_sec < 0 || ((a).tv_sec == 0 && (a).tv_usec <= 0))
 
#define xwGETTIMEOFDAY(a)   gettimeofday((a), 0)
 
#define xwGETTIME(a)   do { xwGETTIMEOFDAY(&(a)); xwSUBTIME((a), (a), genesis_time); } while (0)
 
#define DISPLAY_OPT   300
 
#define UNOPTIMIZE_OPT   301
 
#define VERSION_OPT   302
 
#define ANIMATE_OPT   303
 
#define GEOMETRY_OPT   304
 
#define NAME_OPT   305
 
#define HELP_OPT   306
 
#define WINDOW_OPT   307
 
#define INSTALL_COLORMAP_OPT   308
 
#define INTERACTIVE_OPT   309
 
#define BACKGROUND_OPT   310
 
#define NEW_WINDOW_OPT   311
 
#define TITLE_OPT   312
 
#define MIN_DELAY_OPT   313
 
#define FALLBACK_DELAY_OPT   314
 
#define MEMORY_LIMIT_OPT   315
 
#define WINDOW_TYPE   (Clp_ValFirstUser)
 
#define VISUAL_CLASS   class
 

Typedefs

typedef struct Gt_Viewer Gt_Viewer
 

Functions

int gettimeofday (struct timeval *, struct timezone *)
 
void fatal_error (const char *format,...)
 
void error (const char *format,...)
 
void warning (const char *format,...)
 
void short_usage (void)
 
void usage (void)
 
static void choose_visual (Gt_Viewer *viewer)
 
Gt_Viewernew_viewer (Display *display, Gif_Stream *gfs, const char *name)
 
void delete_viewer (Gt_Viewer *viewer)
 
static Gt_Viewernext_viewer (Gif_Stream *gfs, const char *name)
 
static Gt_Viewerget_input_stream (const char *name)
 
void switch_animating (Gt_Viewer *viewer, int animating)
 
void unschedule (Gt_Viewer *viewer)
 
void schedule (Gt_Viewer *viewer)
 
void schedule_next_frame (Gt_Viewer *viewer)
 
int parse_geometry (const char *const_g, XSizeHints *sh, int screen_width, int screen_height)
 
void create_viewer_window (Gt_Viewer *viewer, int w, int h)
 
void pre_delete_viewer (Gt_Viewer *viewer)
 
Gt_Viewerfind_viewer (Display *display, Window window)
 
void set_viewer_name (Gt_Viewer *viewer, int slow_number)
 
static unsigned screen_memory_kb (const Gt_Viewer *viewer)
 
static Pixmap unoptimized_frame (Gt_Viewer *viewer, int frame, int slow)
 
void prepare_frame (Gt_Viewer *viewer, int frame)
 
void view_frame (Gt_Viewer *viewer, int frame)
 
int frame_argument (Gt_Viewer *viewer, const char *arg)
 
void input_stream_done (Gt_Viewer *viewer, int first_frame)
 
void key_press (Gt_Viewer *viewer, XKeyEvent *e)
 
void loop (void)
 
int main (int argc, char *argv[])
 

Variables

struct timeval genesis_time
 
static unsigned pixel_memory_limit_kb = 40000
 
static unsigned pixel_memory_kb
 
const char * program_name = "gifview"
 
static Clp_Parserclp
 
static const char * cur_display_name = 0
 
static Display * cur_display = 0
 
static const char * cur_geometry_spec = 0
 
static Cursor cur_arrow_cursor = 0
 
static Cursor cur_wait_cursor = 0
 
static const char * cur_resource_name
 
static const char * cur_window_title = 0
 
static Window cur_use_window = None
 
static int cur_use_window_new = 0
 
static const char * cur_background_color = "black"
 
static Gt_Viewerviewers
 
static Gt_Vieweranimations
 
static int animating = 0
 
static int unoptimizing = 0
 
static int install_colormap = 0
 
static int interactive = 1
 
static int min_delay = 0
 
static int fallback_delay = 0
 
static struct timeval preparation_time
 
const Clp_Option options []
 
static Atom wm_delete_window_atom
 
static Atom wm_protocols_atom
 

Macro Definition Documentation

◆ ANIMATE_OPT

#define ANIMATE_OPT   303

Definition at line 173 of file gifview.c.

◆ BACKGROUND_OPT

#define BACKGROUND_OPT   310

Definition at line 180 of file gifview.c.

◆ DISPLAY_OPT

#define DISPLAY_OPT   300

Definition at line 170 of file gifview.c.

◆ EXTERN

#define EXTERN   extern

Definition at line 39 of file gifview.c.

◆ FALLBACK_DELAY_OPT

#define FALLBACK_DELAY_OPT   314

Definition at line 184 of file gifview.c.

◆ GEOMETRY_OPT

#define GEOMETRY_OPT   304

Definition at line 174 of file gifview.c.

◆ HELP_OPT

#define HELP_OPT   306

Definition at line 176 of file gifview.c.

◆ INSTALL_COLORMAP_OPT

#define INSTALL_COLORMAP_OPT   308

Definition at line 178 of file gifview.c.

◆ INTERACTIVE_OPT

#define INTERACTIVE_OPT   309

Definition at line 179 of file gifview.c.

◆ MEMORY_LIMIT_OPT

#define MEMORY_LIMIT_OPT   315

Definition at line 185 of file gifview.c.

◆ MICRO_PER_SEC

#define MICRO_PER_SEC   1000000

Definition at line 45 of file gifview.c.

◆ MIN_DELAY_OPT

#define MIN_DELAY_OPT   313

Definition at line 183 of file gifview.c.

◆ NAME_OPT

#define NAME_OPT   305

Definition at line 175 of file gifview.c.

◆ NEW_WINDOW_OPT

#define NEW_WINDOW_OPT   311

Definition at line 181 of file gifview.c.

◆ TITLE_OPT

#define TITLE_OPT   312

Definition at line 182 of file gifview.c.

◆ UNOPTIMIZE_OPT

#define UNOPTIMIZE_OPT   301

Definition at line 171 of file gifview.c.

◆ VERSION_OPT

#define VERSION_OPT   302

Definition at line 172 of file gifview.c.

◆ VISUAL_CLASS

#define VISUAL_CLASS   class

Definition at line 299 of file gifview.c.

◆ WINDOW_OPT

#define WINDOW_OPT   307

Definition at line 177 of file gifview.c.

◆ WINDOW_TYPE

#define WINDOW_TYPE   (Clp_ValFirstUser)

Definition at line 187 of file gifview.c.

◆ xwADDTIME

#define xwADDTIME (   result,
  a,
 
)
Value:
do { \
(result).tv_sec = (a).tv_sec + (b).tv_sec; \
if (((result).tv_usec = (a).tv_usec + (b).tv_usec) >= MICRO_PER_SEC) { \
(result).tv_sec++; \
(result).tv_usec -= MICRO_PER_SEC; \
} } while (0)

Definition at line 47 of file gifview.c.

◆ xwGETTIME

#define xwGETTIME (   a)    do { xwGETTIMEOFDAY(&(a)); xwSUBTIME((a), (a), genesis_time); } while (0)

Definition at line 86 of file gifview.c.

◆ xwGETTIMEOFDAY

#define xwGETTIMEOFDAY (   a)    gettimeofday((a), 0)

Definition at line 79 of file gifview.c.

◆ xwSETMINTIME

#define xwSETMINTIME (   a,
 
)
Value:
do { \
if ((b).tv_sec < (a).tv_sec || \
((b).tv_sec == (a).tv_sec && (b).tv_usec < (a).tv_usec)) \
(a) = (b); \
} while (0)

Definition at line 61 of file gifview.c.

◆ xwSUBTIME

#define xwSUBTIME (   result,
  a,
 
)
Value:
do { \
(result).tv_sec = (a).tv_sec - (b).tv_sec; \
if (((result).tv_usec = (a).tv_usec - (b).tv_usec) < 0) { \
(result).tv_sec--; \
(result).tv_usec += MICRO_PER_SEC; \
} } while (0)

Definition at line 54 of file gifview.c.

◆ xwTIMEGEQ

#define xwTIMEGEQ (   a,
 
)
Value:
((a).tv_sec > (b).tv_sec || \
((a).tv_sec == (b).tv_sec && (a).tv_usec >= (b).tv_usec))

Definition at line 67 of file gifview.c.

◆ xwTIMEGT

#define xwTIMEGT (   a,
 
)
Value:
((a).tv_sec > (b).tv_sec || \
((a).tv_sec == (b).tv_sec && (a).tv_usec > (b).tv_usec))

Definition at line 70 of file gifview.c.

◆ xwTIMELEQ0

#define xwTIMELEQ0 (   a)    ((a).tv_sec < 0 || ((a).tv_sec == 0 && (a).tv_usec <= 0))

Definition at line 73 of file gifview.c.

Typedef Documentation

◆ Gt_Viewer

typedef struct Gt_Viewer Gt_Viewer

Function Documentation

◆ choose_visual()

◆ create_viewer_window()

◆ delete_viewer()

void delete_viewer ( Gt_Viewer viewer)

Definition at line 491 of file gifview.c.

◆ error()

void error ( const char *  format,
  ... 
)

Definition at line 224 of file gifview.c.

Referenced by frame_argument(), and parse_geometry().

◆ fatal_error()

void fatal_error ( const char *  format,
  ... 
)

Definition at line 213 of file gifview.c.

References clp, Clp_vsnprintf(), and program_name.

◆ find_viewer()

Gt_Viewer* find_viewer ( Display *  display,
Window  window 
)

Definition at line 801 of file gifview.c.

◆ frame_argument()

int frame_argument ( Gt_Viewer viewer,
const char *  arg 
)

Definition at line 1039 of file gifview.c.

References error(), Gt_Viewer::gfs, Gif_GetNamedImage(), Gif_ImageNumber(), and Gt_Viewer::nim.

◆ get_input_stream()

static Gt_Viewer* get_input_stream ( const char *  name)
static

Definition at line 519 of file gifview.c.

◆ gettimeofday()

int gettimeofday ( struct timeval *  ,
struct timezone *   
)

◆ input_stream_done()

void input_stream_done ( Gt_Viewer viewer,
int  first_frame 
)

Definition at line 1068 of file gifview.c.

◆ key_press()

void key_press ( Gt_Viewer viewer,
XKeyEvent *  e 
)

Definition at line 1079 of file gifview.c.

◆ loop()

void loop ( void  )

Definition at line 1156 of file gifview.c.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 1261 of file gifview.c.

◆ new_viewer()

Gt_Viewer* new_viewer ( Display *  display,
Gif_Stream gfs,
const char *  name 
)

Definition at line 373 of file gifview.c.

◆ next_viewer()

static Gt_Viewer* next_viewer ( Gif_Stream gfs,
const char *  name 
)
static

Definition at line 511 of file gifview.c.

◆ parse_geometry()

int parse_geometry ( const char *  const_g,
XSizeHints *  sh,
int  screen_width,
int  screen_height 
)

Definition at line 661 of file gifview.c.

References error(), screen_height, and screen_width.

Referenced by create_viewer_window().

◆ pre_delete_viewer()

void pre_delete_viewer ( Gt_Viewer viewer)

Definition at line 786 of file gifview.c.

◆ prepare_frame()

void prepare_frame ( Gt_Viewer viewer,
int  frame 
)

Definition at line 899 of file gifview.c.

◆ schedule()

void schedule ( Gt_Viewer viewer)

Definition at line 603 of file gifview.c.

◆ schedule_next_frame()

void schedule_next_frame ( Gt_Viewer viewer)

Definition at line 626 of file gifview.c.

◆ screen_memory_kb()

static unsigned screen_memory_kb ( const Gt_Viewer viewer)
static

Definition at line 853 of file gifview.c.

◆ set_viewer_name()

void set_viewer_name ( Gt_Viewer viewer,
int  slow_number 
)

Definition at line 812 of file gifview.c.

◆ short_usage()

void short_usage ( void  )

Definition at line 244 of file gifview.c.

◆ switch_animating()

void switch_animating ( Gt_Viewer viewer,
int  animating 
)

◆ unoptimized_frame()

static Pixmap unoptimized_frame ( Gt_Viewer viewer,
int  frame,
int  slow 
)
static

Definition at line 859 of file gifview.c.

References Gt_Viewer::gfs, Gif_Stream::screen_height, and Gif_Stream::screen_width.

◆ unschedule()

void unschedule ( Gt_Viewer viewer)

Definition at line 587 of file gifview.c.

◆ usage()

void usage ( void  )

Definition at line 251 of file gifview.c.

◆ view_frame()

void view_frame ( Gt_Viewer viewer,
int  frame 
)

Definition at line 935 of file gifview.c.

◆ warning()

void warning ( const char *  format,
  ... 
)

Definition at line 234 of file gifview.c.

Variable Documentation

◆ animating

int animating = 0
static

Definition at line 160 of file gifview.c.

Referenced by switch_animating().

◆ animations

Gt_Viewer* animations
static

Definition at line 159 of file gifview.c.

◆ clp

Clp_Parser* clp
static

Definition at line 145 of file gifview.c.

Referenced by fatal_error().

◆ cur_arrow_cursor

Cursor cur_arrow_cursor = 0
static

Definition at line 150 of file gifview.c.

◆ cur_background_color

const char* cur_background_color = "black"
static

Definition at line 156 of file gifview.c.

◆ cur_display

Display* cur_display = 0
static

Definition at line 148 of file gifview.c.

◆ cur_display_name

const char* cur_display_name = 0
static

Definition at line 147 of file gifview.c.

◆ cur_geometry_spec

const char* cur_geometry_spec = 0
static

Definition at line 149 of file gifview.c.

Referenced by create_viewer_window().

◆ cur_resource_name

const char* cur_resource_name
static

Definition at line 152 of file gifview.c.

Referenced by create_viewer_window().

◆ cur_use_window

Window cur_use_window = None
static

Definition at line 154 of file gifview.c.

◆ cur_use_window_new

int cur_use_window_new = 0
static

Definition at line 155 of file gifview.c.

◆ cur_wait_cursor

Cursor cur_wait_cursor = 0
static

Definition at line 151 of file gifview.c.

◆ cur_window_title

const char* cur_window_title = 0
static

Definition at line 153 of file gifview.c.

◆ fallback_delay

int fallback_delay = 0
static

Definition at line 165 of file gifview.c.

◆ genesis_time

struct timeval genesis_time

Definition at line 87 of file gifview.c.

◆ install_colormap

int install_colormap = 0
static

Definition at line 162 of file gifview.c.

Referenced by choose_visual().

◆ interactive

int interactive = 1
static

Definition at line 163 of file gifview.c.

Referenced by create_viewer_window().

◆ min_delay

int min_delay = 0
static

Definition at line 164 of file gifview.c.

◆ options

const Clp_Option options[]
Initial value:
= {
{ "animate", 'a', 303 , 0, Clp_Negate },
{ "background", 'b', 310 , Clp_ValString, 0 },
{ "bg", 't', 310 , Clp_ValString, 0 },
{ "display", 'd', 300 , Clp_ValStringNotOption, 0 },
{ "geometry", 'g', 304 , Clp_ValString, 0 },
{ "install-colormap", 'i', 308 , 0, Clp_Negate },
{ "interactive", 'e', 309 , 0, Clp_Negate },
{ "help", 0, 306 , 0, 0 },
{ "memory-limit", 0, 315 , Clp_ValUnsigned, Clp_Negate },
{ "min-delay", 0, 313 , Clp_ValInt, Clp_Negate },
{ "fallback-delay", 0, 314 , Clp_ValInt, Clp_Negate },
{ "name", 0, 305 , Clp_ValString, 0 },
{ "title", 'T', 312 , Clp_ValString, 0 },
{ "unoptimize", 'U', 301 , 0, Clp_Negate },
{ "version", 0, 302 , 0, 0 },
{ "window", 'w', 307 , (Clp_ValFirstUser) , 0 },
{ "new-window", 0, 311 , (Clp_ValFirstUser) , 0 }
}

Definition at line 189 of file gifview.c.

◆ pixel_memory_kb

unsigned pixel_memory_kb
static

Definition at line 94 of file gifview.c.

◆ pixel_memory_limit_kb

unsigned pixel_memory_limit_kb = 40000
static

Definition at line 93 of file gifview.c.

◆ preparation_time

struct timeval preparation_time
static

Definition at line 167 of file gifview.c.

◆ program_name

const char* program_name = "gifview"

Definition at line 144 of file gifview.c.

Referenced by fatal_error().

◆ unoptimizing

int unoptimizing = 0
static

Definition at line 161 of file gifview.c.

◆ viewers

Gt_Viewer* viewers
static

Definition at line 158 of file gifview.c.

Referenced by choose_visual().

◆ wm_delete_window_atom

Atom wm_delete_window_atom
static

Definition at line 708 of file gifview.c.

Referenced by create_viewer_window().

◆ wm_protocols_atom

Atom wm_protocols_atom
static

Definition at line 709 of file gifview.c.

Referenced by create_viewer_window().

Clp_Negate
#define Clp_Negate
Option flag: option may be negated.
Definition: clp.h:139
Clp_ValStringNotOption
#define Clp_ValStringNotOption
Option value is a non-option string.
Definition: clp.h:62
Clp_ValUnsigned
#define Clp_ValUnsigned
Option value is an unsigned int.
Definition: clp.h:91
Clp_ValFirstUser
#define Clp_ValFirstUser
Value types >= Clp_ValFirstUser are available for user types.
Definition: clp.h:115
Clp_ValInt
#define Clp_ValInt
Option value is a signed int.
Definition: clp.h:78
MICRO_PER_SEC
#define MICRO_PER_SEC
Definition: gifview.c:45
Clp_ValString
#define Clp_ValString
Option value is an arbitrary string.
Definition: clp.h:59