#ifndef _NNTP_H_ #define _NNTP_H_ /* * Copyright (c) 1996, Ruslan R. Laishev (@RRL) */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * */ extern char *ID$IDcpy; extern char *ID$IDsrv; extern char *ID$IDver; /* * */ #define NNTP_EOL "\r\n" #define NNTP_EOT ".\r\n" #define NNTP_OK ".\r\n" #define NNTPMAXWORKER 128 typedef struct { char *cmd; int (*nntp_fun) (); char *hlp; } NNTP_cmd_t; /* * Structure of nntp$msg.db */ #define Msg_MaxRec 32000 #define MsgGrp$_pos 0 #define MsgGrp$_len 64+16 #define MsgGrp$_ref 0 #define MsgId$_pos MsgGrp$_len #define MsgId$_len 64 #define MsgId$_ref 1 #define MsgDate$_pos MsgId$_pos+MsgId$_len #define MsgDate$_len sizeof(time_t) #define MsgDate$_ref 2 typedef struct { char Grp [MsgGrp$_len]; char MsgId [MsgId$_len]; time_t Date; } MsgKey; /* * Structure of nntp$grp.db */ typedef struct { #define GrpName$_len 64 /* News group name */ char GrpName [GrpName$_len]; unsigned long First; /* # of first available message */ unsigned long Last; /* # of last available message */ char PostFlag; /* 'form of posting' flag */ char SuckFlag; /* 'group cached' flag */ time_t DateCr; /* date of news group creation */ time_t DateUp; /* date of last 'GROUP ...' */ } GrpKey; #define Grp_MaxRec sizeof(GrpKey) #define GrpName$_pos 0 #define GrpName$_ref 0 /* * Structure of nntp$suck.db */ typedef struct { #define Suck$_len (16+1+GrpName$_len) char Host_Grp [Suck$_len]; /* IP address in ASCII form + "," */ /* + news group name */ unsigned long Last; /* Index of last geted message */ } SuckRec; #define Suck_MaxRec sizeof(SuckRec) #define Suck$_pos 0 #define Suck$_ref 0 /* * Structure of nntp$feed.db */ typedef struct { #define Feed$_len (Suck$_len) char Host_Grp [Feed$_len]; /* IP address in ASCII form + "," */ /* + news group name */ unsigned long Last; /* Index of last feeded message */ } FeedRec; #define Feed_MaxRec sizeof(FeedRec) #define Feed$_pos 0 #define Feed$_ref 0 /* * */ enum {T_Null,T_Suck,T_Feed,T_Clnt}; /* "Type" code's for Wctx.type */ enum {A_Read = 0x1,A_Post = 0x2,A_Ihav = 0x4}; typedef struct { int type; /* Type of worker: suck,feed,client */ pthread_mutex_t mutex; /* Mutual exclusion lock flag */ pthread_t tid; /* Thread identificator */ int indx; int chan; /* TCP I/O socket */ #define BUFPSZ 512 char bufp [ BUFPSZ ]; struct RAB Grprab; struct RAB Msgrab; struct RAB Suckrab; struct RAB Feedrab; char MsgBuff [Msg_MaxRec]; #define MSGBUFFSZ Msg_MaxRec #define MSGMAXSZ (MSGBUFFSZ - sizeof(MsgKey)) /* Current News Group */ char Grp [GrpName$_len]; int MsgNum; /* Current Message number */ int MsgNumf; } WorkerContext; typedef struct { char *LocalHost; char *LocalPath; char *LocalTZ; int LocalPort; int LocalMgr; int MsgDBsize; int MsgPurgeDay; int MsgOld; int MsgPurgeNum; int ClientTimeOut; int SuckTimeOut; int FeedTimeOut; char *GrpME; int GrpDay; char *Suck; char *Feed; char *Client; int LogLevel; int SuckInterval; int FeedInterval; time_t Expire; } nntp_conf_t; #ifndef nntp_conf nntp_conf_t nntp_conf; #else external nntp_conf_t nntp_conf; #endif #endif /* _NNTP_H_ */