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)  

nntpd.c File Reference
#include "leafnode.h"
#include "masock.h"
#include "mastring.h"
#include "validatefqdn.h"
#include "strlcpy.h"
#include "ln_log.h"
#include "nntpd.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include "system.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <syslog.h>
#include <unistd.h>
#include <utime.h>
Include dependency graph for nntpd.c:

Go to the source code of this file.

Macros

#define MAXLINELENGTH   1000
 
#define OFFSET   (time_t)1026380000L
 
#define ADDRLEN   16
 

Functions

static void fatal_write (void)
 
static void rereadactive (void)
 
static FILE * buildpseudoart (const char *grp)
 
static int parserange (char *arg, unsigned long *a, unsigned long *b)
 
static int is_pseudogroup (const struct newsgroup *g)
 
static void markinterest (const char *ng)
 
static FILE * fopenpseudoart (const char *arg, const unsigned long article_num)
 
static FILE * fopenart (const char *arg)
 
static int markdownload (const char *ng, unsigned long id)
 
static void nogroup (void)
 
static void doarticle (const char *arg, int what)
 
static int dogroup (const char *arg)
 
static void dohelp (void)
 
static void domove (int by)
 
static int is_pattern (const char *s)
 
static void printlist (const struct newsgroup *g, const int what)
 
static void list (struct newsgroup *g, const int what, const char *pattern)
 
static void dolist (char *arg)
 
static void donewgroups (const char *arg)
 
static char * generateMessageID (void)
 
static int dopost (void)
 
static void invalidrange (void)
 
static int checkrange (const struct newsgroup *g, unsigned long a, unsigned long b)
 
static void doxhdr (char *arg)
 
static void doxover (char *arg)
 
static void dolistgroup (const char *arg)
 
static void parser (void)
 
int main (int argc, char **argv)
 

Variables

static struct newsgroupgroup
 
static struct newsgroupxovergroup = NULL
 
static unsigned long artno
 
static char * cmd
 
static time_t activetime
 
int debug = 0
 
int verbose = 0
 

Macro Definition Documentation

◆ ADDRLEN

#define ADDRLEN   16

◆ MAXLINELENGTH

#define MAXLINELENGTH   1000

Definition at line 60 of file nntpd.c.

◆ OFFSET

#define OFFSET   (time_t)1026380000L

Definition at line 987 of file nntpd.c.

Function Documentation

◆ buildpseudoart()

static FILE * buildpseudoart ( const char *  grp)
static

◆ checkrange()

static int checkrange ( const struct newsgroup g,
unsigned long  a,
unsigned long  b 
)
static

Definition at line 1322 of file nntpd.c.

References newsgroup::first, invalidrange(), and newsgroup::last.

Referenced by doxhdr(), and doxover().

◆ doarticle()

static void doarticle ( const char *  arg,
int  what 
)
static

◆ dogroup()

static int dogroup ( const char *  arg)
static

◆ dohelp()

static void dohelp ( void  )
static

Definition at line 690 of file nntpd.c.

Referenced by parser().

◆ dolist()

static void dolist ( char *  arg)
static

Definition at line 821 of file nntpd.c.

References active, debugmode, and list().

Referenced by parser().

◆ dolistgroup()

static void dolistgroup ( const char *  arg)
static

◆ domove()

static void domove ( int  by)
static

Definition at line 717 of file nntpd.c.

References artno, debugmode, newsgroup::first, getheader(), group, newsgroup::last, nogroup(), and SIZE_s.

Referenced by parser().

◆ donewgroups()

static void donewgroups ( const char *  arg)
static

Definition at line 907 of file nntpd.c.

References active, age(), newsgroup::age, debugmode, newsgroup::first, newsgroup::last, newsgroup::name, now, and timegm().

Referenced by parser().

◆ dopost()

static int dopost ( void  )
static

◆ doxhdr()

◆ doxover()

◆ fatal_write()

static void fatal_write ( void  )
static

Definition at line 83 of file nntpd.c.

Referenced by doarticle().

◆ fopenart()

static FILE * fopenart ( const char *  arg)
static

Definition at line 341 of file nntpd.c.

References artno, fopenpseudoart(), group, is_pseudogroup(), lookup(), markinterest(), and newsgroup::name.

Referenced by doarticle(), and doxhdr().

◆ fopenpseudoart()

static FILE * fopenpseudoart ( const char *  arg,
const unsigned long  article_num 
)
static

◆ generateMessageID()

static char * generateMessageID ( void  )
static

Definition at line 990 of file nntpd.c.

References fqdn, ln_log(), LNLOG_CTOP, LNLOG_SCRIT, now, and OFFSET.

Referenced by dopost().

◆ invalidrange()

static void invalidrange ( void  )
static

Definition at line 1310 of file nntpd.c.

References debugmode.

Referenced by checkrange(), and doxover().

◆ is_pattern()

static int is_pattern ( const char *  s)
static

Definition at line 765 of file nntpd.c.

Referenced by list().

◆ is_pseudogroup()

static int is_pseudogroup ( const struct newsgroup g)
static

◆ list()

static void list ( struct newsgroup g,
const int  what,
const char *  pattern 
)
static

◆ main()

◆ markdownload()

static int markdownload ( const char *  ng,
unsigned long  id 
)
static

Definition at line 387 of file nntpd.c.

References BODY_DOWNLOAD_LIMIT, debugmode, getaline(), SIZE_s, spooldir, and xsnprintf().

Referenced by doarticle().

◆ markinterest()

static void markinterest ( const char *  ng)
static

◆ nogroup()

static void nogroup ( void  )
static

Definition at line 427 of file nntpd.c.

References debugmode.

Referenced by doarticle(), dolistgroup(), domove(), doxhdr(), and doxover().

◆ parser()

◆ parserange()

static int parserange ( char *  arg,
unsigned long *  a,
unsigned long *  b 
)
static

Definition at line 189 of file nntpd.c.

References SKIPLWS.

Referenced by doxhdr(), and doxover().

◆ printlist()

static void printlist ( const struct newsgroup g,
const int  what 
)
static

◆ rereadactive()

static void rereadactive ( void  )
static

Variable Documentation

◆ activetime

time_t activetime
static

Definition at line 77 of file nntpd.c.

Referenced by rereadactive().

◆ artno

unsigned long artno
static

Definition at line 75 of file nntpd.c.

Referenced by doarticle(), dogroup(), dolistgroup(), domove(), doxover(), fopenart(), and main().

◆ cmd

char* cmd
static

Definition at line 76 of file nntpd.c.

Referenced by getgroup(), and parser().

◆ debug

int debug = 0

Definition at line 79 of file nntpd.c.

Referenced by dopost(), and parser().

◆ group

◆ verbose

int verbose = 0

Definition at line 80 of file nntpd.c.

Referenced by main().

◆ xovergroup

struct newsgroup* xovergroup = NULL
static

Definition at line 74 of file nntpd.c.

Referenced by dolistgroup(), doxhdr(), doxover(), and rereadactive().