#ifndef _SYSLOGD_H
#define _SYSLOGD_H
#ifdef __cplusplus
extern "C" {
#endif
struct utmpx dummy;
#define DEBUGFILE "/var/adm/syslog.debug"
#define MAXLINE 1024
#define DEFUPRI (LOG_USER|LOG_INFO)
#define DEFSPRI (LOG_KERN|LOG_CRIT)
#define MARKCOUNT 3
#define UNAMESZ (sizeof (dummy.ut_user))
#define UDEVSZ (sizeof (dummy.ut_line))
#define MAXUNAMES 20
#define Q_HIGHWATER_MARK 10000
#define NOPRI 0x10
#define LOG_MARK (LOG_NFACILITIES << 3)
typedef struct host_list {
int hl_cnt;
char **hl_hosts;
pthread_mutex_t hl_mutex;
int hl_refcnt;
} host_list_t;
typedef struct host_info {
struct netconfig *ncp;
struct netbuf addr;
} host_info_t;
typedef struct filed_stats {
int flag;
int total;
int dups;
int cantfwd;
int errs;
} filed_stats_t;
typedef struct log_message {
pthread_mutex_t msg_mutex;
int refcnt;
int pri;
int flags;
time_t ts;
host_list_t *hlp;
void *ptr;
char msg[MAXLINE+1];
} log_message_t;
typedef struct saved_msg {
int pri;
int flags;
time_t time;
char host[SYS_NMLN+1];
char msg[MAXLINE+1];
} saved_message_t;
#define IGN_CONS 0x001
#define IGN_FILE 0x002
#define SYNC_FILE 0x004
#define NOCOPY 0x008
#define ADDDATE 0x010
#define MARK 0x020
#define LOGSYNC 0x040
#define NETWORK 0x100
#define SHUTDOWN 0x200
#define FLUSHMSG 0x400
struct filed {
pthread_mutex_t filed_mutex;
pthread_t f_thread;
dataq_t f_queue;
int f_queue_count;
int f_prev_queue_count;
short f_type;
short f_orig_type;
int f_file;
int f_msgflag;
filed_stats_t f_stat;
saved_message_t f_prevmsg;
saved_message_t f_current;
int f_prevcount;
uchar_t f_pmask[LOG_NFACILITIES+1];
union {
char f_uname[MAXUNAMES][SYS_NMLN + 1];
struct {
char f_hname[SYS_NMLN + 1];
struct netbuf f_addr;
} f_forw;
char f_fname[MAXPATHLEN + 1];
} f_un;
};
#define F_UNUSED 0
#define F_FILE 1
#define F_TTY 2
#define F_CONSOLE 3
#define F_FORW 4
#define F_USERS 5
#define F_WALL 6
#define CURRENT 0
#define SAVED 1
#define CURRENT_VALID 0x01
#define OLD_VALID 0x02
struct code {
char *c_name;
int c_val;
};
typedef struct wall_device {
pthread_t thread;
pthread_attr_t thread_attr;
char dev[PATH_MAX + 1];
char msg[MAXLINE+1];
char ut_name[sizeof (dummy.ut_name)];
} walldev_t;
struct hostname_cache {
struct hostname_cache *next;
struct netbuf addr;
struct netconfig *ncp;
host_list_t *h;
time_t expire;
};
#define DEF_HNC_SIZE 2037
#define DEF_HNC_TTL 1200
#define MAX_BUCKETS 30
int main(int argc, char **argv);
static void usage(void);
static void untty(void);
static void formatnet(struct netbuf *nbp, log_message_t *mp);
static void formatsys(struct log_ctl *lp, char *msg, int sync);
static void *logmsg(void *ap);
static void wallmsg(struct filed *f, char *from, char *msg);
static host_list_t *cvthname(struct netbuf *nbp, struct netconfig *ncp, char *);
static void set_flush_msg(struct filed *f);
static void flushmsg(int flags);
void logerror(const char *type, ...);
static void init(void);
static void conf_init(void);
static void cfline(char *line, int lineno, struct filed *f);
static int decode(char *name, struct code *codetab);
static int ismyaddr(struct netbuf *nbp);
static void getnets(void);
static int addnet(struct netconfig *ncp, struct netbuf *nbp);
static void bindnet(void);
static int logforward(struct filed *f, char *ebuf, size_t elen);
static int amiloghost(void);
static int same_addr(struct netbuf *, struct netbuf *);
static void prepare_sys_poll(void);
static void *sys_poll(void *ap);
static void getkmsg(int);
static void *net_poll(void *ap);
static log_message_t *new_msg(void);
static void free_msg(log_message_t *lm);
static int logmymsg(int pri, char *msg, int flags, int);
static void *logit(void *ap);
static void freehl(host_list_t *h);
static int filed_init(struct filed *h);
static void copy_msg(struct filed *f);
static void dumpstats(int fd);
static void filter_string(char *orig, char *new, size_t max);
static int openklog(char *name, int mode);
static void writemsg(int selection, struct filed *f);
static void *writetodev(void *ap);
static int shutdown_msg(void);
static void server(void *, char *, size_t, door_desc_t *, uint_t);
static void *create_door_thr(void *);
static void door_server_pool(door_info_t *);
static char *alloc_stacks(int);
static void dealloc_stacks(int);
static int checkm4(void);
static void filed_destroy(struct filed *f);
static void open_door(void);
static void close_door(void);
static void delete_doorfiles(void);
static void signull(int, siginfo_t *, void *);
static int putctrlc(int, char **, size_t *, size_t);
static size_t findnl_bkwd(const char *, const size_t);
static size_t copynl_frwd(char *, const size_t, const char *, const size_t);
static size_t copy_frwd(char *, const size_t, const char *, const size_t);
static void logerror_format(const char *, char *, va_list);
static int logerror_to_console(int, const char *);
static void properties(void);
static void shutdown_input(void);
static void *hostname_lookup(void *);
static void reconfigure(void);
static void disable_errorlog(void);
static void enable_errorlog(void);
static void hnc_init(int);
static host_list_t *hnc_lookup(struct netbuf *,
struct netconfig *, int *);
static void hnc_register(struct netbuf *,
struct netconfig *, host_list_t *, int);
static void hnc_unreg(struct hostname_cache **);
static int addr_hash(struct netbuf *nbp);
#ifdef __cplusplus
}
#endif
#endif