tCleanup header files - synk - synchronize files between hosts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit ee0f6f75bd5de8de145fda094c6aef938732c6b9
 (DIR) parent b3f644e436534e648650db11022bd575defe56f9
 (HTM) Author: Willy <willyatmailoodotorg>
       Date:   Wed,  7 Sep 2016 13:44:12 +0200
       
       Cleanup header files
       
       Diffstat:
         M parse.y                             |      12 ++----------
         M synk.c                              |      17 ++++++++++++++---
         M synk.h                              |      16 ----------------
       
       3 files changed, 16 insertions(+), 29 deletions(-)
       ---
 (DIR) diff --git a/parse.y b/parse.y
       t@@ -19,8 +19,6 @@
         */
        
        %{
       -#include <sys/stat.h>
       -
        #include <errno.h>
        #include <ctype.h>
        #include <stdarg.h>
       t@@ -99,7 +97,7 @@ yyerror(const char *fmt, ...)
                if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0)
                        perror("vsnprintf");
                va_end(ap);
       -        printf("%s:%d: %s", file->name, yylval.lineno, buf);
       +        fprintf(stderr, "%s:%d: %s\n", file->name, yylval.lineno, buf);
                return 0;
        }
        
       t@@ -377,16 +375,10 @@ popfile(void)
        int
        parseconf(struct peers_t *plist, const char *filename)
        {
       -        struct stat sb;
                int errors = 0;
        
       -        if (stat(filename, &sb) == 0 && sb.st_mode & 007) {
       -                printf("%s: shouldn't be readable by others", filename);
       -                return -1;
       -        }
       -
                if (!(file = pushfile(filename))) {
       -                printf("failed to open %s", filename);
       +                fprintf(stderr, "failed to open %s\n", filename);
                        return -1;
                }
                topfile = file;
 (DIR) diff --git a/synk.c b/synk.c
       t@@ -1,5 +1,4 @@
        #include <errno.h>
       -#include <limits.h>
        #include <stdarg.h>
        #include <stdint.h>
        #include <stdio.h>
       t@@ -7,8 +6,6 @@
        #include <string.h>
        #include <netdb.h>
        #include <unistd.h>
       -#include <arpa/inet.h>
       -#include <sys/queue.h>
        #include <sys/socket.h>
        #include <sys/stat.h>
        #include <sys/types.h>
       t@@ -19,6 +16,20 @@
        #include "synk.h"
        
        #define IS_LOOPBACK(p)        ((p)->peer.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
       +#define log(l,...) if(verbose>=l){printf(__VA_ARGS__);}
       +
       +/* different operationnal mode for TCP connection */
       +enum {
       +        SYNK_CLIENT,
       +        SYNK_SERVER
       +};
       +
       +enum {
       +        LOG_NONE = 0,
       +        LOG_ERROR = 1,
       +        LOG_VERBOSE = 2,
       +        LOG_DEBUG = 3,
       +};
        
        static void usage(char *name);
        static char *echo(char * []);
 (DIR) diff --git a/synk.h b/synk.h
       t@@ -1,10 +1,7 @@
        #include <arpa/inet.h>
        #include <sys/queue.h>
       -#include <sys/socket.h>
        #include <limits.h>
        
       -#define log(l,...) if(verbose>=l){printf(__VA_ARGS__);}
       -
        #define DEFADDR      "127.0.0.1"
        #define DEFPORT      9723
        #define SERVERTIMEO  5 /* in seconds */
       t@@ -36,18 +33,5 @@ struct peer_t {
        };
        SLIST_HEAD(peers_t, peer_t);
        
       -/* different operationnal mode for TCP connection */
       -enum {
       -        SYNK_CLIENT,
       -        SYNK_SERVER
       -};
       -
       -enum {
       -        LOG_NONE = 0,
       -        LOG_ERROR = 1,
       -        LOG_VERBOSE = 2,
       -        LOG_DEBUG = 3,
       -};
       -
        struct peer_t *addpeer(struct peers_t *, char *, in_port_t);
        int parseconf(struct peers_t *, const char *);