annotate src/server.c @ 223:ffb1848a39db noffle

[svn] * src/util.c: Improve (correct) error detection when updating timestamp file. * src/content.h, src/content.c: Return Boolean success/fail from Cont_write. Also ensure cont.first isn't polluted in the event of a failed update. * src/client.c,src/control.c,src/fetch.c,src/noffle.c,src/post.c, src/pseudo.c: If Cont_write fails, don't do actions that need it to have worked. Typically, don't update first and last article numbers in group database. * src/server.c: If groupinfo.lastupdate is unreadable or corrupt, spot this and report it and give an explicit error when processing NNTP NEWGROUPS command.
author bears
date Sun, 09 Dec 2001 12:31:57 +0000
parents 24d4cd032da5
children f8a91e2b4060
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
2 server.c
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
3
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
4 $Id: server.c 342 2001-12-09 12:31:57Z bears $
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
5 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
6
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
7 #if HAVE_CONFIG_H
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
8 #include <config.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
9 #endif
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
10
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
11 #if TIME_WITH_SYS_TIME
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
12 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
13 #include <time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
14 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
15 #if HAVE_SYS_TIME_H
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
16 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
17 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
18 #include <time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
19 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
20 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
21
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
22 #include <stdio.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
23 #include <ctype.h>
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
24 #include <errno.h>
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include <signal.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <stdarg.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include <sys/types.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 #include <unistd.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 #include "client.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 #include "common.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
31 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 #include "content.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "database.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 #include "dynamicstring.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 #include "fetch.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
36 #include "fetchlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
37 #include "group.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 #include "itemlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 #include "lock.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
41 #include "online.h"
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
42 #include "over.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
43 #include "post.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
44 #include "protocol.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
45 #include "pseudo.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46 #include "request.h"
197
24d4cd032da5 [svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents: 191
diff changeset
47 #include "server.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48 #include "util.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 #include "wildmat.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
50 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 struct
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
53 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
54 Bool running;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
55 time_t lastServerOpen;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
56 int artPtr;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57 Str grp; /* selected group, "" if none */
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
58 DynStr *reply;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
59 Bool eotAfterReply;
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
60 Bool groupReady;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
61 } server = { FALSE, 0L, 0, "", NULL, FALSE, FALSE };
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
63 typedef struct Cmd
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
65 const char *name;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
66 const char *syntax;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
67 /* Returns false, if quit cmd */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
68 Bool (*cmdProc)( char *arg, const struct Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
69 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
70 Cmd;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
71
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
72 static Bool doArt( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
73 static Bool doBody( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
74 static Bool doGrp( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
75 static Bool doHead( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
76 static Bool doHelp( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 static Bool doIhave( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
78 static Bool doLast( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79 static Bool doList( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
80 static Bool doListgrp( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
81 static Bool doMode( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
82 static Bool doNewgrps( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
83 static Bool doNext( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
84 static Bool doPost( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85 static Bool doSlave( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
86 static Bool doStat( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 static Bool doQuit( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
88 static Bool doXhdr( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
89 static Bool doXpat( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
90 static Bool doXOver( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
91 static Bool notImplemented( char *arg, const Cmd *cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 static void putStat( unsigned int stat, const char *fmt, ... );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
93
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
94 static void closeServer( void );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
95 static Bool initServer( void );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
96
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
97 Cmd commands[] =
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
98 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
99 { "article", "ARTICLE [msg-id|n]", &doArt },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
100 { "body", "BODY [msg-id|n]", &doBody },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
101 { "head", "HEAD [msg-id|n]", &doHead },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
102 { "group", "GROUP grp", &doGrp },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
103 { "help", "HELP", &doHelp },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
104 { "ihave", "IHAVE (ignored)", &doIhave },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
105 { "last", "LAST", &doLast },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106 { "list", "LIST [ACTIVE [pat]]|ACTIVE.TIMES [pat]|"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
107 "EXTENSIONS|NEWSGROUPS [pat]|OVERVIEW.FMT", &doList },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
108 { "listgroup", "LISTGROUP grp", &doListgrp },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
109 { "mode", "MODE (ignored)", &doMode },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
110 { "newgroups", "NEWGROUPS [xx]yymmdd hhmmss [GMT]", &doNewgrps },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
111 { "newnews", "NEWNEWS (not implemented)", &notImplemented },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
112 { "next", "NEXT", &doNext },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
113 { "post", "POST", &doPost },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 { "quit", "QUIT", &doQuit },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
115 { "slave", "SLAVE (ignored)", &doSlave },
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
116 { "stat", "STAT [msg-id|n]", &doStat },
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
117 { "xhdr", "XHDR over-field [msg-id|m[-[n]]]", &doXhdr },
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
118 { "xpat", "XPAT over-field msg-id|m[-[n]] pat", &doXpat },
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
119 { "xover", "XOVER [m[-[n]]]", &doXOver }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
120 };
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
121
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
122 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
123 Notice interest in reading this group.
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
124 Automatically subscribe if option set in config file.
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
125 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
126 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127 noteInterest( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
129 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
130
191
28488e0e3630 [svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents: 188
diff changeset
131 Grp_setLastAccess( server.grp );
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
132 if ( ! Grp_local ( server.grp ) && ! Online_true() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
134 Fetchlist_read();
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
135 if ( ! Fetchlist_contains( server.grp ) )
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
136 {
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
137 if ( Cfg_autoSubscribe() )
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
138 {
106
46062d2f9d20 [svn] Auto subscribe mode now group-dependent
bears
parents: 88
diff changeset
139 if ( strcmp( Cfg_autoSubscribeMode( server.grp ), "full" ) == 0 )
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
140 mode = FULL;
106
46062d2f9d20 [svn] Auto subscribe mode now group-dependent
bears
parents: 88
diff changeset
141 else if ( strcmp( Cfg_autoSubscribeMode( server.grp ), "thread" ) == 0 )
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
142 mode = THREAD;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
143 else
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
144 mode = OVER;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
145 Fetchlist_add( server.grp, mode );
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
146 Fetchlist_write();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
147 Pseudo_autoSubscribed();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
148 }
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
149 else if ( Cfg_infoAlways() )
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
150 {
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
151 int first, last;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
152
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
153 /* Ensure new gen info for next time */
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
154 first = Cont_first();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
155 last = Cont_last();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
156
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
157 if ( first == last )
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
158 first = last + 1;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
159
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
160 Grp_setFirstLast( Cont_grp(), first, last );
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
161 }
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
162 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
163 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
164 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
165
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
166 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
167 putStat( unsigned int stat, const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
168 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
169 Str s, line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
170 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
171
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
172 ASSERT( stat <= 999 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
173 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
174 vsnprintf( s, MAXCHAR, fmt, ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
175 va_end( ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
176 snprintf( line, MAXCHAR, "%u %s", stat, s );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
177 DynStr_appLn( server.reply, line );
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 181
diff changeset
178 Log_dbg( LOG_DBG_PROTOCOL, "[S] %s", line );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
179 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
180
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
181 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
182 putTxtLn( const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
183 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
184 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
185 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
186
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
187 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
188 vsnprintf( line, MAXCHAR, fmt, ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
189 va_end( ap );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
190 DynStr_appLn( server.reply, line );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
191 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
192
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
193 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
194 putTxtBuf( const char *buf )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
196 if ( buf )
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
197 DynStr_app( server.reply, buf );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
198 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
199
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
200 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
201 putEndOfTxt( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
202 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
203 server.eotAfterReply = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
204 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
205
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
206 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
207 putSyntax( const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
208 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
209 putStat( STAT_SYNTAX_ERR, "Syntax error. Usage: %s", cmd->syntax );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
210 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
211
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
212 static void
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
213 initOutput( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
214 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
215 server.reply = new_DynStr( 100 );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
216 server.eotAfterReply = FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
217 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
218
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
219 static void
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
220 sendOutput( void )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
221 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
222 Prt_putTxtBuf( DynStr_str( server.reply ), stdout );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
223 if ( server.eotAfterReply )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
224 Prt_putEndOfTxt( stdout );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
225 fflush( stdout );
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 181
diff changeset
226 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
227 del_DynStr( server.reply );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
230 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
231 getTxtLn( Str line, Bool *err )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
232 {
144
8b9366fc1361 [svn] Added timeout to Prt_getLn to avoid Noffle hanging if the
enz
parents: 127
diff changeset
233 return Prt_getTxtLn( line, err, stdin, -1 );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
234 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
235
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
236 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
237 notImplemented( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
238 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
239 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
240 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
241
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
242 putStat( STAT_NO_PERMISSION, "Command not implemented" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
243 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
244 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
245
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
246 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
247 checkNewArts( const char *grp )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
248 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
249 if ( ! Online_true()
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
250 || strcmp( grp, server.grp ) == 0
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
251 || Grp_local( grp )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
252 || time( NULL ) - Grp_lastAccess( server.grp ) < 1800 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
253 return;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
254 if ( Fetch_init( Grp_server( grp ) ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
255 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
256 Fetch_getNewArts( grp, OVER );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
257 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
258 }
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
259 else
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
260 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
261 Log_inf( "Connection to server failed. Leaving online mode." );
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
262 Online_set( FALSE );
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
263 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
264 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
265
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266 static void
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
267 postArts( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
269 Str s;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
270
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
271 Cfg_beginServEnum();
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
272 while ( Cfg_nextServ( s ) )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
273 if ( Fetch_init( s ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
274 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
275 Fetch_postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
276 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
277 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
278 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
279
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
280 static Bool
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
281 needsPseudoGenInfo( const char *grp )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
282 {
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
283 return ! ( Grp_local( grp )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
284 || Fetchlist_contains( grp )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
285 || Online_true() );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
286 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
287
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
288 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
289 readCont( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
290 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
291 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
292 Cont_read( name );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
293 if ( needsPseudoGenInfo( name ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
294 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
295 Pseudo_appGeneralInfo();
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
296 /* This adds the pseudo message to the overview contents
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
297 but NOT to the group info. If an article gets added,
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
298 the group info will get updated then from the
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
299 contents, so the article number will be preserved.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
300 Otherwise it will be lost when the content is discarded. */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
301 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
302 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
303
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
304 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
305 changeToGrp( const char *grp )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
306 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
307 checkNewArts( grp );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
308 Utl_cpyStr( server.grp, grp );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
309 readCont( grp );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
310 server.artPtr = Cont_first();
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
311 server.groupReady = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
312 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
313
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
314 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
315 doGrp( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
316 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
317 int first, last, numb;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
318
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
319 if ( arg[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
320 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
321 else if ( ! Grp_exists( arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 putStat( STAT_NO_SUCH_GRP, "No such group" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
325 Utl_cpyStr( server.grp, arg );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
326 server.groupReady = FALSE;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
327 server.artPtr = Grp_first( arg );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
328 first = server.artPtr;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
329 last = Grp_last( arg );
160
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
330
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
331 if ( ( first == 0 && last == 0 )
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
332 || first > last ) {
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
333 changeToGrp( arg );
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
334 first = Cont_first();
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
335 last = Cont_last();
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
336 }
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
337
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
338 if ( ( first == 0 && last == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
339 || first > last )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
340 first = last = numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
341 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
342 numb = last - first + 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
343 putStat( STAT_GRP_SELECTED, "%lu %lu %lu %s selected",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
344 numb, first, last, arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
345 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
346 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
347 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
348
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
349 static Bool
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
350 loadGrpIfSelected( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
351 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
352 Str group;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
353 if ( *server.grp == '\0' )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
354 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
355 putStat( STAT_NO_GRP_SELECTED, "No group selected" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
356 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
357 }
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
358 if ( ! server.groupReady )
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
359 {
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
360 Utl_cpyStr( group, server.grp );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
361 changeToGrp( group );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
362 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
363 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
364 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
365
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
366 static void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
367 findServer( const char *msgId, Str result )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
368 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
369 const char *p, *pColon, *srv;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
370 Str s, grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
371
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
372 Utl_cpyStr( result, "(unknown)" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
373 if ( Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
374 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
375 Utl_cpyStr( s, Db_xref( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
376 p = strtok( s, " \t" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
377 if ( p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
378 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
379 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
380 pColon = strstr( p, ":" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
381 if ( pColon )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
382 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
383 Utl_cpyStrN( grp, p, pColon - p );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
384 srv = Grp_server( grp );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
385 if ( Cfg_servIsPreferential( srv, result ) )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
386 Utl_cpyStr( result, srv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
387 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
388 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
389 while ( ( p = strtok( NULL, " \t" ) ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
390 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
391 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
392
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
393 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
394 retrieveArt( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
395 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
396 Str s;
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
397 int stat;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
398
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
399 findServer( msgId, s );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
400 if ( strcmp( s, "(unknown)" ) == 0
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
401 || strcmp( s, GRP_LOCAL_SERVER_NAME ) == 0 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
402 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
403 if ( ! Client_connect( s ) )
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
404 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
405 Log_inf( "Connection to server failed. Leaving online mode." );
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
406 Online_set( FALSE );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
407 return FALSE;
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
408 }
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
409 stat = Client_retrieveArt( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
410 Client_disconnect();
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
411 if ( IS_FATAL( stat ) )
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
412 {
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
413 Log_inf( "Server connection failed or newsbase problem. "
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
414 "Leaving online mode." );
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
415 Online_set( FALSE );
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
416 return FALSE;
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
417 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
418 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
419 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
420
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
421 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
422 checkNumb( int numb )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
423 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
424 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
425 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
426 if ( ! Cont_validNumb( numb ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
427 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
428 putStat( STAT_NO_SUCH_NUMB, "No such article number" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
429 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
430 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
431 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
432 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
433
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
435 Parse arguments for ARTICLE, BODY, HEAD, STAT commands.
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
436 Return message-ID and article number (0 if unknown).
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
437 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
438 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
439 whichId( const char **msgId, int *numb, char *arg )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
440 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
441 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
442 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
443
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
444 if ( sscanf( arg, "%d", &n ) == 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
445 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
446 if ( ! checkNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
447 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
448 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
449 ov = Cont_get( n );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
450 *msgId = Ov_msgId( ov );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
451 *numb = n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
452 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
453 else if ( strcmp( arg, "" ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
454 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
455 if ( ! checkNumb( server.artPtr ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
456 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
457 ov = Cont_get( server.artPtr );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
458 *msgId = Ov_msgId( ov );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
459 *numb = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
461 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
462 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
463 *msgId = arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
464 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
465 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466 if ( ! Pseudo_isGeneralInfo( *msgId ) && ! Db_contains( *msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
468 putStat( STAT_NO_SUCH_ID, "No such article" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
469 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
470 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
471 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
472 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
474 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
475 touchArticle( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
477 int status = Db_status( msgId );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
478 status |= DB_INTERESTING;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
479 Db_setStatus( msgId, status );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480 Db_updateLastAccess( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
481 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
482
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
483 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 touchReferences( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
485 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
486 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
487 int len;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
488 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
489 const char *ref = Db_ref( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
490
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
491 while ( TRUE )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
492 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
493 p = s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
494 while ( *ref != '<' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
495 if ( *(ref++) == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
496 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 len = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
498 while ( *ref != '>' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
499 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
500 if ( *ref == '\0' || ++len >= MAXCHAR - 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
501 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
502 *(p++) = *(ref++);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
503 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
504 *(p++) = '>';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
505 *p = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
506 if ( Db_contains( s ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
507 touchArticle( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
508 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
509 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
510
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
511 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
512 doBodyInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
513 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
514 int stat;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
515 Str srv;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
516
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
517 touchArticle( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
518 touchReferences( msgId );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
519 stat = Db_status( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
520 if ( Online_true() && ( stat & DB_NOT_DOWNLOADED ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
521 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
522 retrieveArt( msgId );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
523 stat = Db_status( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
524 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
525 if ( stat & DB_RETRIEVING_FAILED )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
526 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
527 Db_setStatus( msgId, stat & ~DB_RETRIEVING_FAILED );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
528 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
529 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
530 else if ( stat & DB_NOT_DOWNLOADED )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
531 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
532 findServer( msgId, srv );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
533 if ( Req_contains( srv, msgId ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
534 putTxtBuf( Pseudo_alreadyMarkedBody() );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
535 else if ( strcmp( srv, "(unknown)" ) != 0 &&
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
536 strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 &&
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
537 Req_add( srv, msgId ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
538 putTxtBuf( Pseudo_markedBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
539 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
540 putTxtBuf( Pseudo_markingFailedBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
541 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
542 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
543 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
544 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
545
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
546 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
547 doBody( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
548 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
549 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
550 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
551
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
552 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
553
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
554 if ( ! whichId( &msgId, &numb, arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
555 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
556 putStat( STAT_BODY_FOLLOWS, "%ld %s Body", numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
557 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
558 putTxtBuf( Pseudo_generalInfoBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
559 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
560 doBodyInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
561 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
562 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
563 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
564 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
565
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
566 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
567 doHeadInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
568 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
569 putTxtBuf( Db_header( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
570 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
571
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
572 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
573 doHead( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
574 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
575 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
576 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
577
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
578 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
579
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
580 if ( ! whichId( &msgId, &numb, arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
581 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
582 putStat( STAT_HEAD_FOLLOWS, "%ld %s Head", numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
583 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
584 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
585 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
586 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
587 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
588 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
589 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
590
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
591 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
592 doArtInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
593 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
594 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
595 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
596 doBodyInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
597 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
598
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
599 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
600 doArt( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
601 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
602 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
603 int numb;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
604
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
605 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
606
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
607 if ( ! whichId( &msgId, &numb, arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
608 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
609 putStat( STAT_ART_FOLLOWS, "%ld %s Article", numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
610 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
611 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
612 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
613 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
614 putTxtBuf( Pseudo_generalInfoBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
615 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
616 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
617 doArtInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
618 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
619 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
620 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
621 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
622
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
623 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
624 doHelp( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
625 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
626 unsigned int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
627
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
628 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
629 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
630
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
631 putStat( STAT_HELP_FOLLOWS, "Help" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
632 putTxtBuf( "\nCommands:\n\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
633 for ( i = 0; i < sizeof( commands ) / sizeof( commands[ 0 ] ); ++i )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
634 putTxtLn( "%s", commands[ i ].syntax );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
635 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
636 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
637 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
638
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
639 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
640 doIhave( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
641 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
642 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
643 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
644
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
645 putStat( STAT_ART_REJECTED, "Command not used" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
646 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
647 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
648
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
649 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
650 doLast( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
651 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
652 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
653
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
654 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
655 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
656
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
657 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
658 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
659 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
660 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
661 putStat( STAT_NO_ART_SELECTED, "No article selected" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
662 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
663 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
664 while ( ! Cont_validNumb( --n ) && n >= Cont_first() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
665 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
666 putStat( STAT_NO_PREV_ART, "No previous article" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
667 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
668 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
669 putStat( STAT_ART_RETRIEVED, "%ld %s selected",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
670 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
671 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
672 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
673 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
674 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
675 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
676 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
677
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
678 static Bool
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
679 containsWildcards( const char *pattern )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
680 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
681 return ( strpbrk( pattern, "?*[\\" ) == NULL ? FALSE : TRUE );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
682 }
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
683
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
684 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
685 printGroups( const char *pat, void (*printProc)( Str, const char* ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
686 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
687 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
688 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
689
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
690 putStat( STAT_GRPS_FOLLOW, "Groups" );
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
691 if ( containsWildcards( pat ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
692 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
693 if ( Grp_firstGrp( &g ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
694 do
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
695 if ( Wld_match( g, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
696 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
697 (*printProc)( line, g );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
698 putTxtLn( line );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
699 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
700 while ( Grp_nextGrp( &g ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
701 }
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
702 else if ( Grp_exists( pat ) )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
703 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
704 (*printProc)( line, pat );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
705 putTxtLn( line );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
706 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
707 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
708 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
709
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
710 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
711 printActiveTimes( Str result, const char *grp )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
712 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
713 snprintf( result, MAXCHAR, "%s %ld", grp, Grp_created( grp ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
714 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
715
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
716 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
717 doListActiveTimes( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
718 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
719 printGroups( pat, &printActiveTimes );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
720 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
721
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
722 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
723 printActive( Str result, const char *grp )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
724 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
725 int last;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
726
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
727 /* If there will be a pseudo gen info message waiting when we join
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
728 this group, fiddle the group numbers to show it. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
729 last = Grp_last( grp );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
730 if ( needsPseudoGenInfo( grp ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
731 last++;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
732
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
733 snprintf( result, MAXCHAR, "%s %d %d %c",
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
734 grp, last, Grp_first( grp ), Grp_postAllow( grp ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
735 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
736
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
737 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
738 doListActive( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
739 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
740 /* We need to read the fetchlist so we know whether a pseudo
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
741 gen info article needs to be faked when printing the group
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
742 last. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
743 Fetchlist_read();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
744 printGroups( pat, &printActive );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
745 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
746
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
747 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
748 printNewsgrp( Str result, const char *grp )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
749 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
750 snprintf( result, MAXCHAR, "%s %s", grp, Grp_dsc( grp ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
751 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
752
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
753 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
754 doListNewsgrps( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
755 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
756 printGroups( pat, &printNewsgrp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
757 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
758
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
759 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
760 putGrp( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
761 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
762 putTxtLn( "%s %lu %lu y", name, Grp_last( name ), Grp_first( name ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
763 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
764
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
765 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
766 doListOverFmt( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
767 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
768 putStat( STAT_GRPS_FOLLOW, "Overview format" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
769 putTxtBuf( "Subject:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
770 "From:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
771 "Date:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
772 "Message-ID:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
773 "References:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
774 "Bytes:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
775 "Lines:\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
776 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
777 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
778
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
779 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
780 doListExtensions( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
781 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
782 putStat( STAT_CMD_OK, "Extensions" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
783 putTxtBuf( " LISTGROUP\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
784 " XOVER\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
785 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
786 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
787
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
788 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
789 doList( char *line, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
790 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
791 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
792 const char *pat;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
793
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
794 if ( sscanf( line, "%s", s ) != 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
795 doListActive( "*" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
796 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
797 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
798 Utl_toLower( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
799 strcpy( arg, Utl_restOfLn( line, 1 ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
800 pat = Utl_stripWhiteSpace( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
801 if ( pat[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
802 pat = "*";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
803 if ( strcmp( "active", s ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
804 doListActive( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
805 else if ( strcmp( "overview.fmt", s ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
806 doListOverFmt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
807 else if ( strcmp( "newsgroups", s ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
808 doListNewsgrps( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
809 else if ( strcmp( "active.times", s ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
810 doListActiveTimes( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
811 else if ( strcmp( "extensions", s ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
812 doListExtensions();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
813 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
814 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
815 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
816 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
817 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
818
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
819 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
820 doListgrp( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
821 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
822 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
823 int first, last, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
824
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
825 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
826
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
827 if ( ! Grp_exists( arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
828 putStat( STAT_NO_SUCH_GRP, "No such group" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
829 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
830 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
831 changeToGrp( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
832 first = Cont_first();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
833 last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
834 putStat( STAT_GRP_SELECTED, "Article list" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
835 for ( i = first; i <= last; ++i )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
836 if ( ( ov = Cont_get( i ) ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
837 putTxtLn( "%lu", i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
838 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
839 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
840 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
841 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
842
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
843 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
844 doMode( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
845 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
846 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
847 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
848
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
849 putStat( STAT_READY_POST_ALLOW, "Ok" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
850 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
851 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
852
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
853 /* Can return -1, if date is outside the range of time_t. */
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
854 static time_t
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
855 getTimeInSeconds( int year, int mon, int day, int hour, int min, int sec )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
856 {
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
857 struct tm t;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
858 time_t result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
859
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
860 ASSERT( year >= 1900 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
861 ASSERT( mon >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
862 ASSERT( mon <= 12 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
863 ASSERT( day >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
864 ASSERT( day <= 31 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
865 ASSERT( hour >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
866 ASSERT( hour <= 23 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
867 ASSERT( min >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
868 ASSERT( min <= 59 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
869 ASSERT( sec >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
870 ASSERT( sec <= 59 );
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
871 memset( &t, 0, sizeof( t ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
872 t.tm_year = year - 1900;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
873 t.tm_mon = mon - 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
874 t.tm_mday = day;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
875 t.tm_hour = hour;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
876 t.tm_min = min;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
877 t.tm_sec = sec;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
878 result = mktime( &t );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
879 return result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
880 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
881
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
882
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
883 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
884 doNewgrps( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
885 {
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
886 time_t t, now, lastUpdate, nextCentBegin;
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
887 int year, mon, day, hour, min, sec, cent, len;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
888 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
889 Str date, timeofday, file;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
890
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
891 if ( sscanf( arg, "%s %s", date, timeofday ) != 2 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
892 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
893 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
894 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
895 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
896 len = strlen( date );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
897 switch ( len )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
898 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
899 case 6:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
900 if ( sscanf( date, "%2d%2d%2d", &year, &mon, &day ) != 3 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
901 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
902 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
903 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
904 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
905 now = time( NULL );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
906 cent = 1900;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
907 nextCentBegin = getTimeInSeconds( cent + 100, 1, 1, 0, 0, 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
908 while ( nextCentBegin != (time_t)-1 && now != (time_t)-1
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
909 && now > nextCentBegin )
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
910 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
911 cent += 100;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
912 nextCentBegin = getTimeInSeconds( cent + 100, 1, 1, 0, 0, 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
913 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
914 year += cent;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
915 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
916 case 8:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
917 if ( sscanf( date, "%4d%2d%2d", &year, &mon, &day ) != 3 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
918 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
919 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
920 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
921 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
922 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
923 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
924 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
925 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
926 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
927 if ( sscanf( timeofday, "%2d%2d%2d", &hour, &min, &sec ) != 3 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
928 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
929 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
930 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
931 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
932 if ( year < 1970 || mon < 1 || mon > 12 || day < 1 || day > 31
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
933 || hour < 0 || hour > 23 || min < 0 || min > 59
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
934 || sec < 0 || sec > 60 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
935 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
936 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
937 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
938 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
939 snprintf( file, MAXCHAR, "%s/groupinfo.lastupdate", Cfg_spoolDir() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
940 t = getTimeInSeconds( year, mon, day, hour, min, sec );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
941
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
942 if ( ! Utl_getStamp( &lastUpdate, file ) )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
943 {
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
944 /* Can't get stamp. Put out error message. */
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
945 putStat( STAT_PROGRAM_FAULT, "Server error reading %s", file );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
946 return TRUE;
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
947 }
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
948
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
949 putStat( STAT_NEW_GRP_FOLLOW, "New groups since %s", arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
950
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
951 if ( t == (time_t)-1 || t <= lastUpdate )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
952 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
953 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
954 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
955 if ( Grp_created( g ) > t )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
956 putGrp( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
957 while ( Grp_nextGrp( &g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
958 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
959 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
960 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
961 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
962
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
963 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
964 doNext( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
965 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
966 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
967
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
968 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
969 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
970
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
971 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
972 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
973 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
974 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
975 putStat( STAT_NO_ART_SELECTED, "No article selected" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
976 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
977 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
978 while ( ! Cont_validNumb( ++n ) && n <= Cont_last() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
979 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
980 putStat( STAT_NO_NEXT_ART, "No next article" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
981 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
982 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
983 putStat( STAT_ART_RETRIEVED, "%ld %s selected",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
984 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
985 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
986 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
987 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
988 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
989 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
990 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
991
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
992 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
993 doPost( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
994 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
995 DynStr *s;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
996 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
997 Bool err;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
998
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
999 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1000 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1001
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1002 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1003 * The article may take some time coming in, so release the
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1004 * lock while collecting it.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1005 */
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1006 putStat( STAT_SEND_ART, "Continue (end with period)" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1007 sendOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1008 closeServer();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1009
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1010 s = new_DynStr( 10000 );
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1011 err = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1012 while ( ! err && getTxtLn( line, &err ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1013 DynStr_appLn( s, line );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1014
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1015 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1016 if ( ! initServer() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1017 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1018 del_DynStr( s );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1019 return FALSE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1020 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1021
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1022 if ( ! err
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1023 && Post_open( DynStr_str( s ), 0 )
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 106
diff changeset
1024 && Post_post() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1025 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1026 putStat( STAT_POST_OK, "Message posted" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1027 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1028 postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1029 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1030 else
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1031 putStat( STAT_POST_FAILED, "Posting failed" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1032 Post_close();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1033 del_DynStr( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1034 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1035 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1036
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1037 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1038 parseRange( const char *s, int *first, int *last, int *numb )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1039 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1040 int r, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1041 char* p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1042 Str t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1043
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1044 Utl_cpyStr( t, s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1045 p = Utl_stripWhiteSpace( t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1046 r = sscanf( p, "%d-%d", first, last );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1047 if ( r < 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1048 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1049 *first = server.artPtr;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1050 *last = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1051 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1052 else if ( r == 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1053 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1054 if ( p[ strlen( p ) - 1 ] == '-' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1055 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1056 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1057 *last = *first;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1058 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1059 if ( *first < Cont_first() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1060 *first = Cont_first();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1061 if ( *last > Cont_last() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1062 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1063 if ( *first > Cont_last() || *last < Cont_first() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1064 *last = *first - 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1065 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1066 for ( i = *first; i <= *last; ++i )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1067 if ( Cont_validNumb( i ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1068 ++(*numb);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1069 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1070
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1071 enum XhdrType { SUBJ, FROM, DATE, MSG_ID, REF, BYTES, LINES, XREF, UNKNOWN };
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1072
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1073 static enum XhdrType
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1074 whatXhdrField( const char * fieldname )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1075 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1076 Str name;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1077
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1078 Utl_cpyStr( name, fieldname );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1079 Utl_toLower( name );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1080 if ( strcmp( name, "subject" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1081 return SUBJ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1082 else if ( strcmp( name, "from" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1083 return FROM;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1084 else if ( strcmp( name, "date" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1085 return DATE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1086 else if ( strcmp( name, "message-id" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1087 return MSG_ID;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1088 else if ( strcmp( name, "references" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1089 return REF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1090 else if ( strcmp( name, "bytes" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1091 return BYTES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1092 else if ( strcmp( name, "lines" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1093 return LINES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1094 else if ( strcmp( name, "xref" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1095 return XREF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1096 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1097 return UNKNOWN;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1098 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1099
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1100 static void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1101 getXhdrField( enum XhdrType what, const Over * ov, Str res )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1102 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1103 const char * msgId;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1104 Str host;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1105
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1106 switch ( what )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1107 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1108 case SUBJ:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1109 Utl_cpyStr( res, Ov_subj( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1110 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1111 case FROM:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1112 Utl_cpyStr( res, Ov_from( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1113 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1114 case DATE:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1115 Utl_cpyStr( res, Ov_date( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1116 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1117 case MSG_ID:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1118 Utl_cpyStr( res, Ov_msgId( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1119 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1120 case REF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1121 Utl_cpyStr( res, Ov_ref( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1122 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1123 case BYTES:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1124 snprintf( res, MAXCHAR, "%d", Ov_bytes( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1125 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1126 case LINES:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1127 snprintf( res, MAXCHAR, "%d", Ov_lines( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1128 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1129 case XREF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1130 msgId = Ov_msgId( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1131 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1132 * Gen info messages don't have an Xref header. When INN is asked
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1133 * for a header that doesn't exist in a message, it reports the
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1134 * header value as '(none)', so do the same.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1135 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1136 if ( Pseudo_isGeneralInfo( msgId ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1137 Utl_cpyStr( res, "none" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1138 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1139 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1140 gethostname( host, MAXCHAR );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1141 snprintf( res, MAXCHAR, "%s %s", host, Db_xref( msgId ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1142 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1143 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1144 default:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1145 ASSERT( FALSE );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1146 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1147 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1148
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1149 /*
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1150 Note this only handles a subset of headers. But they are all
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1151 the headers any newsreader should need to work properly.
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1152
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1153 That last sentence will at some stage be proved wrong.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1154 */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1155 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1156 doXhdr( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1157 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1158 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1159 const char *p;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1160 Str whatStr;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1161
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1162 if ( sscanf( arg, "%s", whatStr ) != 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1163 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1164 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1165 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1166 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1167 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1168 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1169 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1170 putStat( STAT_HEAD_FOLLOWS, "Unknown header (empty list follows)" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1171 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1172 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1173 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1174 p = Utl_restOfLn( arg, 1 );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1175 if ( p[ 0 ] == '<' )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1176 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1177 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1178 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1179
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1180 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1181 ov = Db_over( p );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1182 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1183 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1184 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1185 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1186 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1187 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, p ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1188 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1189 putTxtLn( "%s %s", p, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1190 del_Over( ov );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1191 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1192 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1193 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1194 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1195 int first, last, i, n, numb;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1196 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1197
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1198 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1199 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1200 return TRUE;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1201 parseRange( p, &first, &last, &numb );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1202 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1203 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1204 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1205 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1206 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1207 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1208 whatStr, first, last ) ;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1209 for ( i = first; i <= last; ++i )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1210 if ( ( ov = Cont_get( i ) ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1211 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1212 n = Ov_numb( ov );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1213 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1214 putTxtLn( "%lu %s", n, field );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1215 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1216 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1217 putEndOfTxt();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1218 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1219 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1220
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1221 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1222 doXpat( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1223 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1224 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1225 Str whatStr, articles, pat;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1226
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1227 if ( sscanf( arg, "%s %s %s", whatStr, articles, pat ) != 3 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1228 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1229 putSyntax( cmd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1230 return TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1231 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1232 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1233 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1234 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1235 putStat( STAT_HEAD_FOLLOWS, "Unknown header (empty list follows)" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1236 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1237 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1238 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1239 if ( articles[ 0 ] == '<' )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1240 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1241 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1242 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1243
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1244 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1245 ov = Db_over( articles );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1246 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1247 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1248 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1249 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1250 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1251 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, articles ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1252 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1253 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1254 putTxtLn( "%s %s", articles, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1255 del_Over( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1256 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1257 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1258 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1259 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1260 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1261 int first, last, i, n, numb;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1262
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1263 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1264 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1265 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1266 parseRange( articles, &first, &last, &numb );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1267 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1268 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1269 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1270 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1271 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1272 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1273 whatStr, first, last ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1274 for ( i = first; i <= last; ++i )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1275 if ( ( ov = Cont_get( i ) ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1276 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1277 n = Ov_numb( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1278 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1279 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1280 putTxtLn( "%lu %s", n, field );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1281 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1282 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1283 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1284 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1285 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1286
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1287 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1288 doSlave( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1289 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1290 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1291 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1292
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1293 putStat( STAT_CMD_OK, "Ok" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1294 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1295 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1296
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1297 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1298 doStat( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1299 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1300 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1301 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1302
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1303 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1304
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1305 if ( ! whichId( &msgId, &numb, arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1306 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1307 if ( numb > 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1308 putStat( STAT_ART_RETRIEVED, "%ld %s selected",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1309 numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1310 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1311 putStat( STAT_ART_RETRIEVED, "0 %s selected", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1312 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1313 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1314
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1315 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1316 doQuit( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1317 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1318 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1319 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1320
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1321 putStat( STAT_GOODBYE, "Goodbye" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1322 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1323 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1324
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1325 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1326 doXOver( char *arg, const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1327 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1328 int first, last, i, n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1329 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1330
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1331 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1332
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1333 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1334 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1335 parseRange( arg, &first, &last, &n );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1336 if ( n == 0 )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1337 first = last = server.artPtr;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1338 putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1339 for ( i = first; i <= last; ++i )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1340 if ( ( ov = Cont_get( i ) ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1341 putTxtLn( "%lu\t%s\t%s\t%s\t%s\t%s\t%d\t%d\t",
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1342 Ov_numb( ov ), Ov_subj( ov ), Ov_from( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1343 Ov_date( ov ), Ov_msgId( ov ), Ov_ref( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1344 Ov_bytes( ov ), Ov_lines( ov ) );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1345 putEndOfTxt();
191
28488e0e3630 [svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents: 188
diff changeset
1346 Grp_setLastAccess( server.grp );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1347 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1348 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1349
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1350 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1351 putFatal( const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1352 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1353 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1354 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1355
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1356 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1357 vsnprintf( s, MAXCHAR, fmt, ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1358 va_end( ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1359 Log_err( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1360 putStat( STAT_PROGRAM_FAULT, "%s", s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1361 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1362
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1363 /* Parse line, execute command and return FALSE, if it was the quit command. */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1364 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1365 parseAndExecute( Str line )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1366 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1367 unsigned int i, n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1368 Cmd *c;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1369 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1370 Bool ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1371
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1372 if ( sscanf( line, "%s", s ) == 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1373 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1374 Utl_toLower( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1375 strcpy( arg, Utl_restOfLn( line, 1 ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1376 n = sizeof( commands ) / sizeof( commands[ 0 ] );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1377 for ( i = 0, c = commands; i < n; ++i, ++c )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1378 if ( strcmp( c->name, s ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1379 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1380 ret = c->cmdProc( Utl_stripWhiteSpace( arg ), c );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1381 return ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1382 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1383 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1384 putStat( STAT_NO_SUCH_CMD, "Command not recognized" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1385 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1386 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1387
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1388 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1389 putWelcome( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1390 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1391 initOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1392 putStat( STAT_READY_POST_ALLOW, "NNTP server NOFFLE %s",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1393 Cfg_version() );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1394 sendOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1395 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1396
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1397 static Bool
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1398 initServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1399 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1400 ASSERT( ! server.running );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1401 if ( ! Lock_openDatabases() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1402 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1403 server.running = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1404 server.lastServerOpen = time( NULL );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1405 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1406 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1407
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1408 static void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1409 closeServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1410 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1411 ASSERT( server.running );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1412 server.running = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1413 Lock_closeDatabases();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1414 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1415
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1416 void
167
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1417 Server_flushCache( void )
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1418 {
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1419 server.groupReady = FALSE;
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1420 }
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1421
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1422 void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1423 Server_run( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1424 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1425 Bool done;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1426 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1427
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1428 putWelcome();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1429 done = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1430 while ( ! done )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1431 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1432 if ( Prt_getLn( line, stdin, -1 ) )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1433 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1434 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1435
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1436 if ( ! initServer() )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1437 {
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1438 putFatal( "Cannot init server" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1439 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1440 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1441 else
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1442 {
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1443 if ( ! parseAndExecute( line ) )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1444 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1445 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1446
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1447 if ( server.running )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1448 closeServer();
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1449
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1450 sendOutput();
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1451 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1452 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1453 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1454 Log_inf( "Client disconnected. Terminating." );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1455 done = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1456 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1457 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1458 if ( server.running )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1459 closeServer();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1460 }