view src/wflogs-config.h @ 0:0aa1171aebd2 stable-1-0-0

initial version
author Carl Byington <>
date Wed, 15 May 2013 13:15:59 -0700
children 400b1de6e1c6
line wrap: on
line source


Copyright (c) 2007 Carl Byington - 510 Software Group, released under
the GPL version 3 or any later version at your choice available at


struct ltint
  bool operator()(const int s1, const int s2) const
    return (unsigned)s1 < (unsigned)s2;

const int buflen = 1024;

class CONFIG {
    // the only mutable stuff once it has been loaded from the config file
    int                 reference_count;    // protected by the global config_mutex
    // input side
    int                 fd;                 // input fn syslog file
    struct stat         openfdstat;
    int                 len;        // bytes in the buffer
    char                buf[buflen];
    // output side
    int                 fdo;                // output tempin wflogs file
    time_t              open_time;          // time when fdo opened
    // all the rest is constant after loading from the config file
    int                 generation;
    time_t              load_time;
    string_set          config_files;
    TOKEN               *tokp;
    // our data
    int             period;     // in seconds
    int             versions;   // number to keep
    // all strings owned by the string table
    const char *    output;     // output file name pattern
    const char *    tempin;     // temp wflogs input file name
    const char *    wflogs;     // wflogs command line
    const char *    fn;         // name of the syslog file
    const char *    pattern;    // regex to filter lines
    regex_t         re;         // internal regex to filter lines

    void    set_token(TOKEN &tok)       { tokp = &tok; };
    void    set_period(int p)           { period = p; };
    void    set_versions(int v)         { versions = v; };
    void    set_output(const char * o)  { output = o; };
    void    set_tempin(const char * t)  { tempin = t; openo(true); };
    void    set_wflogs(const char * w)  { wflogs = w; };
    void    set_file(const char * f)    { fn = f; open(true); };
    void    set_pattern(const char * p) { pattern = p; };
    bool    failedo()                   { return (fdo == -1); };
    bool    failed()                    { return (fd == -1); };
    void    dump();
    void    open(bool msg);
    void    openo(bool msg);
    bool    read();
    bool    write(char *p);
    void    process(char *p);
    void    close();
    void    closeo();
    void    sleep(int duration, time_t &previous);
    void    check_wflog();      // time to call it?
    void    free_all();

void        discard(string_set &s);
const char* register_string(string_set &s, const char *name);
const char* register_string(const char *name);
void        clear_strings();
int         ip_address(const char *have);
bool        load_conf(CONFIG &dc, const char *fn);
void        token_init();

extern const char *token_file;
extern const char *token_include;
extern const char *token_lbrace;
extern const char *token_output;
extern const char *token_pattern;
extern const char *token_period;
extern const char *token_rbrace;
extern const char *token_semi;
extern const char *token_tempin;
extern const char *token_versions;
extern const char *token_wflogs;