Mercurial > noffle
annotate src/fetch.c @ 197:24d4cd032da5 noffle
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
src/protocol.h,src/server.c: Merge with latest 1.0 branch. I do not
intend to do any further merges from the 1.0 branch; future changes to
1.0 should be carried over by hand if necessary.
* src/configfile.c,src/content.c,src/control.c,src/database.c,
src/dynamicstring.c,src/fetch.c,src/filter.c,src/group.c,
src/itemlist.c,src/lock.c,src/outgoing.c,src/over.c,src/post.c,
src/pseudo.c,src/request.c,src/util.c: Minor includes rearrangement.
author | bears |
---|---|
date | Wed, 31 Oct 2001 11:44:53 +0000 |
parents | 021d145e34e9 |
children | ffb1848a39db |
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 fetch.c |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
3 |
197
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
193
diff
changeset
|
4 $Id: fetch.c 316 2001-10-31 11:44:53Z 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 <stdio.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
12 #include <errno.h> |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
13 |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
14 #if TIME_WITH_SYS_TIME |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
15 #include <sys/time.h> |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #include <time.h> |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
17 #else |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
18 #if HAVE_SYS_TIME_H |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
19 #include <sys/time.h> |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
20 #else |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
21 #include <time.h> |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
22 #endif |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
23 #endif |
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
24 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
25 #include <signal.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
26 #include "client.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
27 #include "configfile.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
28 #include "content.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
29 #include "dynamicstring.h" |
197
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
193
diff
changeset
|
30 #include "fetch.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 #include "fetchlist.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
32 #include "request.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
33 #include "group.h" |
127 | 34 #include "lock.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
35 #include "log.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 #include "outgoing.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
37 #include "protocol.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
38 #include "pseudo.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
39 #include "util.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
40 #include "portable.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 |
127 | 42 #define MAX_ARTICLE_CMDS_QUEUED 20 |
43 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
44 struct Fetch |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
45 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
46 Bool ready; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
47 Str serv; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
48 } fetch = { FALSE, "" }; |
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 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
51 connectToServ( const char *name ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
52 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
53 Log_inf( "Fetch from '%s'", name ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
54 if ( ! Client_connect( name ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
55 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
56 Log_err( "Could not connect to %s", name ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
57 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
58 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
59 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
60 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
61 |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
62 Bool |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
63 Fetch_getNewGrps( void ) |
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 time_t t; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
66 Str file; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
67 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
68 ASSERT( fetch.ready ); |
127 | 69 snprintf( file, MAXCHAR, "%s/lastupdate.%s", |
70 Cfg_spoolDir(), fetch.serv ); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
71 if ( ! Utl_getStamp( &t, file ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
72 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
73 Log_err( "Cannot read %s. Please run noffle --query groups", file ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
74 return FALSE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
75 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
76 Log_inf( "Updating groupinfo" ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
77 |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
78 /* |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
79 * If NEWGROUPS fails, it isn't necessarily fatal. You can do |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
80 * a periodic noffle --query groups to refresh your group list. |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
81 * So only return failure here if the status indicates the link |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
82 * itself failed. |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
83 * |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
84 * In particular, older versions of NNTPcache have a Y2K bug that |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
85 * stops NEWGROUPS working. |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
86 */ |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
87 return ( ! IS_FATAL( Client_getNewgrps( &t ) ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
88 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
89 |
127 | 90 /* Databases open on entry, closed on exit. */ |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
91 static int |
127 | 92 fetchNewArts( const char *name, FetchMode mode ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
93 { |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
94 int next, first, last, refetch, stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
95 |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
96 stat = Client_changeToGrp( name ); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
97 if ( stat != STAT_OK ) |
43
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 Log_err( "Could not change to group %s", name ); |
129 | 100 if ( Lock_gotLock() ) |
101 Lock_closeDatabases(); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
102 return stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
103 } |
127 | 104 Client_rmtFirstLast( &first, &last ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
105 Cont_read( name ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
106 next = Grp_rmtNext( name ); |
102 | 107 if ( next == GRP_RMT_NEXT_NOT_SUBSCRIBED ) |
108 next = first; | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
109 if ( next == last + 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
110 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
111 Log_inf( "No new articles in %s", name ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
112 Cont_write(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
113 Grp_setFirstLast( name, Cont_first(), Cont_last() ); |
127 | 114 Lock_closeDatabases(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
115 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
116 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
117 if ( first == 0 && last == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
118 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
119 Log_inf( "No articles in %s", name ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
120 Cont_write(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
121 Grp_setFirstLast( name, Cont_first(), Cont_last() ); |
127 | 122 Lock_closeDatabases(); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
123 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
124 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
125 if ( next > last + 1 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
126 { |
155
22b81617d427
[svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents:
154
diff
changeset
|
127 refetch = last - Cfg_maxFetch() + 1; |
22b81617d427
[svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents:
154
diff
changeset
|
128 if ( refetch < 0 ) refetch = 1; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
129 Log_err( "Article number inconsistent (%s rmt=%lu-%lu, next=%lu). " |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
130 "Refetching from %lu", |
155
22b81617d427
[svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents:
154
diff
changeset
|
131 name, first, last, next, refetch ); |
22b81617d427
[svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents:
154
diff
changeset
|
132 Pseudo_cntInconsistent( name, first, last, next, refetch ); |
22b81617d427
[svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents:
154
diff
changeset
|
133 first = refetch; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
134 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
135 else if ( next < first ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
136 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
137 Log_inf( "Missing articles (%s first=%lu next=%lu)", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
138 name, first, next ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
139 Pseudo_missArts( name, first, next ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
140 |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
141 /* |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
142 * If we are missing articles but there are none to fetch, |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
143 * we must ensure we don't repeatedly generate missing |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
144 * article warning on every fetch until there is something |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
145 * to fetch. To guard against this, update the group remote |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
146 * next now. |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
147 */ |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
148 Grp_setRmtNext( name, first ); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
149 next = first; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
150 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
151 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
152 first = next; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
153 if ( last - first > Cfg_maxFetch() ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
154 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
155 Log_ntc( "Cutting number of overviews to %lu", Cfg_maxFetch() ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
156 first = last - Cfg_maxFetch() + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
157 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
158 Log_inf( "Getting remote overviews %lu-%lu for group %s", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
159 first, last, name ); |
127 | 160 Lock_closeDatabases(); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
161 return Client_getOver( name, first, last, mode ); |
127 | 162 } |
163 | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
164 Bool |
127 | 165 Fetch_getNewArts( const char *name, FetchMode mode ) |
166 { | |
167 if ( ! Lock_openDatabases() ) | |
168 { | |
169 Log_err( "Could not open message base" ); | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
170 return FALSE; |
127 | 171 } |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
172 return fetchNewArts( name, mode ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
173 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
174 |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
175 Bool |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
176 Fetch_updateGrps( void ) |
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 FetchMode mode; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
179 int i, size; |
127 | 180 const char *name; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
181 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
182 ASSERT( fetch.ready ); |
127 | 183 if ( ! Lock_openDatabases() ) |
184 { | |
185 Log_err( "Could not open message base" ); | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
186 return FALSE; |
127 | 187 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
188 Fetchlist_read(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
189 size = Fetchlist_size(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
190 for ( i = 0; i < size; ++i ) |
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 Fetchlist_element( &name, &mode, i ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
193 if ( strcmp( Grp_server( name ), fetch.serv ) == 0 ) |
127 | 194 { |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
195 if ( IS_FATAL( fetchNewArts( name, mode ) ) ) |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
196 return FALSE; |
127 | 197 if ( ! Lock_openDatabases() ) |
198 { | |
199 Log_err( "Could not open message base" ); | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
200 return FALSE; |
127 | 201 } |
202 } | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
203 } |
127 | 204 Lock_closeDatabases(); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
205 return TRUE; |
127 | 206 } |
207 | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
208 static int |
127 | 209 fetchMessageList( const char *list, int *artcnt, int artmax ) |
210 { | |
211 const char *p; | |
212 Str msgId; | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
213 int stat; |
127 | 214 |
215 ASSERT( Lock_gotLock() ); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
216 stat = Client_retrieveArtList( list, artcnt, artmax ); |
193
021d145e34e9
[svn] * src/fetch.c: Only leave articles in the requested list if the error
bears
parents:
188
diff
changeset
|
217 if ( IS_FATAL( stat ) ) |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
218 return stat; |
127 | 219 p = list; |
220 while ( ( p = Utl_getLn( msgId, p ) ) ) | |
221 Req_remove( fetch.serv, msgId ); | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
222 return STAT_OK; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
223 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
224 |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
225 Bool |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
226 Fetch_getReq_( void ) |
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 Str msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
229 DynStr *list; |
127 | 230 DynStr *fetchList; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
231 const char *p; |
120 | 232 int count = 0, artcnt = 0, artmax = 0; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
233 Bool res; |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
234 int stat; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
235 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
236 ASSERT( fetch.ready ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
184
diff
changeset
|
237 Log_dbg( LOG_DBG_FETCH, "Retrieving articles marked for download" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
238 list = new_DynStr( 10000 ); |
127 | 239 fetchList = new_DynStr( 1000 ); |
240 if ( list == NULL || fetchList == NULL ) | |
241 { | |
242 if ( list != NULL ) | |
243 del_DynStr( list ); | |
244 Log_err( "Out of memory in Fetch_get_Req_"); | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
245 return FALSE; |
127 | 246 } |
247 | |
248 /* | |
249 * Get all waiting message IDs for this server. We copy into a master | |
250 * list as the requests file will be closed and re-opened during the | |
251 * fetch and the position therein will be lost. | |
252 */ | |
253 if ( ! Lock_openDatabases() ) | |
254 { | |
255 Log_err( "Could not open message base" ); | |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
256 return FALSE; |
127 | 257 } |
258 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
259 if ( Req_first( fetch.serv, msgId ) ) |
127 | 260 { |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
261 do |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
262 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
263 DynStr_appLn( list, msgId ); |
127 | 264 artmax++; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
265 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
266 while ( Req_next( msgId ) ); |
127 | 267 Log_inf( "%d TOTAL messages to download", artmax); |
268 } | |
269 | |
270 /* Retrieve in groups of up to size MAX_ARTICLE_CMDS_QUEUED. */ | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
271 p = DynStr_str( list ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
272 res = TRUE; |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
273 while ( res && ( p = Utl_getLn( msgId, p ) ) != NULL ) |
127 | 274 { |
275 DynStr_appLn( fetchList, msgId ); | |
276 if ( ++count % MAX_ARTICLE_CMDS_QUEUED == 0 ) | |
277 { | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
278 stat = fetchMessageList( DynStr_str( fetchList ), &artcnt, |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
279 artmax ); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
280 res = ! IS_FATAL( stat ); |
127 | 281 DynStr_clear( fetchList ); |
282 } | |
283 } | |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
284 stat = fetchMessageList( DynStr_str( fetchList ), &artcnt, artmax ); |
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
285 res = res && ! IS_FATAL( stat ); |
127 | 286 |
287 del_DynStr( fetchList ); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
288 del_DynStr( list ); |
127 | 289 Lock_closeDatabases(); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
290 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
291 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
292 |
79
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
293 static void |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
294 returnArticleToSender( const char *sender, const char *reason, |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
295 const char *article ) |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
296 { |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
297 int ret; |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
298 Str cmd; |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
299 FILE *f; |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
300 sig_t lastHandler; |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
301 |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
302 Log_err( "Return article to '%s' by mail", sender ); |
154 | 303 snprintf( cmd, MAXCHAR, "%s -t -oi", SENDMAILPROG); |
79
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
304 lastHandler = signal( SIGPIPE, SIG_IGN ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
305 f = popen( cmd, "w" ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
306 if ( f == NULL ) |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
307 Log_err( "Invocation of '%s' failed (%s)", cmd, strerror( errno ) ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
308 else |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
309 { |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
310 fprintf( f, |
154 | 311 "To: %s\n" |
312 "Subject: [ NOFFLE: Posting failed ]\n" | |
313 "\n" | |
79
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
314 "\t[ NOFFLE: POSTING OF ARTICLE FAILED ]\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
315 "\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
316 "\t[ The posting of your article failed. ]\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
317 "\t[ Reason of failure at remote server: ]\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
318 "\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
319 "\t[ %s ]\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
320 "\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
321 "\t[ Full article text has been appended. ]\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
322 "\n" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
323 "%s" |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
324 ".\n", |
154 | 325 sender, |
79
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
326 reason, article ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
327 ret = pclose( f ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
328 if ( ret != EXIT_SUCCESS ) |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
329 Log_err( "'%s' exit value %d", cmd, ret ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
330 signal( SIGPIPE, lastHandler ); |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
331 } |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
332 } |
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
333 |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
334 Bool |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
335 Fetch_postArts( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
336 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
337 DynStr *s; |
79
28aeb0b93509
[svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents:
61
diff
changeset
|
338 Str msgId, errStr, sender; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
339 const char *txt; |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
340 Bool res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
341 |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
342 res = TRUE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
343 s = new_DynStr( 10000 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
344 if ( Out_first( fetch.serv, msgId, s ) ) |
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 Log_inf( "Posting articles" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
347 do |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
348 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
349 txt = DynStr_str( s ); |
188
f1bacee93ca6
[svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents:
185
diff
changeset
|
350 if ( Client_postArt( msgId, txt, errStr ) != STAT_OK ) |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
351 { |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
352 res = FALSE; |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
353 break; |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
354 } |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
355 |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
356 /* |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
357 * OK, no server communication SNAFU during post. Now, do we |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
358 * get an error response? If so, try to return article to sender. |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
359 */ |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
360 Out_remove( fetch.serv, msgId ); |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
361 if ( errStr[0] != '\0' ) |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
362 { |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
363 Utl_cpyStr( sender, Cfg_mailTo() ); |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
364 if ( strcmp( sender, "" ) == 0 |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
365 && ! Prt_searchHeader( txt, "SENDER", sender ) |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
366 && ! Prt_searchHeader( txt, "X-NOFFLE-X-SENDER", |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
367 sender ) /* see server.c */ |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
368 && ! Prt_searchHeader( txt, "FROM", sender ) ) |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
369 Log_err( "Article %s has no From/Sender/X-Sender field", |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
370 msgId ); |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
371 else |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
372 returnArticleToSender( sender, errStr, txt ); |
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
373 } |
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 while ( Out_next( msgId, s ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
376 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
377 del_DynStr( s ); |
180
09ca6eb5c7ff
[svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents:
155
diff
changeset
|
378 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
379 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
380 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
381 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
382 Fetch_init( const char *serv ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
383 { |
127 | 384 Lock_closeDatabases(); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
385 if ( ! connectToServ( serv ) ) |
139 | 386 { |
387 Lock_openDatabases(); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
388 return FALSE; |
139 | 389 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
390 Utl_cpyStr( fetch.serv, serv ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
391 fetch.ready = TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
392 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
393 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
394 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
395 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
396 Fetch_close() |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
397 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
398 Client_disconnect(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
399 fetch.ready = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
400 Log_inf( "Fetch from '%s' finished", fetch.serv ); |
127 | 401 Lock_openDatabases(); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
402 } |