/* acidblood header file */
/* Copyright (C) 1997-1999 Bryan Schwab */

#define VERSION "1.2.10"

#include <stdio.h>
#include <time.h>

/* structure for bot information from config file */
struct botstruct {
        char *user;
        char *nick;
        char *altnick;
        char *fname;
        char *channel;
        char *server;
        char *awaymsg;
 	int ctcp;
 	int autoop;
 	int reqpass;
        int port;
	char *ver;
	int ns;
	char *nspass;
        char *image;
	int timer;
	int timeout;
};
struct botstruct *botinfo;

/* structure for parsed server information */
struct serverstruct {
        char *nick;         /* user nick name*/
        char *username;     /* user name */
        char *ip;           /* ip address */
        char *action;       /* irc action */
        char *message;      /* message */
        char *extra;        /* last part of server message */
};
struct serverstruct *serverdata; /* pointer to structure */

/* link list of user entries */
struct userdata {
        char *usernick;
        char *userip;
        int userstatus;
        char *userchan;
        char *userpass;
        struct userdata *next;
};

/* massdeop list */
struct mddata {
        char *nick;
        struct mddata *next;
};

/* channel list */
struct channels {
        char *channel;
        char *key;
        struct channels *next;
};
struct channels *channeldata; /* pointer to structure */

/* Global variables */
struct userdata *curr; /* current pointer of linked list */
struct userdata *top;  /* top pointer of linked list */
struct userdata *prev; /* previous pointer in linked list */
struct mddata *curr2;  /* pointers for 2nd linked list of users for massdeops */
struct mddata *top2;
struct mddata *prev2;
struct channels *curr3;  /* channel list pointers */
struct channels *top3;
struct channels *prev3;
struct channels *temp3;
char *protect;         /* protected user from massdeops */
int no_parse;
long totalbytes;

/* global place counter */
int globalx;

/* global interrupt flag */
int globalint;

/* global input string */
char *input;

/* parser functions */
int read_user_data();
int read_config();
int parse_server (char *input, struct serverstruct *serverdata, FILE **fp_debug, FILE **fp_log);
int get_channel(struct channels *channeldata, char *data, char *key);
void strip_delim(char *data);

/* network functions */
int connect_to_server(struct botstruct *botinfo, FILE **fp_socket, FILE **fp_log, int *s);
int getline_from_server(struct botstruct *botinfo, char *c ,int s);

/* list functions */
int insert_channels(char *data, char *key);
int free_list();
int insert_users(char *nick, char *ip, char *status, char *channels, char *password);
int match_ip(char *listip, char *serverip);
int check_chan(char *userchan, char *serverchan);
int traverse_users(struct serverstruct *serverdata, char *channel, char *password);
int delete_channel(char *data);
int check_level(struct serverstruct *serverdata);
int check_pass(char *userpass, char *serverpass);
int insert_channels(char *data, char *key);

/* action functions */
int execute(struct serverstruct *serverdata, struct botstruct *botinfo, FILE **fp_debug, FILE **fp_socket, FILE **fp_log, int *s, char *timestr, time_t starttime);
