-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroup.H
149 lines (130 loc) · 4.37 KB
/
Group.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//
// Group.H -- Manage newsgroup groups
//
// Copyright 2003 Michael Sweet
// Copyright 2002 Greg Ercolano
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public Licensse as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef GROUP_H
#define GROUP_H
#include "everything.H"
class Group
{
// ".info" FILE DATA
unsigned long start, end, total; // start/end/total articles
// ".config" FILE DATA
string desc; // group description
string creator; // group creator email
string name; // group name
string ccpost; // email address to cc all postings to
string replyto; // optional replyto address
string voidemail; // bit bucket
int postok, // allow posting to this group
postlimit; // posting line limit
string dirname; // directory name
time_t ctime; // creation time
int valid; // is group valid? 0=invalid
string errmsg; // error message
char datebuf[80]; // RFC822 date buffer
// GENERAL LOCKING
// Write lock whenever posting or saving info file.
// Read lock before accessing info file.
//
int WriteLock();
int ReadLock();
void Unlock(int fd);
int WriteString(FILE *fp, const char *buf);
int BuildInfo(int dolock = 1);
int LoadInfo(int dolock = 1);
int SaveInfo(int dolock = 1);
int LoadConfig(int dolock = 1);
int SaveConfig();
void ReorderHeader(const char*overview[], vector<string>& head);
const char *DateRFC822();
void _Copy(const Group&o)
{
start = o.start;
end = o.end;
total = o.total;
desc = o.desc;
creator = o.creator;
name = o.name;
ccpost = o.ccpost;
replyto = o.replyto;
voidemail = o.voidemail;
postok = o.postok;
postlimit = o.postlimit;
ctime = o.ctime;
valid = o.valid;
}
public:
Group()
{
start = end = total = 0;
desc = "";
creator = "news";
name = "";
ccpost = "-";
replyto = "-";
voidemail = "root";
postok = 0;
postlimit = 0;
ctime = 0;
valid = 0;
}
~Group()
{ }
Group(const Group&o)
{
_Copy(o);
}
Group& operator=(const Group&o)
{
_Copy(o);
return(*this);
}
// ACCESSORS
unsigned long Start() { return(start); }
unsigned long End() { return(end); }
unsigned long Total() { return(total); }
int PostOK() { return(postok); }
int PostLimit() { return(postlimit); }
long Ctime() { return(ctime); }
int IsValid() { return(valid); }
int IsCCPost() { return(ccpost == "-" ? 0 : 1); }
int IsReplyTo() { return(replyto == "-" ? 0 : 1); }
const char *Description() { return(desc.c_str()); }
const char *Creator() { return(creator.c_str()); }
const char *Name() { return(name.c_str()); }
const char *CCPost() { return(ccpost.c_str()); }
const char *ReplyTo() { return(replyto.c_str()); }
const char *VoidEmail() { return(voidemail.c_str()); }
const char *Errmsg() { return(errmsg.c_str()); }
void Start(unsigned long val) { start = val; }
void End(unsigned long val) { end = val; }
void Total(unsigned long val) { total = val; }
void Name(const char*val) { name = val; }
int Load(const char *group, int dolock = 1);
int WriteInfo(int fd);
int FindArticleByMessageID(const char *find_messageid, unsigned long &articlenum);
int Post(const char*overview[], vector<string> &head,
vector<string> &body, const char *remoteip_str, bool force = false);
const char *Dirname();
int NewGroup();
int ParseArticle(string &msg, vector<string>&head, vector<string>&body);
void UpdatePath(vector<string>&head);
};
#endif /*!GROUP_H*/