Mercurial > noffle
annotate src/client.c @ 191:28488e0e3630 noffle
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
only ever called with last param as time(NULL), so remove it and call
time() inside the implementation of Grp_setLastAccess.
* src/client.c,src/group.h,src/group.c,src/noffle.c,src/post.c: Groups are
automatically unsubscribed when the last access to the group is older
than a particular threshold. However, for very low traffic groups, the
last access may exceed the threshold simply because there has been no new
article posted. In this case, rather than unsubscribe, update the group
last access time. This means that groups are now only unsubscribed if
the last access exceeds the threshold AND articles have arrived in the
group since. Add Grp_setLastPostTime() to track the last time an article
arrived in the group.
author | bears |
---|---|
date | Sat, 20 Oct 2001 14:23:46 +0100 |
parents | f1bacee93ca6 |
children | 24d4cd032da5 |
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 client.c |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
3 |
191
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
4 $Id: client.c 310 2001-10-20 13:23:46Z 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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
11 #include "client.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
12 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
13 #include <stdio.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
14 #include <arpa/inet.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
15 #include <ctype.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #include <netdb.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
17 #include <netinet/in.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
18 #include <signal.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
19 #include <stdarg.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
20 #include <sys/socket.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
21 #include <unistd.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
22 #include "configfile.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
23 #include "content.h" |
95 | 24 #include "control.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
25 #include "dynamicstring.h" |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
26 #include "filter.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
27 #include "group.h" |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
28 #include "itemlist.h" |
127 | 29 #include "lock.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
30 #include "log.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 #include "over.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
32 #include "protocol.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
33 #include "pseudo.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
34 #include "request.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
35 #include "util.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 #include "wildmat.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
48
diff
changeset
|
37 #include "portable.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
38 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
39 /* |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
40 Some newsgroups names are reserved for server-specific or server |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 pseudo groups. We don't want to fetch them. For example, INN |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
42 keeps all its control messages in a 'control' hierarchy, and |
103 | 43 used the "to." hierarchy for dark and mysterious purposes I think |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
44 are to do with newsfeeds. The recommended restrictions are documented |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
45 in C.Lindsay, "News Article Format", <draft-ietf-usefor-article-03.txt>. |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
46 */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
47 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
48 struct ForbiddenGroupName |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
49 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
50 const char *pattern; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
51 Bool match; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
52 } forbiddenGroupNames[] = |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
53 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
54 { "*.*", FALSE }, /* Single component */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
55 { "control.*", TRUE }, /* control.* groups */ |
103 | 56 { "to.*", TRUE }, /* to.* groups */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
57 { "*.all", TRUE }, /* 'all' as a component */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
58 { "*.all.*", TRUE }, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
59 { "all.*", TRUE }, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
60 { "*.ctl", TRUE }, /* 'ctl' as a component */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
61 { "*.ctl.*", TRUE }, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
62 { "ctl.*", TRUE } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
63 }; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
64 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
65 struct |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
66 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
67 FILE* in; /* Receiving socket from server */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
68 FILE* out; /* Sending socket to server */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
69 Str lastCmd; /* Last command line */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
70 Str lastStat; /* Response from server to last command */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
71 Str grp; /* Selected group */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
72 int rmtFirst; /* First article of current group at server */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
73 int rmtLast; /* Last article of current group at server */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
74 Bool auth; /* Authetication already done? */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
75 Str serv; /* Remote server name */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
76 } client = { NULL, NULL, "", "", "", 1, 0, FALSE, "" }; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
77 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
78 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
79 logBreakDown( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
80 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
81 Log_err( "Connection to remote server lost " |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
82 "(article numbers could be inconsistent)" ); |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
85 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
86 getLn( Str line ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
87 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
88 Bool r; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
89 |
144
8b9366fc1361
[svn] Added timeout to Prt_getLn to avoid Noffle hanging if the
enz
parents:
130
diff
changeset
|
90 r = Prt_getLn( line, client.in, Cfg_connectTimeout() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
91 if ( ! r ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
92 logBreakDown(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
93 return r; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
94 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
95 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
96 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
97 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
|
98 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
99 Bool r; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
100 |
144
8b9366fc1361
[svn] Added timeout to Prt_getLn to avoid Noffle hanging if the
enz
parents:
130
diff
changeset
|
101 r = Prt_getTxtLn( line, err, client.in, Cfg_connectTimeout() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
102 if ( *err ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
103 logBreakDown(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
104 return r; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
105 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
106 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
107 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
108 putTxtBuf( const char *buf ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
109 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
110 Prt_putTxtBuf( buf, client.out ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
111 fflush( client.out ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
112 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
113 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
114 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
115 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
116 putEndOfTxt( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
117 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
118 Prt_putEndOfTxt( client.out ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
119 fflush( client.out ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
120 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
121 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
122 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
123 static Bool |
157
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
124 putCmdLn( const char *line ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
125 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
126 Bool err; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
127 unsigned int n; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
128 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
129 strcpy( client.lastCmd, line ); |
157
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
130 strcpy( client.lastStat, "[no status available]" ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
131 Log_dbg( LOG_DBG_PROTOCOL, "[S] %s", line ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
132 n = fprintf( client.out, "%s\r\n", line ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
133 err = ( n != strlen( line ) + 2 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
134 if ( err ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
135 logBreakDown();; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
136 return ! err; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
137 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
138 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
139 static Bool |
157
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
140 putCmd( const char *fmt, ... ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
141 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
142 Str line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
143 va_list ap; |
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 va_start( ap, fmt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
146 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
|
147 va_end( ap ); |
157
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
148 if ( ! putCmdLn( line ) ) |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
149 return FALSE; |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
150 fflush( client.out ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
151 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); |
157
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
152 return TRUE; |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
153 } |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
154 |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
155 static Bool |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
156 putCmdNoFlush( const char *fmt, ... ) |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
157 { |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
158 Str line; |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
159 va_list ap; |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
160 |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
161 va_start( ap, fmt ); |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
162 vsnprintf( line, MAXCHAR, fmt, ap ); |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
163 va_end( ap ); |
976ff791c7ec
[svn] Extract common code from putCmd and putCmdNoFlush,
enz
parents:
144
diff
changeset
|
164 return putCmdLn( line ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
165 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
166 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
167 static int getStat( void ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
168 |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
169 static int |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
170 performAuth( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
171 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
172 int stat; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
173 Str user, pass; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
174 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
175 Cfg_authInfo( client.serv, user, pass ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
176 if ( strcmp( user, "" ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
177 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
178 Log_err( "No username for authentication set" ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
179 return STAT_AUTH_REQUIRED; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
180 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
181 putCmd( "AUTHINFO USER %s", user ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
182 stat = getStat(); |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
183 if ( stat == STAT_AUTH_ACCEPTED |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
184 || stat == STAT_AUTH_ACCEPTED_DEPREC ) |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
185 return stat; |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
186 else if ( stat != STAT_MORE_AUTH_REQUIRED_DEPREC |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
187 && stat != STAT_AUTH_REQUIRED ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
188 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
189 Log_err( "Username rejected. Server stat: %s", client.lastStat ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
190 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
191 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
192 if ( strcmp( pass, "" ) == 0 ) |
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 Log_err( "No password for authentication set" ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
195 return STAT_AUTH_REQUIRED; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
196 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
197 putCmd( "AUTHINFO PASS %s", pass ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
198 stat = getStat(); |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
199 if ( stat != STAT_AUTH_ACCEPTED |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
200 && stat != STAT_AUTH_ACCEPTED_DEPREC) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
201 Log_err( "Password rejected. Server status: %s", client.lastStat ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
202 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
203 } |
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 static int |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
206 getStat( void ) |
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 int result; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
209 Str lastCmd; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
210 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
211 if ( ! getLn( client.lastStat ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
212 result = STAT_CONNECTION_LOST; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
213 else if ( sscanf( client.lastStat, "%d", &result ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
214 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
215 Log_err( "Invalid server status: %s", client.lastStat ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
216 result = STAT_PROGRAM_FAULT; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
217 } |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
218 if ( ( result == STAT_AUTH_REQUIRED |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
219 || result == STAT_AUTH_REQUIRED_DEPREC ) |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
220 && ! client.auth ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
221 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
222 client.auth = TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
223 strcpy( lastCmd, client.lastCmd ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
224 result = performAuth(); |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
225 if ( result == STAT_AUTH_ACCEPTED |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
226 || result == STAT_AUTH_ACCEPTED_DEPREC ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
227 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
228 putCmd( lastCmd ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
229 return getStat(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
230 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
231 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
232 return result; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
233 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
234 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
235 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
236 connectAlarm( int sig ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
237 { |
74 | 238 UNUSED( sig ); |
239 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
240 return; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
241 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
242 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
243 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
244 connectWithTimeout( int sock, const struct sockaddr *servAddr, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
245 socklen_t addrLen ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
246 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
247 sig_t oldHandler; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
248 int r, to; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
249 |
164
94f2e5607772
[svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents:
157
diff
changeset
|
250 oldHandler = Utl_installSignalHandler( SIGALRM, connectAlarm ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
251 if ( oldHandler == SIG_ERR ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
252 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
253 Log_err( "client.c:connectWithTimeout: signal failed." ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
254 return FALSE; |
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 to = Cfg_connectTimeout(); |
74 | 257 if ( alarm( ( unsigned int ) to ) != 0 ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
258 Log_err( "client.c:connectWithTimeout: Alarm was already set." ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
259 r = connect( sock, servAddr, addrLen ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
260 alarm( 0 ); |
164
94f2e5607772
[svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents:
157
diff
changeset
|
261 Utl_installSignalHandler( SIGALRM, oldHandler ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
262 return ( r >= 0 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
263 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
264 |
127 | 265 static DynStr * |
266 collectTxt( void ) | |
267 { | |
268 DynStr *res; | |
269 Str line; | |
270 Bool err; | |
271 | |
272 res = new_DynStr(2048); | |
273 if ( res == NULL ) | |
274 return NULL; | |
275 | |
276 while ( getTxtLn( line, &err ) && ! err ) | |
277 DynStr_appLn( res, line ); | |
278 | |
279 if ( err ) | |
280 { | |
281 del_DynStr( res ); | |
282 return NULL; | |
283 } | |
284 else | |
285 return res; | |
286 } | |
287 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
288 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
289 Client_connect( const char *serv ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
290 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
291 unsigned short int port; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
292 int sock, i; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
293 unsigned int stat; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
294 struct hostent *hp; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
295 char *pStart, *pColon; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
296 Str host, s; |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
297 Str user, pass; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
298 struct sockaddr_in sIn; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
299 |
127 | 300 ASSERT( client.in == NULL && client.out == NULL ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
301 client.auth = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
302 Utl_cpyStr( s, serv ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
303 pStart = Utl_stripWhiteSpace( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
304 pColon = strstr( pStart, ":" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
305 if ( pColon == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
306 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
307 strcpy( host, pStart ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
308 port = 119; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
309 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
310 else |
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 *pColon = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
313 strcpy( host, pStart ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
314 if ( sscanf( pColon + 1, "%hi", &port ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
315 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
316 Log_err( "Syntax error in server name: '%s'", serv ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
317 return FALSE;; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
318 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
319 if ( port <= 0 || port > 65535 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
320 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
321 Log_err( "Invalid port number %hi. Must be in [1, 65535]", port ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
322 return FALSE;; |
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 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
325 memset( (void *)&sIn, 0, sizeof( sIn ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
326 hp = gethostbyname( host ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
327 if ( hp ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
328 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
329 for ( i = 0; (hp->h_addr_list)[ i ]; ++i ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
330 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
331 sIn.sin_family = hp->h_addrtype; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
332 sIn.sin_port = htons( port ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
333 sIn.sin_addr = *( (struct in_addr *)hp->h_addr_list[ i ] ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
334 sock = socket( AF_INET, SOCK_STREAM, 0 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
335 if ( sock < 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
336 break; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
337 if ( ! connectWithTimeout( sock, (struct sockaddr *)&sIn, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
338 sizeof( sIn ) ) ) |
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 close( sock ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
341 break; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
342 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
343 if ( ! ( client.out = fdopen( sock, "w" ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
344 || ! ( client.in = fdopen( dup( sock ), "r" ) ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
345 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
346 if ( client.out != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
347 fclose( client.out ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
348 close( sock ); |
127 | 349 client.in = client.out = NULL; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
350 break; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
351 } |
172 | 352 Utl_cpyStr( client.serv, serv ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
353 stat = getStat(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
354 switch( stat ) { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
355 case STAT_READY_POST_ALLOW: |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
356 case STAT_READY_NO_POST_ALLOW: |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
357 Log_inf( "Connected to %s:%d", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
358 inet_ntoa( sIn.sin_addr ), port ); |
187
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
359 /* INN needs a MODE READER before it will permit POST. */ |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
360 putCmd( "MODE READER" ); |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
361 getStat(); |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
362 Cfg_authInfo( client.serv, user, pass ); |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
363 if ( strcmp( user, "" ) != 0 ) |
166008a80f03
[svn] src/client.c,src/protocol.h: perform authentication at connect time,
enz
parents:
185
diff
changeset
|
364 performAuth(); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
365 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
366 default: |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
367 Log_err( "Bad server stat %d", stat ); |
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 shutdown( fileno( client.out ), 0 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
370 fclose( client.in ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
371 fclose( client.out ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
372 close( sock ); |
127 | 373 client.in = client.out = NULL; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
374 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
375 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
376 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
377 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
378 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
379 static Bool |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
380 isGetGroup( const char *name ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
381 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
382 GroupEnum *ge; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
383 Bool emptyList; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
384 const char *pattern; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
385 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
386 emptyList = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
387 ge = new_GetGrEn( client.serv ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
388 while ( ( pattern = GrEn_next( ge ) ) != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
389 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
390 emptyList = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
391 if ( Wld_match( name, pattern ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
392 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
393 del_GrEn( ge ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
394 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
395 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
396 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
397 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
398 del_GrEn( ge ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
399 return emptyList; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
400 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
401 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
402 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
403 isOmitGroup( const char *name ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
404 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
405 GroupEnum *ge; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
406 const char *pattern; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
407 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
408 ge = new_OmitGrEn( client.serv ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
409 while ( ( pattern = GrEn_next( ge ) ) != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
410 if ( Wld_match( name, pattern ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
411 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
412 del_GrEn( ge ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
413 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
414 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
415 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
416 del_GrEn( ge ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
417 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
418 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
419 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
420 static Bool |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
421 isForbiddenGroupName( const char *name ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
422 { |
58
b4e6f7f96135
[svn] Add some intermediate variables for easier debugging in needsMark().
enz
parents:
57
diff
changeset
|
423 size_t i; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
424 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
425 for ( i = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
426 i < sizeof( forbiddenGroupNames ) / |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
427 sizeof( struct ForbiddenGroupName ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
428 i++ ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
429 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
430 /* Negate result of Wld_match to ensure it is 1 or 0. */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
431 if ( forbiddenGroupNames[i].match != |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
432 ( ! Wld_match( name, forbiddenGroupNames[i].pattern ) ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
433 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
434 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
435 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
436 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
437 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
438 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
439 static void |
127 | 440 processGrps( const char *lines, Bool noServerPattern ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
441 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
442 char postAllow; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
443 int first, last; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
444 Str grp, line, file; |
127 | 445 Bool groupupdate; |
446 | |
447 ASSERT( ! Lock_gotLock() ); | |
448 if ( ! Lock_openDatabases() ) | |
449 return; | |
450 | |
451 groupupdate = FALSE; | |
452 while ( ( lines = Utl_getLn( line, lines) ) != NULL ) | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
453 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
454 if ( sscanf( line, "%s %d %d %c", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
455 grp, &last, &first, &postAllow ) != 4 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
456 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
457 Log_err( "Unknown reply to LIST or NEWGROUPS: %s", line ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
458 continue; |
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 if ( isForbiddenGroupName( grp ) ) |
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 Log_inf( "Group %s forbidden", grp ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
463 continue; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
464 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
465 if ( noServerPattern && ! isGetGroup( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
466 continue; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
467 if ( isOmitGroup( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
468 continue; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
469 if ( ! Grp_exists( grp ) ) |
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 Log_inf( "Registering new group '%s'", grp ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
472 Grp_create( grp ); |
48 | 473 /* Start local numbering with remote first number to avoid |
474 new numbering at the readers if noffle is re-installed */ | |
475 if ( first != 0 ) | |
476 Grp_setFirstLast( grp, first, first - 1 ); | |
477 else | |
478 Grp_setFirstLast( grp, 1, 0 ); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
479 Grp_setServ( grp, client.serv ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
480 Grp_setPostAllow( grp, postAllow ); |
127 | 481 groupupdate = TRUE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
482 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
483 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
484 { |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
485 if ( Cfg_servIsPreferential( client.serv, Grp_server( grp ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
486 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
487 Log_inf( "Changing server for '%s': '%s'->'%s'", |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
488 grp, Grp_server( grp ), client.serv ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
489 Grp_setServ( grp, client.serv ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
490 Grp_setRmtNext( grp, first ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
491 Grp_setPostAllow( grp, postAllow ); |
127 | 492 groupupdate = TRUE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
493 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
494 else |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
495 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
496 "Group %s is already fetched from %s", |
127 | 497 grp, Grp_server( grp ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
498 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
499 } |
127 | 500 |
501 snprintf( file, MAXCHAR, "%s/lastupdate.%s", | |
502 Cfg_spoolDir(), client.serv ); | |
503 Utl_stamp( file ); | |
504 if ( groupupdate ) | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
505 { |
127 | 506 snprintf( file, MAXCHAR, "%s/groupinfo.lastupdate", |
507 Cfg_spoolDir() ); | |
508 Utl_stamp( file ); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
509 } |
127 | 510 Lock_closeDatabases(); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
511 } |
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 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
514 Client_disconnect( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
515 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
516 if ( putCmd( "QUIT" ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
517 getStat(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
518 fclose( client.in ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
519 fclose( client.out ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
520 client.in = client.out = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
521 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
522 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
523 static int |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
524 doGetGrps( const char *pattern, Bool *noServerPattern ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
525 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
526 Str cmd; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
527 int stat; |
127 | 528 DynStr *response; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
529 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
530 Utl_cpyStr( cmd, "LIST ACTIVE" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
531 if ( pattern[ 0 ] != '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
532 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
533 Utl_catStr( cmd, " " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
534 Utl_catStr( cmd, pattern ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
535 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
536 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
537 *noServerPattern = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
538 if ( ! putCmd( cmd ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
539 return STAT_CONNECTION_LOST; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
540 stat = getStat(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
541 if ( IS_FATAL( stat ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
542 return stat; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
543 |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
544 /* |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
545 * Try LIST instead of LIST ACTIVE in case server doesn't |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
546 * support LIST ACTIVE. |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
547 */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
548 if ( pattern[ 0 ] != '\0' && stat != STAT_GRPS_FOLLOW ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
549 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
550 *noServerPattern = TRUE; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
551 if ( ! putCmd( "LIST" ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
552 return STAT_CONNECTION_LOST; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
553 stat = getStat(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
554 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
555 if ( stat != STAT_GRPS_FOLLOW ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
556 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
557 Log_err( "%s failed: %s", cmd, client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
558 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
559 } |
127 | 560 |
561 response = collectTxt(); | |
562 if ( response == NULL ) | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
563 return STAT_CONNECTION_LOST; |
127 | 564 |
565 processGrps( DynStr_str( response ), *noServerPattern ); | |
566 del_DynStr( response ); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
567 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
568 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
569 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
570 int |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
571 Client_getGrps( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
572 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
573 GroupEnum *ge; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
574 const char *pattern; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
575 Bool doneOne, noServerPattern; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
576 int res; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
577 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
578 Log_inf( "Getting groups" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
579 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
580 doneOne = FALSE; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
581 res = STAT_OK; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
582 ge = new_GetGrEn( client.serv ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
583 while ( res == STAT_OK && ( pattern = GrEn_next( ge ) ) != NULL ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
584 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
585 res = doGetGrps( pattern, &noServerPattern ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
586 doneOne = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
587 if ( noServerPattern ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
588 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
589 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
590 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
591 if ( ! doneOne ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
592 res = doGetGrps( "", &noServerPattern ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
593 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
594 del_GrEn( ge ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
595 return res; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
596 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
597 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
598 static int |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
599 doGetDsc( const char *pattern, Bool *noServerPattern ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
600 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
601 Str name, line, dsc, cmd; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
602 int stat; |
127 | 603 DynStr *response; |
604 const char *lines; | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
605 Bool result; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
606 |
127 | 607 ASSERT( ! Lock_gotLock() ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
608 Utl_cpyStr( cmd, "LIST NEWSGROUPS" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
609 if ( pattern[ 0 ] != '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
610 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
611 Utl_catStr( cmd, " " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
612 Utl_catStr( cmd, pattern ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
613 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
614 |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
615 *noServerPattern = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
616 if ( ! putCmd( cmd ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
617 return STAT_CONNECTION_LOST; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
618 stat = getStat(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
619 if ( IS_FATAL( stat ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
620 return stat; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
621 |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
622 /* Try without pattern in case server doesn't support patterns. */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
623 if ( pattern[ 0 ] != '\0' && stat != STAT_GRPS_FOLLOW ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
624 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
625 *noServerPattern = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
626 if ( !putCmd( "LIST NEWSGROUPS" ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
627 return STAT_CONNECTION_LOST; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
628 stat = getStat(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
629 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
630 if ( stat != STAT_GRPS_FOLLOW ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
631 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
632 Log_err( "%s failed: %s", cmd, client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
633 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
634 } |
127 | 635 |
636 response = collectTxt(); | |
637 if ( response == NULL ) | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
638 return STAT_CONNECTION_LOST; |
127 | 639 |
640 if ( ! Lock_openDatabases() ) | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
641 return STAT_NEWSBASE_FATAL; |
127 | 642 |
643 lines = DynStr_str( response ); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
644 result = STAT_OK; |
127 | 645 while ( ( lines = Utl_getLn( line, lines) ) != NULL ) |
43
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 if ( sscanf( line, "%s", name ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
648 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
649 Log_err( "Unknown reply to LIST NEWSGROUPS: %s", line ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
650 result = STAT_PROGRAM_FAULT; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
651 break; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
652 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
653 if ( *noServerPattern && ! isGetGroup( name ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
654 continue; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
655 strcpy( dsc, Utl_restOfLn( line, 1 ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
656 if ( Grp_exists( name ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
657 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
658 Log_dbg( LOG_DBG_FETCH, "Description of %s: %s", name, dsc ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
659 Grp_setDsc( name, dsc ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
660 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
661 } |
127 | 662 Lock_closeDatabases(); |
663 del_DynStr( response ); | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
664 return result; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
665 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
666 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
667 int |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
668 Client_getDsc( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
669 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
670 GroupEnum *ge; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
671 const char *pattern; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
672 Bool doneOne, noServerPattern; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
673 int res; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
674 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
675 Log_inf( "Querying group descriptions" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
676 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
677 doneOne = FALSE; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
678 res = STAT_OK; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
679 ge = new_GetGrEn( client.serv ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
680 while ( res == STAT_OK && ( pattern = GrEn_next( ge ) ) != NULL ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
681 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
682 res = doGetDsc( pattern, &noServerPattern ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
683 doneOne = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
684 if ( noServerPattern ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
685 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
686 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
687 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
688 if ( ! doneOne ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
689 res = doGetDsc( "", &noServerPattern ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
690 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
691 del_GrEn( ge ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
692 return res; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
693 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
694 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
695 int |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
696 Client_getNewgrps( const time_t *lastTime ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
697 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
698 Str s; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
699 const char *p; |
127 | 700 DynStr *response; |
182
a43a528cfbe7
[svn] * src/client.c: Only return failure getting NEWGROUPS if the connection
bears
parents:
180
diff
changeset
|
701 int stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
702 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
703 ASSERT( *lastTime > 0 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
704 strftime( s, MAXCHAR, "%Y%m%d %H%M00", gmtime( lastTime ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
705 /* |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
706 Do not use century for working with old server software until 2000. |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
707 According to newest IETF draft, this is still valid after 2000. |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
708 (directly using %y in fmt string causes a Y2K compiler warning) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
709 */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
710 p = s + 2; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
711 if ( ! putCmd( "NEWGROUPS %s GMT", p ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
712 return STAT_CONNECTION_LOST; |
182
a43a528cfbe7
[svn] * src/client.c: Only return failure getting NEWGROUPS if the connection
bears
parents:
180
diff
changeset
|
713 stat = getStat(); |
a43a528cfbe7
[svn] * src/client.c: Only return failure getting NEWGROUPS if the connection
bears
parents:
180
diff
changeset
|
714 if ( stat != STAT_NEW_GRP_FOLLOW ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
715 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
716 Log_err( "NEWGROUPS command failed: %s", client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
717 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
718 } |
127 | 719 |
720 response = collectTxt(); | |
721 if ( response == NULL ) | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
722 return STAT_CONNECTION_LOST; |
127 | 723 |
724 processGrps( DynStr_str( response ), TRUE ); | |
725 del_DynStr( response ); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
726 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
727 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
728 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
729 static const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
730 readField( Str result, const char *p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
731 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
732 size_t len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
733 char *r; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
734 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
735 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
736 return NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
737 r = result; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
738 *r = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
739 len = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
740 while ( *p != '\t' && *p != '\n' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
741 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
742 if ( ! *p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
743 return p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
744 *(r++) = *(p++); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
745 ++len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
746 if ( len >= MAXCHAR - 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
747 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
748 *r = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
749 Log_err( "Field in overview too long: %s", r ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
750 return ++p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
751 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
752 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
753 *r = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
754 return ++p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
755 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
756 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
757 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
758 parseOvLn( Str line, int *numb, Str subj, Str from, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
759 Str date, Str msgId, Str ref, size_t *bytes, size_t *lines ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
760 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
761 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
762 Str t; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
763 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
764 p = readField( t, line ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
765 if ( sscanf( t, "%d", numb ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
766 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
767 p = readField( subj, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
768 p = readField( from, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
769 p = readField( date, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
770 p = readField( msgId, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
771 p = readField( ref, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
772 p = readField( t, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
773 *bytes = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
774 *lines = 0; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
775 if ( sscanf( t, "%d", bytes ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
776 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
777 p = readField( t, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
778 if ( sscanf( t, "%d", lines ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
779 return TRUE; |
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 const char* |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
784 nextXref( const char *pXref, Str grp, int *numb ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
785 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
786 Str s; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
787 const char *pColon, *src; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
788 char *dst; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
789 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
790 src = pXref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
791 while ( *src && isspace( *src ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
792 ++src; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
793 dst = s; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
794 while ( *src && ! isspace( *src ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
795 *(dst++) = *(src++); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
796 *dst = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
797 if ( strlen( s ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
798 return NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
799 pColon = strstr( s, ":" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
800 if ( ! pColon || sscanf( pColon + 1, "%d", numb ) != 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
801 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
802 Log_err( "Corrupt Xref at position '%s'", pXref ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
803 return NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
804 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
805 Utl_cpyStrN( grp, s, pColon - s ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
806 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
807 "client.c: nextXref: grp '%s' numb %lu", |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
808 grp, numb ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
809 return src; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
810 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
811 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
812 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
813 needsMark( const char *ref ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
814 { |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
815 Bool interesting, result; |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
816 const char *msgId; |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
817 int status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
818 time_t lastAccess, nowTime; |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
819 double threadFollowTime, maxTime, timeSinceLastAccess; |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
820 ItemList *itl; |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
821 const double secPerDay = 24.0 * 3600.0; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
822 |
127 | 823 ASSERT( Lock_gotLock() ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
824 Log_dbg( LOG_DBG_FETCH, "Checking references '%s' for thread mode", ref ); |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
825 result = FALSE; |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
826 itl = new_Itl( ref, " \t" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
827 nowTime = time( NULL ); |
57
84e32c84666b
[svn] add some intermediate variables for easier debugging
enz
parents:
54
diff
changeset
|
828 threadFollowTime = (double)Cfg_threadFollowTime(); |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
829 maxTime = threadFollowTime * secPerDay; |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
830 Log_dbg( LOG_DBG_FETCH, "Max time = %.0f", maxTime ); |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
831 for ( msgId = Itl_first( itl ); msgId != NULL; msgId = Itl_next( itl ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
832 { |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
833 /* |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
834 References does not have to contain only Message IDs, |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
835 but often it does, so we look up every item in the database. |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
836 */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
837 if ( Db_contains( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
838 { |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
839 status = Db_status( msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
840 lastAccess = Db_lastAccess( msgId ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
841 interesting = ( status & DB_INTERESTING ); |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
842 timeSinceLastAccess = difftime( nowTime, lastAccess ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
843 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
844 "Msg ID '%s': since last access = %.0f, interesting = %s", |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
845 msgId, timeSinceLastAccess, ( interesting ? "y" : "n" ) ); |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
846 if ( interesting && timeSinceLastAccess <= maxTime ) |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
847 { |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
848 result = TRUE; |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
849 break; |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
850 } |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
851 } |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
852 else |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
853 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
854 Log_dbg( LOG_DBG_FETCH, "MsgID '%s': not in database.", msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
855 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
856 } |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
857 del_Itl( itl ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
858 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
859 "Article %s marking for download.", |
67
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
860 ( result ? "needs" : "doesn't need" ) ); |
2e47992d7f5c
[svn] Rewrote needsMark(): use itemlist.h, more debugging output.
enz
parents:
61
diff
changeset
|
861 return result; |
43
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
864 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
865 prepareEntry( Over *ov ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
866 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
867 Str g, t; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
868 const char *msgId, *p, *xref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
869 int n; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
870 |
127 | 871 ASSERT( Lock_gotLock() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
872 msgId = Ov_msgId( ov ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
873 if ( Pseudo_isGeneralInfo( msgId ) ) |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
874 Log_dbg( LOG_DBG_FETCH, "Skipping general info '%s'", msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
875 else if ( Db_contains( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
876 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
877 xref = Db_xref( msgId ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
878 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
879 "Entry '%s' already in db with Xref '%s'", |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
880 msgId, xref ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
881 p = nextXref( xref, g, &n ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
882 if ( p == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
883 Log_err( "Overview with no group in Xref '%s'", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
884 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
885 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
886 /* TODO: This code block seems unnessesary. Can we remove it? */ |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
887 if ( Cfg_servIsPreferential( client.serv, Grp_server( g ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
888 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
889 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
890 "Changing first server for '%s' from '%s' to '%s'", |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
891 msgId, Grp_server( g ), client.serv ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
892 snprintf( t, MAXCHAR, "%s:%d %s", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
893 client.grp, Ov_numb( ov ), xref ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
894 Db_setXref( msgId, t ); |
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 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
897 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
898 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
899 "Adding '%s' to Xref of '%s'", g, msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
900 snprintf( t, MAXCHAR, "%s %s:%d", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
901 xref, client.grp, Ov_numb( ov ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
902 Db_setXref( msgId, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
903 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
904 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
905 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
906 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
907 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
908 Log_dbg( LOG_DBG_FETCH, "Preparing '%s' in database", msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
909 Db_prepareEntry( ov, client.grp, Ov_numb( ov ) ); |
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 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
912 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
913 int |
127 | 914 Client_getOver( const char *grp, int rmtFirst, int rmtLast, FetchMode mode ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
915 { |
127 | 916 size_t nbytes, nlines; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
917 int rmtNumb, groupsNumb, oldLast, cntMarked; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
918 Over *ov; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
919 Str line, subj, from, date, msgId, ref, groups; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
920 DynStr *response, *newsgroups; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
921 const char *lines, *groupLines; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
922 char *p; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
923 FilterAction action; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
924 int stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
925 |
127 | 926 ASSERT( ! Lock_gotLock() ); |
927 ASSERT( strcmp( grp, "" ) != 0 ); | |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
928 |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
929 /* Do we need the article Newsgroups: for filtering? */ |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
930 if ( Flt_getNewsgroups() ) |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
931 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
932 if ( ! putCmd( "XHDR Newsgroups %lu-%lu", rmtFirst, rmtLast ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
933 return STAT_CONNECTION_LOST; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
934 stat = getStat(); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
935 if ( stat != STAT_HEAD_FOLLOWS ) |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
936 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
937 Log_err( "XHDR command failed: %s", client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
938 return stat; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
939 } |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
940 |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
941 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
942 "Requesting Newsgroups headers for remote %lu-%lu", |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
943 rmtFirst, rmtLast ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
944 |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
945 newsgroups = collectTxt(); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
946 if ( newsgroups == NULL ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
947 return STAT_CONNECTION_LOST; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
948 |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
949 groupLines = DynStr_str( newsgroups ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
950 } |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
951 else |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
952 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
953 groupLines = NULL; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
954 newsgroups = NULL; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
955 } |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
956 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
957 if ( ! putCmd( "XOVER %lu-%lu", rmtFirst, rmtLast ) ) |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
958 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
959 del_DynStr( newsgroups ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
960 return STAT_CONNECTION_LOST; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
961 } |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
962 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
963 stat = getStat(); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
964 if ( stat != STAT_OVERS_FOLLOW ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
965 { |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
966 del_DynStr( newsgroups ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
967 Log_err( "XOVER command failed: %s", client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
968 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
969 } |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
970 Log_dbg( LOG_DBG_FETCH, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
971 "Requesting overview for remote %lu-%lu", |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
972 rmtFirst, rmtLast ); |
127 | 973 |
974 response = collectTxt(); | |
975 if ( response == NULL ) | |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
976 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
977 del_DynStr( newsgroups ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
978 return STAT_CONNECTION_LOST; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
979 } |
127 | 980 |
981 if ( ! Lock_openDatabases() ) | |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
982 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
983 del_DynStr( newsgroups ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
984 del_DynStr( response ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
985 return STAT_NEWSBASE_FATAL; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
986 } |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
987 |
127 | 988 Cont_read( grp ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
989 oldLast = Cont_last(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
990 cntMarked = 0; |
127 | 991 lines = DynStr_str( response ); |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
992 while ( ( lines = Utl_getLn( line, lines ) ) != NULL ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
993 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
994 if ( ! parseOvLn( line, &rmtNumb, subj, from, date, msgId, ref, |
127 | 995 &nbytes, &nlines ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
996 Log_err( "Bad overview line: %s", line ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
997 else if ( Cont_find( msgId ) >= 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
74
diff
changeset
|
998 Log_inf( "Already have '%s'", msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
999 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1000 { |
127 | 1001 ov = new_Over( subj, from, date, msgId, ref, nbytes, nlines ); |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1002 groupsNumb = 0; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1003 p = NULL; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1004 if ( groupLines != NULL ) |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1005 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1006 do |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1007 { |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1008 groupLines = Utl_getLn( groups, groupLines ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1009 groupsNumb = strtoul( groups, &p, 10 ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1010 } while ( groupLines != NULL |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1011 && p > groups |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1012 && groupsNumb < rmtNumb ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1013 if ( groupsNumb != rmtNumb ) |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1014 p = NULL; |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1015 } |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1016 |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1017 action = Flt_checkFilters( grp, p, ov, mode ); |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1018 if ( action == FILTER_DISCARD ) |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1019 continue; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1020 Cont_app( ov ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1021 prepareEntry( ov ); |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1022 if ( action == FILTER_FULL |
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1023 || ( action == FILTER_THREAD && needsMark( ref ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1024 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1025 Req_add( client.serv, msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1026 ++cntMarked; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1027 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1028 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1029 Grp_setRmtNext( client.grp, rmtNumb + 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1030 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1031 if ( oldLast != Cont_last() ) |
191
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1032 { |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1033 Log_inf( "Added %s %lu-%lu", client.grp, oldLast + 1, Cont_last() ); |
191
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1034 Log_inf( "%u articles marked for download in %s", |
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1035 cntMarked, client.grp ); |
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1036 Cont_write(); |
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1037 Grp_setFirstLast( grp, Cont_first(), Cont_last() ); |
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1038 Grp_setLastPostTime( grp ); |
28488e0e3630
[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents:
188
diff
changeset
|
1039 } |
127 | 1040 Lock_closeDatabases(); |
1041 del_DynStr( response ); | |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1042 del_DynStr( newsgroups ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1043 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1044 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1045 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1046 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1047 retrievingFailed( const char* msgId, const char *reason ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1048 { |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
1049 int status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1050 |
127 | 1051 ASSERT( ! Lock_gotLock() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1052 Log_err( "Retrieving of %s failed: %s", msgId, reason ); |
127 | 1053 if ( ! Lock_openDatabases() ) |
1054 return; | |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
1055 status = Db_status( msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1056 Pseudo_retrievingFailed( msgId, reason ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
1057 Db_setStatus( msgId, status | DB_RETRIEVING_FAILED ); |
127 | 1058 Lock_closeDatabases(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1059 return; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1060 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1061 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1062 static int |
120 | 1063 retrieveAndStoreArt( const char *msgId, int artcnt, int artmax ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1064 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1065 Bool err; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1066 DynStr *s = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1067 |
127 | 1068 ASSERT( ! Lock_gotLock() ); |
120 | 1069 Log_inf( "[%d/%d] Retrieving %s", artcnt, artmax, msgId ); |
127 | 1070 err = TRUE; |
1071 | |
1072 s = collectTxt(); | |
1073 if ( s != NULL ) | |
95 | 1074 { |
1075 const char *txt; | |
127 | 1076 |
95 | 1077 txt = DynStr_str( s ); |
127 | 1078 if ( ! Lock_openDatabases() ) |
1079 { | |
1080 del_DynStr( s ); | |
1081 retrievingFailed( msgId, "Can't open message base" ); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1082 return STAT_NEWSBASE_FATAL; |
127 | 1083 } |
1084 | |
95 | 1085 err = ! Db_storeArt( msgId, txt ); |
1086 if ( ! err ) | |
1087 { | |
102 | 1088 Str supersedeIds; |
1089 | |
1090 if ( Prt_searchHeader( txt, "Supersedes", supersedeIds ) ) | |
1091 { | |
1092 ItemList *ids; | |
103 | 1093 const char *supersededMsgId; |
95 | 1094 |
102 | 1095 ids = new_Itl( supersedeIds, " \n\t" ); |
103 | 1096 for ( supersededMsgId = Itl_first( ids ); |
1097 supersededMsgId != NULL; | |
1098 supersededMsgId = Itl_next( ids ) ) | |
1099 Ctrl_cancel( supersededMsgId ); | |
102 | 1100 del_Itl( ids ); |
1101 } | |
95 | 1102 } |
127 | 1103 Lock_closeDatabases(); |
1104 del_DynStr( s ); | |
95 | 1105 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1106 else |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1107 { |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1108 retrievingFailed( msgId, "Connection broke down" ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1109 return STAT_CONNECTION_LOST; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1110 } |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1111 return err ? STAT_NEWSBASE_FATAL : STAT_OK; |
43
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 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1114 int |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1115 Client_retrieveArt( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1116 { |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1117 int res; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1118 |
127 | 1119 ASSERT( Lock_gotLock() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1120 if ( ! Db_contains( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1121 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1122 Log_err( "Article '%s' not prepared in database. Skipping.", msgId ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1123 return STAT_PROGRAM_FAULT; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1124 } |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
1125 if ( ! ( Db_status( msgId ) & DB_NOT_DOWNLOADED ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1126 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1127 Log_inf( "Article '%s' already retrieved. Skipping.", msgId ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1128 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1129 } |
127 | 1130 |
1131 Lock_closeDatabases(); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1132 if ( ! putCmd( "ARTICLE %s", msgId ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1133 { |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1134 retrievingFailed( msgId, "Connection broke down" ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1135 res = STAT_CONNECTION_LOST; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1136 } |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1137 else if ( ( res = getStat() ) != STAT_ART_FOLLOWS ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1138 retrievingFailed( msgId, client.lastStat ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1139 else |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1140 res = retrieveAndStoreArt( msgId, 0, 0 ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1141 if ( ! Lock_openDatabases() ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1142 res = STAT_NEWSBASE_FATAL; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1143 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1144 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1145 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1146 int |
120 | 1147 Client_retrieveArtList( const char *list, int *artcnt, int artmax ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1148 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1149 Str msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1150 DynStr *s; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1151 const char *p; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1152 int res, msgStat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1153 |
127 | 1154 ASSERT( Lock_gotLock() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1155 Log_inf( "Retrieving article list" ); |
58
b4e6f7f96135
[svn] Add some intermediate variables for easier debugging in needsMark().
enz
parents:
57
diff
changeset
|
1156 s = new_DynStr( (int)strlen( list ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1157 p = list; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1158 res = STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1159 while ( ( p = Utl_getLn( msgId, p ) ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1160 if ( ! Db_contains( msgId ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1161 { |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1162 Log_err( "[%d/%d] Skipping retrieving of %s " |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1163 "(not prepared in database)", |
123
ec190bad201b
[svn] Applied patch from M.Nalis for fixing a small problem with
enz
parents:
120
diff
changeset
|
1164 ++(*artcnt), artmax, msgId ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1165 res = STAT_PROGRAM_FAULT; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1166 } |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
58
diff
changeset
|
1167 else if ( ! ( Db_status( msgId ) & DB_NOT_DOWNLOADED ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1168 Log_inf( "[%d/%d] Skipping %s (already retrieved)", |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1169 ++(*artcnt), artmax, msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1170 else if ( ! putCmdNoFlush( "ARTICLE %s", msgId ) ) |
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 retrievingFailed( msgId, "Connection broke down" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1173 del_DynStr( s ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1174 return STAT_CONNECTION_LOST; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1175 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1176 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1177 DynStr_appLn( s, msgId ); |
127 | 1178 |
1179 Lock_closeDatabases(); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1180 fflush( client.out ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
183
diff
changeset
|
1181 Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); |
127 | 1182 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1183 /* |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1184 * We got something. Try to process all messages and return the |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1185 * 'worst' error encountered (note we may have already hit a |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1186 * STAT_PROGRAM_FAULT). |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1187 */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1188 p = DynStr_str( s ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1189 while ( ! IS_FATAL( res ) && ( p = Utl_getLn( msgId, p ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1190 { |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1191 msgStat = getStat(); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1192 if ( msgStat == STAT_ART_FOLLOWS ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1193 msgStat = retrieveAndStoreArt( msgId, ++(*artcnt), artmax ); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1194 else |
183
c912e8288164
[svn] * src/client.c: Only bail out of fetching multiple articles if the
bears
parents:
182
diff
changeset
|
1195 retrievingFailed( msgId, client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1196 |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1197 if ( res == STAT_OK || ( ! IS_FATAL( res ) && IS_FATAL( msgStat ) ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1198 res = msgStat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1199 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1200 del_DynStr( s ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1201 if ( ! Lock_openDatabases() && ! IS_FATAL( res ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1202 res = STAT_NEWSBASE_FATAL; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1203 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1204 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1205 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1206 int |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1207 Client_changeToGrp( const char* name ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1208 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1209 unsigned int stat; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1210 int estimatedNumb, first, last, res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1211 |
127 | 1212 ASSERT( Lock_gotLock() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1213 if ( ! Grp_exists( name ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1214 return STAT_NEWSBASE_FATAL; |
130
d6c006a27ffe
[svn] Add article fetching and fix potential lock bug
bears
parents:
127
diff
changeset
|
1215 Lock_closeDatabases(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1216 stat = STAT_OK; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1217 if ( ! putCmd( "GROUP %s", name ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1218 res = STAT_CONNECTION_LOST; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1219 if ( stat == STAT_OK ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1220 stat = getStat(); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1221 if ( ! Lock_openDatabases() ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1222 return STAT_NEWSBASE_FATAL; |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1223 if ( stat != STAT_GRP_SELECTED ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1224 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1225 if ( sscanf( client.lastStat, "%u %d %d %d", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1226 &stat, &estimatedNumb, &first, &last ) != 4 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1227 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1228 Log_err( "Bad server response to GROUP: %s", client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1229 return STAT_PROGRAM_FAULT; |
43
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 Utl_cpyStr( client.grp, name ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1232 client.rmtFirst = first; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1233 client.rmtLast = last; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1234 return STAT_OK; |
43
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1237 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1238 Client_rmtFirstLast( int *first, int *last ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1239 { |
127 | 1240 ASSERT( Lock_gotLock() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1241 *first = client.rmtFirst; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1242 *last = client.rmtLast; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1243 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1244 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1245 int |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1246 Client_postArt( const char *msgId, const char *artTxt, Str errStr ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1247 { |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1248 int stat; |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1249 |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1250 errStr[0] = '\0'; |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1251 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1252 if ( ! putCmd( "POST" ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1253 return STAT_CONNECTION_LOST; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1254 stat = getStat(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1255 if ( IS_FATAL( stat ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1256 return stat; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1257 else if ( stat != STAT_SEND_ART ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1258 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1259 Log_err( "Posting of %s not allowed: %s", msgId, client.lastStat ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1260 strcpy( errStr, client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1261 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1262 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1263 putTxtBuf( artTxt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1264 putEndOfTxt(); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1265 stat = getStat(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1266 if ( IS_FATAL( stat ) ) |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1267 return stat; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
172
diff
changeset
|
1268 else if ( stat != STAT_POST_OK ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1269 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1270 Log_err( "Posting of %s failed: %s", msgId, client.lastStat ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1271 strcpy( errStr, client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1272 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1273 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1274 Log_inf( "Posted %s (Status: %s)", msgId, client.lastStat ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
187
diff
changeset
|
1275 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
1276 } |