annotate src/post.c @ 136:55ba957023f9 noffle

[svn] do no longer always replace invalid message-IDs
author enz
date Wed, 23 Aug 2000 10:52:25 +0100
parents d45b0abe7c79
children 1c7303c71f66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
2 post.c
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
3
136
55ba957023f9 [svn] do no longer always replace invalid message-IDs
enz
parents: 117
diff changeset
4 $Id: post.c 202 2000-08-23 09:52:25Z enz $
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
5 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
6
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
7 #if HAVE_CONFIG_H
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
8 #include <config.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
9 #endif
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
10
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
11 #include <stdio.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
12 #include "post.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
13 #include <string.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
14 #include "common.h"
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
15 #include "configfile.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
16 #include "content.h"
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
17 #include "control.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
18 #include "database.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
19 #include "group.h"
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
20 #include "itemlist.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
21 #include "log.h"
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
22 #include "outgoing.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
23 #include "over.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
24 #include "protocol.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include "util.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 43
diff changeset
26 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 struct OverInfo
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 Str subject;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
31 Str from;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 Str date;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 Str msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 Str ref;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 size_t bytes;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
36 size_t lines;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
37 };
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 struct Article
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 {
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
41 DynStr *text; /* Processed article text */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
42 ItemList *newsgroups; /* Newsgroups for dispatch */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
43 ItemList *control; /* Control message? NULL if not */
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
44 Bool approved; /* Has Approved: header? */
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
45 Bool posted; /* Has it been put in the article database? */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46 struct OverInfo over;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
47 };
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
49 static struct Article article = { NULL, NULL, NULL, FALSE, FALSE,
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
50 { "", "", "", "", "", 0, 0 } };
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 /* Add the article to a group. */
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
53 static Bool
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
54 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
55 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
56 Over * over;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57 const char *msgId;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
58
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 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
60 article.over.from,
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
61 article.over.date,
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62 article.over.msgId,
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
63 article.over.ref,
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 article.over.bytes,
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
65 article.over.lines );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
66
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
67 msgId = article.over.msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
68
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
69 Cont_read( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
70 Cont_app( over );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
71 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
72
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
73 if ( !article.posted )
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 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
76 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
77 || ! 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
78 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79 article.posted = TRUE;
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 else
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 Str t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
84 const char *xref;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
86 xref = Db_xref( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 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
88 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
89 Db_setXref( msgId, t );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 Cont_write();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
93 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
94 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
95 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
96
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
97 static Bool
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
98 checkPostableNewsgroup( void )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
99 {
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
100 const char * grp;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
101 Bool knownGrp = FALSE;
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
102 Bool postAllowedGrp = TRUE;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
103 Bool local;
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 /*
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
106 * 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
107 * at least one known group.
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
108 */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
109 for( grp = Itl_first( article.newsgroups );
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
110 postAllowedGrp && grp != NULL;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
111 grp = Itl_next( article.newsgroups ) )
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 if ( Grp_exists( grp ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
114 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
115 local = Grp_local( grp );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
116 knownGrp = TRUE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
117 switch( Grp_postAllow( grp ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
118 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
119 case 'n':
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
120 postAllowedGrp = FALSE;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
121 break;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
122 case 'y':
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
123 break;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
124 case 'm':
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
125 /*
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
126 * Can post to moderated groups if *either*
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
127 * 1. Group is local and article approved, or
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
128 * 2. Group is external
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
129 */
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
130 postAllowedGrp =
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
131 ! local ||
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
132 article.approved;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
133 break;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
134 default:
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
135 /*
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
136 * Unknown mode for local groups. Forward
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
137 * to server for external groups; presumably the
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
138 * server knows what to do.
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
139 */
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
140 postAllowedGrp = ! local;
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 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
143 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
144 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
145
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
146 if ( ! knownGrp )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
147 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
148 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
149 return FALSE;
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 else if ( ! postAllowedGrp )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
152 {
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
153 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
154 return FALSE;
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 return TRUE;
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
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
160 /* 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
161 static Bool
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
162 getArticleText( const char *p )
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 DynStr * s;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
165 Str line, field, value;
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
166 Bool replyToFound, pathFound;
93
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
167 time_t t;
88
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 s = new_DynStr( 10000 );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
170 article.text = s;
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 memset( &article.over, 0, sizeof( article.over ) );
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
173 replyToFound = pathFound = FALSE;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
174
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
175 /* 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
176 while ( ( p = Utl_getHeaderLn( line, p ) ) != NULL
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
177 && line[ 0 ] != '\0'
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
178 && Prt_getField( field, value, line ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
179 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
180 /* Look for headers we need to stash. */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
181 if ( strcmp( field, "subject" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
182 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
183 Utl_cpyStr( article.over.subject, value );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
184 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
185 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
186 else if ( strcmp ( field, "from" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
187 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
188 Utl_cpyStr( article.over.from, value );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
189 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
190 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
191 else if ( strcmp ( field, "date" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
192 Utl_cpyStr( article.over.date, value );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
193 else if ( strcmp ( field, "references" ) == 0 )
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 Utl_cpyStr( article.over.ref, value );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
196 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
197 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
198 else if ( strcmp ( field, "message-id" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
199 Utl_cpyStr( article.over.msgId, value );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
200 else if ( strcmp ( field, "newsgroups" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
201 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
202 article.newsgroups = new_Itl( value, " ,\n\t" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
203 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
204 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
205 else if ( strcmp ( field, "control" ) == 0 )
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 article.control = new_Itl( value, " " );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
208 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
209 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
210 else if ( strcmp ( field, "reply-to" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
211 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
212 replyToFound = TRUE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
213 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
214 }
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
215 else if ( strcmp ( field, "approved" ) == 0 )
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
216 {
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
217 article.approved = TRUE;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
218 DynStr_appLn( s, line );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
219 }
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
220 else if ( strcmp ( field, "path" ) == 0 )
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
221 {
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
222 pathFound = TRUE;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
223 DynStr_appLn( s, line );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
224 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
225 else if ( strcmp ( field, "x-sender" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
226 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
227 DynStr_app( s, "X-NOFFLE-X-Sender: " );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
228 DynStr_appLn( s, value );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
229 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
230 else if ( strcmp ( field, "xref" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
231 Log_inf( "Xref header in post ignored" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
232 else
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
233 DynStr_appLn( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
234 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
235
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
236 /* Now sort header-related issues */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
237 if ( article.over.from[ 0 ] == '\0' )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
238 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
239 Log_err( "Posted message has no From field" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
240 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
241 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
242 if ( article.over.subject[ 0 ] == '\0' )
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 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
245 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
246 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
247 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
248 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
249 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
250 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
251 }
93
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
252
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
253 /* Ensure correctly formatted date */
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
254 t = Utl_parseNewsDate( article.over.date );
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
255 if ( t == (time_t) -1 )
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
256 {
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
257 time( &t );
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
258 Utl_newsDate( t, article.over.date );
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
259 }
100
af51bf245bc3 [svn] Fix stupid Date: bug
bears
parents: 93
diff changeset
260 DynStr_app( s, "Date: " );
af51bf245bc3 [svn] Fix stupid Date: bug
bears
parents: 93
diff changeset
261 DynStr_appLn( s, article.over.date );
93
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
262
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
263 /* 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
264 if ( Cfg_replaceMsgId() )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
265 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
266 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
267 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
268 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
269 else if ( article.over.msgId[ 0 ] == '\0' )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
270 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
271 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
272 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
273 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
274 DynStr_app( s, "Message-ID: " );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
275 DynStr_appLn( s, article.over.msgId );
93
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
276
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
277 /* Ensure Path header */
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
278 if ( ! pathFound )
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
279 {
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
280 Str path;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
281
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
282 Log_dbg( "Adding Path field to posted message." );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
283 DynStr_app( s, "Path: " );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
284 Utl_cpyStr( path, Cfg_pathHeader() );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
285 if ( path[ 0 ] == '\0' )
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
286 Prt_genPathHdr( path, article.over.from );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
287 DynStr_appLn( s, path );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
288 }
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
289
93
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
290 /* Ensure Reply-To header */
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
291 if ( ! replyToFound )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
292 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
293 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
294 DynStr_app( s, "Reply-To: " );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
295 DynStr_appLn( s, article.over.from );
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
93
eb522db0d032 [svn] Renamed date format and enforce correct date format on post
bears
parents: 88
diff changeset
298 /* 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
299 if ( p == NULL || p[ 0 ] == '\0' )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
300 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
301 Log_err( "Posted message has no body" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
302 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
303 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
304
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
305 /* 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
306 DynStr_appLn( s, "" );
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 /* Now pop on the rest of the body and count the lines & bytes */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
309 DynStr_app( s, p );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
310 for ( p++, article.over.lines = 0; *p != '\0'; p++ )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
311 if ( *p == '\n' )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
312 article.over.lines++;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
313 article.over.bytes = DynStr_len( s );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
314
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
315 return TRUE;
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
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
318 /* Add article to outgoing if needs be */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
319 static Bool
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
320 postExternal( void )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
321 {
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
322 const char * grp;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
323 Str serversSeen;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
324 Bool err;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
325
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
326 /*
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
327 * 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
328 * not seen the post already.
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
329 */
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
330 serversSeen[ 0 ] = '\0';
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
331 err = FALSE;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
332
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
333 for ( grp = Itl_first( article.newsgroups );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
334 grp != NULL;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
335 grp = Itl_next( article.newsgroups ) )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
336 {
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
337 if ( Grp_exists( grp ) && ! Grp_local( grp ) )
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
338 {
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
339 const char * servName = Grp_server( grp );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
340
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
341 if ( strstr( serversSeen, servName ) != NULL )
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
342 continue;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
343
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
344 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
345 {
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
346 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
347 err = TRUE;
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
348 }
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
349 Utl_catStr( serversSeen, " " );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
350 Utl_catStr( serversSeen, servName );
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
351 }
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
352 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
353
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
354 return err;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
355 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
356
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
357 /* 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
358 static Bool
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
359 controlCancel( const char *cancelId )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
360 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
361 return ( Ctrl_cancel( cancelId ) == CANCEL_NEEDS_MSG );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
362 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
363
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
364 /*
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
365 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
366 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
367 as ignored for local groups.
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 static Bool
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
370 handleControl( void )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
371 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
372 const char *grp;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
373 const char *op;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
374
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
375 op = Itl_first( article.control );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
376 if ( op == NULL )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
377 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
378 Log_err( "Malformed control line." );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
379 return TRUE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
380 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
381 else if ( strcasecmp( op, "cancel" ) == 0 )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
382 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
383 if ( ! controlCancel( Itl_next( article.control ) ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
384 return TRUE; /* Handled entirely locally */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
385 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
386 else
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
387 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
388 /* Log 'can't do' for internal groups. */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
389 for( grp = Itl_first( article.newsgroups );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
390 grp != NULL;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
391 grp = Itl_next( article.newsgroups ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
392 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
393 if ( Grp_exists( grp ) && Grp_local( grp ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
394 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
395 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
396 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
397
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
398 return postExternal();
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
399 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
400
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
401 static Bool
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
402 postArticle( void )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
403 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
404 const char *grp;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
405 Bool err;
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
406 Bool local;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
407 Bool postLocal;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
408
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
409 err = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
410 postLocal = Cfg_postLocal();
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
411
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
412 /*
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
413 * Run round first doing all local groups.
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
414 * 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
415 */
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
416 for( grp = Itl_first( article.newsgroups );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
417 grp != NULL;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
418 grp = Itl_next( article.newsgroups ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
419 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
420 local = Grp_local( grp );
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
421 if ( ! ( postLocal || local ) )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
422 continue;
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
423 err = addToGroup( grp ) && err;
88
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
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
426 return postExternal() && err;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
427 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
428
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
429 /* Register an article for posting. */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
430 Bool
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
431 Post_open( const char * text )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
432 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
433 if ( article.text != NULL )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
434 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
435 Log_err( "Busy article in Post_open." );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
436 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
437 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
438
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
439 if ( ! getArticleText( text ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
440 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
441
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
442 if ( Db_contains( article.over.msgId ) )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
443 {
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
444 Post_close();
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
445 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
446 return FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
447 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
448
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
449 return TRUE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
450 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
451
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
452 /* Process the posting */
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
453 Bool
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
454 Post_post( void )
88
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 if ( ! checkPostableNewsgroup() )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
457 return FALSE;
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 return ( article.control == NULL )
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
460 ? ! postArticle()
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
461 : ! handleControl();
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
462 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
463
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
464 /* 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
465 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466 Post_close( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 {
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
468 if ( article.text != NULL )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
469 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
470 del_DynStr( article.text );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
471 article.text = NULL;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
472 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
473 if ( article.newsgroups != NULL )
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
474 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
475 del_Itl( article.newsgroups );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
476 article.newsgroups = NULL;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
477 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
478 if ( article.control != 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 del_Itl( article.control );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
481 article.control = NULL;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 64
diff changeset
482 }
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
483 article.approved = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 article.posted = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
485 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
486
115
3b4db42990e0 [svn] Approved: header, group check before post, all external servers.
bears
parents: 100
diff changeset
487