Mercurial > noffle
annotate src/post.c @ 500:614a3177b15c noffle tip
Add mail-from option.
Some modern mail systems will try and ensure the sender email is a legitimate
address. Which will fail if there isn't such an address.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Wed, 14 Aug 2013 12:04:39 +0100 |
parents | 372f8b55506e |
children |
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 post.c |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
3 |
494
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
4 $Id: post.c 645 2006-07-12 19:26:41Z 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 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
11 #include <errno.h> |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
12 #include <pwd.h> |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
13 #include <stdio.h> |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
14 #include <sys/types.h> |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
15 #include <unistd.h> |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #include <string.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
17 #include "common.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
18 #include "configfile.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
19 #include "content.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
20 #include "control.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
21 #include "database.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
22 #include "group.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
23 #include "itemlist.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
24 #include "log.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
25 #include "outgoing.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
26 #include "over.h" |
197
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
191
diff
changeset
|
27 #include "portable.h" |
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
191
diff
changeset
|
28 #include "post.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
29 #include "protocol.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
30 #include "util.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
32 #define BEGIN_SIG "-- " |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
33 #define SIG_FILE "/.signature" |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
34 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
35 struct OverInfo |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
37 Str subject; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
38 Str from; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
39 Str date; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
40 Str msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 Str ref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
42 size_t bytes; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
43 size_t lines; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
44 }; |
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 struct Article |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
47 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
48 DynStr *text; /* Processed article text */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
49 ItemList *newsgroups; /* Newsgroups for dispatch */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
50 ItemList *control; /* Control message? NULL if not */ |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
51 Bool approved; /* Has Approved: header? */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
52 Bool posted; /* Has it been put in the article database? */ |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
53 int flags; /* Posting flags */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
54 struct OverInfo over; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
55 }; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
56 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
57 static struct Article article = { NULL, NULL, NULL, FALSE, FALSE, 0, |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
58 { "", "", "", "", "", 0, 0 } }; |
43
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 /* Add the article to a group. */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
61 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
62 addToGroup( const char * grp ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
63 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
64 Over * over; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
65 const char *msgId; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
66 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
67 over = new_Over( article.over.subject, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
68 article.over.from, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
69 article.over.date, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
70 article.over.msgId, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
71 article.over.ref, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
72 article.over.bytes, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
73 article.over.lines ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
74 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
75 msgId = article.over.msgId; |
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 Cont_read( grp ); |
240
fbff73fe5b40
[svn] * src/client.c: That wasn't a memory leak fixed on Feb 8th. That was a
bears
parents:
223
diff
changeset
|
78 Cont_app( over ); /* Cont modules owns ov after this */ |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
79 Log_dbg( LOG_DBG_POST, "Added message '%s' to group '%s'.", msgId, grp ); |
43
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 if ( !article.posted ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
82 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
83 Log_inf( "Added '%s' to database.", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
84 if ( ! Db_prepareEntry( over, Cont_grp(), Cont_last() ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
85 || ! Db_storeArt ( msgId, DynStr_str( article.text ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
86 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
87 article.posted = TRUE; |
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 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
90 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
91 Str t; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
92 const char *xref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
93 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
94 xref = Db_xref( msgId ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
95 Log_dbg( LOG_DBG_POST, "Adding '%s' to Xref of '%s'", grp, msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
96 snprintf( t, MAXCHAR, "%s %s:%i", xref, grp, Ov_numb( over ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
97 Db_setXref( msgId, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
98 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
99 |
223
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
100 if ( Cont_write() ) |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
101 { |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
102 Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() ); |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
103 Grp_setLastPostTime( Cont_grp() ); |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
104 return TRUE; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
105 } |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
106 else |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
107 return FALSE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
108 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
109 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
110 static Bool |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
111 checkPostableNewsgroup( void ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
112 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
113 const char * grp; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
114 Bool knownGrp = FALSE; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
115 Bool postAllowedGrp = TRUE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
116 Bool local; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
117 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
118 /* |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
119 * Check all known groups are writeable, and there is |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
120 * at least one known group. |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
121 */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
122 for( grp = Itl_first( article.newsgroups ); |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
123 postAllowedGrp && grp != NULL; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
124 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
125 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
126 if ( Grp_exists( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
127 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
128 local = Grp_local( grp ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
129 knownGrp = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
130 switch( Grp_postAllow( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
131 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
132 case 'n': |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
133 postAllowedGrp = FALSE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
134 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
135 case 'y': |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
136 break; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
137 case 'm': |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
138 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
139 * Can post to moderated groups if *either* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
140 * 1. Group is local and article approved, or |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
141 * 2. Group is external |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
142 */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
143 postAllowedGrp = |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
144 ! local || |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
145 article.approved; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
146 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
147 default: |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
148 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
149 * Unknown mode for local groups. Forward |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
150 * to server for external groups; presumably the |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
151 * server knows what to do. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
152 */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
153 postAllowedGrp = ! local; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
154 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
155 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
156 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
157 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
158 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
159 if ( ! knownGrp ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
160 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
161 Log_err( "No known group in Newsgroups header field" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
162 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
163 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
164 else if ( ! postAllowedGrp ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
165 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
166 Log_err( "A group does not permit posting" ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
167 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
168 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
169 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
170 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
171 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
172 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
173 /* Get article text, check for validity & build overview. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
174 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
175 getArticleText( const char *p ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
176 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
177 DynStr * s; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
178 Str line, field, value; |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
179 Bool dateFound, fromFound, msgIdFound, subjectFound; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
180 Bool newsgroupsFound, pathFound; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
181 Bool replyToFound, orgFound; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
182 Bool continuation; |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
183 time_t t; |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
184 int sigLines; |
494
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
185 Bool addMsgIdIfMissing; |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
186 Bool processMsgId = TRUE; |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
187 |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
188 addMsgIdIfMissing = Cfg_addMsgIdIfMissing(); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
189 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
190 s = new_DynStr( 10000 ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
191 article.text = s; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
192 |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
193 /* RFC says only one of these headers. */ |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
194 dateFound = fromFound = msgIdFound = subjectFound = |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
195 newsgroupsFound = pathFound = FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
196 |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
197 /* Stuff we might want to add. */ |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
198 replyToFound = orgFound = FALSE; |
247 | 199 |
200 field[ 0 ] = '\0'; | |
201 | |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
202 /* |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
203 * Grab header lines first, getting overview info as we go. |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
204 * Note that a line may be a continuation line, hence we always |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
205 * cat the information into the destination. |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
206 */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
207 while ( ( p = Utl_getHeaderLn( line, p ) ) != NULL |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
208 && line[ 0 ] != '\0' |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
209 && Prt_getField( field, value, &continuation, line ) ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
210 { |
247 | 211 if ( field [ 0 ] == '\0' ) |
212 { | |
213 /* Error! Continuation without preceding header. */ | |
214 Log_err( "First header line started with white space" ); | |
215 return FALSE; | |
216 } | |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
217 /* Look for headers we need to stash. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
218 if ( strcmp( field, "subject" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
219 { |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
220 if ( !continuation && subjectFound ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
221 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
222 Log_err( "Duplicate Subject: header" ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
223 return FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
224 } |
247 | 225 Utl_catStr( article.over.subject, value ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
226 DynStr_appLn( s, line ); |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
227 subjectFound = TRUE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
228 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
229 else if ( strcmp ( field, "from" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
230 { |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
231 if ( !continuation && fromFound ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
232 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
233 Log_err( "Duplicate From: header" ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
234 return FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
235 } |
247 | 236 Utl_catStr( article.over.from, value ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
237 DynStr_appLn( s, line ); |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
238 fromFound = TRUE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
239 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
240 else if ( strcmp ( field, "date" ) == 0 ) |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
241 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
242 if ( !continuation && dateFound ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
243 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
244 Log_err( "Duplicate Date: header" ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
245 return FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
246 } |
247 | 247 Utl_catStr( article.over.date, value ); |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
248 dateFound = TRUE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
249 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
250 else if ( strcmp ( field, "references" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
251 { |
247 | 252 Utl_catStr( article.over.ref, value ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
253 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
254 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
255 else if ( strcmp ( field, "message-id" ) == 0 ) |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
256 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
257 if ( !continuation && msgIdFound ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
258 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
259 Log_err( "Duplicate Message-Id: header" ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
260 return FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
261 } |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
262 Utl_catStr( article.over.msgId, value ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
263 msgIdFound = TRUE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
264 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
265 else if ( strcmp ( field, "newsgroups" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
266 { |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
267 if ( !continuation && newsgroupsFound ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
268 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
269 Log_err( "Duplicate Newsgroups: header" ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
270 return FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
271 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
272 article.newsgroups = new_Itl( value, " ,\n\t" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
273 DynStr_appLn( s, line ); |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
274 newsgroupsFound = TRUE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
275 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
276 else if ( strcmp ( field, "control" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
277 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
278 article.control = new_Itl( value, " " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
279 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
280 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
281 else if ( strcmp ( field, "reply-to" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
282 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
283 replyToFound = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
284 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
285 } |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
286 else if ( strcmp ( field, "approved" ) == 0 ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
287 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
288 article.approved = TRUE; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
289 DynStr_appLn( s, line ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
290 } |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
291 else if ( strcmp ( field, "path" ) == 0 ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
292 { |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
293 if ( !continuation && pathFound ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
294 { |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
295 Log_err( "Duplicate Path: header" ); |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
296 return FALSE; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
297 } |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
298 pathFound = TRUE; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
299 DynStr_appLn( s, line ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
300 } |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
301 else if ( strcmp ( field, "organization" ) == 0 ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
302 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
303 orgFound = TRUE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
304 DynStr_appLn( s, line ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
305 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
306 else if ( strcmp ( field, "x-sender" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
307 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
308 DynStr_app( s, "X-NOFFLE-X-Sender: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
309 DynStr_appLn( s, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
310 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
311 else if ( strcmp ( field, "xref" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
312 Log_inf( "Xref header in post ignored" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
313 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
314 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
315 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
316 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
317 /* Now sort header-related issues */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
318 if ( article.over.from[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
319 { |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
320 if ( article.flags & POST_ADD_FROM ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
321 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
322 Log_dbg( LOG_DBG_POST, "Adding From field to posted message." ); |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
323 DynStr_app( s, "From: " ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
324 if ( ! Prt_genFromHdr( article.over.from ) ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
325 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
326 Log_err( "Can't generate From field" ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
327 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
328 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
329 DynStr_appLn( s, article.over.from ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
330 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
331 else |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
332 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
333 Log_err( "Posted message has no From field" ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
334 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
335 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
336 } |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
337 if ( ! subjectFound ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
338 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
339 Log_err( "Posted message has no Subject field" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
340 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
341 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
342 if ( article.newsgroups == NULL || Itl_count( article.newsgroups) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
343 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
344 Log_err( "Posted message has no valid Newsgroups field" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
345 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
346 } |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
347 |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
348 /* Ensure correctly formatted date */ |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
349 t = Utl_parseNewsDate( article.over.date ); |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
350 if ( t == (time_t) -1 ) |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
351 { |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
352 time( &t ); |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
353 Utl_newsDate( t, article.over.date ); |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
354 } |
100 | 355 DynStr_app( s, "Date: " ); |
356 DynStr_appLn( s, article.over.date ); | |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
357 |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
358 /* Ensure Message ID is present and valid */ |
222
bf290632d29e
[svn] * src/post.c: Always replace message ID in posted message if existing
bears
parents:
197
diff
changeset
|
359 if ( article.over.msgId[ 0 ] == '\0' ) |
bf290632d29e
[svn] * src/post.c: Always replace message ID in posted message if existing
bears
parents:
197
diff
changeset
|
360 { |
bf290632d29e
[svn] * src/post.c: Always replace message ID in posted message if existing
bears
parents:
197
diff
changeset
|
361 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); |
bf290632d29e
[svn] * src/post.c: Always replace message ID in posted message if existing
bears
parents:
197
diff
changeset
|
362 Log_inf( "Adding missing Message-ID '%s'", article.over.msgId ); |
494
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
363 |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
364 if ( ! addMsgIdIfMissing ) |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
365 processMsgId = FALSE; |
222
bf290632d29e
[svn] * src/post.c: Always replace message ID in posted message if existing
bears
parents:
197
diff
changeset
|
366 } |
bf290632d29e
[svn] * src/post.c: Always replace message ID in posted message if existing
bears
parents:
197
diff
changeset
|
367 else if ( ! Prt_isValidMsgId( article.over.msgId ) || Cfg_replaceMsgId() ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
368 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
369 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
370 Log_dbg( LOG_DBG_POST, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
371 "Replacing Message-ID with '%s'", |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
372 article.over.msgId ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
373 } |
494
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
374 |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
375 if ( processMsgId ) |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
376 { |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
377 DynStr_app( s, "Message-ID: " ); |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
378 DynStr_appLn( s, article.over.msgId ); |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
379 } |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
380 else |
372f8b55506e
[svn] Apply patch from Jan De Luyck. Add new option 'add-messageid-if-missing',
bears
parents:
377
diff
changeset
|
381 Log_inf( "Not storing Message-ID '%s' in message.", article.over.msgId ); |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
382 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
383 /* Ensure Path header */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
384 if ( ! pathFound ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
385 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
386 Str path; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
387 |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
388 Log_dbg( LOG_DBG_POST, "Adding Path field to posted message." ); |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
389 DynStr_app( s, "Path: " ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
390 Utl_cpyStr( path, Cfg_pathHeader() ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
391 if ( path[ 0 ] == '\0' ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
392 Prt_genPathHdr( path, article.over.from ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
393 DynStr_appLn( s, path ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
394 } |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
395 |
357
b0ee77fa24d4
[svn] * src/post.c,src/configfile.c,src/configfile.h,docs/noffle.conf.5,
bears
parents:
282
diff
changeset
|
396 /* Ensure Reply-To header if configuration demands it */ |
b0ee77fa24d4
[svn] * src/post.c,src/configfile.c,src/configfile.h,docs/noffle.conf.5,
bears
parents:
282
diff
changeset
|
397 if ( ! replyToFound && Cfg_appendReplyTo() ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
398 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
399 Log_dbg( LOG_DBG_POST, "Adding Reply-To field to posted message." ); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
400 DynStr_app( s, "Reply-To: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
401 DynStr_appLn( s, article.over.from ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
402 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
403 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
404 /* Ensure Organization header if required */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
405 if ( ( ! orgFound ) && ( article.flags & POST_ADD_ORG ) ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
406 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
407 Str org; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
408 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
409 Utl_cpyStr( org, Cfg_organization() ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
410 if ( org[ 0 ] != '\0' ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
411 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
412 Log_dbg( LOG_DBG_POST, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
413 "Adding Organization field to posted message." ); |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
414 DynStr_app( s, "Organization: " ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
415 DynStr_appLn( s, org ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
416 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
417 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
418 |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
419 /* OK, header ready to roll. Something to accompany it? */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
420 if ( p == NULL || p[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
421 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
422 Log_err( "Posted message has no body" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
423 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
424 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
425 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
426 /* Add the empty line separating header and body */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
427 DynStr_appLn( s, "" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
428 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
429 /* Now pop on the rest of the body */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
430 DynStr_app( s, p ); |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
431 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
432 /* Add a signature if requested to do so and if one found. */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
433 sigLines = 0; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
434 if ( article.flags & POST_ADD_SIG ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
435 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
436 Str sigfile; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
437 struct passwd *pwd; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
438 FILE *f; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
439 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
440 /* Generate sig file path */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
441 pwd = getpwuid( getuid() ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
442 Utl_cpyStr( sigfile, pwd->pw_dir ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
443 Utl_catStr( sigfile, SIG_FILE ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
444 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
445 f = fopen( sigfile, "r" ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
446 if ( f == NULL ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
447 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
448 /* If err is ENOENT, file doesn't exist. This is OK. */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
449 if ( errno != ENOENT ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
450 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
451 Log_err( "Can't access .signature file (%s), " |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
452 "article not posted.", |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
453 strerror( errno ) ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
454 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
455 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
456 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
457 else |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
458 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
459 /* OK, try to add it. */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
460 Str sline; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
461 |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
179
diff
changeset
|
462 Log_dbg( LOG_DBG_POST, "Adding .signature to posted message." ); |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
463 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
464 DynStr_appLn( s, BEGIN_SIG ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
465 sigLines++; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
466 while ( Prt_getLn( sline, f, 0 ) ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
467 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
468 DynStr_appLn( s, sline ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
469 sigLines++; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
470 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
471 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
472 if ( ferror( f ) ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
473 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
474 Log_err( "Error reading .signature file (%s), " |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
475 "article not posted.", |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
476 strerror( errno ) ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
477 fclose( f ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
478 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
479 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
480 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
481 fclose( f ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
482 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
483 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
484 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
485 /* |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
486 * Count the lines & bytes. This counts the original number of |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
487 * lines in the supplied body, so add in the number of signature |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
488 * lines added, including the separator. |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
489 */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
490 for ( p++, article.over.lines = sigLines; *p != '\0'; p++ ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
491 if ( *p == '\n' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
492 article.over.lines++; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
493 article.over.bytes = DynStr_len( s ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
494 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
495 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
496 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
497 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
498 /* Add article to outgoing if needs be */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
499 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
500 postExternal( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
501 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
502 const char * grp; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
503 Str serversSeen; |
153
945501c95a4e
[svn] Undo change to post.c that only sent moderated articles to one server.
bears
parents:
152
diff
changeset
|
504 Bool err; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
505 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
506 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
507 * For each external group, send to that group's server if it has |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
508 * not seen the post already. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
509 */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
510 serversSeen[ 0 ] = '\0'; |
153
945501c95a4e
[svn] Undo change to post.c that only sent moderated articles to one server.
bears
parents:
152
diff
changeset
|
511 err = FALSE; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
512 |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
513 for ( grp = Itl_first( article.newsgroups ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
514 grp != NULL; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
515 grp = Itl_next( article.newsgroups ) ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
516 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
517 if ( Grp_exists( grp ) && ! Grp_local( grp ) ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
518 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
519 const char * servName = Grp_server( grp ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
520 |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
521 if ( strstr( serversSeen, servName ) != NULL ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
522 continue; |
152
ca9769519c96
[svn] * src/post.c: When posting to a non-local moderated group, only
bears
parents:
150
diff
changeset
|
523 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
524 if ( ! Out_add( servName, article.over.msgId, article.text ) ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
525 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
526 Log_err( "Cannot add posted article to outgoing directory" ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
527 err = TRUE; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
528 } |
152
ca9769519c96
[svn] * src/post.c: When posting to a non-local moderated group, only
bears
parents:
150
diff
changeset
|
529 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
530 Utl_catStr( serversSeen, " " ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
531 Utl_catStr( serversSeen, servName ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
532 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
533 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
534 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
535 return err; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
536 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
537 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
538 /* Cancel and return TRUE if need to send cancel message on to server. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
539 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
540 controlCancel( const char *cancelId ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
541 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
542 return ( Ctrl_cancel( cancelId ) == CANCEL_NEEDS_MSG ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
543 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
544 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
545 /* |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
546 It's a control message. Currently we only know about 'cancel' |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
547 messages; others are passed on for outside groups, and logged |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
548 as ignored for local groups. |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
549 */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
550 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
551 handleControl( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
552 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
553 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
554 const char *op; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
555 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
556 op = Itl_first( article.control ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
557 if ( op == NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
558 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
559 Log_err( "Malformed control line." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
560 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
561 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
562 else if ( strcasecmp( op, "cancel" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
563 { |
377
21300895412f
[svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents:
366
diff
changeset
|
564 if ( ! controlCancel( Itl_next( article.control ) ) ) |
21300895412f
[svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents:
366
diff
changeset
|
565 return TRUE; /* Handled entirely locally */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
566 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
567 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
568 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
569 /* Log 'can't do' for internal groups. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
570 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
571 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
572 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
573 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
574 if ( Grp_exists( grp ) && Grp_local( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
575 Log_inf( "Ignoring control '%s' for '%s'.", op, grp ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
576 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
577 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
578 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
579 return postExternal(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
580 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
581 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
582 static Bool |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
583 postArticle( void ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
584 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
585 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
586 Bool err; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
587 Bool local; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
588 Bool postLocal; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
589 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
590 err = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
591 postLocal = Cfg_postLocal(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
592 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
593 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
594 * Run round first doing all local groups. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
595 * Remember, we've already checked it is OK to post to them all. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
596 */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
597 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
598 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
599 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
600 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
601 local = Grp_local( grp ); |
179
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
602 |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
603 /* |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
604 * Only post locally to external group if that group's post |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
605 * status is 'y'. Otherwise retrieve from upstream server - |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
606 * for example, we don't want to immediately post locally articles |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
607 * destined for the moderator of a moderated group. |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
608 */ |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
609 if ( local || ( postLocal && Grp_postAllow( grp ) == 'y' ) ) |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
247
diff
changeset
|
610 err = addToGroup( grp ) && err; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
611 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
612 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
613 return postExternal() && err; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
614 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
615 |
223
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
616 |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
617 static void |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
618 clearArticleInfo( void ) |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
619 { |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
620 article.text = NULL; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
621 article.newsgroups = NULL; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
622 article.control = NULL; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
623 article.approved = FALSE; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
624 article.posted = FALSE; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
625 article.flags = 0; |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
626 memset( &article.over, 0, sizeof( article.over ) ); |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
627 } |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
628 |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
629 /* Register an article for posting. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
630 Bool |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
631 Post_open( const char * text, unsigned flags ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
632 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
633 if ( article.text != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
634 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
635 Log_err( "Busy article in Post_open." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
636 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
637 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
638 |
223
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
639 clearArticleInfo(); |
ffb1848a39db
[svn] * src/util.c: Improve (correct) error detection when updating
bears
parents:
222
diff
changeset
|
640 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
641 article.flags = flags; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
642 if ( ! getArticleText( text ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
643 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
644 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
645 if ( Db_contains( article.over.msgId ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
646 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
647 Post_close(); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
648 Log_err( "Duplicate article %s.", article.over.msgId ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
649 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
650 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
651 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
652 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
653 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
654 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
655 /* Process the posting */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
656 Bool |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
657 Post_post( void ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
658 { |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
659 if ( article.flags & POST_DEBUG ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
660 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
661 fputs( DynStr_str( article.text ), stdout ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
662 return TRUE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
663 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
664 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
665 if ( ! checkPostableNewsgroup() ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
666 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
667 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
668 return ( article.control == NULL ) |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
669 ? ! postArticle() |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
670 : ! handleControl(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
671 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
672 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
673 /* Done with article - tidy up. */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
674 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
675 Post_close( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
676 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
677 if ( article.text != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
678 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
679 del_DynStr( article.text ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
680 article.text = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
681 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
682 if ( article.newsgroups != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
683 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
684 del_Itl( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
685 article.newsgroups = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
686 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
687 if ( article.control != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
688 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
689 del_Itl( article.control ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
690 article.control = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
691 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
692 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
693 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
694 |