/***********************************************************************
 *
 *    tcpserver_blocker
 *
 *    Author: Nico Schottelius
 *    Date: 2006-08-03
 *
 *    Main header
 */

#ifndef TCPSERVER_BLOCKER_H
#define TCPSERVER_BLOCKER_H

struct prog_opts {
   unsigned long begin;    /* the first time to take into account       */
   int   cur_time;         /* the current time                          */
   int   *intervals;       /* 0 terminated list of intervals            */
   char  **ipns;           /* NULL terminated list of ipns to take      */
   char  *logdir;
} options;

struct result {
   char  *ipn;             /* ipn or in case of total: "Totals"         */
   int   *intervals;       /* -1   terminated list of results           */
   int   *values;          /* -1   terminated list of raw values        */
   struct result *next;    /* where to find the next data               */
};

struct result *results;    /* linked list                               */


#define ARGV_COUNT_MIN  3  /* logdir interval                           */

#define MSG_USAGE    "tcpserver_analyzer 0.1 "              \
                     "- written by Nico Schottelius\n\n"    \
                     "Usage: tcpserver_analyzer "           \
                     "<logdir> <seconds start> "            \
                     "<intervals ...> --  <ipns ...>\n"

/***********************************************************************
 * Functions
 */

int   do_argv        (int, char **);
int   calculate      (struct result *res);   /* calculate               */
int   read_data      (void);                 /* read data from db       */
int   read_data_all  (void);                 /* read data for all ipn   */
int   check_ip       (void);
int   fork_cmd       (void);
int   get_time       (void);
void  mini_printf    (char *,int);
void  print_errno    (char *);
struct result *read_data_ipn  (char * , char*);   /* read data for one ipn   */

int list_add(struct result *);
struct result *list_next(struct result *);


#include <unistd.h>
int ultostr(unsigned long, unsigned int, char*, size_t);

#endif
