#include "str.h"
#include "domain.h"
/*char *busy_names[]={"XOVER ","XHDR ","BODY ","LIST ","LIST_NAMES","NEWGROUPS","NEWNEWS","FEED","HDR_BODY","HDR_ARTICLE","DELAY","GROUP_SUCK","THREAD","","",""};*/

enum {M_XOVER,M_XHDR,M_BODY,M_LIST,M_LIST_NAMES,M_NEWGROUPS,M_NEWNEWS,M_FEED,M_HDR_BODY,M_HDR_ARTICLE,M_XDELAY,M_SUCK_GROUP,M_THREAD};
enum {C_CMD,C_POST,C_GETITEM,C_CHECK,C_GETLIST,C_WAIT,C_IHAVE,
	C_GETITEM_STATUS,C_GETITEM_NEXT,
	C_STREAM_NEXT,C_STREAM_ITEM,C_STREAM_GROUP,C_LIVE,C_ID_READ,C_CLOSED,C_POP_READ,
	C_FN,C_LISTGROUP};
#include "maxchan.h"
void chan_cleardom(void);
void chan_setdom(int c, Dom *d);
Dom *chan_getdom(int c);
int chan_allow(int c);
void chan_setisihave(int c, int x);
void chan_setused(int c);
int chan_isihave(int c);
int chan_setready(int c, int x);
char *chan_getusergroups(int c);
int rad_acct(char *user,int nbytes,char *host,char *seckey,int chanid,int type);
int thin_socket_read(int c, char *bf, int sz, int msec, char *reason);

int nntp_wait_write(int c, int msec);
int chan_setinbody(int c,int x);
int chan_setinspeed(int c, int x);
int chan_setcompress(int c);
int chan_gethash(int c);
int nntp_isclosing(int c);
int nntp_isslowdown(int i);
void chan_setfn(int c, int (*fn)(int chan, char *data, int sz));
char *chan_busystr(int c);
void chan_purge_ihave(void);
void nntp_set_bind(char *ipaddr);
int chan_isdrop(int c);
int chan_open_bind(char *s, char *ip);
void chan_sendlog(char *s);
void chan_addlog(int c);
void chan_setauth(int c, int x);
void nntp_setports(int c, int local, int remote);
void cstat_addin(int c, int n);
void cstat_addout(int c, int n);
void cstat_addnread(int c, int n);
void cstat_init(int chan);
void cstat_log(int c);
char *cstat_fname(void);
int chan_waitfor(int c, int ms);
int chan_setlimits(int mb, int con, int sp);
int nntp_setmulti(int chan, int t);
int nntp_ismulti(int chan);

int chan_nusers(void);
void chan_sethitrate(int c, double h);
void chan_write_slen(int c, char *s,int len);
int chan_isreject(int c);
void user_report(int c);
void user_record(int c);
void user_addinfo(int c, int nread, int nxov, int nbytes);
void chan_setreject(int c, int t);
int chan_otheruser(int x);
int dll_group(char *user, char *group, int type);

void chan_setrealuser(int i);
void chan_setaccess(int c, int t);
int chan_getaccess(int c);
int nntp_chanwait(int c, int sec);
int chan_inspeed(int c);
char *chan_con(void);

char *chan_elimit(void);
void chan_gotdup(int c);
void chan_setlog(int c,int x);
char *chan_getid(int c);
char *chan_getipnum(int c);
int chan_isfree(int c);
void chan_newchan(int c);
void chan_setident(int c, char *s);
void chan_readbf(int c);
int chan_ismore(int c);
void chan_dorest(int c);
int chan_needauth(int c);
void chan_settimeout(int c, int t);
void chan_write_buff_str(int c, String *s);
int chan_cantalk(int c);
void chan_purge(void);
String *chan_status(void);
void channel_read(int c);
void chan_setstate(int c, int st);
int chan_read(int c, char *ss, int sz);
int do_cmd(int chan, char *in, int sz);
void chan_write_buff(int c, char *s);
void chan_write_s(int c, char *s);
void chan_write(int c, String *s);
void chan_write_str(int c, String *s);
void chan_write_flush(int c);
void chan_close(int c);
int chan_open(char *s);

int chan_getgrp(int c);
void chan_setgrp(int c, int g);
int chan_getnum(int c);


int chan_getnum(int c);
void chan_setnum(int c, int g);
int chan_canpost(int c);
void chan_setuser(int c, char *u);
char *chan_getuser(int c);
int chan_check(int c, char *p);
void chan_gotarticle(int c);
void chan_gotpost(int c, int ok, int size);
int chan_isopen(int c);

void access_read(void);
int access_check(char *ipname, char *ipnum,char *ipuser, char *ippass	, char *postgrps, char *readgrps, int *canpost, int *canread, int *canihave, int *isauth);
int chan_canreadgrp(int c, char *grp);
int chan_canpostgrp(int c, char *grp);
int chan_canihave(int c);
char *chan_getipname(int c);
void chan_setipname(int c, char *s);
void chan_setipnum(int c, char *s);
void chan_setpass(int c, char *u);
char *chan_getpass(int c);
int chan_readart(int chan, char *gname, int article, int size, char *reason);

/*RHP prototypes missing*/
void chan_init(int c);
void test_read(void);
