Mercurial > noffle
annotate src/post.c @ 179:f973675760dc noffle
[svn] * src/post.c: If post-locally is set, only do immediate local posting
on groups with status 'y'. We don't want to post locally articles
destined for the moderator of a moderated group.
author | bears |
---|---|
date | Wed, 09 May 2001 12:15:31 +0100 |
parents | 945501c95a4e |
children | fed1334d766b |
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 |
179
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
4 $Id: post.c 278 2001-05-09 11:15:31Z 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 "post.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
17 #include <string.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
18 #include "common.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
19 #include "configfile.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
20 #include "content.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
21 #include "control.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
22 #include "database.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
23 #include "group.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
24 #include "itemlist.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
25 #include "log.h" |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
26 #include "outgoing.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
27 #include "over.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
28 #include "protocol.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
29 #include "util.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
30 #include "portable.h" |
43
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 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
78 Cont_app( over ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
79 Log_dbg( "Added message '%s' to group '%s'.", msgId, grp ); |
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 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
95 Log_dbg( "Adding '%s' to Xref of '%s'", grp, msgId ); |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
100 Cont_write(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
101 Grp_setFirstLast( Cont_grp(), Cont_first(), Cont_last() ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
102 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
103 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
104 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
105 static Bool |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
106 checkPostableNewsgroup( void ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
107 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
108 const char * grp; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
109 Bool knownGrp = FALSE; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
110 Bool postAllowedGrp = TRUE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
111 Bool local; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
112 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
113 /* |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
114 * 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
|
115 * at least one known group. |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
116 */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
117 for( grp = Itl_first( article.newsgroups ); |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
118 postAllowedGrp && grp != NULL; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
119 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
120 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
121 if ( Grp_exists( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
122 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
123 local = Grp_local( grp ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
124 knownGrp = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
125 switch( Grp_postAllow( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
126 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
127 case 'n': |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
128 postAllowedGrp = FALSE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
129 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
130 case 'y': |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
131 break; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
132 case 'm': |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
133 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
134 * Can post to moderated groups if *either* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
135 * 1. Group is local and article approved, or |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
136 * 2. Group is external |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
137 */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
138 postAllowedGrp = |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
139 ! local || |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
140 article.approved; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
141 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
142 default: |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
143 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
144 * Unknown mode for local groups. Forward |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
145 * to server for external groups; presumably the |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
146 * server knows what to do. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
147 */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
148 postAllowedGrp = ! local; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
149 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
150 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
151 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
152 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
153 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
154 if ( ! knownGrp ) |
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 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
|
157 return FALSE; |
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 else if ( ! postAllowedGrp ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
160 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
161 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
|
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
165 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
166 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
167 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
168 /* 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
|
169 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
170 getArticleText( const char *p ) |
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 DynStr * s; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
173 Str line, field, value; |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
174 Bool replyToFound, pathFound, orgFound; |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
175 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
|
176 int sigLines; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
177 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
178 s = new_DynStr( 10000 ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
179 article.text = s; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
180 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
181 memset( &article.over, 0, sizeof( article.over ) ); |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
182 replyToFound = pathFound = orgFound = FALSE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
183 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
184 /* Grab header lines first, getting overview info as we go. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
185 while ( ( p = Utl_getHeaderLn( line, p ) ) != NULL |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
186 && line[ 0 ] != '\0' |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
187 && Prt_getField( field, value, line ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
188 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
189 /* Look for headers we need to stash. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
190 if ( strcmp( field, "subject" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
191 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
192 Utl_cpyStr( article.over.subject, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
193 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
194 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
195 else if ( strcmp ( field, "from" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
196 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
197 Utl_cpyStr( article.over.from, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
198 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
199 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
200 else if ( strcmp ( field, "date" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
201 Utl_cpyStr( article.over.date, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
202 else if ( strcmp ( field, "references" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
203 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
204 Utl_cpyStr( article.over.ref, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
205 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
206 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
207 else if ( strcmp ( field, "message-id" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
208 Utl_cpyStr( article.over.msgId, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
209 else if ( strcmp ( field, "newsgroups" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
210 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
211 article.newsgroups = new_Itl( value, " ,\n\t" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
212 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
213 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
214 else if ( strcmp ( field, "control" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
215 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
216 article.control = new_Itl( value, " " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
217 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
218 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
219 else if ( strcmp ( field, "reply-to" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
220 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
221 replyToFound = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
222 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
223 } |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
224 else if ( strcmp ( field, "approved" ) == 0 ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
225 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
226 article.approved = TRUE; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
227 DynStr_appLn( s, line ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
228 } |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
229 else if ( strcmp ( field, "path" ) == 0 ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
230 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
231 pathFound = TRUE; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
232 DynStr_appLn( s, line ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
233 } |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
234 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
|
235 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
236 orgFound = TRUE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
237 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
|
238 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
239 else if ( strcmp ( field, "x-sender" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
240 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
241 DynStr_app( s, "X-NOFFLE-X-Sender: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
242 DynStr_appLn( s, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
243 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
244 else if ( strcmp ( field, "xref" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
245 Log_inf( "Xref header in post ignored" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
246 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
247 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
248 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
249 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
250 /* Now sort header-related issues */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
251 if ( article.over.from[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
252 { |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
253 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
|
254 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
255 Log_dbg( "Adding From field to posted message." ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
256 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
|
257 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
|
258 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
259 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
|
260 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
261 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
262 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
|
263 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
264 else |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
265 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
266 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
|
267 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
268 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
269 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
270 if ( article.over.subject[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
271 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
272 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
|
273 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
274 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
275 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
|
276 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
277 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
|
278 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
279 } |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
280 |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
281 /* Ensure correctly formatted date */ |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
282 t = Utl_parseNewsDate( article.over.date ); |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
283 if ( t == (time_t) -1 ) |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
284 { |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
285 time( &t ); |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
286 Utl_newsDate( t, article.over.date ); |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
287 } |
100 | 288 DynStr_app( s, "Date: " ); |
289 DynStr_appLn( s, article.over.date ); | |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
290 |
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
291 /* Ensure Message ID is present and valid */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
292 if ( Cfg_replaceMsgId() ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
293 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
294 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
295 Log_dbg( "Replacing Message-ID with '%s'", article.over.msgId ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
296 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
297 else if ( article.over.msgId[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
298 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
299 Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
300 Log_inf( "Adding missing Message-ID '%s'", article.over.msgId ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
301 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
302 DynStr_app( s, "Message-ID: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
303 DynStr_appLn( s, article.over.msgId ); |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
304 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
305 /* Ensure Path header */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
306 if ( ! pathFound ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
307 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
308 Str path; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
309 |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
310 Log_dbg( "Adding Path field to posted message." ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
311 DynStr_app( s, "Path: " ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
312 Utl_cpyStr( path, Cfg_pathHeader() ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
313 if ( path[ 0 ] == '\0' ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
314 Prt_genPathHdr( path, article.over.from ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
315 DynStr_appLn( s, path ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
316 } |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
317 |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
318 /* Ensure Reply-To header */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
319 if ( ! replyToFound ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
320 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
321 Log_dbg( "Adding Reply-To field to posted message." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
322 DynStr_app( s, "Reply-To: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
323 DynStr_appLn( s, article.over.from ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
324 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
325 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
326 /* 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
|
327 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
|
328 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
329 Str org; |
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 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
|
332 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
|
333 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
334 Log_dbg( "Adding Organization field to posted message." ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
335 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
|
336 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
|
337 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
338 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
339 |
93
eb522db0d032
[svn] Renamed date format and enforce correct date format on post
bears
parents:
88
diff
changeset
|
340 /* 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
|
341 if ( p == NULL || p[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
342 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
343 Log_err( "Posted message has no body" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
344 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
345 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
346 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
347 /* 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
|
348 DynStr_appLn( s, "" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
349 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
350 /* 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
|
351 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
|
352 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
353 /* 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
|
354 sigLines = 0; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
355 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
|
356 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
357 Str sigfile; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
358 struct passwd *pwd; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
359 FILE *f; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
360 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
361 /* 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
|
362 pwd = getpwuid( getuid() ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
363 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
|
364 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
|
365 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
366 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
|
367 if ( f == NULL ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
368 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
369 /* 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
|
370 if ( errno != ENOENT ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
371 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
372 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
|
373 "article not posted.", |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
374 strerror( errno ) ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
375 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
376 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
377 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
378 else |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
379 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
380 /* 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
|
381 Str sline; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
382 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
383 Log_dbg( "Adding .signature to posted message." ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
384 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
385 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
|
386 sigLines++; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
387 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
|
388 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
389 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
|
390 sigLines++; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
391 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
392 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
393 if ( ferror( f ) ) |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
394 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
395 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
|
396 "article not posted.", |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
397 strerror( errno ) ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
398 fclose( f ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
399 return FALSE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
400 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
401 |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
402 fclose( f ); |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
403 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
404 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
405 |
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 * 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
|
408 * 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
|
409 * 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
|
410 */ |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
411 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
|
412 if ( *p == '\n' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
413 article.over.lines++; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
414 article.over.bytes = DynStr_len( s ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
415 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
416 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
417 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
418 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
419 /* Add article to outgoing if needs be */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
420 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
421 postExternal( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
422 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
423 const char * grp; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
424 Str serversSeen; |
153
945501c95a4e
[svn] Undo change to post.c that only sent moderated articles to one server.
bears
parents:
152
diff
changeset
|
425 Bool err; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
426 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
427 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
428 * 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
|
429 * not seen the post already. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
430 */ |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
431 serversSeen[ 0 ] = '\0'; |
153
945501c95a4e
[svn] Undo change to post.c that only sent moderated articles to one server.
bears
parents:
152
diff
changeset
|
432 err = FALSE; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
433 |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
434 for ( grp = Itl_first( article.newsgroups ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
435 grp != NULL; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
436 grp = Itl_next( article.newsgroups ) ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
437 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
438 if ( Grp_exists( grp ) && ! Grp_local( grp ) ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
439 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
440 const char * servName = Grp_server( grp ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
441 |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
442 if ( strstr( serversSeen, servName ) != NULL ) |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
443 continue; |
152
ca9769519c96
[svn] * src/post.c: When posting to a non-local moderated group, only
bears
parents:
150
diff
changeset
|
444 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
445 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
|
446 { |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
447 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
|
448 err = TRUE; |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
449 } |
152
ca9769519c96
[svn] * src/post.c: When posting to a non-local moderated group, only
bears
parents:
150
diff
changeset
|
450 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
451 Utl_catStr( serversSeen, " " ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
452 Utl_catStr( serversSeen, servName ); |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
453 } |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
454 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
455 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
456 return err; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
457 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
458 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
459 /* 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
|
460 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
461 controlCancel( const char *cancelId ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
462 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
463 return ( Ctrl_cancel( cancelId ) == CANCEL_NEEDS_MSG ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
464 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
465 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
466 /* |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
467 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
|
468 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
|
469 as ignored for local groups. |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
470 */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
471 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
472 handleControl( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
473 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
474 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
475 const char *op; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
476 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
477 op = Itl_first( article.control ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
478 if ( op == NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
479 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
480 Log_err( "Malformed control line." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
481 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
482 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
483 else if ( strcasecmp( op, "cancel" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
484 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
485 if ( ! controlCancel( Itl_next( article.control ) ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
486 return TRUE; /* Handled entirely locally */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
487 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
488 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
489 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
490 /* Log 'can't do' for internal groups. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
491 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
492 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
493 grp = Itl_next( article.newsgroups ) ) |
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 if ( Grp_exists( grp ) && Grp_local( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
496 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
|
497 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
498 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
499 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
500 return postExternal(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
501 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
502 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
503 static Bool |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
504 postArticle( void ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
505 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
506 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
507 Bool err; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
508 Bool local; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
509 Bool postLocal; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
510 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
511 err = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
512 postLocal = Cfg_postLocal(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
513 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
514 /* |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
515 * Run round first doing all local groups. |
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
516 * 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
|
517 */ |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
518 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
519 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
520 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
521 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
522 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
|
523 |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
524 /* |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
525 * 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
|
526 * 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
|
527 * 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
|
528 * 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
|
529 */ |
f973675760dc
[svn] * src/post.c: If post-locally is set, only do immediate local posting
bears
parents:
153
diff
changeset
|
530 if ( ! local && ( ! postLocal || Grp_postAllow( grp ) != 'y' ) ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
531 continue; |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
532 err = addToGroup( grp ) && err; |
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 postExternal() && 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 /* Register an article for posting. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
539 Bool |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
540 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
|
541 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
542 if ( article.text != NULL ) |
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 Log_err( "Busy article in Post_open." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
545 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
546 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
547 |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
548 article.flags = flags; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
549 |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
550 if ( ! getArticleText( text ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
551 return FALSE; |
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 if ( Db_contains( article.over.msgId ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
554 { |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
555 Post_close(); |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
556 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
|
557 return FALSE; |
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 |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
563 /* Process the posting */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
564 Bool |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
565 Post_post( void ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
566 { |
150
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
567 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
|
568 { |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
569 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
|
570 return TRUE; |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
571 } |
1c7303c71f66
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents:
136
diff
changeset
|
572 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
573 if ( ! checkPostableNewsgroup() ) |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
574 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
575 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
576 return ( article.control == NULL ) |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
577 ? ! postArticle() |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
578 : ! handleControl(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
579 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
580 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
581 /* 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
|
582 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
583 Post_close( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
584 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
585 if ( article.text != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
586 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
587 del_DynStr( article.text ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
588 article.text = NULL; |
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 if ( article.newsgroups != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
591 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
592 del_Itl( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
593 article.newsgroups = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
594 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
595 if ( article.control != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
596 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
597 del_Itl( article.control ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
598 article.control = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
599 } |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
600 article.approved = FALSE; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
601 article.posted = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
602 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
603 |
115
3b4db42990e0
[svn] Approved: header, group check before post, all external servers.
bears
parents:
100
diff
changeset
|
604 |