annotate src/client.c @ 404:775af896124a noffle

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