From e72175aa7cdf7ac9407e694148ff44bfec28debd Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 4 Jan 2010 21:23:13 -0800 Subject: cleanup and declare some methods as static --- src/main.c | 36 ++++++++++++++---------------------- src/xlib.c | 2 +- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/main.c b/src/main.c index 2204393..7a74b87 100644 --- a/src/main.c +++ b/src/main.c @@ -13,10 +13,10 @@ #define MODE_NORM 0 #define MODE_LIST 1 #define MODE_CTL 2 -int mode; +static int mode; /* Supported Formats */ -struct imageformat *formats[] = { +static struct imageformat *formats[] = { &libjpeg, &bmp, &libpng, @@ -27,7 +27,7 @@ struct imageformat *formats[] = { }; -void usage(){ +static void usage(){ printf("USAGE: meh [FILE1 [FILE2 [...]]]\n"); printf(" meh -list [LISTFILE] : Treat file as list of images. Defaults to stdin.\n"); printf(" meh -ctl : Display files as they are received on stdin\n"); @@ -35,7 +35,7 @@ void usage(){ exit(EXIT_FAILURE); } -struct image *newimage(FILE *f){ +static struct image *newimage(FILE *f){ struct image *img = NULL; struct imageformat **fmt = formats; for(fmt = formats; *fmt; fmt++){ @@ -48,12 +48,8 @@ struct image *newimage(FILE *f){ return NULL; } -struct image *imgopen(FILE *f){ - return newimage(f); -} - /* For MODE_CTL */ -int ctlfd; +static int ctlfd; static int imageslen; static int imageidx; @@ -62,7 +58,7 @@ static char **images; int width = 0, height = 0; struct image *curimg = NULL; -void freeimage(struct image *img){ +static void freeimage(struct image *img){ if(img){ backend_free(img); if(img->buf) @@ -71,14 +67,14 @@ void freeimage(struct image *img){ } } -void nextimage(){ +static void nextimage(){ if(++imageidx == imageslen) imageidx = 0; freeimage(curimg); curimg = NULL; } -void previmage(){ +static void previmage(){ if(--imageidx < 0) imageidx = imageslen - 1; freeimage(curimg); @@ -92,16 +88,12 @@ void key_reload(){ curimg = NULL; } void key_next(){ - if(mode != MODE_CTL){ - direction = nextimage; - direction(); - } + if(mode != MODE_CTL) + (direction = nextimage)(); } void key_prev(){ - if(mode != MODE_CTL){ - direction = previmage; - direction(); - } + if(mode != MODE_CTL) + (direction = previmage)(); } void key_quit(){ exit(EXIT_SUCCESS); @@ -116,7 +108,7 @@ struct image *imageopen2(char *filename){ struct image *i; FILE *f; if((f = fopen(filename, "rb"))){ - if((i = imgopen(f))){ + if((i = newimage(f))){ return i; } else @@ -202,7 +194,7 @@ static int doredraw(struct image **i){ return 0; } -void readlist(FILE *f){ +static void readlist(FILE *f){ int lsize = 16; imageslen = 0; images = NULL; diff --git a/src/xlib.c b/src/xlib.c index 06f63f8..26586a3 100644 --- a/src/xlib.c +++ b/src/xlib.c @@ -19,7 +19,7 @@ struct data_t{ }; /* Globals */ -Display *display; +static Display *display; static int screen; static Window window; static GC gc; -- cgit v1.2.3 n1' href='#n1'>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153