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)  

miscutil.c File Reference
#include "leafnode.h"
#include "validatefqdn.h"
#include "strlcpy.h"
#include "mastring.h"
#include "ln_log.h"
#include <fcntl.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "system.h"
#include <signal.h>
#include <stdarg.h>
Include dependency graph for miscutil.c:

Go to the source code of this file.

Data Structures

struct  msgidtree
 

Macros

#define LM_SIZE   65536
 

Enumerations

enum  { hashsize = 1000 }
 

Functions

static void whoami (void)
 
static void suicide (void)
 
static int createmsgiddir (void)
 
int initvars (char *progname)
 
int isinteresting (const char *groupname)
 
void overrun (void)
 
const char * lookup (const char *msgid)
 
static int makedir (char *d)
 
static int migrate (const char *name)
 
int chdirgroup (const char *group, int creatdir)
 
void prependtolist (struct stringlist **list, const char *newentry)
 
char * findinlist (struct stringlist *haystack, char *needle)
 
struct stringlist ** lfindinlist (struct stringlist **haystack, char *needle, size_t len)
 
void replaceinlist (struct stringlist **haystack, char *needle, size_t len)
 
void freelist (struct stringlist *list)
 
static int comparemsgid (const char *id1, const char *id2)
 
void insertmsgid (const char *msgid)
 
int findmsgid (const char *msgid)
 
static void begone (struct msgidtree *m)
 
void clearidtree (void)
 
static int xtraverseidtree (struct msgidtree *m, tmihook h)
 
int traverseidtree (tmihook h)
 
const char * rfctime (void)
 
int ngmatch (const char *pattern, const char *str)
 
int xsnprintf (char *str, size_t n, const char *format,...)
 
size_t xstrlcpy (char *dst, const char *src, size_t size)
 

Variables

char fqdn [255+1] = ""
 
static const mode_t default_umask = 0002
 
struct xoverinfoxoverinfo
 
unsigned long xfirst
 
unsigned long xlast
 
struct {
   const char *   name
 
   mode_t   mode
 
dirs []
 
static const int dirs_count = sizeof(dirs)/sizeof(dirs[0])
 
static struct msgidtreehead
 

Macro Definition Documentation

◆ LM_SIZE

#define LM_SIZE   65536

Definition at line 359 of file miscutil.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
hashsize 

Definition at line 67 of file miscutil.c.

Function Documentation

◆ begone()

static void begone ( struct msgidtree m)
static

Definition at line 719 of file miscutil.c.

References begone(), msgidtree::left, and msgidtree::right.

Referenced by begone(), and clearidtree().

◆ chdirgroup()

◆ clearidtree()

void clearidtree ( void  )

Definition at line 729 of file miscutil.c.

References begone(), and head.

Referenced by dogroup(), and expiremsgid().

◆ comparemsgid()

static int comparemsgid ( const char *  id1,
const char *  id2 
)
static

Definition at line 649 of file miscutil.c.

Referenced by findmsgid(), and insertmsgid().

◆ createmsgiddir()

static int createmsgiddir ( void  )
static

◆ findinlist()

char * findinlist ( struct stringlist haystack,
char *  needle 
)

Definition at line 576 of file miscutil.c.

References stringlist::next, and stringlist::string.

Referenced by processupstream().

◆ findmsgid()

int findmsgid ( const char *  msgid)

Definition at line 695 of file miscutil.c.

References comparemsgid(), head, msgidtree::left, msgidtree::msgid, and msgidtree::right.

Referenced by dogroup(), and expiremsgid().

◆ freelist()

void freelist ( struct stringlist list)

Definition at line 626 of file miscutil.c.

References list().

Referenced by addnonexpiring(), expiregroup(), get_grouplist(), nntpactive(), and processupstream().

◆ initvars()

int initvars ( char *  progname)

◆ insertmsgid()

void insertmsgid ( const char *  msgid)

Definition at line 662 of file miscutil.c.

References comparemsgid(), critmalloc(), head, and msgidtree::msgid.

Referenced by dogroup(), and readmids().

◆ isinteresting()

int isinteresting ( const char *  groupname)

Definition at line 271 of file miscutil.c.

References dirent, FALSE, SIZE_s, spooldir, TRUE, and xsnprintf().

Referenced by doarticle(), dogroup(), list(), and store().

◆ lfindinlist()

struct stringlist ** lfindinlist ( struct stringlist **  haystack,
char *  needle,
size_t  len 
)

Definition at line 594 of file miscutil.c.

References len, stringlist::next, and stringlist::string.

Referenced by replaceinlist().

◆ lookup()

const char * lookup ( const char *  msgid)

construct file name for message.id/NNN/ in spooldir from message ID

Parameters
msgidif LOOKUP_FREE, release static resources

Definition at line 306 of file miscutil.c.

References critmalloc(), LOOKUP_FREE, name, and spooldir.

Referenced by dogroup(), expiremsgid(), fopenart(), freeconfig(), getbody_insitu(), getbody_newno(), getgroup(), is_articlepresent(), main(), and th().

◆ makedir()

static int makedir ( char *  d)
static

Definition at line 362 of file miscutil.c.

References verbose.

Referenced by chdirgroup().

◆ migrate()

static int migrate ( const char *  name)
static

Definition at line 394 of file miscutil.c.

References barf(), critmalloc(), critstrdup(), ln_log(), LNLOG_CTOP, LNLOG_SERR, name, and spooldir.

Referenced by chdirgroup().

◆ ngmatch()

int ngmatch ( const char *  pattern,
const char *  str 
)

Definition at line 792 of file miscutil.c.

References wildmat().

Referenced by list(), and lookup_expireent().

◆ overrun()

void overrun ( void  )

Definition at line 296 of file miscutil.c.

Referenced by xsnprintf(), and xstrlcpy().

◆ prependtolist()

void prependtolist ( struct stringlist **  list,
const char *  newentry 
)

Definition at line 558 of file miscutil.c.

References critmalloc(), list(), stringlist::next, and stringlist::string.

Referenced by myscandir(), nntpactive(), and replaceinlist().

◆ replaceinlist()

void replaceinlist ( struct stringlist **  haystack,
char *  needle,
size_t  len 
)

Definition at line 607 of file miscutil.c.

References critmalloc(), len, lfindinlist(), stringlist::next, and prependtolist().

Referenced by processupstream().

◆ rfctime()

const char * rfctime ( void  )

Definition at line 752 of file miscutil.c.

References now, and xsnprintf().

Referenced by buildpseudoart(), dopost(), doxhdr(), doxover(), and main().

◆ suicide()

static void suicide ( void  )
static

Definition at line 51 of file miscutil.c.

Referenced by initvars().

◆ traverseidtree()

int traverseidtree ( tmihook  h)

Definition at line 747 of file miscutil.c.

References head, and xtraverseidtree().

Referenced by dogroup().

◆ whoami()

static void whoami ( void  )
static

Definition at line 521 of file miscutil.c.

References fqdn, is_validfqdn(), and xstrlcpy().

Referenced by initvars().

◆ xsnprintf()

◆ xstrlcpy()

size_t xstrlcpy ( char *  dst,
const char *  src,
size_t  size 
)

Definition at line 812 of file miscutil.c.

References overrun(), and strlcpy().

Referenced by main(), readconfig(), and whoami().

◆ xtraverseidtree()

static int xtraverseidtree ( struct msgidtree m,
tmihook  h 
)
static

Definition at line 736 of file miscutil.c.

References msgidtree::left, msgidtree::msgid, msgidtree::right, and xtraverseidtree().

Referenced by traverseidtree(), and xtraverseidtree().

Variable Documentation

◆ default_umask

const mode_t default_umask = 0002
static

Definition at line 60 of file miscutil.c.

Referenced by initvars().

◆ 

struct { ... } dirs[]
Initial value:
= {
{"", 04755 },
{"interesting.groups", 02775 },
{"leaf.node", 0755 },
{"failed.postings", 02775 },
{"message.id", 0755 },
{"out.going", 0755 },
{"temp.files", 0755 },
}

Referenced by initvars().

◆ dirs_count

const int dirs_count = sizeof(dirs)/sizeof(dirs[0])
static

Definition at line 136 of file miscutil.c.

Referenced by initvars().

◆ fqdn

◆ head

struct msgidtree* head
static

Definition at line 646 of file miscutil.c.

Referenced by clearidtree(), findmsgid(), insertmsgid(), and traverseidtree().

◆ mode

mode_t mode

Definition at line 126 of file miscutil.c.

Referenced by initvars(), parse_line(), and ygetaline().

◆ name

◆ xfirst

unsigned long xfirst

Definition at line 64 of file miscutil.c.

Referenced by dolistgroup(), doxhdr(), doxover(), freexover(), getxover(), and initvars().

◆ xlast

unsigned long xlast

Definition at line 64 of file miscutil.c.

Referenced by dolistgroup(), doxhdr(), doxover(), freexover(), getxover(), and initvars().

◆ xoverinfo

Definition at line 63 of file miscutil.c.