style changes - xscreenshot - screen capture tool
 (HTM) git clone git://git.codemadness.org/xscreenshot
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit cd1359cce761e458e956453bd99b4bac021723f2
 (DIR) parent 85ee16921ed51359ffe1496f7380684f5a03979d
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Mon, 16 Nov 2015 17:58:49 +0100
       
       style changes
       
       Diffstat:
         M xscreenshot.c                       |      41 +++++++++++++++----------------
       
       1 file changed, 20 insertions(+), 21 deletions(-)
       ---
 (DIR) diff --git a/xscreenshot.c b/xscreenshot.c
       @@ -1,28 +1,28 @@
        /* see LICENSE / README for more info */
       +#include <arpa/inet.h>
       +
       +#include <endian.h>
       +#include <errno.h>
        #include <stdio.h>
        #include <stdint.h>
       -#include <string.h>
        #include <stdlib.h>
       -#include <errno.h>
       -#include <endian.h>
       +#include <string.h>
        
        #include <X11/X.h>
        #include <X11/Xlib.h>
        #include <X11/Xutil.h>
       -#include <arpa/inet.h>
        
        static void
        die(const char *s) {
                fprintf(stderr, "xscreenshot: %s\n", s);
       -        exit(EXIT_FAILURE);
       +        exit(1);
        }
        
        static void
       -usage(void)
       +usage(char *argv0)
        {
       -        die("xscreenshot-" VERSION
       -            ", (c) 2014 xscreenshot engineers, see LICENSE for details\n"
       -            "usage: xscreenshot [winid]");
       +        fprintf(stderr, "usage: %s [winid]\n", argv0);
       +        exit(1);
        }
        
        int
       @@ -35,18 +35,17 @@ main(int argc, char *argv[])
                uint32_t tmp, w, h;
                uint16_t rgba[4];
        
       -        dpy = XOpenDisplay(NULL);
       -        if(!dpy)
       +        if (!(dpy = XOpenDisplay(NULL)))
                        die("Can't XOpenDisplay");
        
                /* identify window */
       -        if(argc > 1) {
       -                if(strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-v") == 0)
       -                        usage();
       +        if (argc > 1) {
       +                if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-v") == 0)
       +                        usage(argv[0]);
                        errno = 0;
                        win = (Window)strtol(argv[1], NULL, 0);
       -                if(errno != 0)
       -                        usage();
       +                if (errno != 0)
       +                        usage(argv[0]);
                } else {
                        win = RootWindow(dpy, 0);
                }
       @@ -57,7 +56,7 @@ main(int argc, char *argv[])
                                ZPixmap);
                XUngrabServer(dpy);
                XCloseDisplay(dpy);
       -        if(!img)
       +        if (!img)
                        die("Can't XGetImage");
        
                /* write header with big endian width and height-values */
       @@ -68,19 +67,19 @@ main(int argc, char *argv[])
                fwrite(&tmp, sizeof(uint32_t), 1, stdout);
        
                /* write pixels */
       -        for(h = 0; h < (uint32_t)img->height; h++) {
       -                for(w = 0; w < (uint32_t)img->width; w++) {
       +        for (h = 0; h < (uint32_t)img->height; h++) {
       +                for (w = 0; w < (uint32_t)img->width; w++) {
                                tmp = XGetPixel(img, w, h);
                                rgba[0] = htobe16((tmp & img->red_mask) >> 8);
                                rgba[1] = htobe16(tmp & img->green_mask);
                                rgba[2] = htobe16((tmp & img->blue_mask) << 8);
                                rgba[3] = htobe16(65535);
        
       -                        if(fwrite(&rgba, 4*sizeof(uint16_t), 1, stdout) != 1)
       +                        if (fwrite(&rgba, 4 * sizeof(uint16_t), 1, stdout) != 1)
                                        die("fwrite() failed");
                        }
                }
                XDestroyImage(img);
        
       -        return EXIT_SUCCESS;
       +        return 0;
        }