#define MAXSUCK 200
#define SHORTSTR 200
typedef struct SUCK {
	char site[BFSZ];
	char user[BFSZ];
	char pass[BFSZ];
	char groups[BFSZ];
	char disable[200];
	int warned;
	int later;
	int nlinks;
	int id;
	int con;
	int ispull;
	int percent;
	int maxitems;
	int maxage;
	int speed;
	int mb;	/* Per day */
	double bytes;
	char *mask;
	int nmask;
	int gupto;
	int nok,nrej,ndup,ngot;
	int nok2,nrej2,ndup2;
	double bytes2;
	int nonext; /* next command doesn't work */
	char lasterr[BFSZ];
	char lastok[BFSZ];
} Suck;
typedef struct LINK {
	int chan;
	int state;
	char gname[BFSZ];	/* Group we are fetching */
	char mid[BFSZ];
	int grp;
	int id;
	int uptoi;
	int min,max,nitems;
	int xtime;
	long batchsize;
	struct LINK *next;
	Suck *suck;
} Link;

int pull_clear(void);

char *pull_status(void);
int pull_isstop(Suck *p) ;
void pull_die(void);
void pull_safe_check(char *when);
void pull_double_grab(void);

void pull_double_check(char *whenxc);
void pull_init(void);
void pull_init_one(int sk);
void pull_idle(void);
void pull_start(int sk);
void pull_open_link(Link *l);
void pull_start_link(Link *l);
int set_useage(int x);
int  pull_data_chan(int chan, char *data, int len);
void pull_store(Link *l);
void pull_data_body(Link *l,char *data,int len);
void pmsg(Link *l, char *fmt, ...);
void pemsg(Link *l, char *fmt, ...);
int pull_write(Link *l, char *fmt, ...);
Link *pull_new_link(int sk);
void pull_data(Link *l, char *line);
void pull_fetch(char *group, char *site);
int pull_add(int grp, int suck, int isurgent) ;
int pull_next(int *grp, Suck *sk);
int pull_link_close(Link *l);
int pull_upto_get(Link *sk, int grp);
int pull_upto_set(Link *l, int grp,int v);
void link_close(Link *l);
int pull_link_open(Link *l);
int pull_show(int chan, char *group);
int pull_getold(int grp, int feed, int items);
int pull_true(int suck);
int pull_suck(int grp, int suck, int isurgent);
void pdmsg(Link *l, char *arg_list, ...);
int pull_isstop(Suck *sk) ;
int pull_stop(Suck *sk);
int pull_link_status(int chan);

