From owner-svn-soc-all@freebsd.org Fri Aug 21 15:43:36 2015 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C4BED9BFE80 for ; Fri, 21 Aug 2015 15:43:36 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A469C386 for ; Fri, 21 Aug 2015 15:43:36 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id t7LFhaiZ051151 for ; Fri, 21 Aug 2015 15:43:36 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id t7LFhZ3x051132 for svn-soc-all@FreeBSD.org; Fri, 21 Aug 2015 15:43:35 GMT (envelope-from roam@FreeBSD.org) Date: Fri, 21 Aug 2015 15:43:35 GMT Message-Id: <201508211543.t7LFhZ3x051132@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r290020 - in soc2015/roam: ayiya_listen ayiya_resp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2015 15:43:37 -0000 Author: roam Date: Fri Aug 21 15:43:35 2015 New Revision: 290020 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290020 Log: ayiya_listen, ayiya_resp: use C99's bool. ObQuote: "You say 'yes', I say 'no'" Modified: soc2015/roam/ayiya_listen/main.c soc2015/roam/ayiya_resp/main.c Modified: soc2015/roam/ayiya_listen/main.c ============================================================================== --- soc2015/roam/ayiya_listen/main.c Fri Aug 21 15:43:31 2015 (r290019) +++ soc2015/roam/ayiya_listen/main.c Fri Aug 21 15:43:35 2015 (r290020) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,7 @@ static int verbose; -static void usage(int _ferr); +static void usage(bool _ferr); static void version(void); static void debug(const char *fmt, ...) __printflike(1, 2); @@ -89,7 +90,7 @@ static void accept_connection(int); static void handle_tunnel(struct tunnel *, const char *, const struct sockaddr_in *, const char *, size_t); -static void stop_tunnel(struct tunnel *, int); +static void stop_tunnel(struct tunnel *, bool); static void start_tunnel(struct tunnel *, const struct sockaddr_in *, const char *); static void check_wait_result(pid_t res, int stat, pid_t expected, @@ -106,10 +107,11 @@ int main(int argc, char * const argv[]) { - int ch, hflag, Vflag; + int ch; + bool hflag, Vflag; const char *addr, *tunnelsfile; - hflag = Vflag = 0; + hflag = Vflag = false; addr = tunnelsfile = NULL; while (ch = getopt(argc, argv, "a:hr:t:Vv"), ch != -1) switch (ch) { @@ -120,7 +122,7 @@ break; case 'h': - hflag = 1; + hflag = true; break; case 'r': @@ -132,7 +134,7 @@ break; case 'V': - Vflag = 1; + Vflag = true; break; case 'v': @@ -140,29 +142,29 @@ break; default: - usage(1); + usage(true); /* NOTREACHED */ } if (Vflag) version(); if (hflag) - usage(0); + usage(true); if (Vflag || hflag) return (0); if (addr == NULL) { warnx("No address (-a) specified"); - usage(1); + usage(true); } else if (tunnelsfile == NULL) { warnx("No tunnels file (-t) specified"); - usage(1); + usage(true); } argc -= optind; argv += optind; if (argc > 0) { warnx("No positional arguments expected"); - usage(1); + usage(true); } if (resppath == NULL) { @@ -243,7 +245,7 @@ } void -usage(const int _ferr) +usage(const bool _ferr) { const char * const s = "Usage:\tayiya_listen [-v] -a address -r resppath -t tunnelsfile config\n" @@ -362,7 +364,7 @@ if (t->pid == pid) { check_wait_result(pid, stat, t->pid, "AYIYA responder"); - stop_tunnel(t, 1); + stop_tunnel(t, true); break; } } @@ -410,7 +412,7 @@ { /* Do we need to kill a tunnel first? */ if (strcmp(t->remote_outer, sender) != 0) { - stop_tunnel(t, 0); + stop_tunnel(t, false); snprintf(t->remote_outer, sizeof(t->remote_outer), "%s", sender); } @@ -451,7 +453,7 @@ } void -stop_tunnel(struct tunnel * const t, const int waited) +stop_tunnel(struct tunnel * const t, const bool waited) { if (t->pid != 0) { close(t->comm[1]); @@ -750,7 +752,7 @@ char *line = NULL; size_t cap = 0; - int in = 0; + bool in = false; struct tunnel *t = tunnels; debug("Parsing the tunnels file %s\n", fname); unsigned flags; @@ -798,7 +800,7 @@ debug("- parsing tunnel %s\n", line); flags = 0; - in = 1; + in = true; continue; } else if (rerr != REG_NOMATCH) { report_regerror(rerr, &re_tunnel); Modified: soc2015/roam/ayiya_resp/main.c ============================================================================== --- soc2015/roam/ayiya_resp/main.c Fri Aug 21 15:43:31 2015 (r290019) +++ soc2015/roam/ayiya_resp/main.c Fri Aug 21 15:43:35 2015 (r290020) @@ -67,10 +67,10 @@ static int inputfd = -1; static STAILQ_HEAD(ayqhead, ayqueue) injectq; -static int quiet; -static int verbose; +static bool quiet; +static bool verbose; -static void usage(int _ferr); +static void usage(bool _ferr); static void version(void); static void debug(const char *fmt, ...) __printflike(1, 2); @@ -107,13 +107,14 @@ int main(int argc, char * const argv[]) { - int ch, hflag, Vflag; + int ch; + bool hflag, Vflag; - hflag = Vflag = 0; + hflag = Vflag = false; while (ch = getopt(argc, argv, "hi:n:qVv"), ch != -1) switch (ch) { case 'h': - hflag = 1; + hflag = true; break; case 'i': @@ -137,25 +138,25 @@ break; case 'q': - quiet = 1; + quiet = true; break; case 'V': - Vflag = 1; + Vflag = true; break; case 'v': - verbose++; + verbose = true; break; default: - usage(1); + usage(true); /* NOTREACHED */ } if (Vflag) version(); if (hflag) - usage(0); + usage(false); if (Vflag || hflag) return (0); @@ -163,7 +164,7 @@ argv += optind; if (argc < 1) { warnx("No command specified"); - usage(1); + usage(true); } const size_t len = strlen(argv[0]); unsigned idx = COMMANDS; @@ -174,20 +175,20 @@ } else if (strncmp(argv[0], commands[i].name, len) == 0) { if (idx != COMMANDS) { warnx("Ambiguous command '%s'", argv[0]); - usage(1); + usage(true); } idx = i; } } if (idx == COMMANDS) { warnx("Unrecognized command '%s'", argv[0]); - usage(1); + usage(true); } return (commands[idx].func)(argv[0], argv + 1, argc - 1); } void -usage(const int _ferr) +usage(const bool _ferr) { const char * const s = "Usage:\tayiya_resp [-v] config\n"