Mercurial > noffle
annotate src/post.c @ 88:1fcdced0246e noffle
[svn] Move posting code to post.c, add command line posting
author | bears |
---|---|
date | Thu, 18 May 2000 13:17:23 +0100 |
parents | 7250be163ec4 |
children | eb522db0d032 |
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 |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
4 $Id: post.c 100 2000-05-18 12:17:23Z bears $ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
5 */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
6 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
7 #if HAVE_CONFIG_H |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
8 #include <config.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
9 #endif |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
10 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
11 #include <stdio.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
12 #include "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 */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
44 Bool posted; /* Has it been put in the article database? */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
45 const char *server; /* Server for external post */ |
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 |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
49 static struct Article article = { NULL, NULL, NULL, FALSE, NULL, |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
98 checkPostableNewsgroup( Bool localOnly ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
99 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
100 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
101 Bool knownGrp = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
102 Bool postAllowedGrp = FALSE; |
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 /* |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
106 Check at least one group is known. Look for external group and |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
107 set server. |
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 article.server = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
110 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
111 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
112 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
113 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
114 if ( Grp_exists( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
115 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
116 local = Grp_local( grp ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
117 if ( localOnly && ! local ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
118 continue; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
119 knownGrp = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
120 switch( Grp_postAllow( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
121 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
122 case 'n': |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
123 if ( localOnly ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
124 postAllowedGrp = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
125 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
126 case 'y': |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
127 postAllowedGrp = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
128 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
129 default: |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
130 if ( localOnly ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
131 postAllowedGrp = TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
132 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
133 /* Can't post to moderated local groups. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
134 postAllowedGrp = ! local; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
135 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
136 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
137 if ( postAllowedGrp && ! local && article.server == NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
138 article.server = Grp_server( grp ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
139 if ( postAllowedGrp && article.server != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
140 break; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
141 } |
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 if ( ! knownGrp ) |
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 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
|
147 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
148 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
149 else if ( ! postAllowedGrp ) |
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 Log_err( "No group permits posting" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
152 return FALSE; |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
155 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
156 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
157 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
158 /* 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
|
159 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
160 getArticleText( const char *p ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
161 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
162 DynStr * s; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
163 Str line, field, value; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
164 Bool replyToFound; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
165 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
166 s = new_DynStr( 10000 ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
167 article.text = s; |
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 memset( &article.over, 0, sizeof( article.over ) ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
170 replyToFound = FALSE; |
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 /* 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
|
173 while ( ( p = Utl_getHeaderLn( line, p ) ) != NULL |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
174 && line[ 0 ] != '\0' |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
175 && Prt_getField( field, value, line ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
176 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
177 /* Look for headers we need to stash. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
178 if ( strcmp( field, "subject" ) == 0 ) |
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 Utl_cpyStr( article.over.subject, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
181 DynStr_appLn( s, line ); |
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 else if ( strcmp ( field, "from" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
184 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
185 Utl_cpyStr( article.over.from, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
186 DynStr_appLn( s, line ); |
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 else if ( strcmp ( field, "date" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
189 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
190 Utl_cpyStr( article.over.date, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
191 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
192 } |
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 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
215 else if ( strcmp ( field, "x-sender" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
216 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
217 DynStr_app( s, "X-NOFFLE-X-Sender: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
218 DynStr_appLn( s, value ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
219 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
220 else if ( strcmp ( field, "xref" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
221 Log_inf( "Xref header in post ignored" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
222 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
223 DynStr_appLn( s, line ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
224 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
225 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
226 /* Now sort header-related issues */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
227 if ( article.over.from[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
228 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
229 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
|
230 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
231 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
232 if ( article.over.subject[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
233 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
234 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
|
235 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
236 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
237 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
|
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 valid Newsgroups 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 ( Cfg_replaceMsgId() ) |
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 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
|
245 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
|
246 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
247 else if ( article.over.msgId[ 0 ] == '\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 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
|
250 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
|
251 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
252 else if ( ! Prt_isValidMsgId( article.over.msgId ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
253 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
254 Log_ntc( "Replacing invalid Message-ID '%s'", article.over.msgId ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
255 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
|
256 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
257 DynStr_app( s, "Message-ID: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
258 DynStr_appLn( s, article.over.msgId ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
259 if ( ! replyToFound ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
260 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
261 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
|
262 DynStr_app( s, "Reply-To: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
263 DynStr_appLn( s, article.over.from ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
264 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
265 if ( article.over.date[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
266 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
267 time_t t; |
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 time( &t ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
270 Utl_rfc822Date( t, article.over.date ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
271 DynStr_app( s, "Date: " ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
272 DynStr_appLn( s, article.over.date ); |
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 if ( p == NULL || p[ 0 ] == '\0' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
275 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
276 Log_err( "Posted message has no body" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
277 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
278 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
279 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
280 /* 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
|
281 DynStr_appLn( s, "" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
282 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
283 /* 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
|
284 DynStr_app( s, p ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
285 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
|
286 if ( *p == '\n' ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
287 article.over.lines++; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
288 article.over.bytes = DynStr_len( s ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
289 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
290 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
291 } |
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 /* Add article to outgoing if needs be */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
294 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
295 postExternal( void ) |
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 if ( article.server == NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
298 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
299 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
300 if ( ! Out_add( article.server, article.over.msgId, article.text ) ) |
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 Log_err( "Cannot add posted article to outgoing directory" ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
303 return FALSE; |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
306 return TRUE; |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
309 /* 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
|
310 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
311 controlCancel( const char *cancelId ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
312 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
313 return ( Ctrl_cancel( cancelId ) == CANCEL_NEEDS_MSG ); |
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 |
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 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
|
318 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
|
319 as ignored for local groups. |
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 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
322 handleControl( void ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
323 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
324 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
325 const char *op; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
326 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
327 op = Itl_first( article.control ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
328 if ( op == NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
329 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
330 Log_err( "Malformed control line." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
331 return TRUE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
332 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
333 else if ( strcasecmp( op, "cancel" ) == 0 ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
334 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
335 if ( ! controlCancel( Itl_next( article.control ) ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
336 return TRUE; /* Handled entirely locally */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
337 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
338 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
339 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
340 /* Log 'can't do' for internal groups. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
341 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
342 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
343 grp = Itl_next( article.newsgroups ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
344 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
345 if ( Grp_exists( grp ) && Grp_local( grp ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
346 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
|
347 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
348 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
349 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
350 return postExternal(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
351 } |
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 static Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
354 postArticle( Bool localOnly ) |
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 const char *grp; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
357 Bool err; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
358 Bool postLocal; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
359 Bool local; |
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 err = FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
362 postLocal = Cfg_postLocal(); |
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 /* Run round & post locally */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
365 for( grp = Itl_first( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
366 grp != NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
367 grp = Itl_next( article.newsgroups ) ) |
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 local = Grp_local( grp ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
370 if ( localOnly && ! local ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
371 continue; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
372 if ( ( local || postLocal ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
373 && ( Grp_postAllow( grp ) == 'y' || localOnly ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
374 err = addToGroup( grp ) && err; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
375 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
376 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
377 if ( localOnly ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
378 return err; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
379 else |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
380 return postExternal() && err; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
381 } |
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 /* Register an article for posting. */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
384 Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
385 Post_open( const char * text ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
386 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
387 if ( article.text != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
388 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
389 Log_err( "Busy article in Post_open." ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
390 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
391 } |
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 ( ! getArticleText( text ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
394 return FALSE; |
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 if ( Db_contains( article.over.msgId ) ) |
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 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
|
399 return FALSE; |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
402 return TRUE; |
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 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
405 /* Process the posting */ |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
406 Bool |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
407 Post_post( Bool localOnly ) |
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 if ( ! checkPostableNewsgroup( localOnly ) ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
410 return FALSE; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
411 |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
412 return ( article.control == NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
413 ? ! postArticle( localOnly ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
414 : ! handleControl(); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
415 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
416 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
417 /* 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
|
418 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
419 Post_close( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
420 { |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
421 if ( article.text != NULL ) |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
422 { |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
423 del_DynStr( article.text ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
424 article.text = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
425 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
426 if ( article.newsgroups != NULL ) |
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 del_Itl( article.newsgroups ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
429 article.newsgroups = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
430 } |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
431 if ( article.control != NULL ) |
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 del_Itl( article.control ); |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
434 article.control = NULL; |
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
435 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
436 article.posted = FALSE; |
88
1fcdced0246e
[svn] Move posting code to post.c, add command line posting
bears
parents:
64
diff
changeset
|
437 article.server = NULL; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
438 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
439 |