anntp

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

commit fc79753b29f0cb3d4fa908be24d21b48b3e21faa
parent 89393f236eaeddf25bdcd336c22610fdd1330abf
Author: Mario Rosell R. Martinez <mario@mariorosell.es>
Date:   Sun, 22 Mar 2026 12:13:00 +0100

Prepare for v0.1.

Diffstat:
MNEWS | 7++++---
MREADME | 28++++++++++++++++++++++++----
Mexamples/nntpsh.c | 2+-
Mtests/test.c | 16++++++++++++++++
4 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS @@ -3,10 +3,10 @@ NEWS Sorted newest to oldest. Unreleased is what is being done for the next release and always on the top. -Unreleased ----------- +v0.1 +---- -* First DEVELOPMENT releae +* First release! * Entirely by Mario Rosell * Features: - connections in TLS and unsecure @@ -42,3 +42,4 @@ Unreleased - Fixed buffer sizes - Few headers parsed - Limited API +* Download: https://dl.mariorosell.es/anntp/v0.1 diff --git a/README b/README @@ -12,7 +12,7 @@ semi-portable C99. It is low-level, but still usable, minimalist, and portabl Right now, it supports: -* multiple connection, +* multiple connections, * low-level server/client I/O, with a billion variation of the same two functions, * auth, * TLS (just TLS, no STARTTLS, sorry), @@ -61,14 +61,34 @@ There is an AnntpErrCode enum with the types of errors: * ANE_OK - success * ANE_PARAMS - wrong parameters * ANE_IO - I/O error (OOM, sending, receiving, ..., pretty broad of a variant) -* ANE_TLS - tLS error +* ANE_TLS - TLS error * ANE_PROTO - protocol exception; server sent something unexpected * ANE_AUTH - authentication failure EXAMPLES ======== -See examples/ for a couple examples. +See examples/ for a couple examples, but for now you can read the greeting with: + + #include <stdio.h> + #define ANNTP_IMPLEMENTATION + #include "anntp.h" + + int + main() + { + anntp_init(); + AnntpConnection* c = anntp_mkconn("news.example.com", "119", false); + if (!c) return 1; + + char line[256]; + if (anntp_readline(c, line, sizeof(line)) > 0) { + puts(line); + } + + anntp_freeconn(c); + return 0; + } LICENSE ======= @@ -80,7 +100,7 @@ See more information at the LICENSE file. CONTACT ======= -* Mario Rosell <mario@mariorosell.es (broken right now) +* Mario Rosell <mario@mariorosell.es (email broken right now) * Contributors: See CONTRIBUTORS file for more. TODOS diff --git a/examples/nntpsh.c b/examples/nntpsh.c @@ -78,7 +78,7 @@ sendin(char line[512]) if (line[0] == '\n' || line[0] == '\0') return; - line[strcspn(line, "\n")] = 0; // remove newline + line[strcspn(line, "\n")] = 0; /* remove newline */ ssize_t n = anntp_writeline(c, line); diff --git a/tests/test.c b/tests/test.c @@ -144,6 +144,22 @@ test_list(void) anntp_freeconn(c); } +void +test_group(void) +{ + AnntpConnection* c = anntp_mkconn("news.eternal-september.org", "119", false); + require(c != NULL, "connection for GROUP test"); + + char line[256]; + anntp_readline(c, line, sizeof(line)); + + AnntpGroup g; + int err = anntp_group(c, "eternal-september.talk", &g); + require(err == ANE_OK, "groups"); + + anntp_freeconn(c); +} + /*********************************************************************************************************************/ int