annotate src/noffle.c @ 500:614a3177b15c noffle tip

Add mail-from option. Some modern mail systems will try and ensure the sender email is a legitimate address. Which will fail if there isn't such an address.
author Jim Hague <jim.hague@acm.org>
date Wed, 14 Aug 2013 12:04:39 +0100
parents a04c52f87b6e
children
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 noffle.c
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
3
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
4 Main program. Implements specified actions, but running as server, which
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
5 is done by Server_run(), declared in server.h.
43
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 Locking policy: lock access to databases while noffle is running, but
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
8 not as server. If noffle runs as server, locking is performed while
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
9 executing NNTP commands, but temporarily released if no new command is
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
10 received for some seconds (to allow multiple clients connect at the same
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
11 time).
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
12
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
13 $Id: noffle.c 629 2004-10-13 23:26:48Z bears $
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
14 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
15
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
16 #if HAVE_CONFIG_H
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
17 #include <config.h>
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
18 #endif
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
19
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
20 #include <ctype.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
21 #include <errno.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
22 #include <signal.h>
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
23 #include <string.h>
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
24 #include <sys/time.h>
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include <sys/resource.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <syslog.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include <unistd.h>
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
28 #include <sys/types.h>
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
29 #include <sys/stat.h>
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
30 #include "common.h"
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
31 #include "authenticate.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 #include "client.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "content.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 #include "control.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
36 #include "database.h"
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
37 #include "expire.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 #include "fetch.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 #include "fetchlist.h"
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 237
diff changeset
40 #include "filter.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
41 #include "group.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42 #include "itemlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
43 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
44 #include "online.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
45 #include "outgoing.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46 #include "over.h"
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
47 #include "post.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48 #include "pseudo.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 #include "util.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
50 #include "server.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51 #include "request.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 #include "lock.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
53 #include "portable.h"
208
mirkol
parents: 192
diff changeset
54 #include "wildmat.h"
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 struct Noffle
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
58 Bool queryGrps;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 Bool queryDsc;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60 Bool queryTimes;
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
61 Bool lockAtStartup;
208
mirkol
parents: 192
diff changeset
62 char *serverPattern;
mirkol
parents: 192
diff changeset
63 } noffle = { FALSE, FALSE, FALSE, TRUE, NULL };
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
65 static Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
66 doArt( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
67 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
68 const char *id;
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
69 Bool res = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
70
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
71 if ( strcmp( msgId, "all" ) == 0 )
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 ( ! Db_first( &id ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
74 fprintf( stderr, "Database empty.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
75 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
76 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 {
477
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
78 /*
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
79 * Output articles in rnews format. The number after
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
80 * the rnews header is the length of the article in bytes,
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
81 * counting line endings as '\n'.
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
82 */
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
83 const char *header = Db_header( id );
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
84 const char *body = Db_body( id );
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
85
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
86 printf( "#! rnews %d\n%s\n%s\n",
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
87 strlen(header) + strlen(body) + 2,
48be71391b9d [svn] * docs/noffle.1,src/noffle.c: When outputing the entire message base
bears
parents: 474
diff changeset
88 header, body);
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
89 res = TRUE;
43
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 while ( Db_next( &id ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
93 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
94 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
95 if ( ! Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
96 fprintf( stderr, "Not in database.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
97 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
98 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
99 printf( "%s\n%s", Db_header( msgId ), Db_body( msgId ) );
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
100 res = TRUE;
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
101 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
102 }
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
103
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
104 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
105 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
107 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
108 doCancel( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
109 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
110 switch( Ctrl_cancel( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
111 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
112 case CANCEL_NO_SUCH_MSG:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
113 printf( "No such message '%s'.\n", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
115
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
116 case CANCEL_OK:
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 366
diff changeset
117 printf( "Message '%s' cancelled.\n", msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
118 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
119
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
120 case CANCEL_NEEDS_MSG:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
121 printf( "Message '%s' cancelled in local database only.\n", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
122 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
123 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
124 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
125
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
126 /* List articles requested from one particular server */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128 listRequested1( const char* serv )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
129 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
130 Str msgid;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
131
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
132 if ( ! Req_first( serv, msgid ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
134 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
135 printf( "%s %s\n", msgid, serv );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
136 while ( Req_next( msgid ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
137 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
138
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
139 /* List requested articles. List for all servers if serv = "all" or serv =
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
140 NULL. */
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
141 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
142 doRequested( const char *arg )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
143 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
144 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
145
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
146 if ( ! arg || ! strcmp( arg, "all" ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
147 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
148 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
149 while ( Cfg_nextServ( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
150 listRequested1( serv );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
152 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
153 listRequested1( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
155
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
156
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
157 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
158 doDb( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
159 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
160 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
161
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
162 if ( ! Db_first( &msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
163 fprintf( stderr, "Database empty.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
164 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
165 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
166 printf( "%s\n", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
167 while ( Db_next( &msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
168 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
169
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
170 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
171 doFetch( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
172 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
173 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
174
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
175 if ( ! Lock_getFetchLock( LOCK_NOWAIT ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
176 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
177 Log_err( "Another 'noffle --fetch' is in progress" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
178 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
179 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
180
306
52ce87d25641 [svn] added logging when fetching news started/finished
godisch
parents: 293
diff changeset
181 Log_inf( "Fetching news..." );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
182 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
183 while ( Cfg_nextServ( serv ) )
208
mirkol
parents: 192
diff changeset
184 if ( ! noffle.serverPattern
mirkol
parents: 192
diff changeset
185 || Wld_match( serv, noffle.serverPattern ) )
mirkol
parents: 192
diff changeset
186 if ( Fetch_init( serv ) )
mirkol
parents: 192
diff changeset
187 {
mirkol
parents: 192
diff changeset
188 Bool connOK;
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
189
208
mirkol
parents: 192
diff changeset
190 connOK = Fetch_postArts();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
191
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 237
diff changeset
192 Flt_init( serv ); /* get filter data before processGrps() calls Utl_stamp(). */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 237
diff changeset
193
208
mirkol
parents: 192
diff changeset
194 connOK = connOK && Fetch_getNewGrps();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
196 /* Get overviews of new articles and store IDs of new articles
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
197 that are to be fetched becase of FULL or THREAD mode in the
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
198 request database. */
208
mirkol
parents: 192
diff changeset
199 connOK = connOK && Fetch_updateGrps();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
200
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
201 /* get requested articles */
208
mirkol
parents: 192
diff changeset
202 connOK = connOK && Fetch_getReq_();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
203
208
mirkol
parents: 192
diff changeset
204 Fetch_close();
mirkol
parents: 192
diff changeset
205 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
206
306
52ce87d25641 [svn] added logging when fetching news started/finished
godisch
parents: 293
diff changeset
207 Log_inf( "Fetching news finished." );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
208 Lock_releaseFetchLock();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
209 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
210
293
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
211 /* List articles queued for posting to one particular server */
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
212 static void
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
213 listOutgoing1( const char* serv )
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
214 {
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
215 Str msgid;
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
216
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
217 if ( ! Out_first( serv, msgid, NULL ) )
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
218 return;
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
219 do
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
220 printf( "%s %s\n", msgid, serv );
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
221 while ( Out_next( msgid, NULL ) );
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
222 }
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
223
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
224 /* List articles queued for posting to a particular server. */
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
225 static void
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
226 doOutgoing( const char *arg )
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
227 {
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
228 Str serv;
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
229
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
230 Cfg_beginServEnum();
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
231 while ( Cfg_nextServ( serv ) )
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
232 if ( ! arg || Wld_match( serv, arg ) )
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
233 listOutgoing1( serv );
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
234 }
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
235
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
236 static Bool
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
237 doPost( FILE *f, unsigned flags )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
238 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
239 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
240 DynStr *s;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
241 Bool res;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
242
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
243 s = new_DynStr( 10000 );
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
244 while ( fgets( line, MAXCHAR, f ) != NULL )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
245 DynStr_app( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
246
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
247 res = TRUE;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
248 if ( ! Post_open( DynStr_str( s ), flags ) )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
249 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
250 fprintf( stderr, "Post failed: Malformed article.\n" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
251 res = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
252 }
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
253 else if ( ! Post_post() )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
254 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
255 fprintf( stderr, "Post failed: Can't post to group.\n" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
256 res = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
257 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
258 Post_close();
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
259 return res;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
260 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
261
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
262 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
263 doQuery( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
264 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
265 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
267 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 while ( Cfg_nextServ( serv ) )
208
mirkol
parents: 192
diff changeset
269 if ( ! noffle.serverPattern
mirkol
parents: 192
diff changeset
270 || Wld_match( serv, noffle.serverPattern ) )
mirkol
parents: 192
diff changeset
271 if ( Fetch_init( serv ) )
mirkol
parents: 192
diff changeset
272 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
273 int status = STAT_OK;
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
274
208
mirkol
parents: 192
diff changeset
275 if ( noffle.queryGrps )
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
276 status = Client_getGrps();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
277 if ( status == STAT_OK && noffle.queryDsc )
208
mirkol
parents: 192
diff changeset
278 Client_getDsc();
mirkol
parents: 192
diff changeset
279 Fetch_close();
mirkol
parents: 192
diff changeset
280 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
281 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
282
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
283 static void
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
284 doExpire( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
285 {
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
286 Exp_expire();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
287 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
288
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
289 static Bool
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
290 doRebuild( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
291 {
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
292 Bool res = TRUE;
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
293
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
294 if ( ! Db_rebuild() )
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
295 {
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
296 res = FALSE;
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
297 fprintf( stderr, "Rebuild failed.\n" );
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
298 }
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
299 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
300 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
301
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
302 static Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
303 doCreateLocalGroup( const char * name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
304 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
305 Str grp;
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
306 Bool res = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
307
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
308 Utl_cpyStr( grp, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
309 Utl_toLower( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
310 name = Utl_stripWhiteSpace( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
311
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
312 if ( Grp_exists( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
313 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
314 fprintf( stderr, "'%s' already exists.\n", name );
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
315 return FALSE;
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
316 }
250
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
317 if ( ! Grp_isValidName( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
318 fprintf( stderr, "'%s' invalid group name.\n", name );
250
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
319 else if ( Grp_isForbiddenName( name ) )
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
320 fprintf( stderr, "'%s' forbidden group name.\n", name );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
321 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 Log_inf( "Creating new local group '%s'", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 Grp_create( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
325 Grp_setLocal( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
326 printf( "New local group '%s' created.\n", name );
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
327 res = TRUE;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
328
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
329 snprintf( grp, MAXCHAR, "%s/groupinfo.lastupdate", Cfg_spoolDir() );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
330 Utl_stamp( grp );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
331 }
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
332
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
333 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
334 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
335
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
336 static Bool
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
337 doDeleteLocalGroup( const char * name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
338 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
339 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
340
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
341 Utl_cpyStr( grp, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
342 Utl_toLower( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
343 name = Utl_stripWhiteSpace( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
344
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
345 if ( ! Grp_exists( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
346 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
347 fprintf( stderr, "'%s' does not exist.\n", name );
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
348 return FALSE;
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
349 }
250
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
350 if ( ! Grp_isValidName( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
351 {
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
352 fprintf( stderr, "'%s' invalid group name. Skipping deletion of overviews.\n", name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
353 Log_inf( "Deleting invalid group '%s' without deleting overviews.", name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
354 Grp_delete( name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
355 printf( "Group '%s' deleted.\n", name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
356 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
357 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
358 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
359 int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
360
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
361 Log_inf( "Deleting group '%s'", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
362
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
363 /*
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
364 Delete all articles that are only in the group or are
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
365 crossposted only to groups that do not exist on this
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
366 server.
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
367 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
368 Cont_read( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
369 for ( i = Cont_first(); i <= Cont_last(); i++ )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
370 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
371 const Over *over;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
372 Bool toDelete;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
373 Str msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
374
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
375 if ( ! Cont_validNumb( i ) )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
376 continue;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
377
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
378 over = Cont_get( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
379 toDelete = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
380 if ( over != NULL )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
381 {
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
382 ItemList *xrefs;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
383 const char *xref;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
384 int localXrefs = 0;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
385
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
386 Utl_cpyStr( msgId, Ov_msgId( over ) );
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
387 xrefs = new_Itl( Db_xref( msgId ), " " );
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
388 for ( xref = Itl_first( xrefs );
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
389 xref != NULL;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
390 xref = Itl_next( xrefs) )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
391 {
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
392 Str xgrp;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
393 int no;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
394
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 366
diff changeset
395 if ( sscanf( xref, "%"MAXCHAR_STR"[^:]:%d", xgrp, &no ) != 2 )
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
396 {
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
397 /* Malformed xref - leave article just in case */
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
398 Log_err( "Malformed Xref: entry in %s: %s",
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
399 msgId, xref);
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
400 toDelete = FALSE;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
401 break;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
402 }
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
403
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
404 if ( Cont_exists( xgrp ) )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
405 ++localXrefs;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
406 }
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
407
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
408 if ( localXrefs > 1 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
409 toDelete = FALSE;
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
410 del_Itl( xrefs );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
411 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
412 Cont_delete( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
413 if ( toDelete )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
414 Db_delete( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
415 }
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
416 if ( Cont_write() )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
417 {
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
418 Grp_delete( name );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
419 printf( "Group '%s' deleted.\n", name );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
420 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
421 }
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
422
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
423 return TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
424 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
425
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
426 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
427 doList( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
428 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
429 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
430 int i, size;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
431 const char *name, *modeStr = "";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
432
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
433 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 size = Fetchlist_size();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
435 if ( size == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
436 fprintf( stderr, "Fetch list is empty.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
437 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
438 for ( i = 0; i < size; ++i )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
439 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
440 Fetchlist_element( &name, &mode, i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
441 switch ( mode )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
442 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
443 case FULL:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
444 modeStr = "full"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
445 case THREAD:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
446 modeStr = "thread"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
447 case OVER:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
448 modeStr = "over"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
449 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
450 printf( "%s %s %s\n", name, Grp_server( name ), modeStr );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
451 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
452 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
453
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
454 /* A modify command. argc/argv start AFTER '-m'. */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
455 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
456 doModify( const char *cmd, int argc, char **argv )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
457 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
458 const char *grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
459
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460 if ( argc < 2 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
461 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
462 fprintf( stderr, "Insufficient arguments to -m\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
463 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
464
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
465 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466 else if ( strcmp( cmd, "desc" ) != 0
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 && strcmp( cmd, "post" ) != 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
468 {
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
469 fprintf( stderr, "Unknown argument -m %s\n", cmd );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
470 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
471 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
472
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473 grp = argv[ 0 ];
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474 argv++;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
475 argc--;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
477 if ( strcmp( cmd, "desc" ) == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
478 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
479 Str desc;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
481 Utl_cpyStr( desc, *( argv++ ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
482 while ( --argc > 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
483 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 Utl_catStr( desc, " " );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
485 Utl_catStr( desc, *( argv++ ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
486 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
487
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
488 Grp_setDsc( grp, desc );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
489 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
490 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
491 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
492 char c;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
493
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
494 if ( ! Grp_local( grp ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
495 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
496 fprintf( stderr, "%s is not a local group\n", grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
498 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
499
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
500 c = **argv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
501 if ( c == 'y' || c == 'm' || c == 'n' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
502 Grp_setPostAllow( grp, c );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
503 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
504 {
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
505 fprintf( stderr, "Access must be 'y', 'n' or 'm'\n" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
506 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
507 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
508 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
509
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
510 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
511 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
512
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
513 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
514 doGrps( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
515 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
516 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
517 Str dateLastAccess, dateCreated;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
518 time_t lastAccess, created;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
519
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
520 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
521 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
522 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
523 lastAccess = Grp_lastAccess( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
524 created = Grp_created( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
525 ASSERT( lastAccess >= 0 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
526 ASSERT( created >= 0 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
527 strftime( dateLastAccess, MAXCHAR, "%Y-%m-%d %H:%M:%S",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
528 localtime( &lastAccess ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
529 strftime( dateCreated, MAXCHAR, "%Y-%m-%d %H:%M:%S",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
530 localtime( &created ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
531 printf( "%s\t%s\t%i\t%i\t%i\t%c\t%s\t%s\t%s\n",
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
532 g, Grp_server( g ), Grp_first( g ), Grp_last( g ),
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
533 Grp_rmtNext( g ), Grp_postAllow( g ), dateCreated,
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
534 dateLastAccess, Grp_dsc( g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
535 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
536 while ( Grp_nextGrp( &g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
537 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
538
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
539 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
540 doSubscribe( const char *name, FetchMode mode )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
541 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
542 if ( ! Grp_exists( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
543 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
544 fprintf( stderr, "%s is not available at remote servers.\n", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
545 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
546 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
547 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
548 if ( Fetchlist_add( name, mode ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
549 printf( "Adding %s to fetch list in %s mode.\n",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
550 name, mode == FULL ? "full" : mode == THREAD ?
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
551 "thread" : "overview" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
552 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
553 printf( "%s is already in fetch list. Mode is now: %s.\n",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
554 name, mode == FULL ? "full" : mode == THREAD ?
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
555 "thread" : "overview" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
556 if ( ! Fetchlist_write() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
557 fprintf( stderr, "Could not save fetchlist.\n" );
191
28488e0e3630 [svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is
bears
parents: 188
diff changeset
558 Grp_setLastAccess( name );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
559 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
560 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
561
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
562 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
563 doUnsubscribe( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
564 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
565 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
566 if ( ! Fetchlist_remove( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
567 printf( "%s is not in fetch list.\n", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
568 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
569 printf( "%s removed from fetch list.\n", name );
102
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
570 if ( Fetchlist_write() )
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
571 Grp_setRmtNext( name, GRP_RMT_NEXT_NOT_SUBSCRIBED );
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
572 else
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
573 fprintf( stderr, "Could not save fetchlist.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
574 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
575
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
576 static void
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
577 doUninteresting( const char *msgId )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
578 {
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
579 unsigned status;
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
580 Str server;
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
581
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
582 if ( ! Db_contains( msgId ) )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
583 fprintf( stderr, "Not in database.\n" );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
584 else
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
585 {
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
586 /* Remove INTERESTING status */
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
587 status = Db_status( msgId );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
588 status &= ~DB_INTERESTING;
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
589 Db_setStatus( msgId, status );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
590
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
591 /* And remove from requested articles queue if server is not local */
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
592 if ( ! Db_findServer( msgId, server ) )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
593 Log_err( "No server for message %s", msgId );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
594 else if ( strcmp( server, GRP_LOCAL_SERVER_NAME ) != 0 )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
595 Req_remove( server, msgId );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
596 }
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
597 }
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
598
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
599 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
600 printUsage( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
601 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
602 static const char *msg =
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
603 "Usage: noffle <option>\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
604 "Option is one of the following:\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
605 " -a | --article <msg id>|all Show article(s) in database\n"
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
606 " -B | --rebuild Rebuild article database\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
607 " -c | --cancel <msg id> Remove article from database\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
608 " -C | --create <grp> Create a local group\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
609 " -d | --database Show content of article database\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
610 " -D | --delete <grp> Delete a group\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
611 " -e | --expire Expire articles\n"
208
mirkol
parents: 192
diff changeset
612 " -f | --fetch [server] Get newsfeed from server/post articles\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
613 " -g | --groups Show all groups available at server\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
614 " -h | --help Show this text\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
615 " -l | --list List groups on fetch list\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
616 " -m | --modify desc <grp> <desc> Modify a group description\n"
390
2ad4c1c97734 [svn] * src/client.c: Return correct status from Client_postArt() and add
bears
parents: 377
diff changeset
617 " -m | --modify post <grp> (y|m|n) Modify posting status of a local group\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
618 " -n | --online Switch to online mode\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
619 " -o | --offline Switch to offline mode\n"
293
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
620 " -O | --outgoing [server] List articles queued for posting\n"
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
621 " -p | --post Post article on stdin\n"
208
mirkol
parents: 192
diff changeset
622 " -q | --query groups [server] Get group list from server\n"
mirkol
parents: 192
diff changeset
623 " -q | --query desc [server] Get group descriptions from server\n"
391
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
624 " -r | --server [auth] Run as server on stdin/stdout\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
625 " -R | --requested List articles marked for download\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
626 " -s | --subscribe-over <grp> Add group to fetch list (overview)\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
627 " -S | --subscribe-full <grp> Add group to fetch list (full)\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
628 " -t | --subscribe-thread <grp> Add group to fetch list (thread)\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
629 " -u | --unsubscribe <grp> Remove group from fetch list\n"
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
630 " -U | --uninteresting <msg id> Article must be read again for download\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
631 " -v | --version Print version\n";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
632 fprintf( stderr, "%s", msg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
633 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
634
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
635
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
636 /* Check we are 'root' or the noffle user (usually 'news') */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
637 static Bool
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
638 checkCurrentUser( void )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
639 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
640 if ( ! Auth_checkPrivs() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
641 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
642
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
643 /*
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
644 * If we're noffle.lockAtStartup, we need to drop privs now.
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
645 * Otherwise we're a server, and privs get dropped after authentication.
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
646 */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
647 if ( noffle.lockAtStartup )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
648 if ( ! Auth_dropPrivs() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
649 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
650
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
651 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
652 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
653
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
654 /*
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
655 Check file ownership and permissions.
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
656 This assumes we have cd'd to the spool directory.
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
657 */
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
658 static Bool
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
659 checkFileOwnership( void )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
660 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
661 Str confFile;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
662 struct stat statBuf;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
663
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
664 Utl_cpyStr( confFile, CONFIGFILE );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
665 if ( stat( confFile, &statBuf ) == 0 )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
666 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
667 if ( ( statBuf.st_mode & S_IROTH ) != 0 )
474
e63a3bc27a75 [svn] * src/noffle.c: Security warning message about config file being globally
bears
parents: 461
diff changeset
668 Log_inf( "Security warning: %s is globally readable.", confFile );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
669 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
670
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
671 return TRUE;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
672 }
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
673
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
674 /*
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
675 Allow core files: Change core limit and change working directory
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
676 to spool directory, where news has write permissions.
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
677 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
678 static void
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
679 enableCorefiles( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
680 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
681 struct rlimit lim;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
682
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
683 if ( getrlimit( RLIMIT_CORE, &lim ) != 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
684 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
685 Log_err( "Cannot get system core limit: %s", strerror( errno ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
686 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
687 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
688 lim.rlim_cur = lim.rlim_max;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
689 if ( setrlimit( RLIMIT_CORE, &lim ) != 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
690 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
691 Log_err( "Cannot set system core limit: %s", strerror( errno ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
692 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
693 }
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
694 Log_dbg( LOG_DBG_NOFFLE, "Core limit set to %i", lim.rlim_max );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
695 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
696
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
697 static Bool
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
698 initNoffle( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
699 {
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
700 Log_init( "noffle", noffle.lockAtStartup, LOG_NEWS );
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
701
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
702 Cfg_read();
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
703 Log_dbg( LOG_DBG_NOFFLE, "NOFFLE version %s", Cfg_version() );
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
704
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
705 if ( ! checkCurrentUser() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
706 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
707
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
708 /* cd to the spool directory */
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
709 if ( chdir( Cfg_spoolDir() ) != 0 )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
710 {
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
711 Log_err( "Cannot change to directory '%s'", Cfg_spoolDir() );
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
712 return FALSE;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
713 }
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
714 Log_dbg( LOG_DBG_NOFFLE, "Changed to directory '%s'", Cfg_spoolDir() );
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
715
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
716 if ( ! checkFileOwnership() )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
717 return FALSE;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
718
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
719 if ( noffle.lockAtStartup )
98
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
720 if ( ! Lock_openDatabases() )
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
721 return FALSE;
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
722 enableCorefiles();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
723 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
724 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
725
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
726 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
727 closeNoffle( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
728 {
281
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
729 if ( Lock_gotLock() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
730 Lock_closeDatabases();
165
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
731 Lock_syncDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
732 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
733
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
734 static RETSIGTYPE
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
735 bugReport( int sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
736 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
737 Log_err( "Received SIGSEGV. Please submit a bug report" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
738 signal( SIGSEGV, SIG_DFL );
165
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
739
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
740 /* Attempt to save database state before passing on sig. */
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
741 Lock_syncDatabases();
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
742
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
743 raise( sig );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
744 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
745
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
746 static RETSIGTYPE
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
747 logSignal( int sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
748 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
749 const char *name;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
750 Bool err = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
751
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
752 switch ( sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
753 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
754 case SIGABRT:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
755 name = "SIGABRT"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
756 case SIGFPE:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
757 name = "SIGFPE"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
758 case SIGILL:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
759 name = "SIGILL"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
760 case SIGINT:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
761 name = "SIGINT"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
762 case SIGTERM:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
763 name = "SIGTERM"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
764 case SIGPIPE:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
765 name = "SIGPIPE"; err = FALSE; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
766 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
767 name = "?"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
768 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
769 if ( err )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
770 Log_err( "Received signal %i (%s). Aborting.", sig, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
771 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
772 Log_inf( "Received signal %i (%s). Aborting.", sig, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
773 signal( sig, SIG_DFL );
165
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
774
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
775 /* Attempt to save database state before passing on sig. */
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
776 Lock_syncDatabases();
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
777
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
778 raise( sig );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
779 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
780
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
781 static void
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
782 printInewsUsage( void )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
783 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
784 static const char *msg =
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
785 "Usage: inews [-D] [-O] [-S] [input]\n"
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
786 " -D Debug - send article to stdout and don't post\n"
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
787 " -O Don't add Organization header\n"
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
788 " -S Don't add .signature\n"
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
789 " input File containing message, standard input if none specified.\n"
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
790 "For compatability, -h, -A, -V, -W are ignored and -N is\n"
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
791 "equivalent to -D.\n";
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
792 fprintf( stderr, "%s", msg );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
793 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
794
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
795 static int
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
796 doInews( int argc, char **argv )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
797 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
798 int result;
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
799 unsigned flags;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
800 FILE *f;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
801
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
802 UNUSED( argc );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
803
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
804 noffle.lockAtStartup = TRUE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
805
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
806 /* Process options */
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
807 flags = POST_ADD_ORG | POST_ADD_SIG | POST_ADD_FROM;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
808 for ( ; argv[0] != NULL && argv[0][0] == '-' ; argv++ )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
809 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
810 if ( argv[0][2] != '\0' )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
811 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
812 printInewsUsage();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
813 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
814 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
815
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
816 switch( argv[0][1] )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
817 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
818 case 'h':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
819 case 'A':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
820 case 'V':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
821 case 'W':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
822 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
823 case 'N':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
824 case 'D':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
825 flags |= POST_DEBUG;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
826 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
827 case 'O':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
828 flags &= ~POST_ADD_ORG;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
829 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
830 case 'S':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
831 flags &= ~POST_ADD_SIG;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
832 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
833 default:
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
834 printInewsUsage();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
835 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
836 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
837 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
838
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
839 if ( argv[0] == NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
840 f = stdin;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
841 else
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
842 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
843 f = fopen( argv[0], "r" );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
844 if ( f == NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
845 {
281
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
846 fprintf( stderr, "Can't access %s (%s).", argv[0], strerror( errno ) );
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
847 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
848 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
849 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
850
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
851 if ( ! initNoffle() )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
852 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
853 result = EXIT_SUCCESS;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
854
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
855 if ( ! doPost( f, flags ) )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
856 result = EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
857
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
858 if ( f != stdin )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
859 fclose( f );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
860
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
861 return result;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
862 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
863
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
864 static int
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
865 getArgLetter(const char *arg)
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
866 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
867 int res;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
868 struct option
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
869 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
870 const char *longOpt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
871 const char *opt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
872 } options[] =
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
873 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
874 { "--article", "-a" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
875 { "--cancel", "-c" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
876 { "--create", "-C" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
877 { "--database", "-d" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
878 { "--delete", "-D" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
879 { "--expire", "-e" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
880 { "--fetch", "-f" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
881 { "--groups", "-g" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
882 { "--help", "-h" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
883 { "--list", "-l" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
884 { "--modify", "-m" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
885 { "--offline", "-o" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
886 { "--online", "-n" },
293
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
887 { "--outgoing", "-O" },
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
888 { "--post", "-p" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
889 { "--query", "-q" },
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
890 { "--rebuild", "-B" },
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
891 { "--server", "-r" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
892 { "--requested", "-R" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
893 { "--subscribe-over", "-s" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
894 { "--subscribe-full", "-S" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
895 { "--subscribe-thread", "-t" },
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
896 { "--uninteresting", "-U" },
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
897 { "--unsubscribe", "-u" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
898 { "--version", "-v" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
899 { NULL, NULL }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
900
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
901 };
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
902 struct option *opt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
903
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
904 res = -1;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
905 for ( opt = options; opt->opt != NULL; opt++ )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
906 if ( strcmp( arg, opt->longOpt ) == 0 ||
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
907 strcmp( arg, opt->opt ) == 0 )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
908 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
909 res = opt->opt[1];
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
910 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
911 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
912
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
913 return res;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
914 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
915
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
916 /* Options available to ordinary users, as opposed to administrators. */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
917 static const char* USER_OPTIONS = "adghlpRv";
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
918
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
919 int main ( int argc, char **argv )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
920 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
921 int c, result;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
922 const char *cmdname, *p;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
923
281
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
924 /* Attempt to ensure databases are properly closed when we exit */
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
925 atexit( closeNoffle );
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
926
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
927 signal( SIGSEGV, bugReport );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
928 signal( SIGABRT, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
929 signal( SIGFPE, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
930 signal( SIGILL, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
931 signal( SIGINT, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
932 signal( SIGTERM, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
933 signal( SIGPIPE, logSignal );
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
934
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
935 /* Set umask, just in case. */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
936 umask(022);
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
937
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
938 /* Find last component of command name. */
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
939 cmdname = argv[0];
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
940 p = strrchr( cmdname, '/' );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
941 if ( p != NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
942 cmdname = ++p;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
943
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
944 argv++;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
945 argc--;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
946
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
947 /* Were we invoked as inews? */
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
948 if ( strcmp( cmdname, "inews" ) == 0 )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
949 return doInews( argc, argv );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
950
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
951 c = 'h';
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
952 if ( *argv != NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
953 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
954 c = getArgLetter( *argv );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
955 argv++;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
956 argc--;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
957 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
958
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
959 /*
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
960 If they asked for help, give it before there's a possibility
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
961 we could fail on init.
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
962 */
319
1e595c7ec15f [svn] * src/noffle.c: Give usage (rather than abort()) if option is unrecognised.
bears
parents: 306
diff changeset
963 if ( c == 'h' || c == -1 )
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
964 {
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
965 printUsage();
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
966 return EXIT_SUCCESS;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
967 }
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
968
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
969 noffle.lockAtStartup = ! ( c == 'r' );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
970
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
971 if ( ! initNoffle() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
972 return EXIT_FAILURE;
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
973
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
974 if ( ! Auth_admin() && strchr( USER_OPTIONS, c ) == NULL )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
975 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
976 fprintf( stderr, "You must be a news administrator to do that.\n" );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
977 return EXIT_FAILURE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
978 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
979
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
980 result = EXIT_SUCCESS;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
981 switch ( c )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
982 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
983 case 'a':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
984 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
985 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
986 fprintf( stderr, "Option -a needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
987 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
988 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
989 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
990 if ( ! doArt( *argv ) )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
991 result = EXIT_FAILURE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
992 break;
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
993 case 'B':
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
994 if ( ! doRebuild() )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
995 result = EXIT_FAILURE;
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
996 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
997 case 'c':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
998 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
999 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1000 fprintf( stderr, "Option -c needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1001 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1002 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1003 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1004 doCancel( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1005 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1006 case 'C':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1007 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1008 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1009 fprintf( stderr, "Option -C needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1010 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1011 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1012 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1013 if ( ! doCreateLocalGroup( *argv ) )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1014 result = EXIT_FAILURE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1015 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1016 case 'd':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1017 doDb();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1018 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1019 case 'D':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1020 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1021 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1022 fprintf( stderr, "Option -D needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1023 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1024 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1025 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1026 if ( ! doDeleteLocalGroup( *argv ) )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1027 result = EXIT_FAILURE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1028 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1029 case 'e':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1030 doExpire();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1031 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1032 case 'f':
208
mirkol
parents: 192
diff changeset
1033 noffle.serverPattern = *argv;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1034 doFetch();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1035 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1036 case 'g':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1037 doGrps();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1038 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1039 case 'l':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1040 doList();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1041 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1042 case 'm':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1043 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1044 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1045 fprintf( stderr, "Option -m needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1046 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1047 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1048 else
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
1049 if ( ! doModify( argv[0], --argc, &argv[1] ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1050 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1051 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1052 case 'n':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1053 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1054 fprintf( stderr, "NOFFLE is already online\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1055 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1056 Online_set( TRUE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1057 break;
293
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
1058 case 'O':
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
1059 doOutgoing( *argv );
b0e754727abf [svn] * docs/noffle.1,src/outgoing.c,src/noffle.c: Added -O/--outgoing
bears
parents: 288
diff changeset
1060 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1061 case 'o':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1062 if ( ! Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1063 fprintf( stderr, "NOFFLE is already offline\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1064 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1065 Online_set( FALSE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1066 break;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
1067 case 'p':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1068 if ( ! doPost( stdin, 0 ) )
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
1069 result = EXIT_FAILURE;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
1070 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1071 case 'q':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1072 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1073 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1074 fprintf( stderr, "Option -q needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1075 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1076 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1077 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1078 {
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1079 if ( strcmp( *argv, "groups" ) == 0 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1080 noffle.queryGrps = TRUE;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1081 else if ( strcmp( *argv, "desc" ) == 0 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1082 noffle.queryDsc = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1083 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1084 {
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1085 fprintf( stderr, "Unknown argument -q %s\n", *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1086 result = EXIT_FAILURE;
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1087 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1088 }
208
mirkol
parents: 192
diff changeset
1089 argv++;
mirkol
parents: 192
diff changeset
1090 argc--;
mirkol
parents: 192
diff changeset
1091 noffle.serverPattern = *argv;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1092 doQuery();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1093 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1094 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1095 case 'r':
391
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1096 if ( *argv != NULL )
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1097 {
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1098 if ( strcmp( *argv, "auth" ) != 0 )
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1099 {
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1100 fprintf( stderr, "Unknown argument -r %s\n", *argv );
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1101 result = EXIT_FAILURE;
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1102 break;
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1103 }
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1104
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1105 Cfg_setClientAuth( TRUE );
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1106 p = ", authentication enabled from command line";
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1107 }
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1108 else
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1109 p = "";
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1110
6cb66f5a0479 [svn] * docs/noffle.1,src/configure.h,src/configfile.c,src/noffle.c: Add optional
bears
parents: 390
diff changeset
1111 Log_inf( "Starting as server%s", p );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1112 Server_run();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1113 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1114 case 'R':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1115 doRequested( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1116 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1117 case 's':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1118 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1119 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1120 fprintf( stderr, "Option -s needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1121 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1122 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1123 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1124 if ( ! doSubscribe( *argv, OVER ) )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1125 result = EXIT_FAILURE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1126 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1127 case 'S':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1128 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1129 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1130 fprintf( stderr, "Option -S needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1131 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1132 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1133 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1134 if ( ! doSubscribe( *argv, FULL ) )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1135 result = EXIT_FAILURE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1136 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1137 case 't':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1138 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1139 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1140 fprintf( stderr, "Option -t needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1141 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1142 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1143 else
461
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1144 if ( ! doSubscribe( *argv, THREAD ) )
b540ecb6f218 [svn] * src/itemlist.c: Add define so test code builds again.
bears
parents: 391
diff changeset
1145 result = EXIT_FAILURE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1146 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1147 case 'u':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1148 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1149 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1150 fprintf( stderr, "Option -u needs argument.\n" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1151 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1152 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1153 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1154 doUnsubscribe( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1155 break;
482
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1156 case 'U':
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1157 if ( *argv == NULL )
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1158 {
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1159 fprintf( stderr, "Option -U needs argument.\n" );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1160 result = EXIT_FAILURE;
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1161 }
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1162 else
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1163 doUninteresting( *argv );
a04c52f87b6e [svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents: 477
diff changeset
1164 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1165 case '?':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1166 /* Error message already printed by getopt_long */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1167 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1168 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1169 case 'v':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1170 printf( "NNTP server NOFFLE, version %s.\n", Cfg_version() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1171 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1172 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1173 abort(); /* Never reached */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1174 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1175 return result;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1176 }