gawk

[old] Sed-like interface to the Gopher protocol
Log | Files | Refs | LICENSE

commit e21d50921b3ec8a2ccf651134b8327b6cf1da6c8
parent 1913561f62b9f7263159329d1e6902b66fc92649
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Tue,  5 Jan 2021 12:53:48 -0800

Fix long lines and improve resolve() warning

Diffstat:
Mgawk.h | 6++++--
Mmain.c | 10++++++----
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/gawk.h b/gawk.h @@ -3,9 +3,11 @@ #define LEN(X) (sizeof(X) / sizeof(*X)) -enum address { AR_PATH, AR_HOST, AR_PORT, AR_NULL }; /* NOTE: see itemtoaddr() */ -enum cstatus { ERROR = -1, OK, UNWIND }; /* command status */ +/* NOTE: don't change address order, see itemtoaddr() */ +enum address { AR_PATH, AR_HOST, AR_PORT, AR_NULL }; enum gphitem { GI_INFO, GI_PATH, GI_HOST, GI_PORT, GI_PLUS, GI_NULL }; + +enum cstatus { ERROR = -1, OK, UNWIND }; /* command status */ enum pstatus { NEXT = -2, FAIL, PASS }; /* pipe status */ typedef int (command)(int, char const **, int, char const **); diff --git a/main.c b/main.c @@ -41,13 +41,13 @@ itemtoaddr(char const **request) } int -argsplit(char const **argv, int size, char *s, char const *const sep, int concatenate) +argsplit(char const **argv, int size, char *s, char const *const sep, int cat) { int argc; for (argc = 0; argc < size && (argv[argc] = strsep(&s, sep)) != NULL;) { - if (!concatenate || *argv[argc] != '\0') + if (!cat || *argv[argc] != '\0') ++argc; } @@ -70,7 +70,8 @@ resolve(char const *const host, char const *const port) error = getaddrinfo(host, port, &hints, &ai0); if (error) { - warn(0, "Unable to resolve: '%s' at '%s': %s", host, port, gai_strerror(error)); + warn(0, "unable to resolve '%s' (%s): %s", + host, port, gai_strerror(error)); return -1; } @@ -331,7 +332,8 @@ tmp_mkpath(char *cache, char const **addr) char tmp[MY_PATH_MAX]; tr(tmp, addr[AR_PATH], '/', '-'); - snprintf(cache, MY_PATH_MAX, "%s/%s_%s_%s", tmpdir, addr[AR_HOST], addr[AR_PORT], tmp); + snprintf(cache, MY_PATH_MAX, "%s/%s_%s_%s", + tmpdir, addr[AR_HOST], addr[AR_PORT], tmp); } int