annotate src/fetch.c @ 155:22b81617d427 noffle

[svn] applied patch from Matija Nalis: better handling of inconsistent counters at remote server; do not read overview on each group command
author enz
date Tue, 05 Dec 2000 19:50:09 +0000
parents b2a4f839affd
children 09ca6eb5c7ff
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
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
4 $Id: fetch.c 236 2000-12-05 19:50:09Z enz $
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 "fetch.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
13 #include <errno.h>
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
14
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
15 #if TIME_WITH_SYS_TIME
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
16 #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
17 #include <time.h>
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
18 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
19 #if HAVE_SYS_TIME_H
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
20 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
21 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
22 #include <time.h>
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 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
25
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <signal.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include "client.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 #include "content.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 #include "dynamicstring.h"
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
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
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
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
42 #define MAX_ARTICLE_CMDS_QUEUED 20
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62 void
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
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
69 snprintf( file, MAXCHAR, "%s/lastupdate.%s",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
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 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
74 return;
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" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 Client_getNewgrps( &t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
78 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
80 /* Databases open on entry, closed on exit. */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
81 static void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
82 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
83 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
84 int next, first, last, refetch;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
86 if ( ! Client_changeToGrp( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
88 Log_err( "Could not change to group %s", name );
129
6b2b93288caa [svn] Fix potential lock bug
bears
parents: 127
diff changeset
89 if ( Lock_gotLock() )
6b2b93288caa [svn] Fix potential lock bug
bears
parents: 127
diff changeset
90 Lock_closeDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
91 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
93 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
94 Cont_read( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
95 next = Grp_rmtNext( name );
102
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 79
diff changeset
96 if ( next == GRP_RMT_NEXT_NOT_SUBSCRIBED )
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 79
diff changeset
97 next = first;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
98 if ( next == last + 1 )
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_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
101 Cont_write();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
102 Grp_setFirstLast( name, Cont_first(), Cont_last() );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
103 Lock_closeDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
104 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
105 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106 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
107 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
108 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
109 Cont_write();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
110 Grp_setFirstLast( name, Cont_first(), Cont_last() );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
111 Lock_closeDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
112 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
113 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 if ( next > last + 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
115 {
155
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
116 refetch = last - Cfg_maxFetch() + 1;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
117 if ( refetch < 0 ) refetch = 1;
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
118 Log_err( "Article number inconsistent (%s rmt=%lu-%lu, next=%lu). Refetching from %lu",
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
119 name, first, last, next, refetch );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
120 Pseudo_cntInconsistent( name, first, last, next, refetch );
22b81617d427 [svn] applied patch from Matija Nalis: better handling of inconsistent counters
enz
parents: 154
diff changeset
121 first = refetch;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
122 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
123 else if ( next < first )
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 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
126 name, first, next );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127 Pseudo_missArts( name, first, next );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
129 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
130 first = next;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
131 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
132 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 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
134 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
135 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
136 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
137 first, last, name );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
138 Lock_closeDatabases();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
139 Client_getOver( name, first, last, mode );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
140 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
141
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
142 void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
143 Fetch_getNewArts( const char *name, FetchMode mode )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
144 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
145 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
146 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
147 Log_err( "Could not open message base" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
148 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
149 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
150 fetchNewArts( name, mode );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
153 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154 Fetch_updateGrps( void )
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 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
157 int i, size;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
158 const char *name;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
159
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
160 ASSERT( fetch.ready );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
161 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
162 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
163 Log_err( "Could not open message base" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
164 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
165 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
166 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
167 size = Fetchlist_size();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
168 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
169 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
170 Fetchlist_element( &name, &mode, i );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
171 if ( strcmp( Grp_server( name ), fetch.serv ) == 0 )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
172 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
173 fetchNewArts( name, mode );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
174 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
175 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
176 Log_err( "Could not open message base" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
177 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
178 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
179 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
180 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
181 Lock_closeDatabases();
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
182 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
183
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
184 static void
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
185 fetchMessageList( const char *list, int *artcnt, int artmax )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
186 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
187 const char *p;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
188 Str msgId;
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 ASSERT( Lock_gotLock() );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
191 Client_retrieveArtList( list, artcnt, artmax );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
192 p = list;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
193 while ( ( p = Utl_getLn( msgId, p ) ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
194 Req_remove( fetch.serv, msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195 }
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 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
198 Fetch_getReq_( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
199 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
200 Str msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
201 DynStr *list;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
202 DynStr *fetchList;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
203 const char *p;
120
05f50c1761d9 [svn] Applied patch from Matija Nalis:
enz
parents: 102
diff changeset
204 int count = 0, artcnt = 0, artmax = 0;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
205
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
206 ASSERT( fetch.ready );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
207 Log_dbg( "Retrieving articles marked for download" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
208 list = new_DynStr( 10000 );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
209 fetchList = new_DynStr( 1000 );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
210 if ( list == NULL || fetchList == NULL )
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 if ( list != NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
213 del_DynStr( list );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
214 Log_err( "Out of memory in Fetch_get_Req_");
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
215 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
216 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
217
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
218 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
219 * 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
220 * 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
221 * fetch and the position therein will be lost.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
222 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
223 if ( ! Lock_openDatabases() )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
224 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
225 Log_err( "Could not open message base" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
226 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
227 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
228
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229 if ( Req_first( fetch.serv, msgId ) )
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
230 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
231 do
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 DynStr_appLn( list, msgId );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
234 artmax++;
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 while ( Req_next( msgId ) );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
237 Log_inf( "%d TOTAL messages to download", artmax);
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
238 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
239
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
240 /* 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
241 p = DynStr_str( list );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
242 while ( ( p = Utl_getLn( msgId, p ) ) != NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
243 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
244 DynStr_appLn( fetchList, msgId );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
245 if ( ++count % MAX_ARTICLE_CMDS_QUEUED == 0 )
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 fetchMessageList( DynStr_str( fetchList ), &artcnt, artmax );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
248 DynStr_clear( fetchList );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
249 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
250 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
251 fetchMessageList( DynStr_str( fetchList ), &artcnt, artmax );
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 del_DynStr( fetchList );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
254 del_DynStr( list );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
255 Lock_closeDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
256 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
257
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
258 static void
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
259 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
260 const char *article )
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
261 {
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
262 int ret;
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
263 Str cmd;
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
264 FILE *f;
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
265 sig_t lastHandler;
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
266
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
267 Log_err( "Return article to '%s' by mail", sender );
154
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
268 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
269 lastHandler = signal( SIGPIPE, SIG_IGN );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
270 f = popen( cmd, "w" );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
271 if ( f == NULL )
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
272 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
273 else
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
274 {
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
275 fprintf( f,
154
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
276 "To: %s\n"
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
277 "Subject: [ NOFFLE: Posting failed ]\n"
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
278 "\n"
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
279 "\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
280 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
281 "\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
282 "\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
283 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
284 "\t[ %s ]\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
285 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
286 "\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
287 "\n"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
288 "%s"
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
289 ".\n",
154
b2a4f839affd [svn] Use sendmail instead of mail
enz
parents: 139
diff changeset
290 sender,
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
291 reason, article );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
292 ret = pclose( f );
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
293 if ( ret != EXIT_SUCCESS )
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
294 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
295 signal( SIGPIPE, lastHandler );
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 }
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
298
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
299 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
300 Fetch_postArts( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
301 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
302 DynStr *s;
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
303 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
304 const char *txt;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
305
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
306 s = new_DynStr( 10000 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
307 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
308 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
309 Log_inf( "Posting articles" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
310 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
311 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
312 txt = DynStr_str( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
313 Out_remove( fetch.serv, msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
314 if ( ! Client_postArt( msgId, txt, errStr ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
315 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
316 Utl_cpyStr( sender, Cfg_mailTo() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
317 if ( strcmp( sender, "" ) == 0
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
318 && ! Prt_searchHeader( txt, "SENDER", sender )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
319 && ! Prt_searchHeader( txt, "X-NOFFLE-X-SENDER",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
320 sender ) /* see server.c */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
321 && ! Prt_searchHeader( txt, "FROM", sender ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 Log_err( "Article %s has no From/Sender/X-Sender field",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 else
79
28aeb0b93509 [svn] Extracted function in Fetch_postArts for returning failed postings to sender
enz
parents: 61
diff changeset
325 returnArticleToSender( sender, errStr, txt );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
326 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
327 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
328 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
329 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
330 del_DynStr( s );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
331 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
332
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
333 Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
334 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
335 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
336 Lock_closeDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
337 if ( ! connectToServ( serv ) )
139
8e350d558c98 [svn] Fixed a bug in Fetch_init, that triggered
enz
parents: 129
diff changeset
338 {
8e350d558c98 [svn] Fixed a bug in Fetch_init, that triggered
enz
parents: 129
diff changeset
339 Lock_openDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
340 return FALSE;
139
8e350d558c98 [svn] Fixed a bug in Fetch_init, that triggered
enz
parents: 129
diff changeset
341 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
342 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
343 fetch.ready = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
344 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
347 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
348 Fetch_close()
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
349 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
350 Client_disconnect();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
351 fetch.ready = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
352 Log_inf( "Fetch from '%s' finished", fetch.serv );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 120
diff changeset
353 Lock_openDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
354 }