00001 #ifndef _GROK_INPUT_H_
00002 #define _GROK_INPUT_H_
00003
00004 #include <sys/stat.h>
00005 #include <sys/time.h>
00006 #include <sys/types.h>
00007 #include <time.h>
00008 #include <event.h>
00009
00010 #include "grok_program.h"
00011
00012 struct grok_program;
00013 typedef struct grok_input grok_input_t;
00014 typedef struct grok_input_process grok_input_process_t;
00015 typedef struct grok_input_file grok_input_file_t;
00016
00017 #define PROCESS_SHOULD_RESTART(gipt) ((gipt)->restart_on_death || (gipt)->run_interval)
00018
00019 struct grok_input_process {
00020 char *cmd;
00021 int cmdlen;
00022
00023
00024 int p_stdin;
00025 int p_stdout;
00026 int p_stderr;
00027 int c_stdin;
00028 int c_stdout;
00029 int c_stderr;
00030 int pid;
00031 int pgid;
00032 struct timeval start_time;
00033
00034
00035 int restart_on_death;
00036 int min_restart_delay;
00037 int run_interval;
00038 int read_stderr;
00039 };
00040
00041 struct grok_input_file {
00042 char *filename;
00043
00044
00045 struct stat st;
00046 char *readbuffer;
00047 off_t offset;
00048 int writer;
00049 int reader;
00050 int fd;
00051 struct timeval waittime;
00052
00053
00054 int follow;
00055 };
00056
00057 struct grok_input {
00058 enum { I_FILE, I_PROCESS } type;
00059 union {
00060 grok_input_file_t file;
00061 grok_input_process_t process;
00062 } source;
00063 struct grok_program *gprog;
00064
00065 struct bufferevent *bev;
00066 int instance_match_count;
00067 int logmask;
00068 int logdepth;
00069 struct timeval restart_delay;
00070 int done;
00071 };
00072
00073 void grok_program_add_input(struct grok_program *gprog, grok_input_t *ginput);
00074 void grok_program_add_input_process(struct grok_program *gprog, grok_input_t *ginput);
00075 void grok_program_add_input_file(struct grok_program *gprog, grok_input_t *ginput);
00076 void grok_input_eof_handler(int fd, short what, void *data);
00077
00078 #endif