purge.cc File Reference
#include "squid.h"
#include "util.h"
#include <cerrno>
#include <climits>
#include <csignal>
#include <cstdarg>
#include <cstdlib>
#include <cstring>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "conffile.hh"
#include "convert.hh"
#include "copyout.hh"
#include "signal.hh"
#include "socket.hh"
#include "squid-tlv.hh"
Include dependency graph for purge.cc:

Go to the source code of this file.

Classes

struct  REList
 

Macros

#define DEFAULTHOST   "localhost"
 
#define DEFAULTPORT   3128
 
#define LINESIZE   512
 

Functions

static char * concat (const char *start,...)
 
static bool isxstring (const char *s, size_t testlen)
 
int log_output (const char *fn, int code, long size, const char *url)
 
static int log_extended (const char *fn, int code, long size, const SquidMetaList *meta)
 
static bool action (int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
 
static bool match (const char *fn, const REList *list)
 
static bool filelevel (const char *directory, const REList *list)
 
static bool dirlevel (const char *dirname, const REList *list, bool level=false)
 
static int checkForPortOnly (const char *arg)
 
static void helpMe (void)
 
static void parseCommandline (int argc, char *argv[], REList *&head, char *&conffile, char *&copyDirPath, struct in_addr &serverHostIp, unsigned short &serverHostPort)
 
static void exiter (void)
 
static void handler (int signo)
 
static int makelinebuffered (FILE *fp, const char *fn=nullptr)
 
int main (int argc, char *argv[])
 

Variables

volatile sig_atomic_t term_flag = 0
 
char * linebuffer = nullptr
 
size_t buffersize = 128*1024
 
static char * copydir = nullptr
 
static uint32_t debugFlag = 0
 
static unsigned purgeMode = 0
 
static bool iamalive = false
 
static bool reminder = false
 
static bool verbose = false
 
static bool envelope = false
 
static bool no_fork = false
 
static const char * programname = nullptr
 
static struct in_addr serverHost
 
static unsigned short serverPort
 

Macro Definition Documentation

◆ DEFAULTHOST

#define DEFAULTHOST   "localhost"

Definition at line 137 of file purge.cc.

◆ DEFAULTPORT

#define DEFAULTPORT   3128

Definition at line 141 of file purge.cc.

◆ LINESIZE

#define LINESIZE   512

Function Documentation

◆ action()

static bool action ( int  fd,
size_t  metasize,
const char *  fn,
const char *  url,
const SquidMetaList &  meta 
)
static

◆ checkForPortOnly()

static int checkForPortOnly ( const char *  arg)
static

Definition at line 573 of file purge.cc.

References errstr.

Referenced by parseCommandline().

◆ concat()

static char * concat ( const char *  start,
  ... 
)
static

Definition at line 206 of file purge.cc.

References size.

Referenced by dirlevel(), and filelevel().

◆ dirlevel()

static bool dirlevel ( const char *  dirname,
const REList list,
bool  level = false 
)
static

Definition at line 536 of file purge.cc.

References concat(), debugFlag, dirlevel(), filelevel(), and strerror().

Referenced by dirlevel(), and main().

◆ exiter()

static void exiter ( void  )
static

Definition at line 845 of file purge.cc.

References linebuffer, psignal(), reminder, and term_flag.

Referenced by main().

◆ filelevel()

static bool filelevel ( const char *  directory,
const REList list 
)
static

Definition at line 496 of file purge.cc.

References assert, concat(), debugFlag, iamalive, isxstring(), match(), and strerror().

Referenced by dirlevel().

◆ handler()

◆ helpMe()

static void helpMe ( void  )
static

Definition at line 591 of file purge.cc.

References DEFAULTHOST, DEFAULTPORT, and programname.

Referenced by parseCommandline().

◆ isxstring()

static bool isxstring ( const char *  s,
size_t  testlen 
)
static

Definition at line 239 of file purge.cc.

Referenced by filelevel().

◆ log_extended()

static int log_extended ( const char *  fn,
int  code,
long  size,
const SquidMetaList *  meta 
)
static

◆ log_output()

int log_output ( const char *  fn,
int  code,
long  size,
const char *  url 
)
inline

Definition at line 255 of file purge.cc.

References code, and size.

Referenced by action(), and match().

◆ main()

◆ makelinebuffered()

static int makelinebuffered ( FILE *  fp,
const char *  fn = nullptr 
)
static

Definition at line 868 of file purge.cc.

References strerror().

Referenced by main().

◆ match()

static bool match ( const char *  fn,
const REList list 
)
static

◆ parseCommandline()

static void parseCommandline ( int  argc,
char *  argv[],
REList *&  head,
char *&  conffile,
char *&  copyDirPath,
struct in_addr &  serverHostIp,
unsigned short &  serverHostPort 
)
static

Variable Documentation

◆ buffersize

size_t buffersize = 128*1024

Definition at line 146 of file purge.cc.

Referenced by copy_out(), main(), and match().

◆ copydir

char* copydir = nullptr
static

Definition at line 147 of file purge.cc.

Referenced by action(), assert_copydir(), copy_out(), and main().

◆ debugFlag

uint32_t debugFlag = 0
static

Definition at line 148 of file purge.cc.

Referenced by action(), dirlevel(), filelevel(), main(), match(), and parseCommandline().

◆ envelope

bool envelope = false
static

Definition at line 153 of file purge.cc.

Referenced by action(), and parseCommandline().

◆ iamalive

bool iamalive = false
static

Definition at line 150 of file purge.cc.

Referenced by filelevel(), main(), and parseCommandline().

◆ linebuffer

char* linebuffer = nullptr

Definition at line 145 of file purge.cc.

Referenced by copy_out(), exiter(), main(), and match().

◆ no_fork

bool no_fork = false
static

Definition at line 154 of file purge.cc.

Referenced by main(), and parseCommandline().

◆ programname

const char* programname = nullptr
static

Definition at line 155 of file purge.cc.

Referenced by helpMe(), and parseCommandline().

◆ purgeMode

unsigned purgeMode = 0
static

Definition at line 149 of file purge.cc.

Referenced by action(), match(), and parseCommandline().

◆ reminder

bool reminder = false
static

Definition at line 151 of file purge.cc.

Referenced by action(), exiter(), and match().

◆ serverHost

struct in_addr serverHost
static

Definition at line 311 of file purge.cc.

Referenced by action(), and main().

◆ serverPort

unsigned short serverPort
static

Definition at line 312 of file purge.cc.

Referenced by action(), and main().

◆ term_flag

volatile sig_atomic_t term_flag = 0

Definition at line 144 of file purge.cc.

Referenced by exiter(), and handler().

◆ verbose

bool verbose = false
static

Definition at line 152 of file purge.cc.

Referenced by action(), match(), and parseCommandline().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors