leafnode  1.12.0
About: Leafnode is a store & forward NNTP proxy for small (dialup) sites.
  Fossies Dox: leafnode-1.12.0.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

nntputil.c File Reference
#include "leafnode.h"
#include "system.h"
#include "mysigact.h"
#include <fcntl.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <netdb.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include "ln_log.h"
Include dependency graph for nntputil.c:

Go to the source code of this file.

Data Structures

struct  versions
 

Macros

#define incopy(a)   (*((struct in_addr *)a))
 

Functions

static int xnntpreply (const struct server *, int)
 
static void authsucc (const struct server *current_server)
 
void putaline (void)
 
int authenticate (const struct server *current_server)
 
void freelastreply (void)
 
char * lastreply (void)
 
int nntpreply (const struct server *s)
 
static int check_linlist (const char *s, const struct versions *list, int count)
 
int nntpconnect (const struct server *upstream)
 
void nntpdisconnect (void)
 
void nntpquit (void)
 

Variables

char last_command [1024+1]
 
char lineout [1024+1]
 
FILE * nntpin = NULL
 
FILE * nntpout = NULL
 
int stat_is_evil = 0
 
int date_is_evil = 0
 
static size_t lllen = 0
 
static char * llstr = NULL
 
static struct versions stat_versions []
 
static const int stat_count = sizeof(stat_versions)/sizeof(stat_versions[0])
 
static struct versions date_versions []
 
static const int date_count = sizeof(date_versions)/sizeof(date_versions[0])
 

Macro Definition Documentation

◆ incopy

#define incopy (   a)    (*((struct in_addr *)a))

Definition at line 309 of file nntputil.c.

Function Documentation

◆ authenticate()

int authenticate ( const struct server current_server)

◆ authsucc()

static void authsucc ( const struct server current_server)
static

Definition at line 64 of file nntputil.c.

References server::name, server::username, and verbose.

Referenced by authenticate().

◆ check_linlist()

static int check_linlist ( const char *  s,
const struct versions list,
int  count 
)
static

Definition at line 298 of file nntputil.c.

References list(), and name.

Referenced by nntpconnect().

◆ freelastreply()

void freelastreply ( void  )

Definition at line 154 of file nntputil.c.

References llstr.

Referenced by freeconfig().

◆ lastreply()

char * lastreply ( void  )

Definition at line 162 of file nntputil.c.

References llstr.

Referenced by check_date(), getgroup(), ismsgidonserver(), nntpactive(), nntpconnect(), and postarticles().

◆ nntpconnect()

◆ nntpdisconnect()

void nntpdisconnect ( void  )

Definition at line 547 of file nntputil.c.

References nntpin, and nntpout.

Referenced by nntpconnect(), and nntpquit().

◆ nntpquit()

void nntpquit ( void  )

Definition at line 560 of file nntputil.c.

References lineout, nntpdisconnect(), putaline(), SIZE_lineout, and xsnprintf().

Referenced by main(), and nntpconnect().

◆ nntpreply()

int nntpreply ( const struct server s)

◆ putaline()

◆ xnntpreply()

static int xnntpreply ( const struct server current_server,
int  may_auth 
)
static

decode an NNTP reply number reads a line from the server and returns an integer

498 is used to mean "protocol error", like smail, and includes timeout and "server disconnect" (EOF) conditions

the text returned is stored in lllen/llstr for later retrieval by lastreply()

from Tim Sweeney: retry in case of AUTHINFO failure.

Parameters
may_authset this to true to enable authentication after 480 reply

Definition at line 181 of file nntputil.c.

References authenticate(), critmalloc(), critstrdup(), debug, debugmode, last_command, lineout, lllen, llstr, ln_log(), LNLOG_CTOP, LNLOG_SERR, mgetaline(), server::name, nntpin, putaline(), verbose, and xnntpreply().

Referenced by authenticate(), nntpreply(), and xnntpreply().

Variable Documentation

◆ date_count

const int date_count = sizeof(date_versions)/sizeof(date_versions[0])
static

Definition at line 296 of file nntputil.c.

Referenced by nntpconnect().

◆ date_is_evil

int date_is_evil = 0

Definition at line 60 of file nntputil.c.

Referenced by main(), and nntpconnect().

◆ date_versions

struct versions date_versions[]
static
Initial value:
= {
{ "NewsCache 0.99.22p", 0 },
{ "NewsCache 0.99.2 ", 1 },
{ "NewsCache 0.99.20", 1 },
{ "NewsCache 0.99.21", 1 },
{ "NewsCache 0.99.22", 1 },
{ "NewsCache 0.99.2", 0 },
{ "NewsCache 1.1.10 ", 1 },
{ "NewsCache 1.1.11 ", 1 },
{ "NewsCache 1.1.1 ", 1 },
{ "NewsCache 1.1.0", 1},
{ "NewsCache 1", 0},
{ "NewsCache", 1 }
}

Definition at line 282 of file nntputil.c.

Referenced by nntpconnect().

◆ last_command

char last_command[1024+1]

Definition at line 53 of file nntputil.c.

Referenced by putaline(), and xnntpreply().

◆ lineout

◆ lllen

size_t lllen = 0
static

Definition at line 148 of file nntputil.c.

Referenced by xnntpreply().

◆ llstr

char* llstr = NULL
static

Definition at line 152 of file nntputil.c.

Referenced by freelastreply(), lastreply(), and xnntpreply().

◆ nntpin

◆ nntpout

FILE* nntpout = NULL

Definition at line 57 of file nntputil.c.

Referenced by authenticate(), nntpconnect(), nntpdisconnect(), postarticles(), and putaline().

◆ stat_count

const int stat_count = sizeof(stat_versions)/sizeof(stat_versions[0])
static

Definition at line 280 of file nntputil.c.

Referenced by nntpconnect().

◆ stat_is_evil

int stat_is_evil = 0

Definition at line 59 of file nntputil.c.

Referenced by ismsgidonserver(), main(), and nntpconnect().

◆ stat_versions

struct versions stat_versions[]
static
Initial value:
= {
{ "NewsCache 0.99.2 ", 1 },
{ "NewsCache 0.99.2", 0 },
{ "NewsCache 0.99.19", 0 },
{ "NewsCache 0.99.18", 0 },
{ "NewsCache 1.0.", 1 },
{ "NewsCache 1", 0 },
{ "NewsCache", 1 },
{ "NNTP news cache", 1 },
}

Definition at line 263 of file nntputil.c.

Referenced by nntpconnect().