annotate src/server.c @ 344:a79adfd728d1 noffle

[svn] added openbsd-inetd dependency option
author godisch
date Wed, 12 Mar 2003 08:45:38 +0000
parents c02c4eb95f95
children f81fdcc2696b
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
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
4 $Id: server.c 420 2003-01-10 23:25:45Z bears $
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
5 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
6
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
7 #if HAVE_CONFIG_H
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
8 #include <config.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
9 #endif
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
10
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
11 #if TIME_WITH_SYS_TIME
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
12 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
13 #include <time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
14 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
15 #if HAVE_SYS_TIME_H
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
16 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
17 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
18 #include <time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
19 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
20 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
21
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
22 #include <stdio.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
23 #include <ctype.h>
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
24 #include <errno.h>
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include <signal.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <stdarg.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include <sys/types.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 #include <unistd.h>
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
29 #include "authenticate.h"
43
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"
197
24d4cd032da5 [svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents: 191
diff changeset
48 #include "server.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 #include "util.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
50 #include "wildmat.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 49
diff changeset
51 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
53 enum AuthState {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
54 NEED_USER,
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
55 NEED_PASS,
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
56 AUTH_DONE
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
57 };
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
58
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 struct
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
61 Bool running;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
62 time_t lastServerOpen;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
63 int artPtr;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 Str grp; /* selected group, "" if none */
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
65 DynStr *reply;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
66 Bool eotAfterReply;
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
67 Bool groupReady;
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
68 enum AuthState auth;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
69 char *user;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
70 } server = {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
71 FALSE, /* running */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
72 0L, /* lastServerOpen */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
73 0, /* artPtr */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
74 "", /* grp */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
75 NULL, /* reply */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
76 FALSE, /* eotAfterReply */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
77 FALSE, /* groupReady */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
78 NEED_USER, /* auth */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
79 NULL /* user */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
80 };
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
81
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
82 typedef struct Cmd
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
83 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
84 const char *name;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85 const char *syntax;
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
86 Bool needAuth;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 /* 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
88 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
89 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
90 Cmd;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
91
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 static Bool doArt( char *arg, const Cmd *cmd );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
93 static Bool doAuthinfo( char *arg, const Cmd *cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
115 static void closeServer( void );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
116 static Bool initServer( void );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
117
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
118 Cmd commands[] =
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
119 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
120 { "article", "ARTICLE [msg-id|n]", TRUE, &doArt },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
121 { "authinfo", "AUTHINFO USER username|PASS password", FALSE, &doAuthinfo },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
122 { "body", "BODY [msg-id|n]", TRUE, &doBody },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
123 { "head", "HEAD [msg-id|n]", TRUE, &doHead },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
124 { "group", "GROUP grp", TRUE, &doGrp },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
125 { "help", "HELP", FALSE, &doHelp },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
126 { "ihave", "IHAVE (ignored)", TRUE, &doIhave },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
127 { "last", "LAST", TRUE, &doLast },
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128 { "list", "LIST [ACTIVE [pat]]|ACTIVE.TIMES [pat]|"
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
129 "EXTENSIONS|NEWSGROUPS [pat]|OVERVIEW.FMT", TRUE, &doList },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
130 { "listgroup", "LISTGROUP grp", TRUE, &doListgrp },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
131 { "mode", "MODE (ignored)", FALSE, &doMode },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
132 { "newgroups", "NEWGROUPS [xx]yymmdd hhmmss [GMT]", TRUE, &doNewgrps },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
133 { "newnews", "NEWNEWS (not implemented)", TRUE, &notImplemented },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
134 { "next", "NEXT", TRUE, &doNext },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
135 { "post", "POST", TRUE, &doPost },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
136 { "quit", "QUIT", FALSE, &doQuit },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
137 { "slave", "SLAVE (ignored)", TRUE, &doSlave },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
138 { "stat", "STAT [msg-id|n]", TRUE, &doStat },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
139 { "xhdr", "XHDR over-field [msg-id|m[-[n]]]", TRUE, &doXhdr },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
140 { "xpat", "XPAT over-field msg-id|m[-[n]] pat", TRUE, &doXpat },
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
141 { "xover", "XOVER [m[-[n]]]", TRUE, &doXOver }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
142 };
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
143
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
144 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
145 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
146 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
147 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
148 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
149 noteInterest( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
150 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
152
191
28488e0e3630 [svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents: 188
diff changeset
153 Grp_setLastAccess( server.grp );
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
154 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
155 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
156 Fetchlist_read();
237
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
157 if ( ! Fetchlist_contains( server.grp, NULL ) )
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
158 {
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
159 if ( Cfg_autoSubscribe() )
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
160 {
106
46062d2f9d20 [svn] Auto subscribe mode now group-dependent
bears
parents: 88
diff changeset
161 if ( strcmp( Cfg_autoSubscribeMode( server.grp ), "full" ) == 0 )
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
162 mode = FULL;
106
46062d2f9d20 [svn] Auto subscribe mode now group-dependent
bears
parents: 88
diff changeset
163 else if ( strcmp( Cfg_autoSubscribeMode( server.grp ), "thread" ) == 0 )
82
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
164 mode = THREAD;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
165 else
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
166 mode = OVER;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
167 Fetchlist_add( server.grp, mode );
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
168 Fetchlist_write();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
169 Pseudo_autoSubscribed();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
170 }
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
171 else if ( Cfg_infoAlways() )
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
172 {
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
173 int first, last;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
174
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
175 /* Ensure new gen info for next time */
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
176 first = Cont_first();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
177 last = Cont_last();
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
178
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
179 if ( first == last )
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
180 first = last + 1;
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
181
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
182 Grp_setFirstLast( Cont_grp(), first, last );
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
183 }
1eb0cdd17c76 [svn] info-always-unread config/doc/implementation
bears
parents: 74
diff changeset
184 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
185 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
188 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
189 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
190 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
191 Str s, line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
192 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
193
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
194 ASSERT( stat <= 999 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
196 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
197 va_end( ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
198 snprintf( line, MAXCHAR, "%u %s", stat, s );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
199 DynStr_appLn( server.reply, line );
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 181
diff changeset
200 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
201 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
202
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
203 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
204 putTxtLn( const char *fmt, ... )
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 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
207 va_list ap;
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 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
210 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
211 va_end( ap );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
212 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
213 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
214
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
215 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
216 putTxtBuf( const char *buf )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
217 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
218 if ( buf )
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
219 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
220 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
221
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
222 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
223 putEndOfTxt( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
224 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
225 server.eotAfterReply = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
226 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
227
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229 putSyntax( const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
230 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
231 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
232 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
233
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
234 static void
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
235 initOutput( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
236 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
237 server.reply = new_DynStr( 100 );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
238 server.eotAfterReply = FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
239 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
240
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
241 static void
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
242 sendOutput( void )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
243 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
244 Prt_putTxtBuf( DynStr_str( server.reply ), stdout );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
245 if ( server.eotAfterReply )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
246 Prt_putEndOfTxt( stdout );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
247 fflush( stdout );
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 181
diff changeset
248 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
249 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
250 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
251
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
252 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
253 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
254 {
144
8b9366fc1361 [svn] Added timeout to Prt_getLn to avoid Noffle hanging if the
enz
parents: 127
diff changeset
255 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
256 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
257
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
258 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
259 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
260 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
261 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
262 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
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 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
265 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
267
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
269 checkNewArts( const char *grp )
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 if ( ! Online_true()
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
272 || 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
273 || Grp_local( grp )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
274 || 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
275 return;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
276 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
277 {
237
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
278 FetchMode mode;
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
279
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
280 /*
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
281 * See if group is on the fetchlist and if so use that mode.
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
282 * That way we preserve the download semantics for groups on
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
283 * the fetchlist. If the group is not on the fetchlist use
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
284 * OVER to get just the overview info.
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
285 */
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
286 Fetchlist_read();
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
287 if ( ! Fetchlist_contains( grp, &mode ) )
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
288 mode = OVER;
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
289
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
290 Fetch_getNewArts( grp, mode );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
291 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
292 }
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
293 else
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
294 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
295 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
296 Online_set( FALSE );
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
297 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
298 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
299
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
300 static void
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
301 postArts( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
302 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
303 Str s;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
304
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
305 Cfg_beginServEnum();
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
306 while ( Cfg_nextServ( s ) )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
307 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
308 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
309 Fetch_postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
310 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
311 }
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
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
314 static Bool
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
315 needsPseudoGenInfo( const char *grp )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
316 {
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
317 return ! ( Grp_local( grp )
237
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
318 || Fetchlist_contains( grp, NULL )
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
319 || Online_true() );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
320 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
321
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 readCont( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
325 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
326 Cont_read( name );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
327 if ( needsPseudoGenInfo( name ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
328 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
329 Pseudo_appGeneralInfo();
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
330 /* This adds the pseudo message to the overview contents
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
331 but NOT to the group info. If an article gets added,
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
332 the group info will get updated then from the
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
333 contents, so the article number will be preserved.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
334 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
335 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
336 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
337
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
338 static void
269
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
339 loadGrpInfo( const char *grp )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
340 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
341 checkNewArts( grp );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
342 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
343 readCont( grp );
269
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
344
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
345 /*
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
346 * This routine is used to change back to a group after releasing
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
347 * the lock. We need to preserve the group cursor if at all possible.
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
348 * So, if the article pointer points to an article before or after
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
349 * the current range, adjust it to the first/last article. Otherwise
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
350 * leave it well alone.
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
351 */
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
352 if ( server.artPtr < Cont_first() )
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
353 server.artPtr = Cont_first();
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
354 else if ( server.artPtr > Cont_last() )
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
355 server.artPtr = Cont_last();
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
356
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
357 server.groupReady = TRUE;
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
358 }
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
359
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
360 static void
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
361 changeToGrp( const char *grp )
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
362 {
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
363 loadGrpInfo( grp );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
364 server.artPtr = Cont_first();
43
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
367 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
368 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
369 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
370 int first, last, numb;
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 if ( arg[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
373 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
374 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
375 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
376 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
377 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
378 Utl_cpyStr( server.grp, arg );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
379 server.groupReady = FALSE;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
380 server.artPtr = Grp_first( arg );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
381 first = server.artPtr;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
382 last = Grp_last( arg );
160
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
383
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
384 if ( ( first == 0 && last == 0 )
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
385 || first > last ) {
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
386 changeToGrp( arg );
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
387 first = Cont_first();
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
388 last = Cont_last();
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
389 }
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
390
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
391 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
392 || first > last )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
393 first = last = numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
394 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
395 numb = last - first + 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
396 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
397 numb, first, last, arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
398 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
399 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
400 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
401
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
402 static Bool
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
403 loadGrpIfSelected( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
404 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
405 Str group;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
406 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
407 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
408 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
409 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
410 }
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
411 if ( ! server.groupReady )
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
412 {
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
413 Utl_cpyStr( group, server.grp );
269
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
414 loadGrpInfo( group );
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
415 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
416 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
417 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
418
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
419 static void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
420 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
421 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
422 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
423 Str s, grp;
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 Utl_cpyStr( result, "(unknown)" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
426 if ( Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
427 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
428 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
429 p = strtok( s, " \t" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
430 if ( p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
431 do
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 pColon = strstr( p, ":" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 if ( pColon )
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 Utl_cpyStrN( grp, p, pColon - p );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
437 srv = Grp_server( grp );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
438 if ( Cfg_servIsPreferential( srv, result ) )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
439 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
440 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
441 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
442 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
443 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
446 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
447 retrieveArt( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
448 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
449 Str s;
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
450 int stat;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
451
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
452 findServer( msgId, s );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
453 if ( strcmp( s, "(unknown)" ) == 0
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
454 || 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
455 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
456 if ( ! Client_connect( s ) )
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
457 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
458 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
459 Online_set( FALSE );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460 return FALSE;
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
461 }
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
462 stat = Client_retrieveArt( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
463 Client_disconnect();
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
464 if ( IS_FATAL( stat ) )
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
465 {
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
466 Log_inf( "Server connection failed or newsbase problem. "
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
467 "Leaving online mode." );
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
468 Online_set( FALSE );
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
469 return FALSE;
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
470 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
471 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
472 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
475 checkNumb( int numb )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
477 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
478 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
479 if ( ! Cont_validNumb( numb ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
481 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
482 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
483 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
485 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
486
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
487 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
488 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
489 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
490 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
491 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
492 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
493 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
494 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
495 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
496
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 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
498 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
499 if ( ! checkNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
500 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
501 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
502 ov = Cont_get( n );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
503 *msgId = Ov_msgId( ov );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
504 *numb = n;
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 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
507 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
508 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
509 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
510 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
511 *msgId = Ov_msgId( ov );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
512 *numb = server.artPtr;
43
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 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
515 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
516 *msgId = arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
517 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
518 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
519 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
520 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
521 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
522 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
523 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
524 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
525 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
526
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
527 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
528 touchArticle( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
529 {
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
530 unsigned status = Db_status( msgId );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
531 status |= DB_INTERESTING;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
532 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
533 Db_updateLastAccess( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
534 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
535
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
536 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
537 touchReferences( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
538 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
539 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
540 int len;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
541 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
542 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
543
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
544 while ( TRUE )
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 p = s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
547 while ( *ref != '<' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
548 if ( *(ref++) == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
549 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
550 len = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
551 while ( *ref != '>' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
552 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
553 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
554 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
555 *(p++) = *(ref++);
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 *(p++) = '>';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
558 *p = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
559 if ( Db_contains( s ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
560 touchArticle( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
561 }
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 void
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
565 updateArt( const char *msgId )
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
566 /* retrieve Article if in online mode */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
567 {
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
568 unsigned status;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
569
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
570 touchArticle( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
571 touchReferences( msgId );
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
572 status = Db_status( msgId );
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
573 if ( Online_true() && ( status & DB_NOT_DOWNLOADED ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
574 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
575 retrieveArt( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
576 }
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
577 }
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
578
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
579 static void
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
580 doBodyInDb( const char *msgId )
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
581 {
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
582 unsigned status;
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
583 Str srv;
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
584
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
585 status = Db_status( msgId );
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
586 if ( status & DB_RETRIEVING_FAILED )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
587 {
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
588 Db_setStatus( msgId, status & ~DB_RETRIEVING_FAILED );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
589 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
590 }
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
591 else if ( status & DB_NOT_DOWNLOADED )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
592 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
593 findServer( msgId, srv );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
594 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
595 putTxtBuf( Pseudo_alreadyMarkedBody() );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
596 else if ( strcmp( srv, "(unknown)" ) != 0 &&
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
597 strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 &&
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
598 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
599 putTxtBuf( Pseudo_markedBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
600 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
601 putTxtBuf( Pseudo_markingFailedBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
602 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
603 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
604 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
605 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
606
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
607 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
608 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
609 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
610 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
611 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
612
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
613 UNUSED( cmd );
43
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 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
616 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
617 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
618 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
619 putTxtBuf( Pseudo_generalInfoBody() );
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
620 else
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
621 {
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
622 updateArt( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
623 doBodyInDb( msgId );
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
624 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
625 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
626 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
627 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
628 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
631 doHeadInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
632 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
633 putTxtBuf( Db_header( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
634 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
635
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
636 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
637 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
638 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
639 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
640 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
641
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
642 UNUSED( cmd );
43
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 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
645 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
646 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
647 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
648 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
649 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
650 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
651 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
652 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
653 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
654
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
655 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
656 doArtInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
657 {
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
658 updateArt( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
659 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
660 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
661 doBodyInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
662 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
663
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
664 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
665 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
666 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
667 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
668 int numb;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
669
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
670 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
671
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
672 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
673 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
674 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
675 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
676 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
677 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
678 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
679 putTxtBuf( Pseudo_generalInfoBody() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
680 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
681 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
682 doArtInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
683 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
684 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
685 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
686 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
687
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
688 static Bool
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
689 doAuthinfo( char *line, const Cmd *cmd )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
690 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
691 #if USE_AUTH
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
692 Str s, arg;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
693 const char *data;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
694
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
695 if ( ! Cfg_needClientAuth() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
696 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
697 putStat( STAT_AUTH_REJECTED, "Authentication not required" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
698 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
699 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
700
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
701 if ( sscanf( line, MAXCHAR_FMT, s ) != 1 )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
702 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
703 badsyntax:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
704 if ( server.auth != AUTH_DONE )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
705 server.auth = NEED_USER;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
706 putSyntax( cmd );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
707 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
708 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
709 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
710 Utl_toLower( s );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
711 Utl_cpyStr( arg, Utl_restOfLn( line, 1 ) );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
712 data = Utl_stripWhiteSpace( arg );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
713
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
714 if ( strcmp( "user", s ) != 0 && strcmp( "pass", s ) != 0 )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
715 goto badsyntax;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
716
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
717 if ( strcmp( "user", s ) == 0 && server.auth == NEED_USER )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
718 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
719 if ( server.user != NULL )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
720 free( server.user );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
721 Utl_allocAndCpy( &server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
722 server.auth = NEED_PASS;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
723 putStat( STAT_MORE_AUTH_REQUIRED, "More authentication required" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
724 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
725 else if ( strcmp( "pass", s ) == 0 && server.auth == NEED_PASS )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
726 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
727 enum AuthResult authRes = Auth_authenticate( server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
728 char *p;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
729
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
730 /* Zap the password */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
731 for ( p = line; *p != '\0'; p++ )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
732 *p = 'X';
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
733
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
734 switch ( authRes )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
735 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
736 case AUTH_OK:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
737 server.auth = AUTH_DONE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
738 putStat( STAT_AUTH_ACCEPTED, "Authentication accepted" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
739 Log_inf( "User %s authenticated", server.user );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
740 break;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
741
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
742 case AUTH_FAILED:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
743 server.auth = NEED_USER;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
744 putStat( STAT_NO_PERMISSION, "No permission");
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
745 Log_dbg( LOG_DBG_AUTH, "User %s password %s rejected",
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
746 server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
747 break;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
748
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
749 case AUTH_DISCONNECT:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
750 putStat( STAT_NO_PERMISSION, "No permission - disconnecting" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
751 Log_dbg( LOG_DBG_AUTH,
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
752 "User %s password %s rejected - disconnecting",
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
753 server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
754 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
755
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
756 default: /* AUTH_ERROR */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
757 putStat( STAT_PROGRAM_FAULT, "Authentication program error" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
758 Log_dbg( LOG_DBG_AUTH,
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
759 "Error authenticating User %s password %s",
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
760 server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
761 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
762 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
763 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
764 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
765 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
766 if ( server.auth == AUTH_DONE )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
767 putStat( STAT_AUTH_REJECTED, "Reauthentication not possible" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
768 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
769 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
770 putStat( STAT_AUTH_REJECTED, "Authentication rejected" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
771 server.auth = NEED_USER;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
772 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
773 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
774 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
775 #else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
776 UNUSED( line );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
777 UNUSED( cmd );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
778
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
779 putStat( STAT_AUTH_REJECTED, "Authentication not possible" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
780 #endif
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
781 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
782 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
783
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
784 static Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
785 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
786 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
787 unsigned int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
788
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
789 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
790 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
791
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
792 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
793 putTxtBuf( "\nCommands:\n\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
794 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
795 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
796 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
797 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
798 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
799
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
800 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
801 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
802 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
803 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
804 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
805
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
806 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
807 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
808 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
811 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
812 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
813 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
814
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
815 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
816 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
817
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
818 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
819 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
820 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
821 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
822 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
823 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
824 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
825 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
826 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
827 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
828 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
829 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
830 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
831 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
832 server.artPtr = n;
43
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
836 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
837 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
838
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
839 static Bool
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
840 containsWildcards( const char *pattern )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
841 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
842 return ( strpbrk( pattern, "?*[\\" ) == NULL ? FALSE : TRUE );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
843 }
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
844
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
845 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
846 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
847 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
848 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
849 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
850
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
851 putStat( STAT_GRPS_FOLLOW, "Groups" );
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
852 if ( containsWildcards( pat ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
853 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
854 if ( Grp_firstGrp( &g ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
855 do
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
856 if ( Wld_match( g, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
857 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
858 (*printProc)( line, g );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
859 putTxtLn( line );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
860 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
861 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
862 }
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
863 else if ( Grp_exists( pat ) )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
864 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
865 (*printProc)( line, pat );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
866 putTxtLn( line );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
867 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
868 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
869 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
870
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
871 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
872 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
873 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
874 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
875 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
876
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
877 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
878 doListActiveTimes( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
879 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
880 printGroups( pat, &printActiveTimes );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
881 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
882
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
883 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
884 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
885 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
886 int last;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
887
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
888 /* If there will be a pseudo gen info message waiting when we join
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
889 this group, fiddle the group numbers to show it. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
890 last = Grp_last( grp );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
891 if ( needsPseudoGenInfo( grp ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
892 last++;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
893
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
894 snprintf( result, MAXCHAR, "%s %d %d %c",
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
895 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
896 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
897
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
898 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
899 doListActive( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
900 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
901 /* We need to read the fetchlist so we know whether a pseudo
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
902 gen info article needs to be faked when printing the group
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
903 last. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
904 Fetchlist_read();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
905 printGroups( pat, &printActive );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
906 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
907
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
908 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
909 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
910 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
911 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
912 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
915 doListNewsgrps( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
916 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
917 printGroups( pat, &printNewsgrp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
918 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
919
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
920 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
921 putGrp( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
922 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
923 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
924 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
925
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
926 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
927 doListOverFmt( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
928 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
929 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
930 putTxtBuf( "Subject:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
931 "From:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
932 "Date:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
933 "Message-ID:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
934 "References:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
935 "Bytes:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
936 "Lines:\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
937 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
938 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
939
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
940 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
941 doListExtensions( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
942 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
943 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
944 putTxtBuf( " LISTGROUP\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
945 " XOVER\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
946 putEndOfTxt();
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
949 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
950 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
951 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
952 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
953 const char *pat;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
954
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
955 if ( sscanf( line, MAXCHAR_FMT, s ) != 1 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
956 doListActive( "*" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
957 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
958 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
959 Utl_toLower( s );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
960 Utl_cpyStr( arg, Utl_restOfLn( line, 1 ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
961 pat = Utl_stripWhiteSpace( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
962 if ( pat[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
963 pat = "*";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
964 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
965 doListActive( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
966 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
967 doListOverFmt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
968 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
969 doListNewsgrps( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
970 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
971 doListActiveTimes( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
972 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
973 doListExtensions();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
974 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
975 putSyntax( cmd );
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 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
978 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
981 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
982 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
983 int first, last, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
984
74
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
264
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
987 if ( *arg != '\0' )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
988 {
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
989 if ( ! Grp_exists( arg ) )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
990 {
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
991 putStat( STAT_NO_SUCH_GRP, "No such group" );
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
992 return TRUE;
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
993 }
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
994 changeToGrp( arg );
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
995 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
996 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
997 {
264
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
998 if ( ! loadGrpIfSelected() )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
999 return TRUE;
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1000
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1001 }
264
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1002
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1003 first = Cont_first();
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1004 last = Cont_last();
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1005 putStat( STAT_GRP_SELECTED, "Article list" );
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1006 for ( i = first; i <= last; ++i )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1007 if ( Cont_get( i ) != NULL )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1008 putTxtLn( "%d", i );
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
1009 putEndOfTxt();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1010 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1011 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1012
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1013 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1014 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
1015 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1016 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1017 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1018
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1019 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
1020 return TRUE;
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
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1023 /*
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1024 * Given a time specification (local time or GMT), return a time_t.
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1025 */
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1026 static time_t
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1027 getTimeInSeconds( int year, int mon, int day,
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1028 int hour, int min, int sec,
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1029 Bool timeIsGMT )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1030 {
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
1031 struct tm t;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1032 time_t result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1033
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1034 ASSERT( year >= 1900 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1035 ASSERT( mon >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1036 ASSERT( mon <= 12 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1037 ASSERT( day >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1038 ASSERT( day <= 31 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1039 ASSERT( hour >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1040 ASSERT( hour <= 23 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1041 ASSERT( min >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1042 ASSERT( min <= 59 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1043 ASSERT( sec >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1044 ASSERT( sec <= 59 );
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
1045 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
1046 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
1047 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
1048 t.tm_mday = day;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1049 t.tm_hour = hour;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1050 t.tm_min = min;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1051 t.tm_sec = sec;
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1052 t.tm_isdst = -1;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1053 result = timeIsGMT ? Utl_mktimeGMT( &t ) : mktime( &t );
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1054 return result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1055 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1056
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1057
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1058 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1059 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
1060 {
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1061 time_t t, now, lastUpdate;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1062 int year, mon, day, hour, min, sec, len, fields, nowYear;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1063 const char *g;
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1064 Str date, timeofday, file, utc;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1065 Bool timeIsGMT = FALSE;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1066 struct tm *tm;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1067
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1068 fields = sscanf( arg, MAXCHAR_FMT " " MAXCHAR_FMT " " MAXCHAR_FMT,
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1069 date, timeofday, utc );
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1070 if ( fields == 3 )
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1071 {
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1072 Utl_toLower( utc );
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1073 if ( strcmp( utc, "gmt" ) != 0 && strcmp( utc, "utc" ) != 0 )
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1074 {
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1075 putSyntax( cmd );
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1076 return TRUE;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1077 }
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1078 timeIsGMT = TRUE;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1079 }
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1080 else if ( fields != 2 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1081 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1082 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1083 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1084 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1085 len = strlen( date );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1086 switch ( len )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1087 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1088 case 6:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1089 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
1090 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1091 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1092 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1093 }
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1094 /*
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1095 * As per current IETF draft, year is this century if <= now,
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1096 * else last century.
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1097 */
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1098 now = time( NULL );
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1099 tm = timeIsGMT ? gmtime( &now ) : localtime( &now );
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1100 nowYear = tm->tm_year + 1900;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1101 year += ( nowYear / 100 ) * 100;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1102 if ( year % 100 > nowYear % 100 )
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1103 year -= 100;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1104 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1105 case 8:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1106 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
1107 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1108 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1109 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1110 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1111 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1112 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1113 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1114 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1115 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1116 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
1117 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1118 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1119 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1120 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1121 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
1122 || hour < 0 || hour > 23 || min < 0 || min > 59
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1123 || 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
1124 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1125 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1126 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1127 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1128 snprintf( file, MAXCHAR, "%s/groupinfo.lastupdate", Cfg_spoolDir() );
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1129 t = getTimeInSeconds( year, mon, day, hour, min, sec, timeIsGMT );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1130
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1131 if ( ! Utl_getStamp( &lastUpdate, file ) )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1132 {
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1133 /* Can't get stamp. Put out error message. */
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1134 putStat( STAT_PROGRAM_FAULT, "Server error reading %s", file );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1135 return TRUE;
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1136 }
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1137
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1138 /* Show timestamp back as news format time for confirmation. */
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1139 Utl_newsDate( t, timeofday );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1140
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1141 putStat( STAT_NEW_GRP_FOLLOW, "New groups since %s", timeofday );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1142
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1143 if ( t == (time_t)-1 || t <= lastUpdate )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1144 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1145 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1146 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1147 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
1148 putGrp( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1149 while ( Grp_nextGrp( &g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1150 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1151 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1152 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1153 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1156 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
1157 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1158 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1159
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1160 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1161 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1162
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1163 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1164 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1165 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1166 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1167 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
1168 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1169 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1170 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
1171 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1172 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
1173 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1174 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1175 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
1176 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1177 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1178 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1179 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1180 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1181 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1182 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1183
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1184 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1185 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
1186 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1187 DynStr *s;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1188 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1189 Bool err;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1190
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1191 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1192 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1193
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1194 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1195 * The article may take some time coming in, so release the
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1196 * lock while collecting it.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1197 */
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1198 putStat( STAT_SEND_ART, "Continue (end with period)" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1199 sendOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1200 closeServer();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1201
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1202 s = new_DynStr( 10000 );
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1203 err = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1204 while ( ! err && getTxtLn( line, &err ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1205 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
1206
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1207 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1208 if ( ! initServer() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1209 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1210 del_DynStr( s );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1211 return FALSE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1212 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1213
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1214 if ( ! err
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1215 && Post_open( DynStr_str( s ), 0 )
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 106
diff changeset
1216 && Post_post() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1217 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1218 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
1219 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1220 postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1221 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1222 else
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1223 putStat( STAT_POST_FAILED, "Posting failed" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1224 Post_close();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1225 del_DynStr( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1226 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1227 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1228
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1229 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1230 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
1231 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1232 int r, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1233 char* p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1234 Str t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1235
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1236 Utl_cpyStr( t, s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1237 p = Utl_stripWhiteSpace( t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1238 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
1239 if ( r < 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1240 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1241 *first = server.artPtr;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1242 *last = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1243 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1244 else if ( r == 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1245 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1246 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
1247 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1248 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1249 *last = *first;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1250 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1251 if ( *first < Cont_first() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1252 *first = Cont_first();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1253 if ( *last > Cont_last() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1254 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1255 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
1256 *last = *first - 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1257 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1258 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
1259 if ( Cont_validNumb( i ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1260 ++(*numb);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1261 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1262
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1263 enum XhdrType { SUBJ, FROM, DATE, MSG_ID, REF, BYTES, LINES, XREF, UNKNOWN };
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1264
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1265 static enum XhdrType
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1266 whatXhdrField( const char * fieldname )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1267 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1268 Str name;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1269
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1270 Utl_cpyStr( name, fieldname );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1271 Utl_toLower( name );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1272 if ( strcmp( name, "subject" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1273 return SUBJ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1274 else if ( strcmp( name, "from" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1275 return FROM;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1276 else if ( strcmp( name, "date" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1277 return DATE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1278 else if ( strcmp( name, "message-id" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1279 return MSG_ID;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1280 else if ( strcmp( name, "references" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1281 return REF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1282 else if ( strcmp( name, "bytes" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1283 return BYTES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1284 else if ( strcmp( name, "lines" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1285 return LINES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1286 else if ( strcmp( name, "xref" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1287 return XREF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1288 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1289 return UNKNOWN;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1290 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1291
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1292 static void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1293 getXhdrField( enum XhdrType what, const Over * ov, Str res )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1294 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1295 const char * msgId;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1296 Str host;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1297
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1298 switch ( what )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1299 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1300 case SUBJ:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1301 Utl_cpyStr( res, Ov_subj( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1302 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1303 case FROM:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1304 Utl_cpyStr( res, Ov_from( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1305 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1306 case DATE:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1307 Utl_cpyStr( res, Ov_date( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1308 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1309 case MSG_ID:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1310 Utl_cpyStr( res, Ov_msgId( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1311 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1312 case REF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1313 Utl_cpyStr( res, Ov_ref( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1314 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1315 case BYTES:
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
1316 snprintf( res, MAXCHAR, "%ld", Ov_bytes( ov ) );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1317 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1318 case LINES:
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 269
diff changeset
1319 snprintf( res, MAXCHAR, "%ld", Ov_lines( ov ) );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1320 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1321 case XREF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1322 msgId = Ov_msgId( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1323 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1324 * 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
1325 * 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
1326 * header value as '(none)', so do the same.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1327 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1328 if ( Pseudo_isGeneralInfo( msgId ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1329 Utl_cpyStr( res, "none" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1330 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1331 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1332 gethostname( host, MAXCHAR );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1333 snprintf( res, MAXCHAR, "%s %s", host, Db_xref( msgId ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1334 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1335 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1336 default:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1337 ASSERT( FALSE );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1338 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1339 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1340
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1341 /*
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1342 Note this only handles a subset of headers. But they are all
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1343 the headers any newsreader should need to work properly.
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1344
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1345 That last sentence will at some stage be proved wrong.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1346 */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1347 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1348 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
1349 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1350 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1351 const char *p;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1352 Str whatStr;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1353
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1354 if ( sscanf( arg, MAXCHAR_FMT, whatStr ) != 1 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1355 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1356 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1357 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1358 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1359 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1360 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1361 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1362 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
1363 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1364 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1365 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1366 p = Utl_restOfLn( arg, 1 );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1367 if ( p[ 0 ] == '<' )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1368 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1369 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1370 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1371
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1372 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1373 ov = Db_over( p );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1374 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1375 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1376 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1377 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1378 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1379 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, p ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1380 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1381 putTxtLn( "%s %s", p, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1382 del_Over( ov );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1383 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1384 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1385 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1386 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1387 int first, last, i, n, numb;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1388 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1389
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1390 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1391 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1392 return TRUE;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1393 parseRange( p, &first, &last, &numb );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1394 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1395 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1396 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1397 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1398 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1399 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1400 whatStr, first, last ) ;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1401 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
1402 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
1403 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1404 n = Ov_numb( ov );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1405 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1406 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
1407 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1408 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1409 putEndOfTxt();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1410 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1411 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1414 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
1415 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1416 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1417 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
1418
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1419 if ( sscanf( arg, MAXCHAR_FMT " " MAXCHAR_FMT " " MAXCHAR_FMT,
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1420 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
1421 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1422 putSyntax( cmd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1423 return TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1424 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1425 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1426 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1427 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1428 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
1429 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1430 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1431 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1432 if ( articles[ 0 ] == '<' )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1433 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1434 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1435 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1436
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1437 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1438 ov = Db_over( articles );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1439 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1440 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1441 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1442 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1443 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1444 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, articles ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1445 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1446 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1447 putTxtLn( "%s %s", articles, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1448 del_Over( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1449 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1450 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1451 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1452 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1453 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1454 int first, last, i, n, numb;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1455
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1456 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1457 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1458 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1459 parseRange( articles, &first, &last, &numb );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1460 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1461 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1462 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1463 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1464 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1465 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1466 whatStr, first, last ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1467 for ( i = first; i <= last; ++i )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1468 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
1469 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1470 n = Ov_numb( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1471 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1472 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1473 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
1474 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1475 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1476 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1477 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1478 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1479
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1480 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1481 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
1482 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1483 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1484 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1485
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1486 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
1487 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1488 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1489
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1490 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1491 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
1492 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1493 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1494 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1495
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1496 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1497
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1498 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
1499 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1500 if ( numb > 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1501 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
1502 numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1503 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1504 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
1505 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1506 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1507
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1508 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1509 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
1510 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1511 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1512 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1513
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1514 putStat( STAT_GOODBYE, "Goodbye" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1515 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1516 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1517
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1518 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1519 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
1520 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1521 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
1522 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1523
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1524 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1525
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1526 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1527 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1528 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
1529 if ( n == 0 )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1530 first = last = server.artPtr;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1531 putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1532 for ( i = first; i <= last; ++i )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1533 if ( ( ov = Cont_get( i ) ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1534 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
1535 Ov_numb( ov ), Ov_subj( ov ), Ov_from( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1536 Ov_date( ov ), Ov_msgId( ov ), Ov_ref( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1537 Ov_bytes( ov ), Ov_lines( ov ) );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1538 putEndOfTxt();
191
28488e0e3630 [svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents: 188
diff changeset
1539 Grp_setLastAccess( server.grp );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1540 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1541 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1542
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1543 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1544 putFatal( const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1545 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1546 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1547 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1548
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1549 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1550 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
1551 va_end( ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1552 Log_err( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1553 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
1554 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1555
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1556 /* 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
1557 static Bool
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1558 parseAndExecute( Str line, Bool authDone )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1559 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1560 unsigned int i, n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1561 Cmd *c;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1562 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1563 Bool ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1564
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1565 if ( sscanf( line, MAXCHAR_FMT, s ) == 1 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1566 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1567 Utl_toLower( s );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1568 Utl_cpyStr( arg, Utl_restOfLn( line, 1 ) );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1569 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
1570 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
1571 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
1572 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1573 #if USE_AUTH
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1574 if ( c->needAuth && ! authDone )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1575 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1576 putStat( STAT_AUTH_REQUIRED, "Authentication required" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1577 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1578 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1579 #else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1580 UNUSED( authDone );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1581 #endif
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1582 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
1583 return ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1584 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1585 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1586 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
1587 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1588 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1589
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1590 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1591 putWelcome( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1592 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1593 initOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1594 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
1595 Cfg_version() );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1596 sendOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1597 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1598
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1599 static Bool
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1600 initServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1601 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1602 ASSERT( ! server.running );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1603 if ( ! Lock_openDatabases() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1604 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1605 server.running = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1606 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
1607 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1608 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1609
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1610 static void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1611 closeServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1612 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1613 ASSERT( server.running );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1614 server.running = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1615 Lock_closeDatabases();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1616 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1617
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1618 void
167
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1619 Server_flushCache( void )
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1620 {
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1621 server.groupReady = FALSE;
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1622 }
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1623
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1624 void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1625 Server_run( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1626 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1627 Bool done;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1628 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1629
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1630 putWelcome();
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1631
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1632 #if USE_AUTH
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1633 /*
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1634 * If authentication is required, we issue the welcome message and
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1635 * go into a command loop that doesn't open the databases and just
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1636 * accepts authentication commands. Once successfully authenticated,
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1637 * we drop root privs (if we have them - they are needed for PAM
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1638 * authentication to work) and proceed to the normal loop.
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1639 */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1640 if ( Cfg_needClientAuth() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1641 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1642 if ( ! Auth_open() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1643 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1644 initOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1645 putFatal( "Cannot open authorisation" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1646 sendOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1647 return;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1648 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1649
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1650 done = FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1651 while ( ! done )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1652 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1653 if ( Prt_getLn( line, stdin, -1 ) )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1654 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1655 initOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1656
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1657 if ( ! parseAndExecute( line, FALSE ) )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1658 done = TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1659
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1660 if ( server.auth == AUTH_DONE )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1661 done = TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1662
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1663 sendOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1664 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1665 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1666 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1667 Log_inf( "Client disconnected. Terminating." );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1668 done = TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1669 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1670 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1671
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1672 Auth_close();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1673
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1674 /* Did we finish because we successfully authenticated? */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1675 if ( server.auth != AUTH_DONE )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1676 return;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1677 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1678 #endif
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1679
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1680 if ( ! Auth_dropPrivs() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1681 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1682 initOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1683 putFatal( "Cannot set user privs" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1684 sendOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1685 return;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1686 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1687
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1688 done = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1689 while ( ! done )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1690 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1691 if ( Prt_getLn( line, stdin, -1 ) )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1692 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1693 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1694
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1695 if ( ! initServer() )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1696 {
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1697 putFatal( "Cannot init server" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1698 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1699 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1700 else
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1701 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1702 if ( ! parseAndExecute( line, TRUE ) )
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1703 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1704 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1705
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1706 if ( server.running )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1707 closeServer();
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1708
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1709 sendOutput();
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1710 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1711 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1712 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1713 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
1714 done = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1715 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1716 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1717 if ( server.running )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1718 closeServer();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1719 }