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)  

fetchnews.c File Reference
#include "leafnode.h"
#include "fetchnews.h"
#include "mastring.h"
#include "ln_log.h"
#include "mysigact.h"
#include <sys/types.h>
#include <ctype.h>
#include "system.h"
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <syslog.h>
#include <sys/resource.h>
#include <unistd.h>
#include <utime.h>
#include <sys/wait.h>
#include "groupselect.h"
Include dependency graph for fetchnews.c:

Go to the source code of this file.

Macros

#define HD_MAX   10
 

Functions

static int age (const char *date)
 
static int postarticles (const struct server *current_server)
 
static void ignore_answer (FILE *f)
 
static void sig_int (int signo)
 
static void usage (void)
 
static int isgrouponserver (const struct server *current_server, char *newsgroups)
 
static int ismsgidonserver (const struct server *current_server, char *msgid)
 
static int getbody_insitu (const struct server *current_server, struct newsgroup *group, unsigned long id)
 
static int getbody_newno (const struct server *current_server, struct newsgroup *group, unsigned long id)
 
static int getbody (const struct server *cs, struct newsgroup *group, unsigned long id)
 
static void getmarked (const struct server *current_server, struct newsgroup *group)
 
static int count_colons (const char *s_in)
 
static int is_articlepresent (const char *mid)
 
static unsigned long getgroup (const struct server *current_server, struct newsgroup *g, unsigned long server)
 
static int expire_interesting (void)
 
static void formatserver (char *d, size_t len, const struct server *serv, const char *suffix)
 
static int nntpactive (struct server *current_server, time_t *stamp)
 
static int movetofailed (const char *name)
 
static int processupstream (const struct server *serv, time_t stamp)
 
static time_t checkactive (void)
 
static int updateactive (void)
 
static void error_refetch (const char *e)
 
static void addnonexpiring (void)
 
int main (int argc, char **argv)
 

Variables

int verbose = 0
 
int debug = 0
 
static time_t now
 
static unsigned long extraarticles = 0
 
static int usesupplement = 1
 
static int postonly = 0
 
static int noexpire = 0
 
static int forceactive = 0
 
static sigjmp_buf jmpbuffer
 
static volatile sig_atomic_t canjump
 

Macro Definition Documentation

◆ HD_MAX

#define HD_MAX   10

Function Documentation

◆ addnonexpiring()

static void addnonexpiring ( void  )
static

re-add non-expiring groups to active

Definition at line 2285 of file fetchnews.c.

References expire, freelist(), get_grouplist(), insertgroup(), lookup_expire(), lookup_expiredays(), stringlist::next, and stringlist::string.

Referenced by main().

◆ age()

int age ( const char *  date)
static

Definition at line 184 of file fetchnews.c.

References now, and SECONDS_PER_DAY.

Referenced by donewgroups(), fakeactive(), getgroup(), and insertgroup().

◆ checkactive()

static time_t checkactive ( void  )
static

Definition at line 2218 of file fetchnews.c.

References activeread(), debugmode, now, SECONDS_PER_DAY, and timeout_active.

Referenced by main().

◆ count_colons()

static int count_colons ( const char *  s_in)
static

count number of colons in the string s_in.

Definition at line 620 of file fetchnews.c.

Referenced by getgroup().

◆ error_refetch()

static void error_refetch ( const char *  e)
static

Definition at line 2277 of file fetchnews.c.

References ln_log(), LNLOG_CTOP, and LNLOG_SERR.

Referenced by main().

◆ expire_interesting()

static int expire_interesting ( void  )
static

◆ formatserver()

static void formatserver ( char *  d,
size_t  len,
const struct server serv,
const char *  suffix 
)
static

Definition at line 1536 of file fetchnews.c.

References len, server::name, server::port, spooldir, and xsnprintf().

Referenced by nntpactive(), and processupstream().

◆ getbody()

static int getbody ( const struct server cs,
struct newsgroup group,
unsigned long  id 
)
static

Definition at line 547 of file fetchnews.c.

References db_situ, getbody_insitu(), getbody_newno(), and group.

Referenced by getmarked().

◆ getbody_insitu()

static int getbody_insitu ( const struct server current_server,
struct newsgroup group,
unsigned long  id 
)
static

◆ getbody_newno()

static int getbody_newno ( const struct server current_server,
struct newsgroup group,
unsigned long  id 
)
static

◆ getgroup()

◆ getmarked()

static void getmarked ( const struct server current_server,
struct newsgroup group 
)
static

◆ ignore_answer()

static void ignore_answer ( FILE *  f)
static

Definition at line 74 of file fetchnews.c.

References mgetaline().

Referenced by getgroup(), and ismsgidonserver().

◆ is_articlepresent()

static int is_articlepresent ( const char *  mid)
static

check if article (by Message ID) is present in spool

Returns
- 0 for false (not present)
  • 1 for true (present)
Parameters
midMessage-ID of article to check

Definition at line 642 of file fetchnews.c.

References lookup().

Referenced by getgroup().

◆ isgrouponserver()

static int isgrouponserver ( const struct server current_server,
char *  newsgroups 
)
static

check whether any of the newsgroups is on server return TRUE if yes, FALSE otherwise

Parameters
newsgroupsstring will be destroyed!

Definition at line 111 of file fetchnews.c.

References debug, FALSE, server::group_pcre, gs_match(), lineout, nntpreply(), server::only_groups_match_all, putaline(), SIZE_lineout, TRUE, and xsnprintf().

Referenced by postarticles().

◆ ismsgidonserver()

static int ismsgidonserver ( const struct server current_server,
char *  msgid 
)
static

◆ main()

◆ movetofailed()

static int movetofailed ( const char *  name)
static

Definition at line 1778 of file fetchnews.c.

References ln_log(), LNLOG_CARTICLE, LNLOG_SERR, name, SIZE_s, spooldir, and xsnprintf().

Referenced by postarticles().

◆ nntpactive()

static int nntpactive ( struct server current_server,
time_t *  stamp 
)
static

◆ postarticles()

◆ processupstream()

static int processupstream ( const struct server serv,
time_t  stamp 
)
static

◆ sig_int()

static void sig_int ( int  signo)
static

Definition at line 81 of file fetchnews.c.

References canjump, and jmpbuffer.

Referenced by main().

◆ updateactive()

static int updateactive ( void  )
static

Definition at line 2244 of file fetchnews.c.

References activeread(), ln_log(), LNLOG_CTOP, LNLOG_SERR, now, and rc.

Referenced by main().

◆ usage()

static void usage ( void  )
static

Definition at line 93 of file fetchnews.c.

Referenced by main().

Variable Documentation

◆ canjump

volatile sig_atomic_t canjump
static

Definition at line 68 of file fetchnews.c.

Referenced by main(), and sig_int().

◆ debug

int debug = 0

◆ extraarticles

unsigned long extraarticles = 0
static

Definition at line 61 of file fetchnews.c.

Referenced by getgroup(), and main().

◆ forceactive

int forceactive = 0
static

Definition at line 65 of file fetchnews.c.

Referenced by main(), and nntpactive().

◆ jmpbuffer

sigjmp_buf jmpbuffer
static

Definition at line 67 of file fetchnews.c.

Referenced by main(), and sig_int().

◆ noexpire

int noexpire = 0
static

Definition at line 64 of file fetchnews.c.

Referenced by main().

◆ now

◆ postonly

int postonly = 0
static

Definition at line 63 of file fetchnews.c.

Referenced by main().

◆ usesupplement

int usesupplement = 1
static

Definition at line 62 of file fetchnews.c.

Referenced by main().

◆ verbose