annotate src/fetch.c @ 500:614a3177b15c noffle tip

Add mail-from option. Some modern mail systems will try and ensure the sender email is a legitimate address. Which will fail if there isn't such an address.
author Jim Hague <jim.hague@acm.org>
date Wed, 14 Aug 2013 12:04:39 +0100
parents d9035d08fe51
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
2 fetch.c
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
3
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
4 $Id: fetch.c 609 2003-07-23 09:32:25Z 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"
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 223
diff changeset
32 #include "filter.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "request.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 #include "group.h"
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
35 #include "lock.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
36 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
37 #include "outgoing.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 #include "protocol.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 #include "pseudo.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 #include "util.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
41 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
43 #define MAX_ARTICLE_CMDS_QUEUED 20
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
44
274
755e03bc7dcf [svn] * src/fetch.c,src/log.c: Make 'fetch' and 'log' variables static; they're
bears
parents: 271
diff changeset
45 static struct Fetch
43
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 Bool ready;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 } fetch = { FALSE, "" };
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
50
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 connectToServ( const char *name )
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 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
55 if ( ! Client_connect( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
56 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57 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
58 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
61 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
63 Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 Fetch_getNewGrps( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
65 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
66 time_t t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
67 Str file;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
68
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
69 ASSERT( fetch.ready );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
70 snprintf( file, MAXCHAR, "%s/lastupdate.%s",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
71 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
72 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
73 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
74 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
75 return FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
76 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 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
78
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
79 /*
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
80 * 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
81 * 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
82 * 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
83 * itself failed.
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
84 *
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
85 * 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
86 * 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
87 */
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
88 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
89 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
90
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
91 /* 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
92 static int
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
93 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
94 {
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
95 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
96
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
97 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
98 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
99 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
100 Log_err( "Could not change to group %s", name );
129
6b2b93288caa [svn] Fix potential lock bug
bears
parents: 127
diff changeset
101 if ( Lock_gotLock() )
6b2b93288caa [svn] Fix potential lock bug
bears
parents: 127
diff changeset
102 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
103 return stat;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
104 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
105 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
106 Cont_read( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
107 next = Grp_rmtNext( name );
102
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 79
diff changeset
108 if ( next == GRP_RMT_NEXT_NOT_SUBSCRIBED )
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 79
diff changeset
109 next = first;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
110 if ( next == last + 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
111 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
112 Log_inf( "No new articles in %s", name );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
113 if ( Cont_write() )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
114 Grp_setFirstLast( name, Cont_first(), Cont_last() );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
115 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
116 return STAT_OK;
43
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 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
119 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
120 Log_inf( "No articles in %s", name );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
121 if ( Cont_write() )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
122 Grp_setFirstLast( name, Cont_first(), Cont_last() );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
123 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
124 return STAT_OK;
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 if ( next > last + 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
128 refetch = last - Cfg_maxFetch() + 1;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
129 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
130 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
131 "Refetching from %lu",
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
132 name, first, last, next, refetch );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
133 Pseudo_cntInconsistent( name, first, last, next, refetch );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
134 first = refetch;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
135 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
136 else if ( next < first )
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 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
139 name, first, next );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
140 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
141
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
142 /*
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
143 * 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
144 * 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
145 * 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
146 * 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
147 * next now.
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
148 */
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
149 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
150 next = first;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
152 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
153 first = next;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154 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
155 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
156 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
157 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
158 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
159 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
160 first, last, name );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
161 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
162 return Client_getOver( name, first, last, mode );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
163 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
164
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
165 Bool
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
166 Fetch_getNewArts( const char *name, FetchMode mode )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
167 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
168 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
169 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
170 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
171 return FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
172 }
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 223
diff changeset
173 Flt_init( fetch.serv ); /* Get filter data. Sorry, can't do it in Client_getOver().
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 223
diff changeset
174 * This is the lowest procedure not in the
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 223
diff changeset
175 * noffle.c:doFetch() tree. */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 223
diff changeset
176
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
177 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
178 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
179
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
180 Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
181 Fetch_updateGrps( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
182 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
183 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
184 int i, size;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
185 const char *name;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
186
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
187 ASSERT( fetch.ready );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
188 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
189 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
190 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
191 return FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
192 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
193 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
194 size = Fetchlist_size();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195 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
196 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
197 Fetchlist_element( &name, &mode, i );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
198 if ( strcmp( Grp_server( name ), fetch.serv ) == 0 )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
199 {
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
200 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
201 return FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
202 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
203 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
204 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
205 return FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
206 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
207 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
208 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
209 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
210 return TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
211 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
212
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
213 static int
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
214 fetchMessageList( const char *list, int *artcnt, int artmax )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
215 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
216 const char *p;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
217 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
218 int stat;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
219
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
220 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
221 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
222 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
223 return stat;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
224 p = list;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
225 while ( ( p = Utl_getLn( msgId, p ) ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
226 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
227 return STAT_OK;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
230 Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
231 Fetch_getReq_( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
232 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
233 Str msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
234 DynStr *list;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
235 DynStr *fetchList;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
236 const char *p;
120
05f50c1761d9 [svn] Applied patch from Matija Nalis:
enz
parents: 102
diff changeset
237 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
238 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
239 int stat;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
240
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
241 ASSERT( fetch.ready );
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 184
diff changeset
242 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
243 list = new_DynStr( 10000 );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
244 fetchList = new_DynStr( 1000 );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
245 if ( list == NULL || fetchList == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
246 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
247 if ( list != NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
248 del_DynStr( list );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
249 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
250 return FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
251 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
252
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
253 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
254 * Get all waiting message IDs for this server. We copy into a master
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
255 * list as the requests file will be closed and re-opened during the
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
256 * fetch and the position therein will be lost.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
257 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
258 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
259 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
260 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
261 return FALSE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
262 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
263
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
264 if ( Req_first( fetch.serv, msgId ) )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
265 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
267 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 DynStr_appLn( list, msgId );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
269 artmax++;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
270 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
271 while ( Req_next( msgId ) );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
272 Log_inf( "%d TOTAL messages to download", artmax);
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
273 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
274
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
275 /* 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
276 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
277 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
278 while ( res && ( p = Utl_getLn( msgId, p ) ) != NULL )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
279 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
280 DynStr_appLn( fetchList, msgId );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
281 if ( ++count % MAX_ARTICLE_CMDS_QUEUED == 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
282 {
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
283 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
284 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 = ! IS_FATAL( stat );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
286 DynStr_clear( fetchList );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
287 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
288 }
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
289 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
290 res = res && ! IS_FATAL( stat );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
291
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
292 del_DynStr( fetchList );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
293 del_DynStr( list );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
294 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
295 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
296 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
297
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
298 static void
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
299 saveArticleInFailedPostings( const char *msgId, const char *article )
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
300 {
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
301
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
302 Utl_writeFile( Cfg_spoolDir(), "failed.posting", msgId, article );
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
303 }
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
304
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
305 static void
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
306 returnArticleToSender( const char *sender, const char *reason,
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
307 const char *msgId, const char *article )
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
308 {
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
309 int ret;
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
310 Str cmd;
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
311 FILE *f;
271
3477050e8d10 [svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents: 249
diff changeset
312 SignalHandler lastHandler;
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
313
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
314 Log_err( "Return article to '%s' by mail", sender );
154
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
315 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
316 lastHandler = signal( SIGPIPE, SIG_IGN );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
317 f = popen( cmd, "w" );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
318 if ( f == NULL )
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
319 {
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
320 Log_err( "Invocation of '%s' failed (%s)", cmd, strerror( errno ) );
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
321 saveArticleInFailedPostings( msgId, article );
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
322 }
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
323 else
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
324 {
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
325 fprintf( f,
154
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
326 "To: %s\n"
500
614a3177b15c Add mail-from option.
Jim Hague <jim.hague@acm.org>
parents: 464
diff changeset
327 "From: %s\n"
154
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
328 "Subject: [ NOFFLE: Posting failed ]\n"
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
329 "\n"
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
330 "\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
331 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
332 "\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
333 "\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
334 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
335 "\t[ %s ]\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
336 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
337 "\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
338 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
339 "%s"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
340 ".\n",
500
614a3177b15c Add mail-from option.
Jim Hague <jim.hague@acm.org>
parents: 464
diff changeset
341 sender, Cfg_mailFrom(),
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
342 reason, article );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
343 ret = pclose( f );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
344 if ( ret != EXIT_SUCCESS )
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
345 {
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
346 Log_err( "'%s' exit value %d", cmd, ret );
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
347 saveArticleInFailedPostings( msgId, article );
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
348 }
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
349 signal( SIGPIPE, lastHandler );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
350 }
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
351 }
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
352
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
353 Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
354 Fetch_postArts( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
355 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
356 DynStr *s;
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
357 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
358 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
359 Bool res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
360
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
361 res = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
362 s = new_DynStr( 10000 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
363 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
364 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
365 Log_inf( "Posting articles" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
366 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
367 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
368 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
369 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
370 {
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
371 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
372 break;
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
373 }
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
374
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
375 /*
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
376 * 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
377 * 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
378 */
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
379 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
380 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
381 {
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
382 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
383 if ( strcmp( sender, "" ) == 0
283
39d9c19ffba4 [svn] * src/fetch.c: Add Reply-To to the front of the list of headers searched
bears
parents: 274
diff changeset
384 && ! Prt_searchHeader( txt, "REPLY-TO", sender )
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
385 && ! 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
386 && ! 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
387 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
388 && ! Prt_searchHeader( txt, "FROM", sender ) )
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
389 {
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
390 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
391 msgId );
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
392 saveArticleInFailedPostings( msgId, txt );
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
393 }
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 155
diff changeset
394 else
464
d9035d08fe51 [svn] * src/fetch.c: Log failed posting that we can't mail back to the sender
bears
parents: 283
diff changeset
395 returnArticleToSender( sender, errStr, msgId, 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
396 }
43
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 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
399 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
400 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
401 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
402 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
403
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
404 Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
405 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
406 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
407 Lock_closeDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
408 if ( ! connectToServ( serv ) )
139
8e350d558c98 [svn] Fixed a bug in Fetch_init, that triggered
enz
parents: 129
diff changeset
409 {
8e350d558c98 [svn] Fixed a bug in Fetch_init, that triggered
enz
parents: 129
diff changeset
410 Lock_openDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
411 return FALSE;
139
8e350d558c98 [svn] Fixed a bug in Fetch_init, that triggered
enz
parents: 129
diff changeset
412 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
413 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
414 fetch.ready = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
415 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
416 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
417
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
418 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
419 Fetch_close()
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
420 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
421 Client_disconnect();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
422 fetch.ready = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
423 Log_inf( "Fetch from '%s' finished", fetch.serv );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
424 Lock_openDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
425 }