annotate src/server.c @ 482:a04c52f87b6e noffle

[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c: Add new '-U, --uninteresting' option. This removes an article from the list of requested articles and removes its INTERESTING marker.
author bears
date Thu, 14 Oct 2004 00:26:48 +0100
parents 466b42bb776e
children a02417000b7b
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
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
4 $Id: server.c 629 2004-10-13 23:26:48Z 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 );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
200 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
203 putTxtLn( const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
204 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
205 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
206 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
207
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
208 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
209 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
210 va_end( ap );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
211 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
212 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
215 putTxtBuf( const char *buf )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
216 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
217 if ( buf )
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
218 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
219 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
222 putEndOfTxt( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
223 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
224 server.eotAfterReply = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
225 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228 putSyntax( const Cmd *cmd )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
230 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
231 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
232
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
233 static void
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
234 initOutput( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
235 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
236 server.reply = new_DynStr( 100 );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
237 server.eotAfterReply = FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
238 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
239
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
240 static void
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
241 sendOutput( void )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
242 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
243 Prt_putTxtBuf( DynStr_str( server.reply ), stdout );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
244 if ( server.eotAfterReply )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
245 Prt_putEndOfTxt( stdout );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
246 fflush( stdout );
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 181
diff changeset
247 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
248 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
249 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
252 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
253 {
144
8b9366fc1361 [svn] Added timeout to Prt_getLn to avoid Noffle hanging if the
enz
parents: 127
diff changeset
254 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
255 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
258 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
259 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
260 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
261 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
262
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
263 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
264 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
265 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
267 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 checkNewArts( const char *grp )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
269 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
270 if ( ! Online_true()
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
271 || 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
272 || Grp_local( grp )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
273 || 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
274 return;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
275 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
276 {
237
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
277 FetchMode mode;
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
278
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 * 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
281 * 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
282 * 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
283 * 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
284 */
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
285 Fetchlist_read();
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
286 if ( ! Fetchlist_contains( grp, &mode ) )
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
287 mode = OVER;
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
288
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
289 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
290 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
291 }
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
292 else
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
293 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
294 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
295 Online_set( FALSE );
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
296 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
297 }
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 static void
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
300 postArts( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
301 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
302 Str s;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
303
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
304 Cfg_beginServEnum();
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
305 while ( Cfg_nextServ( s ) )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
306 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
307 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
308 Fetch_postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
309 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
310 }
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
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
313 static Bool
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
314 needsPseudoGenInfo( const char *grp )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
315 {
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
316 return ! ( Grp_local( grp )
237
f8a91e2b4060 [svn] * src/fetchlist.h,src/fetchlist.c,src/noffle.c: Provide fetchmode for
bears
parents: 223
diff changeset
317 || Fetchlist_contains( grp, NULL )
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
318 || Online_true() );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
319 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
320
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
321 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 readCont( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
325 Cont_read( name );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
326 if ( needsPseudoGenInfo( name ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
327 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
328 Pseudo_appGeneralInfo();
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
329 /* This adds the pseudo message to the overview contents
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
330 but NOT to the group info. If an article gets added,
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
331 the group info will get updated then from the
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
332 contents, so the article number will be preserved.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
333 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
334 }
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 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
338 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
339 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
340 checkNewArts( grp );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
341 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
342 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
343
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 * 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
346 * 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
347 * 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
348 * 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
349 * 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
350 */
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
351 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
352 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 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
354 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
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
356 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
357 }
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 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
360 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
361 {
b3a2f710fe2c [svn] * src/server.c: Fix post 1.0 bug where the article cursor was lost if the
bears
parents: 264
diff changeset
362 loadGrpInfo( grp );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
363 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
364 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
365
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
366 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
367 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
368 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
369 int first, last, numb;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
370
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
371 if ( arg[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
372 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
373 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
374 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
375 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
376 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
377 server.groupReady = FALSE;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
378 server.artPtr = Grp_first( arg );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
379 first = server.artPtr;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
380 last = Grp_last( arg );
160
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
381
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
382 if ( ( first == 0 && last == 0 )
389
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
383 || first > last )
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
384 {
160
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
385 changeToGrp( arg );
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
386 first = Cont_first();
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
387 last = Cont_last();
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
388 }
389
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
389 else
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
390 Utl_cpyStr( server.grp, arg );
160
23a53c92d4d7 [svn] apply bug-fix for lazy group loading by Matija Nalis
enz
parents: 155
diff changeset
391
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
392 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
393 || first > last )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
394 first = last = numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
395 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
396 numb = last - first + 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
397 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
398 numb, first, last, arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
399 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
400 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
403 static Bool
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
404 loadGrpIfSelected( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
405 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
406 Str group;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
407 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
408 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
409 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
410 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
411 }
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
412 if ( ! server.groupReady )
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
413 {
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
414 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
415 loadGrpInfo( group );
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
416 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
417 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
420 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
421 retrieveArt( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
422 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
423 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
424 int stat;
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
425 Bool foundServer;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
426
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
427 foundServer = Db_findServer( msgId, s );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
428 if ( ! foundServer || 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
429 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
430 if ( ! Client_connect( s ) )
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
431 {
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
432 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
433 Online_set( FALSE );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 return FALSE;
119
f50cc311e29a [svn] Leave online mode, if the connection to a remote server
enz
parents: 115
diff changeset
435 }
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
436 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
437 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
438 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
439 {
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
440 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
441 "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
442 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
443 return FALSE;
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
444 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
445 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
446 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
447
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
448 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
449 checkNumb( int numb )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
450 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
451 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
452 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
453 if ( ! Cont_validNumb( numb ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
454 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
455 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
456 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
457 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
458 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
459 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
461 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
462 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
463 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
464 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
465 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466 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
467 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
468 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
469 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
470
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
471 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
472 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473 if ( ! checkNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
475 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476 ov = Cont_get( n );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
477 *msgId = Ov_msgId( ov );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
478 *numb = n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
479 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480 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
481 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
482 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
483 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
484 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
485 *msgId = Ov_msgId( ov );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
486 *numb = server.artPtr;
43
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 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
489 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
490 *msgId = arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
491 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
492 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
493 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
494 {
181
e196de757ecd [svn] * src/server.c: Correct error code given when article requested by
bears
parents: 173
diff changeset
495 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
496 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
498 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
499 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
500
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
501 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
502 touchArticle( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
503 {
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
504 unsigned status = Db_status( msgId );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
505 status |= DB_INTERESTING;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
506 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
507 Db_updateLastAccess( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
508 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
509
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
510 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
511 touchReferences( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
512 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
513 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
514 int len;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
515 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
516 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
517
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
518 while ( TRUE )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
519 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
520 p = s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
521 while ( *ref != '<' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
522 if ( *(ref++) == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
523 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
524 len = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
525 while ( *ref != '>' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
526 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
527 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
528 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
529 *(p++) = *(ref++);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
530 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
531 *(p++) = '>';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
532 *p = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
533 if ( Db_contains( s ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
534 touchArticle( s );
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
537
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
538 static void
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
539 updateArt( const char *msgId )
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
540 /* 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
541 {
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
542 unsigned status;
43
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 touchArticle( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
545 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
546 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
547 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
548 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
549 retrieveArt( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
550 }
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
551 }
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
552
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
553 static void
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
554 doBodyInDb( const char *msgId )
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
555 {
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
556 unsigned status;
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
557 Str srv;
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
558 Bool foundServer;
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
559
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
560 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
561 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
562 {
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
563 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
564 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
565 }
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
566 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
567 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
568 if ( Req_contains( srv, msgId ) )
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
569 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
570 putTxtBuf( Pseudo_alreadyMarkedBody() );
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
571 }
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
572 else
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
573 {
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
574 foundServer = Db_findServer( msgId, srv );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
575 if ( ! foundServer && strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
576 {
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
577 Log_err( "Can't find server for message %s", msgId );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
578 putTxtBuf ( Pseudo_markingFailedBody() );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
579 }
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
580 else if ( Req_add( srv, msgId ) )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
581 putTxtBuf( Pseudo_markedBody() );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
582 else
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
583 putTxtBuf( Pseudo_markingFailedBody() );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 423
diff changeset
584 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
585 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
586 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
587 putTxtBuf( Db_body( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
588 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
589
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
590 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
591 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
592 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
593 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
594 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
595
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
596 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
597
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
598 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
599 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
600 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
601 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
602 putTxtBuf( Pseudo_generalInfoBody() );
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
603 else
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
604 {
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
605 updateArt( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
606 doBodyInDb( msgId );
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
607 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
608 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
609 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
610 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
611 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
612
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
613 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
614 doHeadInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
615 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
616 putTxtBuf( Db_header( msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
617 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
618
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
619 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
620 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
621 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
622 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
623 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
624
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
625 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
626
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
627 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
628 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
629 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
630 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
631 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
632 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
633 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
634 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
635 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
636 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
637
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
638 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
639 doArtInDb( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
640 {
241
d70e9dd6b308 [svn] see Changelog Mar 13 2002
mirkol
parents: 237
diff changeset
641 updateArt( msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
642 doHeadInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
643 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
644 doBodyInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
645 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
646
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
647 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
648 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
649 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
650 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
651 int numb;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
652
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
653 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
654
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
655 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
656 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
657 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
658 if ( Pseudo_isGeneralInfo( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
659 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
660 putTxtBuf( Pseudo_generalInfoHead() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
661 putTxtLn( "" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
662 putTxtBuf( Pseudo_generalInfoBody() );
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 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
665 doArtInDb( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
666 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
667 noteInterest();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
668 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
669 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
670
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
671 static Bool
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
672 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
673 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
674 #if USE_AUTH
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
675 Str s, arg;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
676 const char *data;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
677
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
678 if ( ! Cfg_needClientAuth() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
679 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
680 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
681 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
682 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
683
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
684 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
685 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
686 badsyntax:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
687 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
688 server.auth = NEED_USER;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
689 putSyntax( 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 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
692 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
693 Utl_toLower( s );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
694 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
695 data = Utl_stripWhiteSpace( arg );
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 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
698 goto badsyntax;
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 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
701 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
702 if ( server.user != NULL )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
703 free( server.user );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
704 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
705 server.auth = NEED_PASS;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
706 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
707 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
708 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
709 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
710 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
711 char *p;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
712
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
713 /* Zap the password */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
714 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
715 *p = 'X';
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 switch ( authRes )
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 case AUTH_OK:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
720 server.auth = AUTH_DONE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
721 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
722 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
723 break;
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 case AUTH_FAILED:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
726 server.auth = NEED_USER;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
727 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
728 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
729 server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
730 break;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
731
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
732 case AUTH_DISCONNECT:
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
733 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
734 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
735 "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
736 server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
737 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
738
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
739 default: /* AUTH_ERROR */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
740 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
741 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
742 "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
743 server.user, data );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
744 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
745 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
746 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
747 else
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 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
750 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
751 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
752 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
753 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
754 server.auth = NEED_USER;
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 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
757 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
758 #else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
759 UNUSED( line );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
760 UNUSED( cmd );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
761
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
762 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
763 #endif
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
764 return TRUE;
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
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
767 static Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
768 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
769 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
770 unsigned int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
771
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
772 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
773 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
774
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
775 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
776 putTxtBuf( "\nCommands:\n\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
777 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
778 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
779 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
780 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
781 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
782
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
783 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
784 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
785 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
786 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
787 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
788
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
789 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
790 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
791 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
792
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
793 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
794 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
795 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
796 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
797
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
798 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
799 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
800
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
801 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
802 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
803 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
804 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
805 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
806 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
807 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
808 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
809 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
810 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
811 else
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 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
814 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
815 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
816 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
817 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
818 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
819 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
820 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
821
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
822 static Bool
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
823 containsWildcards( const char *pattern )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
824 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
825 return ( strpbrk( pattern, "?*[\\" ) == NULL ? FALSE : TRUE );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
826 }
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
827
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
828 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
829 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
830 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
831 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
832 const char *g;
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 putStat( STAT_GRPS_FOLLOW, "Groups" );
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
835 if ( containsWildcards( pat ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
836 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
837 if ( Grp_firstGrp( &g ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
838 do
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
839 if ( Wld_match( g, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
840 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
841 (*printProc)( line, g );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
842 putTxtLn( line );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
843 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
844 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
845 }
173
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
846 else if ( Grp_exists( pat ) )
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
847 {
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
848 (*printProc)( line, pat );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
849 putTxtLn( line );
19e3aa717196 [svn] do not search all groups if group does not
enz
parents: 167
diff changeset
850 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
851 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
852 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
853
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
854 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
855 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
856 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
857 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
858 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
859
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
860 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
861 doListActiveTimes( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
862 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
863 printGroups( pat, &printActiveTimes );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
864 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
865
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
866 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
867 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
868 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
869 int last;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
870
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
871 /* If there will be a pseudo gen info message waiting when we join
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
872 this group, fiddle the group numbers to show it. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
873 last = Grp_last( grp );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
874 if ( needsPseudoGenInfo( grp ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
875 last++;
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
876
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
877 snprintf( result, MAXCHAR, "%s %d %d %c",
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
878 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
879 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
880
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
881 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
882 doListActive( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
883 {
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
884 /* We need to read the fetchlist so we know whether a pseudo
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
885 gen info article needs to be faked when printing the group
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
886 last. */
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
887 Fetchlist_read();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
888 printGroups( pat, &printActive );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
889 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
890
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
891 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
892 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
893 {
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 %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
895 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
898 doListNewsgrps( const char *pat )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
899 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
900 printGroups( pat, &printNewsgrp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
901 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
902
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
903 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
904 putGrp( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
905 {
389
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
906 putTxtLn( "%s %lu %lu %c",
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
907 name, Grp_last( name ), Grp_first( name ),
f81fdcc2696b [svn] * src/server.c: Move incorrect updating of server.grp in doGrp() which was
bears
parents: 288
diff changeset
908 Grp_postAllow( name ));
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
909 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
912 doListOverFmt( void )
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 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
915 putTxtBuf( "Subject:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
916 "From:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
917 "Date:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
918 "Message-ID:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
919 "References:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
920 "Bytes:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
921 "Lines:\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
922 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
923 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
926 doListExtensions( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
927 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
928 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
929 putTxtBuf( " LISTGROUP\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
930 " XOVER\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
931 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
932 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
933
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
934 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
935 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
936 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
937 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
938 const char *pat;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
939
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
940 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
941 doListActive( "*" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
942 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
943 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
944 Utl_toLower( s );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
945 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
946 pat = Utl_stripWhiteSpace( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
947 if ( pat[ 0 ] == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
948 pat = "*";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
949 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
950 doListActive( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
951 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
952 doListOverFmt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
953 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
954 doListNewsgrps( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
955 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
956 doListActiveTimes( pat );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
957 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
958 doListExtensions();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
959 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
960 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
961 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
962 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
963 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
964
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
965 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
966 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
967 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
968 int first, last, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
969
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
970 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
971
264
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
972 if ( *arg != '\0' )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
973 {
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
974 if ( ! Grp_exists( arg ) )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
975 {
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
976 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
977 return TRUE;
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
978 }
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
979 changeToGrp( arg );
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
980 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
981 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
982 {
264
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
983 if ( ! loadGrpIfSelected() )
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
984 return TRUE;
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
985
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
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
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
988 first = Cont_first();
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
989 last = Cont_last();
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
990 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
991 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
992 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
993 putTxtLn( "%d", i );
94b7962a0fbe [svn] * src/group.c: Explicitly disallow zero-length group names. Yes, I found one.
bears
parents: 259
diff changeset
994 putEndOfTxt();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
995 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
996 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
997
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
998 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
999 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
1000 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1001 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1002 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1003
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1004 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
1005 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1006 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1007
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1008 /*
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1009 * 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
1010 */
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1011 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
1012 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
1013 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
1014 Bool timeIsGMT )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1015 {
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
1016 struct tm t;
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1017 time_t result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1018
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1019 ASSERT( year >= 1900 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1020 ASSERT( mon >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1021 ASSERT( mon <= 12 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1022 ASSERT( day >= 1 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1023 ASSERT( day <= 31 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1024 ASSERT( hour >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1025 ASSERT( hour <= 23 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1026 ASSERT( min >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1027 ASSERT( min <= 59 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1028 ASSERT( sec >= 0 );
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1029 ASSERT( sec <= 59 );
64
7250be163ec4 [svn] Avoid compiler warnings about incomplete initializer blocks
enz
parents: 61
diff changeset
1030 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
1031 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
1032 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
1033 t.tm_mday = day;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1034 t.tm_hour = hour;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1035 t.tm_min = min;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1036 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
1037 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
1038 result = timeIsGMT ? Utl_mktimeGMT( &t ) : mktime( &t );
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1039 return result;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1040 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1041
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1042
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1043 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1044 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
1045 {
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1046 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
1047 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
1048 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
1049 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
1050 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
1051 struct tm *tm;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1052
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1053 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
1054 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
1055 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
1056 {
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1057 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
1058 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
1059 {
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1060 putSyntax( cmd );
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1061 return TRUE;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1062 }
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1063 timeIsGMT = TRUE;
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1064 }
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1065 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
1066 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1067 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1068 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1069 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1070 len = strlen( date );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1071 switch ( len )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1072 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1073 case 6:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1074 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
1075 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1076 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1077 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1078 }
259
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 * 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
1081 * 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
1082 */
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1083 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
1084 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
1085 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
1086 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
1087 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
1088 year -= 100;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1089 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1090 case 8:
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1091 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
1092 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1093 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1094 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1095 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1096 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1097 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1098 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1099 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1100 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1101 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
1102 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1103 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1104 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1105 }
69
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1106 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
1107 || hour < 0 || hour > 23 || min < 0 || min > 59
21e778b6c3e9 [svn] Rewrote getTimesInSeconds(): arguments ar now int and
enz
parents: 64
diff changeset
1108 || 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
1109 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1110 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1111 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1112 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1113 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
1114 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
1115
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1116 if ( ! Utl_getStamp( &lastUpdate, file ) )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1117 {
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1118 /* Can't get stamp. Put out error message. */
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1119 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
1120 return TRUE;
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1121 }
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1122
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1123 /* 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
1124 Utl_newsDate( t, timeofday );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1125
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1126 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
1127
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
1128 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
1129 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1130 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1131 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1132 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
1133 putGrp( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1134 while ( Grp_nextGrp( &g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1135 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1136 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1137 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1138 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1139
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1140 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1141 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
1142 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1143 int n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1144
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1145 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1146 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1147
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1148 if ( loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1149 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1150 n = server.artPtr;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1151 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1152 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
1153 else
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 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
1156 if ( ! Cont_validNumb( n ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1157 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
1158 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1159 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1160 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
1161 n, Ov_msgId( Cont_get( n ) ) );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1162 server.artPtr = n;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1163 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1164 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1165 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1166 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1167 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1168
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1169 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1170 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
1171 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1172 DynStr *s;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1173 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1174 Bool err;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1175
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1176 UNUSED(arg);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1177 UNUSED(cmd);
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1178
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1179 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1180 * The article may take some time coming in, so release the
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1181 * lock while collecting it.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1182 */
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1183 putStat( STAT_SEND_ART, "Continue (end with period)" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1184 sendOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1185 closeServer();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1186
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1187 s = new_DynStr( 10000 );
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1188 err = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1189 while ( ! err && getTxtLn( line, &err ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1190 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
1191
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1192 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1193 if ( ! initServer() )
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 del_DynStr( s );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1196 return FALSE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1197 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1198
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1199 if ( ! err
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1200 && Post_open( DynStr_str( s ), 0 )
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 106
diff changeset
1201 && Post_post() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1202 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1203 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
1204 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1205 postArts();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1206 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1207 else
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1208 putStat( STAT_POST_FAILED, "Posting failed" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 85
diff changeset
1209 Post_close();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1210 del_DynStr( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1211 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1212 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1213
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1214 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1215 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
1216 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1217 int r, i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1218 char* p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1219 Str t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1220
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1221 Utl_cpyStr( t, s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1222 p = Utl_stripWhiteSpace( t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1223 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
1224 if ( r < 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1225 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1226 *first = server.artPtr;
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1227 *last = server.artPtr;
43
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 else if ( r == 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1230 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1231 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
1232 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1233 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1234 *last = *first;
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 if ( *first < Cont_first() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1237 *first = Cont_first();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1238 if ( *last > Cont_last() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1239 *last = Cont_last();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1240 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
1241 *last = *first - 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1242 *numb = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1243 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
1244 if ( Cont_validNumb( i ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1245 ++(*numb);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1246 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1247
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1248 enum XhdrType { SUBJ, FROM, DATE, MSG_ID, REF, BYTES, LINES, XREF, UNKNOWN };
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1249
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1250 static enum XhdrType
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1251 whatXhdrField( const char * fieldname )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1252 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1253 Str name;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1254
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1255 Utl_cpyStr( name, fieldname );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1256 Utl_toLower( name );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1257 if ( strcmp( name, "subject" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1258 return SUBJ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1259 else if ( strcmp( name, "from" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1260 return FROM;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1261 else if ( strcmp( name, "date" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1262 return DATE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1263 else if ( strcmp( name, "message-id" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1264 return MSG_ID;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1265 else if ( strcmp( name, "references" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1266 return REF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1267 else if ( strcmp( name, "bytes" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1268 return BYTES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1269 else if ( strcmp( name, "lines" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1270 return LINES;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1271 else if ( strcmp( name, "xref" ) == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1272 return XREF;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1273 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1274 return UNKNOWN;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1275 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1276
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1277 static void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1278 getXhdrField( enum XhdrType what, const Over * ov, Str res )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1279 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1280 const char * msgId;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1281 Str host;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1282
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1283 switch ( what )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1284 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1285 case SUBJ:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1286 Utl_cpyStr( res, Ov_subj( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1287 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1288 case FROM:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1289 Utl_cpyStr( res, Ov_from( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1290 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1291 case DATE:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1292 Utl_cpyStr( res, Ov_date( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1293 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1294 case MSG_ID:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1295 Utl_cpyStr( res, Ov_msgId( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1296 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1297 case REF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1298 Utl_cpyStr( res, Ov_ref( ov ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1299 break;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1300 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
1301 snprintf( res, MAXCHAR, "%ld", Ov_bytes( ov ) );
127
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 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
1304 snprintf( res, MAXCHAR, "%ld", Ov_lines( ov ) );
127
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 XREF:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1307 msgId = Ov_msgId( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1308 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1309 * 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
1310 * 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
1311 * header value as '(none)', so do the same.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1312 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1313 if ( Pseudo_isGeneralInfo( msgId ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1314 Utl_cpyStr( res, "none" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1315 else
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1316 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1317 gethostname( host, MAXCHAR );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1318 snprintf( res, MAXCHAR, "%s %s", host, Db_xref( msgId ) );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1319 }
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 default:
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1322 ASSERT( FALSE );
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 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1325
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1326 /*
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1327 Note this only handles a subset of headers. But they are all
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1328 the headers any newsreader should need to work properly.
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1329
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1330 That last sentence will at some stage be proved wrong.
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1331 */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1332 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1333 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
1334 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1335 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1336 const char *p;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1337 Str whatStr;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1338
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1339 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
1340 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1341 putSyntax( cmd );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1342 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1343 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1344 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1345 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1346 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1347 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
1348 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1349 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1350 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1351 p = Utl_restOfLn( arg, 1 );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1352 if ( p[ 0 ] == '<' )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1353 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1354 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1355 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1356
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1357 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1358 ov = Db_over( p );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1359 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1360 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1361 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1362 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1363 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1364 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, p ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1365 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1366 putTxtLn( "%s %s", p, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1367 del_Over( ov );
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1368 }
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1369 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1370 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1371 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1372 int first, last, i, n, numb;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1373 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1374
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1375 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1376 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1377 return TRUE;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1378 parseRange( p, &first, &last, &numb );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1379 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1380 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1381 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1382 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1383 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1384 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1385 whatStr, first, last ) ;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1386 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
1387 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
1388 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1389 n = Ov_numb( ov );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1390 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1391 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
1392 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1393 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1394 putEndOfTxt();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1395 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1396 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1397
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1398 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1399 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
1400 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1401 enum XhdrType what;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1402 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
1403
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1404 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
1405 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
1406 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1407 putSyntax( cmd );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1408 return TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1409 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1410 what = whatXhdrField( whatStr );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1411 if ( what == UNKNOWN )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1412 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1413 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
1414 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1415 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1416 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1417 if ( articles[ 0 ] == '<' )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1418 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1419 Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1420 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1421
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1422 /* Argument is message ID */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1423 ov = Db_over( articles );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1424 if ( ov == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1425 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1426 putStat( STAT_NO_SUCH_ID, "No such article" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1427 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1428 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1429 putStat( STAT_HEAD_FOLLOWS, "%s header %s", whatStr, articles ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1430 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1431 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1432 putTxtLn( "%s %s", articles, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1433 del_Over( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1434 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1435 else
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 const Over * ov;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1438 Str field;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1439 int first, last, i, n, numb;
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 /* Argument is article no. or range */
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1442 if ( ! loadGrpIfSelected() )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1443 return TRUE;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1444 parseRange( articles, &first, &last, &numb );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1445 if ( numb == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1446 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1447 putStat( STAT_NO_ART_SELECTED, "No articles selected" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1448 return TRUE;
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 putStat( STAT_HEAD_FOLLOWS, "%s header %lu-%lu",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1451 whatStr, first, last ) ;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1452 for ( i = first; i <= last; ++i )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1453 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
1454 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1455 n = Ov_numb( ov );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1456 getXhdrField( what, ov, field );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1457 if ( Wld_match( field, pat ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1458 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
1459 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1460 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1461 putEndOfTxt();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1462 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1463 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1464
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1465 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1466 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
1467 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1468 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1469 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1470
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1471 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
1472 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1473 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1474
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1475 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1476 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
1477 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1478 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1479 int numb;
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1480
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1481 UNUSED( cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1482
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1483 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
1484 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1485 if ( numb > 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1486 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
1487 numb, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1488 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1489 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
1490 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1491 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1494 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
1495 {
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1496 UNUSED( arg );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1497 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1498
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1499 putStat( STAT_GOODBYE, "Goodbye" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1500 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1501 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1502
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1503 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1504 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
1505 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1506 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
1507 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1508
74
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1509 UNUSED( cmd );
c7df2cc65cc1 [svn] Introduce UNUSED(x) macro
bears
parents: 69
diff changeset
1510
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 149
diff changeset
1511 if ( ! loadGrpIfSelected() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1512 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1513 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
1514 if ( n == 0 )
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1515 first = last = server.artPtr;
49
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1516 putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1517 for ( i = first; i <= last; ++i )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1518 if ( ( ov = Cont_get( i ) ) )
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1519 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
1520 Ov_numb( ov ), Ov_subj( ov ), Ov_from( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1521 Ov_date( ov ), Ov_msgId( ov ), Ov_ref( ov ),
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1522 Ov_bytes( ov ), Ov_lines( ov ) );
5ecb646acf97 [svn] Article numbering bug fixes
bears
parents: 45
diff changeset
1523 putEndOfTxt();
191
28488e0e3630 [svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents: 188
diff changeset
1524 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
1525 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1526 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1527
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1528 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1529 putFatal( const char *fmt, ... )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1530 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1531 va_list ap;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1532 Str s;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1533
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1534 va_start( ap, fmt );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1535 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
1536 va_end( ap );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1537 Log_err( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1538 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
1539 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1540
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1541 /* 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
1542 static Bool
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1543 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
1544 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1545 unsigned int i, n;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1546 Cmd *c;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1547 Str s, arg;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1548 Bool ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1549
259
b660fadc1814 [svn] * src/server.c,src/util.c,src/util.h: Recognise GMT/UTC on NNTP NEWGROUPS.
bears
parents: 241
diff changeset
1550 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
1551 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1552 Utl_toLower( s );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1553 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
1554 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
1555 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
1556 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
1557 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1558 #if USE_AUTH
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1559 if ( c->needAuth && ! authDone )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1560 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1561 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
1562 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1563 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1564 #else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1565 UNUSED( authDone );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1566 #endif
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1567 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
1568 return ret;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1569 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1570 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1571 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
1572 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1573 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1574
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1575 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1576 putWelcome( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1577 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1578 initOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1579 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
1580 Cfg_version() );
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1581 sendOutput();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1582 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1583
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1584 static Bool
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1585 initServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1586 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1587 ASSERT( ! server.running );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1588 if ( ! Lock_openDatabases() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1589 return FALSE;
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1590 server.running = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1591 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
1592 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1593 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1594
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1595 static void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1596 closeServer( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1597 {
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1598 ASSERT( server.running );
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1599 server.running = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1600 Lock_closeDatabases();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1601 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1602
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1603 void
167
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1604 Server_flushCache( void )
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1605 {
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1606 server.groupReady = FALSE;
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1607 }
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1608
7ba337dafb2c [svn] * TODO,content.c,lock.c,server.c,server.h: Remove bug notice re:
bears
parents: 160
diff changeset
1609 void
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1610 Server_run( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1611 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1612 Bool done;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1613 Str line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1614
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1615 putWelcome();
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1616
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1617 #if USE_AUTH
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1618 /*
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1619 * 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
1620 * 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
1621 * 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
1622 * 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
1623 * 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
1624 */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1625 if ( Cfg_needClientAuth() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1626 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1627 if ( ! Auth_open() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1628 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1629 initOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1630 putFatal( "Cannot open authorisation" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1631 sendOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1632 return;
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
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1635 done = FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1636 while ( ! done )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1637 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1638 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
1639 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1640 initOutput();
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 ( ! parseAndExecute( line, FALSE ) )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1643 done = TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1644
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1645 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
1646 done = TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1647
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1648 sendOutput();
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 else
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1651 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1652 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
1653 done = TRUE;
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 }
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 Auth_close();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1658
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1659 /* 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
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 return;
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 #endif
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 if ( ! Auth_dropPrivs() )
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 initOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1668 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
1669 sendOutput();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1670 return;
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
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1673 done = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1674 while ( ! done )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1675 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1676 if ( Prt_getLn( line, stdin, -1 ) )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1677 {
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1678 initOutput();
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1679
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1680 if ( ! initServer() )
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1681 {
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1682 putFatal( "Cannot init server" );
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1683 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1684 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1685 else
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1686 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 271
diff changeset
1687 if ( ! parseAndExecute( line, TRUE ) )
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1688 done = TRUE;
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1689 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1690
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1691 if ( server.running )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1692 closeServer();
149
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1693
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1694 sendOutput();
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1695 }
bfeea2bc09b6 [svn] Output to buffer, release lock and then send output.
bears
parents: 144
diff changeset
1696 else
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1697 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1698 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
1699 done = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 119
diff changeset
1700 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1701 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1702 if ( server.running )
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1703 closeServer();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1704 }