anntp

a nntp implementation in pure C99
Log | Files | Refs | README | LICENSE

commit 042e34575cb5af4faef3d4c5b93be2635decce8f
parent fc79753b29f0cb3d4fa908be24d21b48b3e21faa
Author: Mario Rosell R. Martinez <mario@mariorosell.es>
Date:   Sun, 22 Mar 2026 13:22:39 +0100

config: Add ANNTP_PRINTF, to allow anntp to shut up.

Diffstat:
Manntp.h | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/anntp.h b/anntp.h @@ -91,6 +91,10 @@ # define ANNTP_API extern #endif +#ifndef ANNTP_PRINTF +# define ANNTP_PRINTF printf +#endif + #ifndef ANNTP_STRDUP # if (defined(__GNUC__) && defined(_GNU_SOURCE)) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) # define ANNTP_STRDUP strdup @@ -108,7 +112,7 @@ anntp__NC__strdup(const char* s) { /*** defs ***/ -#define Bool int +#define Bool char #define true 1 #define false 0 #define ANNTPE(e) (-(ssize_t)(e)) @@ -228,7 +232,7 @@ anntp_mkconn(const char* host, const char* port, Bool tls) /* create socket */ cv->fd = socket(AF_INET, SOCK_STREAM, 0); if (cv->fd < 0) { - perror("anntp - making socket"); + ANNTP_PRINTF("anntp - making socket: %s\n", strerror(errno)); goto cleanup; } @@ -245,7 +249,7 @@ anntp_mkconn(const char* host, const char* port, Bool tls) int err = getaddrinfo(host, port, &hints, &res); if (err != 0 || !res) { - fprintf(stderr, "anntp - cant resolve host `%s': %s\n", host, gai_strerror(err)); + ANNTP_PRINTF(stderr, "anntp - cant resolve host `%s': %s\n", host, gai_strerror(err)); goto cleanup; } @@ -253,7 +257,7 @@ anntp_mkconn(const char* host, const char* port, Bool tls) cv->addr = sa->sin_addr; if (connect(cv->fd, (struct sockaddr*)sa, sizeof(*sa)) < 0) { - perror("anntp - connect failed"); + ANNTP_PRINTF("anntp - connecting: %s\n", strerror(errno)); goto cleanup_addr; }