#include <MPList.h>
Public Member Functions | |
| MPList () | |
| const char * | makeFilter (unsigned int servernbr, const char *listarg) const |
| MPListEntry * | server (const char *group) |
| MPListEntry * | postserver (const char *group) |
| void | init (void) |
| void | read (Lexer &lex) |
| void | readServer (Lexer &lex, const char *host, const char *port) |
| void | printParameters (std::ostream *pOut) |
Public Attributes | |
| std::vector< MPListEntry > | entries |
Definition at line 63 of file MPList.h.
|
|
Definition at line 70 of file MPList.h.
00070 {};
|
|
|
Definition at line 173 of file MPList.h. References entries. Referenced by Config::init().
00174 {
00175 entries.clear();
00176 }
|
|
||||||||||||
|
Definition at line 102 of file MPList.h. References ASSERT, entries, and slog.
00103 {
00104 static string filter;
00105 char c;
00106 unsigned int i;
00107
00108 if (strcmp(listarg, "*") == 0) {
00109 const char *p, *q;
00110 filter = entries[servernbr].read;
00111 for (i = 0; i < entries.size(); i++) {
00112 if (i != servernbr) {
00113 p = entries[i].read;
00114 for (;;) {
00115 q = p;
00116 while ((c = *p) != ',' && c)
00117 p++;
00118 filter += ",!";
00119 filter.append(q, p - q);
00120 if (!c)
00121 break;
00122 p++;
00123 }
00124 }
00125 }
00126 } else {
00127 const char *listp, *p = NULL, *q = NULL;
00128 filter = "*";
00129 if (servernbr == 0)
00130 i = 1;
00131 else
00132 i = 0;
00133 listp = listarg;
00134 c = '\0';
00135 while (i < entries.size()) {
00136 if (!c) {
00137 q = p = entries[i].read;
00138 }
00139 while ((c = *listp) && c == *p) {
00140 listp++;
00141 p++;
00142 }
00143 if (*listp == '*') {
00144 // p is matched by listarg
00145 ASSERT(if (*p == '*') {
00146 slog.
00147 p(Logger::
00148 Error) <<
00149 "Same newsgroup expression configured for two different servers!\n";}
00150 );
00151 filter += ",!";
00152 while ((c = *p) != ',' && c)
00153 p++;
00154 filter.append(q, p - q);
00155 } else {
00156 // p is not matched by listarg
00157 while ((c = *p) != ',' && c)
00158 p++;
00159 }
00160 if (!c) {
00161 i++;
00162 if (servernbr == i)
00163 i++;
00164 } else {
00165 q = ++p;
00166 }
00167 }
00168 }
00169
00170 return filter.c_str();
00171 }
|
|
|
Definition at line 9 of file MPList.cc. References entries, and matchgroup(). Referenced by RServer::post().
00010 {
00011 unsigned int i;
00012 // bm=Best Match
00013 int bm = -1, bmlen = 0, clen;
00014
00015 for (i = 0; i < entries.size(); i++) {
00016 clen = matchgroup(entries[i].postTo, group);
00017 if (clen > bmlen) {
00018 bm = i;
00019 bmlen = clen;
00020 }
00021 }
00022 if (bm >= 0 && entries[bm].hostname[0] != '\0')
00023 return &(entries[bm]);
00024 return NULL;
00025 }
|
|
|
Definition at line 276 of file MPList.cc. References entries. Referenced by Config::printParameters().
|
|
|
Definition at line 112 of file MPList.cc. References ERROR_LOCATION, Lexer::getToken(), and readServer(). Referenced by Config::read().
00113 {
00114 string tok, host, port;
00115
00116 tok = lex.getToken();
00117 if (tok != "{")
00118 throw SyntaxError(lex, "expected '{'", ERROR_LOCATION);
00119 for (;;) {
00120 tok = lex.getToken();
00121 if (tok == "Server") {
00122 host = lex.getToken();
00123 port = lex.getToken();
00124 readServer(lex, host.c_str(), port.c_str());
00125 } else if (tok == "NoServer") {
00126 readServer(lex, NULL, NULL);
00127 } else if (tok == "}") {
00128 break;
00129 } else {
00130 throw SyntaxError(lex,
00131 "expected declaration or '}'",
00132 ERROR_LOCATION);
00133 }
00134 }
00135 }
|
|
||||||||||||||||
|
Definition at line 137 of file MPList.cc. References MPListEntry::bindFrom, entries, ERROR_LOCATION, MPListEntry::flags, Lexer::getToken(), MPListEntry::groupTimeout, MPListEntry::hostname, MPListEntry::nntpflags, MPListEntry::passwd, MPListEntry::postTo, Lexer::putbackToken(), MPListEntry::read, MPListEntry::retries, MPListEntry::servicename, and MPListEntry::user. Referenced by read().
00138 {
00139 string tok, a1, a2, a3;
00140 int havePostTo = 0;
00141 MPListEntry cur;
00142
00143 if (host) {
00144 strcpy(cur.hostname, host);
00145 strcpy(cur.servicename, port);
00146 }
00147
00148 tok = lex.getToken();
00149 if (tok != "{")
00150 throw SyntaxError(lex, "expected '{'", ERROR_LOCATION);
00151 for (;;) {
00152 tok = lex.getToken();
00153 if (tok == "Read") {
00154 a1 = lex.getToken();
00155 if (a1.length() >= sizeof(cur.read))
00156 throw SyntaxError(lex,
00157 "group description too long",
00158 ERROR_LOCATION);
00159 strcpy(cur.read, a1.c_str());
00160 if (!havePostTo) {
00161 if (a1.length() >= sizeof(cur.postTo))
00162 throw SyntaxError(lex,
00163 "group description too long",
00164 ERROR_LOCATION);
00165 strcpy(cur.postTo, a1.c_str());
00166 }
00167 } else if (tok == "BindFrom") {
00168 a1 = lex.getToken();
00169 if (a1.length() >= sizeof(cur.bindFrom))
00170 throw SyntaxError(lex,
00171 "BindFrom field is too long",
00172 ERROR_LOCATION);
00173 strcpy(cur.bindFrom, a1.c_str());
00174 } else if (tok == "PostTo") {
00175 a1 = lex.getToken();
00176 if (a1.length() >= sizeof(cur.postTo))
00177 throw SyntaxError(lex,
00178 "group description too long",
00179 ERROR_LOCATION);
00180 strcpy(cur.postTo, a1.c_str());
00181 } else if (tok == "GroupTimeout") {
00182 a1 = lex.getToken();
00183 cur.groupTimeout = atoi(a1.c_str());
00184 } else if (tok == "Retries") {
00185 a1 = lex.getToken();
00186 cur.retries = atoi(a1.c_str());
00187 } else if (tok == "User") {
00188 a1 = lex.getToken();
00189 strncpy(cur.user, a1.c_str(), 64);
00190 } else if (tok == "Password") {
00191 a1 = lex.getToken();
00192 strncpy(cur.passwd, a1.c_str(), 64);
00193 } else if (tok == "Options") {
00194 int flag;
00195 for (;;) {
00196 a1 = lex.getToken();
00197 if (lex.
00198 isFlag(a1.c_str(), "setpostflag",
00199 &flag)) {
00200 if (flag)
00201 cur.flags |=
00202 MPListEntry::
00203 F_SETPOSTFLAG;
00204 else
00205 cur.flags &=
00206 ~MPListEntry::
00207 F_SETPOSTFLAG;
00208 } else if (lex.
00209 isFlag(a1.c_str(), "cached",
00210 &flag)) {
00211 if (flag)
00212 cur.flags |=
00213 MPListEntry::F_CACHED;
00214 else
00215 cur.flags &=
00216 ~MPListEntry::F_CACHED;
00217 } else if (lex.
00218 isFlag(a1.c_str(), "offline",
00219 &flag)) {
00220 if (flag)
00221 cur.flags |=
00222 MPListEntry::F_OFFLINE;
00223 else
00224 cur.flags &=
00225 ~MPListEntry::
00226 F_OFFLINE;
00227 } else if (a1 == "semioffline") {
00228 cur.flags |=
00229 MPListEntry::F_SEMIOFFLINE;
00230 } else {
00231 break;
00232 }
00233 }
00234 lex.putbackToken(a1);
00235 } else if (tok == "Commands") {
00236 int flag;
00237 for (;;) {
00238 a1 = lex.getToken();
00239 if (lex.
00240 isFlag(a1.c_str(), "listgroup",
00241 &flag)) {
00242 if (flag)
00243 cur.nntpflags |=
00244 MPListEntry::
00245 F_LISTGROUP;
00246 else
00247 cur.nntpflags &=
00248 ~MPListEntry::
00249 F_LISTGROUP;
00250 } else if (lex.
00251 isFlag(a1.c_str(), "over",
00252 &flag)) {
00253 if (flag)
00254 cur.nntpflags |=
00255 MPListEntry::F_OVER;
00256 else
00257 cur.nntpflags &=
00258 ~MPListEntry::F_OVER;
00259 } else {
00260 break;
00261 }
00262 }
00263 lex.putbackToken(a1);
00264 } else if (tok == "}") {
00265 break;
00266 } else {
00267 throw SyntaxError(lex,
00268 "expected declaration or '}'",
00269 ERROR_LOCATION);
00270 }
00271 }
00272
00273 entries.push_back(cur);
00274 }
|
|
|
Definition at line 27 of file MPList.cc. References entries, and matchgroup(). Referenced by CServer::article(), CServer::getgroup(), CServer::groupinfo(), CServer::listgroup(), CServer::overviewdb(), RServer::selectgroup(), and Config::server().
00028 {
00029 unsigned int i;
00030 // bm=Best Match
00031 int bm = -1, bmlen = 0, clen;
00032
00033 for (i = 0; i < entries.size(); i++) {
00034 clen = matchgroup(entries[i].read, group);
00035 if (clen > bmlen) {
00036 bm = i;
00037 bmlen = clen;
00038 }
00039 }
00040 if (bm >= 0 && entries[bm].hostname[0] != '\0')
00041 return &(entries[bm]);
00042 return NULL;
00043 }
|
|
|
Definition at line 65 of file MPList.h. Referenced by CServer::article(), RServer::article(), init(), main(), makeFilter(), RServer::post(), postserver(), printParameters(), readServer(), and server(). |
1.3.6-20040222