"C-Period" to find my messages; "C-Insert" to copy post URL to clipboard
[knntp.git] / nntplist.d
blobc33c29f1a87da3650fdb6bf0a77e1be0f7bd8855
1 /* DigitalMars NNTP reader
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 module nntplist is aliced;
20 import std.datetime;
22 import iv.cmdcon;
23 import iv.strex;
24 import iv.vfs;
25 import iv.vfs.io;
27 import nntp;
30 // ////////////////////////////////////////////////////////////////////////// //
31 void main (string[] args) {
32 if (args.length == 1) args ~= "D";
34 foreach (string group; args[1..$]) {
35 writeln("=== GROUP: ", group, " ===");
37 auto abase = new ArticleBase(group);
38 abase.load();
39 conwriteln(abase.alist.length, " articles read");
41 void writeXStr(char fch=' ') (const(char)[] s, uint maxlen) {
42 s = Article.decodeq(s);
43 if (s.length > maxlen) s = s[0..maxlen];
44 write(s);
45 foreach (immutable _; s.length..maxlen) write(fch);
48 void writeHeader (in ref Article art) {
49 //if (art.msgid == "<fatxgsdzjwzimlgxlliu@forum.dlang.org>") writeln("************************************");
50 if (art.flags&art.Flag.Unread) write("* "); else write(" ");
51 writef("%05d: ", art.number);
52 foreach (immutable _; 0..art.depth) write(' ');
53 writeXStr!'.'(art.subj, 60-art.depth);
54 write(" ");
55 writeXStr!'.'(art.from, 40);
56 write(" ");
57 writeln(SysTime.fromUnixTime(art.time));
60 void doTree (uint idx) {
61 while (idx != 0) {
62 auto art = abase[idx];
63 writeHeader(*art);
64 doTree(art.firstchildidx);
65 idx = art.nextsibidx;
69 auto cur = abase[abase.first];
70 while (cur) {
71 assert(cur.depth == 0);
72 assert(cur.parentidx == 0);
73 writeHeader(*cur);
74 doTree(cur.firstchildidx);
75 cur = abase[cur.nextsibidx];