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