annotate src/server.c @ 185:fed1334d766b noffle

[svn] * src/client.c: Change variable only used on constant to 'const'. * src/filter.c: Add a couple of 'return's after ASSERT() to remove compiler warnings about functions needing returns. * NEWS,TODO,configure,configure.in,noffle.conf.example,docs/NOTES, docs/noffle.conf.5,src/client.c,src/configfile.c,src/content.c, src/control.c,src/database.c,src/fetch.c,src/fetchlist.c,src/filter.c, src/group.c,src/lock.c,src/log.c,src/log.h,src/noffle.c,src/outgoing.c, src/post.c,src/protocol.c,src/request.c,src/server.c,src/util.c: Debug logging is always compiled and selected via noffle.conf. All debug logs are classified as all, none, config, control, expire, fetch, filter, newsbase, noffle, post, protocol, requests and server.
author bears
date Sun, 05 Aug 2001 09:24:22 +0100
parents e196de757ecd
children f1bacee93ca6
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
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 181
diff changeset
4 $Id: server.c 300 2001-08-05 08:24:22Z 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 "server.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
24 #include <ctype.h>
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
25 #include <errno.h>
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <signal.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include <stdarg.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 #include <sys/types.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 #include <unistd.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 #include "client.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
31 #include "common.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "content.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 #include "database.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 #include "dynamicstring.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
36 #include "fetch.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
37 #include "fetchlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 #include "group.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 #include "itemlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 #include "lock.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
41 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42 #include "online.h"
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
43 #include "over.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
44 #include "post.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
45 #include "protocol.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46 #include "pseudo.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
47 #include "request.h"
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
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
131 Grp_setLastAccess( server.grp, time( NULL ) );
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;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
397
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
398 findServer( msgId, s );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
399 if ( strcmp( s, "(unknown)" ) == 0
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
400 || 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
401 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
402 if ( ! Client_connect( s ) )
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
403 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
404 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
405 Online_set( FALSE );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
406 return FALSE;
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
407 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
408 Client_retrieveArt( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
409 Client_disconnect();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
410 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
411 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
412
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
413 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
414 checkNumb( int numb )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
415 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
416 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
417 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
418 if ( ! Cont_validNumb( numb ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
419 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
420 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
421 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
422 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
423 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
424 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
425
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
426 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
427 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
428 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
429 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
430 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
431 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
432 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
433 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
435
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
436 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
437 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
438 if ( ! checkNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
439 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
440 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
441 ov = Cont_get( n );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
442 *msgId = Ov_msgId( ov );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
443 *numb = n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
444 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
445 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
446 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
447 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
448 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
449 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
450 *msgId = Ov_msgId( ov );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
451 *numb = server.artPtr;
43
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
454 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
455 *msgId = arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
456 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
457 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
458 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
459 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
460 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
461 return FALSE;
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 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
464 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
465
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
466 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 touchArticle( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
468 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
469 int status = Db_status( msgId );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
470 status |= DB_INTERESTING;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
471 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
472 Db_updateLastAccess( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
475 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476 touchReferences( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
477 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
478 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
479 int len;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
481 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
482
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
483 while ( TRUE )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
485 p = s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
486 while ( *ref != '<' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
487 if ( *(ref++) == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
488 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
489 len = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
490 while ( *ref != '>' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
491 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
492 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
493 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
494 *(p++) = *(ref++);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
495 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
496 *(p++) = '>';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 *p = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
498 if ( Db_contains( s ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
499 touchArticle( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
500 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
501 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
502
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
503 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
504 doBodyInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
505 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
506 int stat;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
507 Str srv;
43
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 touchArticle( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
510 touchReferences( msgId );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
511 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
512 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
513 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
514 retrieveArt( msgId );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
515 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
516 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
517 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
518 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
519 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
520 putTxtBuf( Db_body( msgId ) );
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 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
523 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
524 findServer( msgId, srv );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
525 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
526 putTxtBuf( Pseudo_alreadyMarkedBody() );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
527 else if ( strcmp( srv, "(unknown)" ) != 0 &&
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
528 strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 &&
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
529 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
530 putTxtBuf( Pseudo_markedBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
531 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
532 putTxtBuf( Pseudo_markingFailedBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
533 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
534 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
535 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
536 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
537
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
538 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
539 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
540 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
541 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
542 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
543
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
544 UNUSED( cmd );
43
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 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
547 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
548 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
549 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
550 putTxtBuf( Pseudo_generalInfoBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
551 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
552 doBodyInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
553 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
554 noteInterest();
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
557
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
558 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
559 doHeadInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
560 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
561 putTxtBuf( Db_header( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
562 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
563
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
564 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
565 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
566 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
567 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
568 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
569
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
570 UNUSED( cmd );
43
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 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
573 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
574 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
575 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
576 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
577 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
578 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
579 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
580 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
581 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
582
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
583 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
584 doArtInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
585 {
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 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
588 doBodyInDb( msgId );
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 Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
592 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
593 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
594 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
595 int numb;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
596
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
597 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
598
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
599 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
600 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
601 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
602 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
603 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
604 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
605 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
606 putTxtBuf( Pseudo_generalInfoBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
607 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
608 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
609 doArtInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
610 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
611 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
612 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
613 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
614
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
615 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
616 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
617 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
618 unsigned int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
619
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
620 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
621 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
622
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
623 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
624 putTxtBuf( "\nCommands:\n\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
625 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
626 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
627 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
628 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
629 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
630
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
631 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
632 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
633 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
634 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
635 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
636
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
637 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
638 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
639 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
640
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
641 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
642 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
643 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
644 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
645
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
646 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
647 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
648
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
649 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
650 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
651 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
652 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
653 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
654 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
655 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
656 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
657 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
658 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
659 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
660 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
661 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
662 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
663 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
664 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
665 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
666 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
667 return TRUE;
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
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
670 static Bool
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
671 containsWildcards( const char *pattern )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
672 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
673 return ( strpbrk( pattern, "?*[\\" ) == NULL ? FALSE : TRUE );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
674 }
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
675
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
676 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
677 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
678 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
679 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
680 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
681
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
682 putStat( STAT_GRPS_FOLLOW, "Groups" );
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
683 if ( containsWildcards( pat ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
684 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
685 if ( Grp_firstGrp( &g ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
686 do
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
687 if ( Wld_match( g, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
688 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
689 (*printProc)( line, g );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
690 putTxtLn( line );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
691 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
692 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
693 }
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
694 else if ( Grp_exists( pat ) )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
695 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
696 (*printProc)( line, pat );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
697 putTxtLn( line );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
698 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
699 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
700 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
701
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
702 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
703 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
704 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
705 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
706 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
707
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
708 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
709 doListActiveTimes( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
710 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
711 printGroups( pat, &printActiveTimes );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
714 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
715 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
716 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
717 int last;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
718
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
719 /* If there will be a pseudo gen info message waiting when we join
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
720 this group, fiddle the group numbers to show it. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
721 last = Grp_last( grp );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
722 if ( needsPseudoGenInfo( grp ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
723 last++;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
724
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
725 snprintf( result, MAXCHAR, "%s %d %d %c",
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
726 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
727 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
728
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
729 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
730 doListActive( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
731 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
732 /* We need to read the fetchlist so we know whether a pseudo
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
733 gen info article needs to be faked when printing the group
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
734 last. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
735 Fetchlist_read();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
736 printGroups( pat, &printActive );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
737 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
738
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
739 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
740 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
741 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
742 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
743 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
744
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
745 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
746 doListNewsgrps( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
747 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
748 printGroups( pat, &printNewsgrp );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
751 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
752 putGrp( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
753 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
754 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
755 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
756
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
757 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
758 doListOverFmt( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
759 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
760 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
761 putTxtBuf( "Subject:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
762 "From:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
763 "Date:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
764 "Message-ID:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
765 "References:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
766 "Bytes:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
767 "Lines:\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
768 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
769 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
770
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
771 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
772 doListExtensions( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
773 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
774 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
775 putTxtBuf( " LISTGROUP\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
776 " XOVER\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
777 putEndOfTxt();
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
780 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
781 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
782 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
783 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
784 const char *pat;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
785
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
786 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
787 doListActive( "*" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
788 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
789 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
790 Utl_toLower( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
791 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
792 pat = Utl_stripWhiteSpace( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
793 if ( pat[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
794 pat = "*";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
795 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
796 doListActive( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
797 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
798 doListOverFmt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
799 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
800 doListNewsgrps( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
801 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
802 doListActiveTimes( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
803 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
804 doListExtensions();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
805 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
806 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
807 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
808 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
809 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
810
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
811 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
812 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
813 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
814 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
815 int first, last, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
816
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
817 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
818
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
819 if ( ! Grp_exists( arg ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
820 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
821 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
822 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
823 changeToGrp( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
824 first = Cont_first();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
825 last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
826 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
827 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
828 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
829 putTxtLn( "%lu", i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
830 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
831 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
832 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
833 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
834
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
835 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
836 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
837 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
838 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
839 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
840
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
841 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
842 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
843 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
844
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
845 /* 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
846 static time_t
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
847 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
848 {
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
849 struct tm t;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
850 time_t result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
851
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
852 ASSERT( year >= 1900 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
853 ASSERT( mon >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
854 ASSERT( mon <= 12 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
855 ASSERT( day >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
856 ASSERT( day <= 31 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
857 ASSERT( hour >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
858 ASSERT( hour <= 23 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
859 ASSERT( min >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
860 ASSERT( min <= 59 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
861 ASSERT( sec >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
862 ASSERT( sec <= 59 );
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
863 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
864 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
865 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
866 t.tm_mday = day;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
867 t.tm_hour = hour;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
868 t.tm_min = min;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
869 t.tm_sec = sec;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
870 result = mktime( &t );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
871 return result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
872 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
873
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
874
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
875 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
876 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
877 {
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
878 time_t t, now, lastUpdate, nextCentBegin;
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
879 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
880 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
881 Str date, timeofday, file;
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 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
884 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
885 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
886 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
887 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
888 len = strlen( date );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
889 switch ( len )
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 case 6:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
892 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
893 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
894 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
895 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
896 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
897 now = time( NULL );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
898 cent = 1900;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
899 nextCentBegin = getTimeInSeconds( cent + 100, 1, 1, 0, 0, 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
900 while ( nextCentBegin != (time_t)-1 && now != (time_t)-1
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
901 && now > nextCentBegin )
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
902 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
903 cent += 100;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
904 nextCentBegin = getTimeInSeconds( cent + 100, 1, 1, 0, 0, 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
905 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
906 year += cent;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
907 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
908 case 8:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
909 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
910 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
911 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
912 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
913 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
914 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
915 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
916 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
917 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
918 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
919 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
920 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
921 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
922 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
923 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
924 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
925 || hour < 0 || hour > 23 || min < 0 || min > 59
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
926 || 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
927 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
928 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
929 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
930 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
931 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
932 t = getTimeInSeconds( year, mon, day, hour, min, sec );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
933 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
934
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
935 if ( ! Utl_getStamp( &lastUpdate, file )
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
936 || 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
937 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
938 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
939 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
940 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
941 putGrp( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
942 while ( Grp_nextGrp( &g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
943 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
944 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
945 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
946 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
947
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
948 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
949 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
950 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
951 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
952
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
953 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
954 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
955
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
956 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
957 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
958 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
959 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
960 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
961 else
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 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
964 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
965 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
966 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
967 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
968 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
969 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
970 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
971 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
972 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
973 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
974 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
975 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
976
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
977 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
978 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
979 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
980 DynStr *s;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
981 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
982 Bool err;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
983
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
984 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
985 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
986
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
987 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
988 * The article may take some time coming in, so release the
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
989 * lock while collecting it.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
990 */
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
991 putStat( STAT_SEND_ART, "Continue (end with period)" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
992 sendOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
993 closeServer();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
994
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
995 s = new_DynStr( 10000 );
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
996 err = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
997 while ( ! err && getTxtLn( line, &err ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
998 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
999
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1000 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1001 if ( ! initServer() )
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 del_DynStr( s );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1004 return FALSE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1005 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1006
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1007 if ( ! err
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1008 && Post_open( DynStr_str( s ), 0 )
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 106
diff changeset
1009 && Post_post() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1010 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1011 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
1012 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1013 postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1014 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1015 else
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1016 putStat( STAT_POST_FAILED, "Posting failed" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1017 Post_close();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1018 del_DynStr( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1019 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1020 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1021
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1022 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1023 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
1024 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1025 int r, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1026 char* p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1027 Str t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1028
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1029 Utl_cpyStr( t, s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1030 p = Utl_stripWhiteSpace( t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1031 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
1032 if ( r < 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1033 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1034 *first = server.artPtr;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1035 *last = server.artPtr;
43
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 else if ( r == 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1038 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1039 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
1040 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1041 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1042 *last = *first;
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 if ( *first < Cont_first() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1045 *first = Cont_first();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1046 if ( *last > Cont_last() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1047 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1048 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
1049 *last = *first - 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1050 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1051 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
1052 if ( Cont_validNumb( i ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1053 ++(*numb);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1054 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1055
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1056 enum XhdrType { SUBJ, FROM, DATE, MSG_ID, REF, BYTES, LINES, XREF, UNKNOWN };
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1057
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1058 static enum XhdrType
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1059 whatXhdrField( const char * fieldname )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1060 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1061 Str name;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1062
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1063 Utl_cpyStr( name, fieldname );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1064 Utl_toLower( name );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1065 if ( strcmp( name, "subject" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1066 return SUBJ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1067 else if ( strcmp( name, "from" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1068 return FROM;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1069 else if ( strcmp( name, "date" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1070 return DATE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1071 else if ( strcmp( name, "message-id" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1072 return MSG_ID;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1073 else if ( strcmp( name, "references" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1074 return REF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1075 else if ( strcmp( name, "bytes" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1076 return BYTES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1077 else if ( strcmp( name, "lines" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1078 return LINES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1079 else if ( strcmp( name, "xref" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1080 return XREF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1081 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1082 return UNKNOWN;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1083 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1084
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1085 static void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1086 getXhdrField( enum XhdrType what, const Over * ov, Str res )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1087 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1088 const char * msgId;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1089 Str host;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1090
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1091 switch ( what )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1092 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1093 case SUBJ:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1094 Utl_cpyStr( res, Ov_subj( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1095 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1096 case FROM:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1097 Utl_cpyStr( res, Ov_from( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1098 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1099 case DATE:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1100 Utl_cpyStr( res, Ov_date( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1101 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1102 case MSG_ID:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1103 Utl_cpyStr( res, Ov_msgId( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1104 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1105 case REF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1106 Utl_cpyStr( res, Ov_ref( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1107 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1108 case BYTES:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1109 snprintf( res, MAXCHAR, "%d", Ov_bytes( 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 LINES:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1112 snprintf( res, MAXCHAR, "%d", Ov_lines( 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 XREF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1115 msgId = Ov_msgId( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1116 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1117 * 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
1118 * 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
1119 * header value as '(none)', so do the same.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1120 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1121 if ( Pseudo_isGeneralInfo( msgId ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1122 Utl_cpyStr( res, "none" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1123 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1124 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1125 gethostname( host, MAXCHAR );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1126 snprintf( res, MAXCHAR, "%s %s", host, Db_xref( msgId ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1127 }
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 default:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1130 ASSERT( FALSE );
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 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1133
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1134 /*
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1135 Note this only handles a subset of headers. But they are all
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1136 the headers any newsreader should need to work properly.
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1137
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1138 That last sentence will at some stage be proved wrong.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1139 */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1140 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1141 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
1142 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1143 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1144 const char *p;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1145 Str whatStr;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1146
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1147 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
1148 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1149 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1150 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1151 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1152 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1153 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1154 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1155 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
1156 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1157 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1158 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1159 p = Utl_restOfLn( arg, 1 );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1160 if ( p[ 0 ] == '<' )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1161 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1162 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1163 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1164
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1165 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1166 ov = Db_over( p );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1167 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1168 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1169 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1170 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1171 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1172 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, p ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1173 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1174 putTxtLn( "%s %s", p, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1175 del_Over( ov );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1176 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1177 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1178 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1179 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1180 int first, last, i, n, numb;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1181 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1182
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1183 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1184 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1185 return TRUE;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1186 parseRange( p, &first, &last, &numb );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1187 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1188 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1189 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1190 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1191 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1192 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1193 whatStr, first, last ) ;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1194 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
1195 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
1196 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1197 n = Ov_numb( ov );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1198 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1199 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
1200 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1201 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1202 putEndOfTxt();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1203 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1204 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1205
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1206 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1207 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
1208 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1209 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1210 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
1211
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1212 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
1213 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1214 putSyntax( cmd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1215 return TRUE;
43
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 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1218 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1219 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1220 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
1221 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1222 return TRUE;
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 if ( articles[ 0 ] == '<' )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1225 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1226 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1227 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1228
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1229 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1230 ov = Db_over( articles );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1231 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1232 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1233 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1234 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1235 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1236 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, articles ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1237 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1238 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1239 putTxtLn( "%s %s", articles, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1240 del_Over( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1241 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1242 else
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 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1245 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1246 int first, last, i, n, numb;
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 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1249 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1250 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1251 parseRange( articles, &first, &last, &numb );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1252 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1253 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1254 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1255 return TRUE;
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 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1258 whatStr, first, last ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1259 for ( i = first; i <= last; ++i )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1260 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
1261 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1262 n = Ov_numb( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1263 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1264 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1265 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
1266 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1267 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1268 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1269 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1270 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1271
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1272 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1273 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
1274 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1275 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1276 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1277
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1278 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
1279 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1280 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1281
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1282 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1283 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
1284 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1285 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1286 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1287
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1288 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1289
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1290 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
1291 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1292 if ( numb > 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1293 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
1294 numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1295 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1296 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
1297 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1298 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1301 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
1302 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1303 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1304 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1305
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1306 putStat( STAT_GOODBYE, "Goodbye" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1307 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1308 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1309
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1310 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1311 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
1312 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1313 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
1314 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1315
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1316 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1317
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1318 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1319 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1320 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
1321 if ( n == 0 )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1322 first = last = server.artPtr;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1323 putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1324 for ( i = first; i <= last; ++i )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1325 if ( ( ov = Cont_get( i ) ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1326 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
1327 Ov_numb( ov ), Ov_subj( ov ), Ov_from( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1328 Ov_date( ov ), Ov_msgId( ov ), Ov_ref( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1329 Ov_bytes( ov ), Ov_lines( ov ) );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1330 putEndOfTxt();
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1331 Grp_setLastAccess( server.grp, time( NULL ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1332 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1333 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1334
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1335 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1336 putFatal( const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1337 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1338 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1339 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1340
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1341 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1342 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
1343 va_end( ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1344 Log_err( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1345 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
1346 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1347
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1348 /* 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
1349 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1350 parseAndExecute( Str line )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1351 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1352 unsigned int i, n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1353 Cmd *c;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1354 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1355 Bool ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1356
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1357 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
1358 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1359 Utl_toLower( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1360 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
1361 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
1362 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
1363 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
1364 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1365 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
1366 return ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1367 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1368 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1369 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
1370 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1373 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1374 putWelcome( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1375 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1376 initOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1377 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
1378 Cfg_version() );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1379 sendOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1380 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1381
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1382 static Bool
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1383 initServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1384 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1385 ASSERT( ! server.running );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1386 if ( ! Lock_openDatabases() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1387 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1388 server.running = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1389 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
1390 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1391 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1392
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1393 static void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1394 closeServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1395 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1396 ASSERT( server.running );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1397 server.running = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1398 Lock_closeDatabases();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1399 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1400
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1401 void
167
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1402 Server_flushCache( void )
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1403 {
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1404 server.groupReady = FALSE;
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1405 }
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1406
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1407 void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1408 Server_run( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1409 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1410 Bool done;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1411 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1412
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1413 putWelcome();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1414 done = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1415 while ( ! done )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1416 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1417 if ( Prt_getLn( line, stdin, -1 ) )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1418 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1419 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1420
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1421 if ( ! initServer() )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1422 {
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1423 putFatal( "Cannot init server" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1424 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1425 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1426 else
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1427 {
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1428 if ( ! parseAndExecute( line ) )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1429 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1430 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1431
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1432 if ( server.running )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1433 closeServer();
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1434
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1435 sendOutput();
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1436 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1437 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1438 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1439 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
1440 done = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1441 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1442 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1443 if ( server.running )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1444 closeServer();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1445 }