Krolyxon
Commit 08ae25d

Branches

Refs →

nsxiv08ae25d

Refactored function definitions to use dangling brace

Author
Bert Münnich
Date
2013-02-08 22:05 +0100
Parent
6d3bbc6
Commit
08ae25da225d22a874b371d018e1942feef8a74e

+247 −124

9 files changed

  1. M Makefile +1 −1
  2. M commands.c +56 −28
  3. M exif.c +8 −4
  4. M image.c +50 −25
  5. M main.c +40 −20
  6. M options.c +6 −3
  7. M thumbs.c +26 −13
  8. M util.c +24 −12
  9. M window.c +36 −18
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20130129
1+VERSION = git-20130208
22
33 PREFIX = /usr/local
44 MANPREFIX = $(PREFIX)/share/man
M commands.c View
@@ -54,12 +54,14 @@ const int ss_delays[] = {
5454 1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600
5555 };
5656
57−bool it_quit(arg_t a) {
57+bool it_quit(arg_t a)
58+{
5859 cleanup();
5960 exit(EXIT_SUCCESS);
6061 }
6162
62−bool it_switch_mode(arg_t a) {
63+bool it_switch_mode(arg_t a)
64+{
6365 if (mode == MODE_IMAGE) {
6466 if (tns.thumbs == NULL)
6567 tns_init(&tns, filecnt, &win);
@@ -75,7 +77,8 @@ bool it_switch_mode(arg_t a) {
7577 return true;
7678 }
7779
78−bool it_toggle_fullscreen(arg_t a) {
80+bool it_toggle_fullscreen(arg_t a)
81+{
7982 win_toggle_fullscreen(&win);
8083 /* redraw after next ConfigureNotify event */
8184 set_timeout(redraw, TO_REDRAW_RESIZE, false);
@@ -86,7 +89,8 @@ bool it_toggle_fullscreen(arg_t a) {
8689 return false;
8790 }
8891
89−bool it_toggle_bar(arg_t a) {
92+bool it_toggle_bar(arg_t a)
93+{
9094 win_toggle_bar(&win);
9195 if (mode == MODE_IMAGE)
9296 img.checkpan = img.dirty = true;
@@ -95,7 +99,8 @@ bool it_toggle_bar(arg_t a) {
9599 return true;
96100 }
97101
98−bool t_reload_all(arg_t a) {
102+bool t_reload_all(arg_t a)
103+{
99104 if (mode == MODE_THUMB) {
100105 tns_free(&tns);
101106 tns_init(&tns, filecnt, &win);
@@ -105,7 +110,8 @@ bool t_reload_all(arg_t a) {
105110 }
106111 }
107112
108−bool it_reload_image(arg_t a) {
113+bool it_reload_image(arg_t a)
114+{
109115 if (mode == MODE_IMAGE) {
110116 load_image(fileidx);
111117 } else {
@@ -120,7 +126,8 @@ bool it_reload_image(arg_t a) {
120126 return true;
121127 }
122128
123−bool it_remove_image(arg_t a) {
129+bool it_remove_image(arg_t a)
130+{
124131 if (mode == MODE_IMAGE) {
125132 remove_file(fileidx, true);
126133 load_image(fileidx >= filecnt ? filecnt - 1 : fileidx);
@@ -136,7 +143,8 @@ bool it_remove_image(arg_t a) {
136143 }
137144 }
138145
139−bool i_navigate(arg_t a) {
146+bool i_navigate(arg_t a)
147+{
140148 long n = (long) a;
141149
142150 if (mode == MODE_IMAGE) {
@@ -156,7 +164,8 @@ bool i_navigate(arg_t a) {
156164 return false;
157165 }
158166
159−bool i_alternate(arg_t a) {
167+bool i_alternate(arg_t a)
168+{
160169 if (mode == MODE_IMAGE) {
161170 load_image(alternate);
162171 return true;
@@ -165,7 +174,8 @@ bool i_alternate(arg_t a) {
165174 }
166175 }
167176
168−bool it_first(arg_t a) {
177+bool it_first(arg_t a)
178+{
169179 if (mode == MODE_IMAGE && fileidx != 0) {
170180 load_image(0);
171181 return true;
@@ -178,7 +188,8 @@ bool it_first(arg_t a) {
178188 }
179189 }
180190
181−bool it_n_or_last(arg_t a) {
191+bool it_n_or_last(arg_t a)
192+{
182193 int n = prefix != 0 && prefix - 1 < filecnt ? prefix - 1 : filecnt - 1;
183194
184195 if (mode == MODE_IMAGE && fileidx != n) {
@@ -193,14 +204,16 @@ bool it_n_or_last(arg_t a) {
193204 }
194205 }
195206
196−bool i_navigate_frame(arg_t a) {
207+bool i_navigate_frame(arg_t a)
208+{
197209 if (mode == MODE_IMAGE && !img.multi.animate)
198210 return img_frame_navigate(&img, (long) a);
199211 else
200212 return false;
201213 }
202214
203−bool i_toggle_animation(arg_t a) {
215+bool i_toggle_animation(arg_t a)
216+{
204217 if (mode != MODE_IMAGE)
205218 return false;
206219
@@ -213,7 +226,8 @@ bool i_toggle_animation(arg_t a) {
213226 return true;
214227 }
215228
216−bool it_scroll_move(arg_t a) {
229+bool it_scroll_move(arg_t a)
230+{
217231 direction_t dir = (direction_t) a;
218232
219233 if (mode == MODE_IMAGE)
@@ -222,7 +236,8 @@ bool it_scroll_move(arg_t a) {
222236 return tns_move_selection(&tns, dir, prefix);
223237 }
224238
225−bool it_scroll_screen(arg_t a) {
239+bool it_scroll_screen(arg_t a)
240+{
226241 direction_t dir = (direction_t) a;
227242
228243 if (mode == MODE_IMAGE)
@@ -231,7 +246,8 @@ bool it_scroll_screen(arg_t a) {
231246 return tns_scroll(&tns, dir, true);
232247 }
233248
234−bool i_scroll_to_edge(arg_t a) {
249+bool i_scroll_to_edge(arg_t a)
250+{
235251 direction_t dir = (direction_t) a;
236252
237253 if (mode == MODE_IMAGE)
@@ -241,11 +257,13 @@ bool i_scroll_to_edge(arg_t a) {
241257 }
242258
243259 /* Xlib helper function for i_drag() */
244−Bool is_motionnotify(Display *d, XEvent *e, XPointer a) {
260+Bool is_motionnotify(Display *d, XEvent *e, XPointer a)
261+{
245262 return e != NULL && e->type == MotionNotify;
246263 }
247264
248−bool i_drag(arg_t a) {
265+bool i_drag(arg_t a)
266+{
249267 int dx = 0, dy = 0, i, ox, oy, x, y;
250268 unsigned int ui;
251269 bool dragging = true, next = false;
@@ -297,7 +315,8 @@ bool i_drag(arg_t a) {
297315 return false;
298316 }
299317
300−bool i_zoom(arg_t a) {
318+bool i_zoom(arg_t a)
319+{
301320 long scale = (long) a;
302321
303322 if (mode != MODE_IMAGE)
@@ -311,14 +330,16 @@ bool i_zoom(arg_t a) {
311330 return false;
312331 }
313332
314−bool i_set_zoom(arg_t a) {
333+bool i_set_zoom(arg_t a)
334+{
315335 if (mode == MODE_IMAGE)
316336 return img_zoom(&img, (prefix ? prefix : (long) a) / 100.0);
317337 else
318338 return false;
319339 }
320340
321−bool i_fit_to_win(arg_t a) {
341+bool i_fit_to_win(arg_t a)
342+{
322343 bool ret = false;
323344 scalemode_t sm = (scalemode_t) a;
324345
@@ -329,7 +350,8 @@ bool i_fit_to_win(arg_t a) {
329350 return ret;
330351 }
331352
332−bool i_fit_to_img(arg_t a) {
353+bool i_fit_to_img(arg_t a)
354+{
333355 int x, y;
334356 unsigned int w, h;
335357 bool ret = false;
@@ -348,7 +370,8 @@ bool i_fit_to_img(arg_t a) {
348370 return ret;
349371 }
350372
351−bool i_rotate(arg_t a) {
373+bool i_rotate(arg_t a)
374+{
352375 direction_t dir = (direction_t) a;
353376
354377 if (mode == MODE_IMAGE) {
@@ -363,7 +386,8 @@ bool i_rotate(arg_t a) {
363386 return false;
364387 }
365388
366−bool i_flip(arg_t a) {
389+bool i_flip(arg_t a)
390+{
367391 flipdir_t dir = (flipdir_t) a;
368392
369393 if (mode == MODE_IMAGE) {
@@ -374,7 +398,8 @@ bool i_flip(arg_t a) {
374398 }
375399 }
376400
377−bool i_toggle_antialias(arg_t a) {
401+bool i_toggle_antialias(arg_t a)
402+{
378403 if (mode == MODE_IMAGE) {
379404 img_toggle_antialias(&img);
380405 return true;
@@ -383,7 +408,8 @@ bool i_toggle_antialias(arg_t a) {
383408 }
384409 }
385410
386−bool it_toggle_alpha(arg_t a) {
411+bool it_toggle_alpha(arg_t a)
412+{
387413 img.alpha = tns.alpha = !img.alpha;
388414 if (mode == MODE_IMAGE)
389415 img.dirty = true;
@@ -392,7 +418,8 @@ bool it_toggle_alpha(arg_t a) {
392418 return true;
393419 }
394420
395−bool it_open_with(arg_t a) {
421+bool it_open_with(arg_t a)
422+{
396423 const char *prog = (const char*) a;
397424 pid_t pid;
398425
@@ -410,7 +437,8 @@ bool it_open_with(arg_t a) {
410437 return false;
411438 }
412439
413−bool it_shell_cmd(arg_t a) {
440+bool it_shell_cmd(arg_t a)
441+{
414442 int n, status;
415443 const char *cmdline = (const char*) a;
416444 pid_t pid;
M exif.c View
@@ -26,7 +26,8 @@
2626 #include "exif.h"
2727 #include "util.h"
2828
29−ssize_t s_read(int fd, const char *fn, void *buf, size_t n) {
29+ssize_t s_read(int fd, const char *fn, void *buf, size_t n)
30+{
3031 ssize_t ret;
3132
3233 ret = read(fd, buf, n);
@@ -38,7 +39,8 @@ ssize_t s_read(int fd, const char *fn, void *buf, size_t n) {
3839 }
3940 }
4041
41−unsigned short btous(unsigned char *buf, byteorder_t order) {
42+unsigned short btous(unsigned char *buf, byteorder_t order)
43+{
4244 if (buf == NULL)
4345 return 0;
4446 if (order == BO_BIG_ENDIAN)
@@ -47,7 +49,8 @@ unsigned short btous(unsigned char *buf, byteorder_t order) {
4749 return buf[1] << 8 | buf[0];
4850 }
4951
50−unsigned int btoui(unsigned char *buf, byteorder_t order) {
52+unsigned int btoui(unsigned char *buf, byteorder_t order)
53+{
5154 if (buf == NULL)
5255 return 0;
5356 if (order == BO_BIG_ENDIAN)
@@ -56,7 +59,8 @@ unsigned int btoui(unsigned char *buf, byteorder_t order) {
5659 return buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
5760 }
5861
59−int exif_orientation(const fileinfo_t *file) {
62+int exif_orientation(const fileinfo_t *file)
63+{
6064 int fd;
6165 unsigned char data[EXIF_MAX_LEN];
6266 byteorder_t order = BO_BIG_ENDIAN;
M image.c View
@@ -38,11 +38,13 @@ enum { MIN_GIF_DELAY = 25 };
3838 float zoom_min;
3939 float zoom_max;
4040
41−int zoomdiff(float z1, float z2) {
41+int zoomdiff(float z1, float z2)
42+{
4243 return (int) (z1 * 1000.0 - z2 * 1000.0);
4344 }
4445
45−void img_init(img_t *img, win_t *win) {
46+void img_init(img_t *img, win_t *win)
47+{
4648 zoom_min = zoom_levels[0] / 100.0;
4749 zoom_max = zoom_levels[ARRLEN(zoom_levels) - 1] / 100.0;
4850
@@ -66,7 +68,8 @@ void img_init(img_t *img, win_t *win) {
6668 img->multi.animate = false;
6769 }
6870
69−void exif_auto_orientate(const fileinfo_t *file) {
71+void exif_auto_orientate(const fileinfo_t *file)
72+{
7073 switch (exif_orientation(file)) {
7174 case 5:
7275 imlib_image_orientate(1);
@@ -95,7 +98,8 @@ void exif_auto_orientate(const fileinfo_t *file) {
9598 }
9699
97100 #if HAVE_GIFLIB
98−bool img_load_gif(img_t *img, const fileinfo_t *file) {
101+bool img_load_gif(img_t *img, const fileinfo_t *file)
102+{
99103 GifFileType *gif;
100104 GifRowType *rows = NULL;
101105 GifRecordType rec;
@@ -266,7 +270,8 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) {
266270 }
267271 #endif /* HAVE_GIFLIB */
268272
269−bool img_load(img_t *img, const fileinfo_t *file) {
273+bool img_load(img_t *img, const fileinfo_t *file)
274+{
270275 const char *fmt;
271276
272277 if (img == NULL || file == NULL || file->name == NULL || file->path == NULL)
@@ -303,7 +308,8 @@ bool img_load(img_t *img, const fileinfo_t *file) {
303308 return true;
304309 }
305310
306−void img_close(img_t *img, bool decache) {
311+void img_close(img_t *img, bool decache)
312+{
307313 int i;
308314
309315 if (img == NULL)
@@ -326,7 +332,8 @@ void img_close(img_t *img, bool decache) {
326332 }
327333 }
328334
329−void img_check_pan(img_t *img, bool moved) {
335+void img_check_pan(img_t *img, bool moved)
336+{
330337 win_t *win;
331338 int ox, oy;
332339
@@ -358,7 +365,8 @@ void img_check_pan(img_t *img, bool moved) {
358365 img->dirty = true;
359366 }
360367
361−bool img_fit(img_t *img) {
368+bool img_fit(img_t *img)
369+{
362370 float z, zmax, zw, zh;
363371
364372 if (img == NULL || img->im == NULL || img->win == NULL)
@@ -394,7 +402,8 @@ bool img_fit(img_t *img) {
394402 }
395403 }
396404
397−void img_render(img_t *img) {
405+void img_render(img_t *img)
406+{
398407 win_t *win;
399408 int sx, sy, sw, sh;
400409 int dx, dy, dw, dh;
@@ -464,7 +473,8 @@ void img_render(img_t *img) {
464473 img->dirty = false;
465474 }
466475
467−bool img_fit_win(img_t *img, scalemode_t sm) {
476+bool img_fit_win(img_t *img, scalemode_t sm)
477+{
468478 if (img == NULL || img->im == NULL)
469479 return false;
470480
@@ -472,7 +482,8 @@ bool img_fit_win(img_t *img, scalemode_t sm) {
472482 return img_fit(img);
473483 }
474484
475−bool img_center(img_t *img) {
485+bool img_center(img_t *img)
486+{
476487 int ox, oy;
477488
478489 if (img == NULL || img->im == NULL || img->win == NULL)
@@ -492,7 +503,8 @@ bool img_center(img_t *img) {
492503 }
493504 }
494505
495−bool img_zoom(img_t *img, float z) {
506+bool img_zoom(img_t *img, float z)
507+{
496508 if (img == NULL || img->im == NULL || img->win == NULL)
497509 return false;
498510
@@ -513,7 +525,8 @@ bool img_zoom(img_t *img, float z) {
513525 }
514526 }
515527
516−bool img_zoom_in(img_t *img) {
528+bool img_zoom_in(img_t *img)
529+{
517530 int i;
518531 float z;
519532
@@ -528,7 +541,8 @@ bool img_zoom_in(img_t *img) {
528541 return false;
529542 }
530543
531−bool img_zoom_out(img_t *img) {
544+bool img_zoom_out(img_t *img)
545+{
532546 int i;
533547 float z;
534548
@@ -543,7 +557,8 @@ bool img_zoom_out(img_t *img) {
543557 return false;
544558 }
545559
546−bool img_move(img_t *img, float dx, float dy) {
560+bool img_move(img_t *img, float dx, float dy)
561+{
547562 float ox, oy;
548563
549564 if (img == NULL || img->im == NULL)
@@ -565,7 +580,8 @@ bool img_move(img_t *img, float dx, float dy) {
565580 }
566581 }
567582
568−bool img_pan(img_t *img, direction_t dir, int d) {
583+bool img_pan(img_t *img, direction_t dir, int d)
584+{
569585 /* d < 0: screen-wise
570586 * d = 0: 1/5 of screen
571587 * d > 0: num of pixels
@@ -595,7 +611,8 @@ bool img_pan(img_t *img, direction_t dir, int d) {
595611 return false;
596612 }
597613
598−bool img_pan_edge(img_t *img, direction_t dir) {
614+bool img_pan_edge(img_t *img, direction_t dir)
615+{
599616 int ox, oy;
600617
601618 if (img == NULL || img->im == NULL || img->win == NULL)
@@ -629,7 +646,8 @@ bool img_pan_edge(img_t *img, direction_t dir) {
629646 }
630647 }
631648
632−void img_rotate(img_t *img, int d) {
649+void img_rotate(img_t *img, int d)
650+{
633651 win_t *win;
634652 int ox, oy, tmp;
635653
@@ -654,15 +672,18 @@ void img_rotate(img_t *img, int d) {
654672 img->dirty = true;
655673 }
656674
657−void img_rotate_left(img_t *img) {
675+void img_rotate_left(img_t *img)
676+{
658677 img_rotate(img, 3);
659678 }
660679
661−void img_rotate_right(img_t *img) {
680+void img_rotate_right(img_t *img)
681+{
662682 img_rotate(img, 1);
663683 }
664684
665−void img_flip(img_t *img, flipdir_t d) {
685+void img_flip(img_t *img, flipdir_t d)
686+{
666687 if (img == NULL || img->im == NULL)
667688 return;
668689
@@ -679,7 +700,8 @@ void img_flip(img_t *img, flipdir_t d) {
679700 img->dirty = true;
680701 }
681702
682−void img_toggle_antialias(img_t *img) {
703+void img_toggle_antialias(img_t *img)
704+{
683705 if (img == NULL || img->im == NULL)
684706 return;
685707
@@ -689,7 +711,8 @@ void img_toggle_antialias(img_t *img) {
689711 img->dirty = true;
690712 }
691713
692−bool img_frame_goto(img_t *img, int n) {
714+bool img_frame_goto(img_t *img, int n)
715+{
693716 if (img == NULL || img->im == NULL)
694717 return false;
695718 if (n < 0 || n >= img->multi.cnt || n == img->multi.sel)
@@ -707,7 +730,8 @@ bool img_frame_goto(img_t *img, int n) {
707730 return true;
708731 }
709732
710−bool img_frame_navigate(img_t *img, int d) {
733+bool img_frame_navigate(img_t *img, int d)
734+{
711735 if (img == NULL|| img->im == NULL || img->multi.cnt == 0 || d == 0)
712736 return false;
713737
@@ -720,7 +744,8 @@ bool img_frame_navigate(img_t *img, int d) {
720744 return img_frame_goto(img, d);
721745 }
722746
723−bool img_frame_animate(img_t *img, bool restart) {
747+bool img_frame_animate(img_t *img, bool restart)
748+{
724749 if (img == NULL || img->im == NULL || img->multi.cnt == 0)
725750 return false;
726751
M main.c View
@@ -85,7 +85,8 @@ timeout_t timeouts[] = {
8585 { { 0, 0 }, false, clear_resize },
8686 };
8787
88−void cleanup(void) {
88+void cleanup(void)
89+{
8990 static bool in = false;
9091
9192 if (!in) {
@@ -96,7 +97,8 @@ void cleanup(void) {
9697 }
9798 }
9899
99−void check_add_file(char *filename) {
100+void check_add_file(char *filename)
101+{
100102 const char *bn;
101103
102104 if (filename == NULL || *filename == '\0')
@@ -129,7 +131,8 @@ void check_add_file(char *filename) {
129131 fileidx++;
130132 }
131133
132−void remove_file(int n, bool manual) {
134+void remove_file(int n, bool manual)
135+{
133136 if (n < 0 || n >= filecnt)
134137 return;
135138
@@ -157,7 +160,8 @@ void remove_file(int n, bool manual) {
157160 tns.cnt--;
158161 }
159162
160−void set_timeout(timeout_f handler, int time, bool overwrite) {
163+void set_timeout(timeout_f handler, int time, bool overwrite)
164+{
161165 int i;
162166
163167 for (i = 0; i < ARRLEN(timeouts); i++) {
@@ -172,7 +176,8 @@ void set_timeout(timeout_f handler, int time, bool overwrite) {
172176 }
173177 }
174178
175−void reset_timeout(timeout_f handler) {
179+void reset_timeout(timeout_f handler)
180+{
176181 int i;
177182
178183 for (i = 0; i < ARRLEN(timeouts); i++) {
@@ -183,7 +188,8 @@ void reset_timeout(timeout_f handler) {
183188 }
184189 }
185190
186−bool check_timeouts(struct timeval *t) {
191+bool check_timeouts(struct timeval *t)
192+{
187193 int i = 0, tdiff, tmin = -1;
188194 struct timeval now;
189195
@@ -207,7 +213,8 @@ bool check_timeouts(struct timeval *t) {
207213 return tmin > 0;
208214 }
209215
210−void read_info(void) {
216+void read_info(void)
217+{
211218 char cmd[4096];
212219 FILE *outp;
213220 int c, i = 0, n = sizeof(bar.l) - 1;
@@ -237,7 +244,8 @@ end:
237244 bar.l[i] = '\0';
238245 }
239246
240−void load_image(int new) {
247+void load_image(int new)
248+{
241249 if (new < 0 || new >= filecnt)
242250 return;
243251
@@ -262,7 +270,8 @@ void load_image(int new) {
262270 reset_timeout(animate);
263271 }
264272
265−void update_info(void) {
273+void update_info(void)
274+{
266275 unsigned int i, fn, fw, n, len = sizeof(bar.r);
267276 int sel;
268277 char *t = bar.r, title[TITLE_LEN];
@@ -310,7 +319,8 @@ void update_info(void) {
310319 win_set_bar_info(&win, bar.l, bar.r);
311320 }
312321
313−void redraw(void) {
322+void redraw(void)
323+{
314324 if (mode == MODE_IMAGE)
315325 img_render(&img);
316326 else
@@ -321,7 +331,8 @@ void redraw(void) {
321331 reset_cursor();
322332 }
323333
324−void reset_cursor(void) {
334+void reset_cursor(void)
335+{
325336 int i;
326337 cursor_t cursor = CURSOR_NONE;
327338
@@ -342,27 +353,32 @@ void reset_cursor(void) {
342353 win_set_cursor(&win, cursor);
343354 }
344355
345−void animate(void) {
356+void animate(void)
357+{
346358 if (img_frame_animate(&img, false)) {
347359 redraw();
348360 set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
349361 }
350362 }
351363
352−void clear_resize(void) {
364+void clear_resize(void)
365+{
353366 resized = false;
354367 }
355368
356−bool keymask(const keymap_t *k, unsigned int state) {
369+bool keymask(const keymap_t *k, unsigned int state)
370+{
357371 return (k->ctrl ? ControlMask : 0) == (state & ControlMask);
358372 }
359373
360−bool buttonmask(const button_t *b, unsigned int state) {
374+bool buttonmask(const button_t *b, unsigned int state)
375+{
361376 return ((b->ctrl ? ControlMask : 0) | (b->shift ? ShiftMask : 0)) ==
362377 (state & (ControlMask | ShiftMask));
363378 }
364379
365−void on_keypress(XKeyEvent *kev) {
380+void on_keypress(XKeyEvent *kev)
381+{
366382 int i;
367383 KeySym ksym;
368384 char key;
@@ -390,7 +406,8 @@ void on_keypress(XKeyEvent *kev) {
390406 }
391407 }
392408
393−void on_buttonpress(XButtonEvent *bev) {
409+void on_buttonpress(XButtonEvent *bev)
410+{
394411 int i, sel;
395412
396413 if (bev == NULL)
@@ -437,7 +454,8 @@ void on_buttonpress(XButtonEvent *bev) {
437454 }
438455 }
439456
440−void run(void) {
457+void run(void)
458+{
441459 int xfd;
442460 fd_set fds;
443461 struct timeval timeout;
@@ -532,11 +550,13 @@ void run(void) {
532550 }
533551 }
534552
535−int fncmp(const void *a, const void *b) {
553+int fncmp(const void *a, const void *b)
554+{
536555 return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name);
537556 }
538557
539−int main(int argc, char **argv) {
558+int main(int argc, char **argv)
559+{
540560 int i, start;
541561 size_t n;
542562 ssize_t len;
M options.c View
@@ -31,16 +31,19 @@
3131 options_t _options;
3232 const options_t *options = (const options_t*) &_options;
3333
34−void print_usage(void) {
34+void print_usage(void)
35+{
3536 printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] "
3637 "[-N name] [-z ZOOM] FILES...\n");
3738 }
3839
39−void print_version(void) {
40+void print_version(void)
41+{
4042 printf("sxiv %s - Simple X Image Viewer\n", VERSION);
4143 }
4244
43−void parse_options(int argc, char **argv) {
45+void parse_options(int argc, char **argv)
46+{
4447 int opt, t;
4548
4649 _options.recursive = false;
M thumbs.c View
@@ -36,14 +36,16 @@ static const int thumb_dim = THUMB_SIZE + 10;
3636 static const char * const CACHE_DIR = ".sxiv/cache";
3737 static char *cache_dir = NULL;
3838
39−bool tns_cache_enabled(void) {
39+bool tns_cache_enabled(void)
40+{
4041 struct stat stats;
4142
4243 return cache_dir != NULL && stat(cache_dir, &stats) == 0 &&
4344 S_ISDIR(stats.st_mode) && access(cache_dir, W_OK) == 0;
4445 }
4546
46−char* tns_cache_filepath(const char *filepath) {
47+char* tns_cache_filepath(const char *filepath)
48+{
4749 size_t len;
4850 char *cfile = NULL;
4951
@@ -59,7 +61,8 @@ char* tns_cache_filepath(const char *filepath) {
5961 return cfile;
6062 }
6163
62−Imlib_Image* tns_cache_load(const char *filepath) {
64+Imlib_Image* tns_cache_load(const char *filepath)
65+{
6366 char *cfile;
6467 struct stat cstats, fstats;
6568 Imlib_Image *im = NULL;
@@ -77,7 +80,8 @@ Imlib_Image* tns_cache_load(const char *filepath) {
7780 return im;
7881 }
7982
80−void tns_cache_write(thumb_t *t, bool force) {
83+void tns_cache_write(thumb_t *t, bool force)
84+{
8185 char *cfile, *dirend;
8286 struct stat cstats, fstats;
8387 struct utimbuf times;
@@ -118,7 +122,8 @@ void tns_cache_write(thumb_t *t, bool force) {
118122 }
119123 }
120124
121−void tns_clean_cache(tns_t *tns) {
125+void tns_clean_cache(tns_t *tns)
126+{
122127 int dirlen;
123128 bool delete;
124129 char *cfile, *filename, *tpos;
@@ -154,7 +159,8 @@ void tns_clean_cache(tns_t *tns) {
154159 }
155160
156161
157−void tns_init(tns_t *tns, int cnt, win_t *win) {
162+void tns_init(tns_t *tns, int cnt, win_t *win)
163+{
158164 int len;
159165 char *homedir;
160166
@@ -185,7 +191,8 @@ void tns_init(tns_t *tns, int cnt, win_t *win) {
185191 }
186192 }
187193
188−void tns_free(tns_t *tns) {
194+void tns_free(tns_t *tns)
195+{
189196 int i;
190197
191198 if (tns == NULL)
@@ -282,7 +289,8 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file,
282289 return true;
283290 }
284291
285−void tns_check_view(tns_t *tns, bool scrolled) {
292+void tns_check_view(tns_t *tns, bool scrolled)
293+{
286294 int r;
287295
288296 if (tns == NULL)
@@ -309,7 +317,8 @@ void tns_check_view(tns_t *tns, bool scrolled) {
309317 }
310318 }
311319
312−void tns_render(tns_t *tns) {
320+void tns_render(tns_t *tns)
321+{
313322 thumb_t *t;
314323 win_t *win;
315324 int i, cnt, r, x, y;
@@ -364,7 +373,8 @@ void tns_render(tns_t *tns) {
364373 tns_highlight(tns, tns->sel, true);
365374 }
366375
367−void tns_highlight(tns_t *tns, int n, bool hl) {
376+void tns_highlight(tns_t *tns, int n, bool hl)
377+{
368378 thumb_t *t;
369379 win_t *win;
370380 int x, y;
@@ -392,7 +402,8 @@ void tns_highlight(tns_t *tns, int n, bool hl) {
392402 }
393403 }
394404
395−bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) {
405+bool tns_move_selection(tns_t *tns, direction_t dir, int cnt)
406+{
396407 int old, max;
397408
398409 if (tns == NULL || tns->thumbs == NULL)
@@ -427,7 +438,8 @@ bool tns_move_selection(tns_t *tns, direction_t dir, int cnt) {
427438 return tns->sel != old;
428439 }
429440
430−bool tns_scroll(tns_t *tns, direction_t dir, bool screen) {
441+bool tns_scroll(tns_t *tns, direction_t dir, bool screen)
442+{
431443 int d, max, old;
432444
433445 if (tns == NULL)
@@ -452,7 +464,8 @@ bool tns_scroll(tns_t *tns, direction_t dir, bool screen) {
452464 return tns->first != old;
453465 }
454466
455−int tns_translate(tns_t *tns, int x, int y) {
467+int tns_translate(tns_t *tns, int x, int y)
468+{
456469 int n;
457470
458471 if (tns == NULL || tns->thumbs == NULL)
M util.c View
@@ -36,7 +36,8 @@ enum {
3636
3737 void cleanup(void);
3838
39−void* s_malloc(size_t size) {
39+void* s_malloc(size_t size)
40+{
4041 void *ptr;
4142
4243 ptr = malloc(size);
@@ -45,14 +46,16 @@ void* s_malloc(size_t size) {
4546 return ptr;
4647 }
4748
48−void* s_realloc(void *ptr, size_t size) {
49+void* s_realloc(void *ptr, size_t size)
50+{
4951 ptr = realloc(ptr, size);
5052 if (ptr == NULL)
5153 die("could not allocate memory");
5254 return ptr;
5355 }
5456
55−char* s_strdup(char *s) {
57+char* s_strdup(char *s)
58+{
5659 char *d = NULL;
5760
5861 if (s != NULL) {
@@ -64,7 +67,8 @@ char* s_strdup(char *s) {
6467 return d;
6568 }
6669
67−void warn(const char* fmt, ...) {
70+void warn(const char* fmt, ...)
71+{
6872 va_list args;
6973
7074 if (fmt == NULL || options->quiet)
@@ -77,7 +81,8 @@ void warn(const char* fmt, ...) {
7781 va_end(args);
7882 }
7983
80−void die(const char* fmt, ...) {
84+void die(const char* fmt, ...)
85+{
8186 va_list args;
8287
8388 if (fmt == NULL)
@@ -93,7 +98,8 @@ void die(const char* fmt, ...) {
9398 exit(EXIT_FAILURE);
9499 }
95100
96−ssize_t get_line(char **buf, size_t *n, FILE *stream) {
101+ssize_t get_line(char **buf, size_t *n, FILE *stream)
102+{
97103 size_t len;
98104 char *s;
99105
@@ -125,7 +131,8 @@ ssize_t get_line(char **buf, size_t *n, FILE *stream) {
125131 return s - *buf + len;
126132 }
127133
128−void size_readable(float *size, const char **unit) {
134+void size_readable(float *size, const char **unit)
135+{
129136 const char *units[] = { "", "K", "M", "G" };
130137 int i;
131138
@@ -134,7 +141,8 @@ void size_readable(float *size, const char **unit) {
134141 *unit = units[MIN(i, ARRLEN(units) - 1)];
135142 }
136143
137−char* absolute_path(const char *filename) {
144+char* absolute_path(const char *filename)
145+{
138146 size_t len;
139147 const char *basename;
140148 char *dir, *dirname = NULL, *path = NULL, *s;
@@ -206,7 +214,8 @@ end:
206214 return path;
207215 }
208216
209−int r_opendir(r_dir_t *rdir, const char *dirname) {
217+int r_opendir(r_dir_t *rdir, const char *dirname)
218+{
210219 if (rdir == NULL || dirname == NULL || *dirname == '\0')
211220 return -1;
212221
@@ -226,7 +235,8 @@ int r_opendir(r_dir_t *rdir, const char *dirname) {
226235 return 0;
227236 }
228237
229−int r_closedir(r_dir_t *rdir) {
238+int r_closedir(r_dir_t *rdir)
239+{
230240 int ret = 0;
231241
232242 if (rdir == NULL)
@@ -252,7 +262,8 @@ int r_closedir(r_dir_t *rdir) {
252262 return ret;
253263 }
254264
255−char* r_readdir(r_dir_t *rdir) {
265+char* r_readdir(r_dir_t *rdir)
266+{
256267 size_t len;
257268 char *filename;
258269 struct dirent *dentry;
@@ -304,7 +315,8 @@ char* r_readdir(r_dir_t *rdir) {
304315 return NULL;
305316 }
306317
307−int r_mkdir(const char *path) {
318+int r_mkdir(const char *path)
319+{
308320 char *dir, *d;
309321 struct stat stats;
310322 int err = 0;
M window.c View
@@ -52,7 +52,8 @@ static struct {
5252 static int fontheight;
5353 static int barheight;
5454
55−void win_init_font(Display *dpy, const char *fontstr) {
55+void win_init_font(Display *dpy, const char *fontstr)
56+{
5657 int n;
5758 char *def, **missing;
5859
@@ -84,7 +85,8 @@ void win_init_font(Display *dpy, const char *fontstr) {
8485 barheight = fontheight + 2 * V_TEXT_PAD;
8586 }
8687
87−unsigned long win_alloc_color(win_t *win, const char *name) {
88+unsigned long win_alloc_color(win_t *win, const char *name)
89+{
8890 XColor col;
8991
9092 if (win == NULL)
@@ -98,7 +100,8 @@ unsigned long win_alloc_color(win_t *win, const char *name) {
98100 return col.pixel;
99101 }
100102
101−void win_init(win_t *win) {
103+void win_init(win_t *win)
104+{
102105 win_env_t *e;
103106
104107 if (win == NULL)
@@ -132,7 +135,8 @@ void win_init(win_t *win) {
132135 wm_delete_win = XInternAtom(e->dpy, "WM_DELETE_WINDOW", False);
133136 }
134137
135−void win_set_sizehints(win_t *win) {
138+void win_set_sizehints(win_t *win)
139+{
136140 XSizeHints sizehints;
137141
138142 if (win == NULL || win->xwin == None)
@@ -146,7 +150,8 @@ void win_set_sizehints(win_t *win) {
146150 XSetWMNormalHints(win->env.dpy, win->xwin, &sizehints);
147151 }
148152
149−void win_open(win_t *win) {
153+void win_open(win_t *win)
154+{
150155 win_env_t *e;
151156 XClassHint classhint;
152157 XColor col;
@@ -229,7 +234,8 @@ void win_open(win_t *win) {
229234 win_toggle_fullscreen(win);
230235 }
231236
232−void win_close(win_t *win) {
237+void win_close(win_t *win)
238+{
233239 if (win == NULL || win->xwin == None)
234240 return;
235241
@@ -244,7 +250,8 @@ void win_close(win_t *win) {
244250 XCloseDisplay(win->env.dpy);
245251 }
246252
247−bool win_configure(win_t *win, XConfigureEvent *c) {
253+bool win_configure(win_t *win, XConfigureEvent *c)
254+{
248255 bool changed;
249256
250257 if (win == NULL || c == NULL)
@@ -266,7 +273,8 @@ bool win_configure(win_t *win, XConfigureEvent *c) {
266273 return changed;
267274 }
268275
269−void win_expose(win_t *win, XExposeEvent *e) {
276+void win_expose(win_t *win, XExposeEvent *e)
277+{
270278 if (win == NULL || win->xwin == None || win->pm == None || e == NULL)
271279 return;
272280
@@ -274,7 +282,8 @@ void win_expose(win_t *win, XExposeEvent *e) {
274282 e->x, e->y, e->width, e->height, e->x, e->y);
275283 }
276284
277−bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
285+bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h)
286+{
278287 if (win == NULL || win->xwin == None)
279288 return false;
280289
@@ -299,7 +308,8 @@ bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
299308 return true;
300309 }
301310
302−void win_toggle_fullscreen(win_t *win) {
311+void win_toggle_fullscreen(win_t *win)
312+{
303313 XEvent ev;
304314 XClientMessageEvent *cm;
305315
@@ -323,7 +333,8 @@ void win_toggle_fullscreen(win_t *win) {
323333 SubstructureNotifyMask | SubstructureRedirectMask, &ev);
324334 }
325335
326−void win_toggle_bar(win_t *win) {
336+void win_toggle_bar(win_t *win)
337+{
327338 if (win == NULL || win->xwin == None)
328339 return;
329340
@@ -336,7 +347,8 @@ void win_toggle_bar(win_t *win) {
336347 }
337348 }
338349
339−void win_clear(win_t *win) {
350+void win_clear(win_t *win)
351+{
340352 int h;
341353 win_env_t *e;
342354
@@ -353,7 +365,8 @@ void win_clear(win_t *win) {
353365 XFillRectangle(e->dpy, win->pm, gc, 0, 0, win->w, h);
354366 }
355367
356−void win_draw_bar(win_t *win) {
368+void win_draw_bar(win_t *win)
369+{
357370 int len, olen, x, y, w, tw;
358371 char rest[3];
359372 const char *dots = "...";
@@ -408,7 +421,8 @@ void win_draw_bar(win_t *win) {
408421 }
409422 }
410423
411−void win_draw(win_t *win) {
424+void win_draw(win_t *win)
425+{
412426 if (win == NULL || win->xwin == None || win->pm == None)
413427 return;
414428
@@ -437,7 +451,8 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h,
437451 XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h);
438452 }
439453
440−int win_textwidth(const char *text, unsigned int len, bool with_padding) {
454+int win_textwidth(const char *text, unsigned int len, bool with_padding)
455+{
441456 XRectangle r;
442457 int padding = with_padding ? 2 * H_TEXT_PAD : 0;
443458
@@ -449,7 +464,8 @@ int win_textwidth(const char *text, unsigned int len, bool with_padding) {
449464 }
450465 }
451466
452−void win_set_title(win_t *win, const char *title) {
467+void win_set_title(win_t *win, const char *title)
468+{
453469 if (win == NULL || win->xwin == None)
454470 return;
455471
@@ -469,14 +485,16 @@ void win_set_title(win_t *win, const char *title) {
469485 PropModeReplace, (unsigned char *) title, strlen(title));
470486 }
471487
472−void win_set_bar_info(win_t *win, char *linfo, char *rinfo) {
488+void win_set_bar_info(win_t *win, char *linfo, char *rinfo)
489+{
473490 if (win != NULL) {
474491 win->bar.l = linfo;
475492 win->bar.r = rinfo;
476493 }
477494 }
478495
479−void win_set_cursor(win_t *win, cursor_t cursor) {
496+void win_set_cursor(win_t *win, cursor_t cursor)
497+{
480498 if (win == NULL || win->xwin == None)
481499 return;
482500