annotate src/noffle.c @ 288:c02c4eb95f95 noffle

[svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user and noffle-group configs. * src/configfile.c,src/fetch.c,src/fetchlist.c,src/protocol.c, src/server.c: Replace strcpy() with Utl_cpyStr() where appropriate. See Debian bug 168128. * src/control.c,src/configfile.c,src/noffle.c: Replace [s]scanf("%s") with [s]scanf(MAXCHAR_FMT). * src/noffle.c: Log warning if noffle.conf is world readable. * src/noffle.c: Restrict most options to news admins; i.e. those who are root or news on running Noffle. * Makefile.in,acconfig.h,aclocal.m4,config.h.in,configure,configure.in, docs/Makefile.in,docs/noffle.conf.5,packages/Makefile.in, packages/redhat/Makefile.in,src/Makefile.am,src/Makefile.in, src/authenticate.c,src/authenticate.h,src/noffle.c,src/server.c: Add basic authentication using either Noffle-specific user file or authenticating via PAM (service 'noffle'). PAM authentication needs to run as root, so a Noffle server that needs PAM must be started by root. Helpful (?) error messages will be logged if not. Noffle will switch ruid and euid to 'news' (or whatever is configured) ASAP. * src/noffle.c: Add uid checking.
author bears
date Fri, 10 Jan 2003 23:25:45 +0000
parents 5eece4dfd945
children b0e754727abf
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
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
13 $Id: noffle.c 420 2003-01-10 23:25:45Z 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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
65 static void
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;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
69
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
70 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
71 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
72 if ( ! Db_first( &id ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
73 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
74 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
75 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
76 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 printf( "From %s %s\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
78 "%s\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79 "%s\n",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
80 Db_from( id ), Db_date( id ),
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
81 Db_header( id ),
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
82 Db_body( id ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
83 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
84 while ( Db_next( &id ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
86 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
88 if ( ! Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
89 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
90 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
91 printf( "%s\n%s", Db_header( msgId ), Db_body( msgId ) );
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 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
96 doCancel( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
97 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
98 switch( Ctrl_cancel( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
99 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
100 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
101 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
102 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
103
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
104 case CANCEL_OK:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
105 printf( "Message '%s' cancelled.\n", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
107
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
108 case CANCEL_NEEDS_MSG:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
109 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
110 break;
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
113
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 /* 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
115 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
116 listRequested1( const char* serv )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
117 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
118 Str msgid;
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 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
121 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
122 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
123 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
124 while ( Req_next( msgid ) );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127 /* 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
128 NULL. */
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
129 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
130 doRequested( const char *arg )
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 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
134 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
135 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
136 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
137 while ( Cfg_nextServ( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
138 listRequested1( serv );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
139 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
140 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
141 listRequested1( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
142 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
145 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
146 doDb( void )
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 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
149
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
150 if ( ! Db_first( &msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151 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
152 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
153 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154 printf( "%s\n", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
155 while ( Db_next( &msgId ) );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
158 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
159 doFetch( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
160 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
161 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
162
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
163 if ( ! Lock_getFetchLock( LOCK_NOWAIT ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
164 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
165 Log_err( "Another 'noffle --fetch' is in progress" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
166 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
167 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
168
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
169 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
170 while ( Cfg_nextServ( serv ) )
208
mirkol
parents: 192
diff changeset
171 if ( ! noffle.serverPattern
mirkol
parents: 192
diff changeset
172 || Wld_match( serv, noffle.serverPattern ) )
mirkol
parents: 192
diff changeset
173 if ( Fetch_init( serv ) )
mirkol
parents: 192
diff changeset
174 {
mirkol
parents: 192
diff changeset
175 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
176
208
mirkol
parents: 192
diff changeset
177 connOK = Fetch_postArts();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
178
249
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 237
diff changeset
179 Flt_init( serv ); /* get filter data before processGrps() calls Utl_stamp(). */
0340b9c17edc [svn] *** empty log message ***
mirkol
parents: 237
diff changeset
180
208
mirkol
parents: 192
diff changeset
181 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
182
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
183 /* 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
184 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
185 request database. */
208
mirkol
parents: 192
diff changeset
186 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
187
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
188 /* get requested articles */
208
mirkol
parents: 192
diff changeset
189 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
190
208
mirkol
parents: 192
diff changeset
191 Fetch_close();
mirkol
parents: 192
diff changeset
192 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
193
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
194 Lock_releaseFetchLock();
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
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
197 static Bool
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
198 doPost( FILE *f, unsigned flags )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
199 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
200 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
201 DynStr *s;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
202 Bool res;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
203
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
204 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
205 while ( fgets( line, MAXCHAR, f ) != NULL )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
206 DynStr_app( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
207
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
208 res = TRUE;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
209 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
210 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
211 fprintf( stderr, "Post failed: Malformed article.\n" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
212 res = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
213 }
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
214 else if ( ! Post_post() )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
215 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
216 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
217 res = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
218 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
219 Post_close();
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
220 return res;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
221 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
222
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
223 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
224 doQuery( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
225 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
226 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
227
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229 while ( Cfg_nextServ( serv ) )
208
mirkol
parents: 192
diff changeset
230 if ( ! noffle.serverPattern
mirkol
parents: 192
diff changeset
231 || Wld_match( serv, noffle.serverPattern ) )
mirkol
parents: 192
diff changeset
232 if ( Fetch_init( serv ) )
mirkol
parents: 192
diff changeset
233 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
234 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
235
208
mirkol
parents: 192
diff changeset
236 if ( noffle.queryGrps )
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
237 status = Client_getGrps();
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
238 if ( status == STAT_OK && noffle.queryDsc )
208
mirkol
parents: 192
diff changeset
239 Client_getDsc();
mirkol
parents: 192
diff changeset
240 Fetch_close();
mirkol
parents: 192
diff changeset
241 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
242 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
243
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
244 static void
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
245 doExpire( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
246 {
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
247 Exp_expire();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
248 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
249
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
250 static void
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
251 doRebuild( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
252 {
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
253 if ( ! Db_rebuild() )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
254 fprintf( stderr, "Rebuild failed.\n" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
255 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
256
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
257 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
258 doCreateLocalGroup( const char * name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
259 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
260 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
261
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
262 Utl_cpyStr( grp, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
263 Utl_toLower( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
264 name = Utl_stripWhiteSpace( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
265
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266 if ( Grp_exists( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
267 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 fprintf( stderr, "'%s' already exists.\n", name );
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
269 return;
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
270 }
250
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
271 if ( ! Grp_isValidName( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
272 fprintf( stderr, "'%s' invalid group name.\n", name );
250
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
273 else if ( Grp_isForbiddenName( name ) )
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
274 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
275 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
276 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
277 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
278 Grp_create( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
279 Grp_setLocal( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
280 printf( "New local group '%s' created.\n", name );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
281
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
282 snprintf( grp, MAXCHAR, "%s/groupinfo.lastupdate", Cfg_spoolDir() );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
283 Utl_stamp( grp );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
284 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
285 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
286
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
287 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
288 doDeleteLocalGroup( const char * name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
289 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
290 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
291
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
292 Utl_cpyStr( grp, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
293 Utl_toLower( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
294 name = Utl_stripWhiteSpace( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
295
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
296 if ( ! Grp_exists( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
297 {
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
298 fprintf( stderr, "'%s' does not exist.\n", name );
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
299 return;
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
300 }
250
93d5d8b098da [svn] *** empty log message ***
mirkol
parents: 249
diff changeset
301 if ( ! Grp_isValidName( name ) )
228
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
302 {
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
303 fprintf( stderr, "'%s' invalid group name. Skipping deletion of overviews.\n", name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
304 Log_inf( "Deleting invalid group '%s' without deleting overviews.", name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
305 Grp_delete( name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
306 printf( "Group '%s' deleted.\n", name );
1ad2602f57db [svn] see Changelog Dec 18 2001
mirkol
parents: 223
diff changeset
307 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
308 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
309 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
310 int i;
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 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
313
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
314 /*
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
315 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
316 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
317 server.
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
318 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
319 Cont_read( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
320 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
321 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 const Over *over;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 Bool toDelete;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 Str msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
325
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
326 if ( ! Cont_validNumb( i ) )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
327 continue;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
328
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
329 over = Cont_get( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
330 toDelete = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
331 if ( over != NULL )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
332 {
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
333 ItemList *xrefs;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
334 const char *xref;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
335 int localXrefs = 0;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
336
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
337 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
338 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
339 for ( xref = Itl_first( xrefs );
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
340 xref != NULL;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
341 xref = Itl_next( xrefs) )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
342 {
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
343 Str xgrp;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
344 int no;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
345
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
346 if ( sscanf( xref, MAXCHAR_FMT ":%d", xgrp, &no ) != 2 )
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
347 {
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
348 /* 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
349 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
350 msgId, xref);
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
351 toDelete = FALSE;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
352 break;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
353 }
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
354
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
355 if ( Cont_exists( xgrp ) )
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
356 ++localXrefs;
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
357 }
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
358
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
359 if ( localXrefs > 1 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
360 toDelete = FALSE;
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
361 del_Itl( xrefs );
43
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 Cont_delete( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
364 if ( toDelete )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
365 Db_delete( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
366 }
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
367 if ( Cont_write() )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
368 {
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
369 Grp_delete( name );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
370 printf( "Group '%s' deleted.\n", name );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 218
diff changeset
371 }
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
372 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
373 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
374
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
375 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
376 doList( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
377 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
378 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
379 int i, size;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
380 const char *name, *modeStr = "";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
381
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
382 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
383 size = Fetchlist_size();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
384 if ( size == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
385 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
386 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
387 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
388 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
389 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
390 switch ( mode )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
391 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
392 case FULL:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
393 modeStr = "full"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
394 case THREAD:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
395 modeStr = "thread"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
396 case OVER:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
397 modeStr = "over"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
398 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
399 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
400 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
401 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
402
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
403 /* 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
404 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
405 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
406 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
407 const char *grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
408
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
409 if ( argc < 2 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
410 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
411 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
412 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
413
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
414 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
415 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
416 && strcmp( cmd, "post" ) != 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
417 {
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
418 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
419 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
420 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
421
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
422 grp = argv[ 0 ];
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
423 argv++;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
424 argc--;
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 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
427 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
428 Str desc;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
429
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
430 Utl_cpyStr( desc, *( argv++ ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
431 while ( --argc > 0 )
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 Utl_catStr( desc, " " );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 Utl_catStr( desc, *( argv++ ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
435 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
436
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
437 Grp_setDsc( grp, desc );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
438 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
439 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
440 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
441 char c;
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 if ( ! Grp_local( grp ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
444 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
445 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
446 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
447 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
448
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
449 c = **argv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
450 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
451 Grp_setPostAllow( grp, c );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
452 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
453 {
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
454 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
455 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
456 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
459 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
463 doGrps( void )
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 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466 Str dateLastAccess, dateCreated;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 time_t lastAccess, created;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
468
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
469 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
470 do
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 lastAccess = Grp_lastAccess( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473 created = Grp_created( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474 ASSERT( lastAccess >= 0 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
475 ASSERT( created >= 0 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476 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
477 localtime( &lastAccess ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
478 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
479 localtime( &created ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480 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
481 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
482 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
483 dateLastAccess, Grp_dsc( g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
485 while ( Grp_nextGrp( &g ) );
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
489 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
490 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
491 if ( ! Grp_exists( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
492 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
493 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
494 return FALSE;
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 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 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
498 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
499 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
500 "thread" : "overview" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
501 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
502 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
503 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
504 "thread" : "overview" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
505 if ( ! Fetchlist_write() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
506 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
507 Grp_setLastAccess( name );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
508 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
511 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
512 doUnsubscribe( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
513 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
514 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
515 if ( ! Fetchlist_remove( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
516 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
517 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
518 printf( "%s removed from fetch list.\n", name );
102
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
519 if ( Fetchlist_write() )
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
520 Grp_setRmtNext( name, GRP_RMT_NEXT_NOT_SUBSCRIBED );
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
521 else
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
522 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
523 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
524
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
525 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
526 printUsage( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
527 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
528 static const char *msg =
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
529 "Usage: noffle <option>\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
530 "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
531 " -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
532 " -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
533 " -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
534 " -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
535 " -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
536 " -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
537 " -e | --expire Expire articles\n"
208
mirkol
parents: 192
diff changeset
538 " -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
539 " -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
540 " -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
541 " -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
542 " -m | --modify desc <grp> <desc> Modify a group description\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
543 " -m | --modify post <grp> (y|n) Modify posting status of a local group\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
544 " -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
545 " -o | --offline Switch to offline mode\n"
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
546 " -p | --post Post article on stdin\n"
208
mirkol
parents: 192
diff changeset
547 " -q | --query groups [server] Get group list from server\n"
mirkol
parents: 192
diff changeset
548 " -q | --query desc [server] Get group descriptions from server\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
549 " -r | --server Run as server on stdin/stdout\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
550 " -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
551 " -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
552 " -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
553 " -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
554 " -u | --unsubscribe <grp> Remove group from fetch list\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
555 " -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
556 fprintf( stderr, "%s", msg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
557 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
558
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
559
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
560 /* 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
561 static Bool
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
562 checkCurrentUser( void )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
563 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
564 if ( ! Auth_checkPrivs() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
565 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
566
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
567 /*
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
568 * 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
569 * 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
570 */
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
571 if ( noffle.lockAtStartup )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
572 if ( ! Auth_dropPrivs() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
573 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
574
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
575 return TRUE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
576 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
577
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
578 /*
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
579 Check file ownership and permissions.
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
580 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
581 */
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
582 static Bool
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
583 checkFileOwnership( void )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
584 {
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
585 Str confFile;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
586 struct stat statBuf;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
587
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
588 Utl_cpyStr( confFile, CONFIGFILE );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
589 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
590 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
591 if ( ( statBuf.st_mode & S_IROTH ) != 0 )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
592 Log_inf( "Security warning: %s is globally readable." );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
593 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
594
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
595 return TRUE;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
596 }
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
597
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
598 /*
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
599 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
600 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
601 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
602 static void
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
603 enableCorefiles( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
604 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
605 struct rlimit lim;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
606
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
607 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
608 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
609 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
610 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
611 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
612 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
613 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
614 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
615 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
616 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
617 }
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
618 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
619 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
620
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
621 static Bool
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
622 initNoffle( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
623 {
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
624 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
625
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
626 Cfg_read();
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
627 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
628
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
629 if ( ! checkCurrentUser() )
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
630 return FALSE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
631
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
632 /* cd to the spool directory */
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
633 if ( chdir( Cfg_spoolDir() ) != 0 )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
634 {
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
635 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
636 return FALSE;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
637 }
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
638 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
639
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
640 if ( ! checkFileOwnership() )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
641 return FALSE;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
642
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
643 if ( noffle.lockAtStartup )
98
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
644 if ( ! Lock_openDatabases() )
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
645 return FALSE;
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
646 enableCorefiles();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
647 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
648 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
649
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
650 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
651 closeNoffle( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
652 {
281
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
653 if ( Lock_gotLock() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
654 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
655 Lock_syncDatabases();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
656 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
657
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
658 static RETSIGTYPE
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
659 bugReport( int sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
660 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
661 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
662 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
663
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
664 /* 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
665 Lock_syncDatabases();
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
666
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
667 raise( sig );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
668 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
669
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
670 static RETSIGTYPE
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
671 logSignal( int sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
672 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
673 const char *name;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
674 Bool err = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
675
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
676 switch ( sig )
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 case SIGABRT:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
679 name = "SIGABRT"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
680 case SIGFPE:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
681 name = "SIGFPE"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
682 case SIGILL:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
683 name = "SIGILL"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
684 case SIGINT:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
685 name = "SIGINT"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
686 case SIGTERM:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
687 name = "SIGTERM"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
688 case SIGPIPE:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
689 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
690 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
691 name = "?"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
692 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
693 if ( err )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
694 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
695 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
696 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
697 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
698
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
699 /* 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
700 Lock_syncDatabases();
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
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 raise( sig );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
703 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
704
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
705 static void
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
706 printInewsUsage( void )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
707 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
708 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
709 "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
710 " -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
711 " -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
712 " -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
713 " 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
714 "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
715 "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
716 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
717 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
718
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
719 static int
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
720 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
721 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
722 int result;
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
723 unsigned flags;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
724 FILE *f;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
725
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
726 UNUSED( argc );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
727
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
728 noffle.lockAtStartup = TRUE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
729
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
730 /* Process options */
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
731 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
732 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
733 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
734 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
735 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
736 printInewsUsage();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
737 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
738 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
739
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
740 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
741 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
742 case 'h':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
743 case 'A':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
744 case 'V':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
745 case 'W':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
746 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
747 case 'N':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
748 case 'D':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
749 flags |= POST_DEBUG;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
750 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
751 case 'O':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
752 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
753 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
754 case 'S':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
755 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
756 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
757 default:
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
758 printInewsUsage();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
759 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
760 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
761 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
762
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
763 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
764 f = stdin;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
765 else
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
766 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
767 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
768 if ( f == NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
769 {
281
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
770 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
771 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
772 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
773 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
774
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
775 if ( ! initNoffle() )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
776 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
777 result = EXIT_SUCCESS;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
778
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
779 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
780 result = EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
781
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
782 if ( f != stdin )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
783 fclose( f );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
784
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
785 return result;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
786 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
787
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
788 static int
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
789 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
790 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
791 int res;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
792 struct option
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 const char *longOpt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
795 const char *opt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
796 } options[] =
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 { "--article", "-a" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
799 { "--cancel", "-c" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
800 { "--create", "-C" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
801 { "--database", "-d" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
802 { "--delete", "-D" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
803 { "--expire", "-e" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
804 { "--fetch", "-f" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
805 { "--groups", "-g" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
806 { "--help", "-h" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
807 { "--list", "-l" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
808 { "--modify", "-m" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
809 { "--offline", "-o" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
810 { "--online", "-n" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
811 { "--post", "-p" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
812 { "--query", "-q" },
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
813 { "--rebuild", "-B" },
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
814 { "--server", "-r" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
815 { "--requested", "-R" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
816 { "--subscribe-over", "-s" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
817 { "--subscribe-full", "-S" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
818 { "--subscribe-thread", "-t" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
819 { "--unsubscribe", "-u" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
820 { "--version", "-v" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
821 { NULL, NULL }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
822
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
823 };
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
824 struct option *opt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
825
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
826 res = -1;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
827 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
828 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
829 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
830 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
831 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
832 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
833 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
834
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
835 return res;
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
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
838 /* 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
839 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
840
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
841 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
842 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
843 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
844 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
845
281
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
846 /* 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
847 atexit( closeNoffle );
5eece4dfd945 [svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents: 270
diff changeset
848
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
849 signal( SIGSEGV, bugReport );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
850 signal( SIGABRT, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
851 signal( SIGFPE, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
852 signal( SIGILL, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
853 signal( SIGINT, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
854 signal( SIGTERM, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
855 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
856
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
857 /* 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
858 umask(022);
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
859
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
860 /* 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
861 cmdname = argv[0];
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
862 p = strrchr( cmdname, '/' );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
863 if ( p != NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
864 cmdname = ++p;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
865
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
866 argv++;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
867 argc--;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
868
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
869 /* 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
870 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
871 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
872
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
873 c = 'h';
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
874 if ( *argv != NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
875 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
876 c = getArgLetter( *argv );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
877 argv++;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
878 argc--;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
879 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
880
270
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
881 /*
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
882 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
883 we could fail on init.
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
884 */
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
885 if ( c == 'h' )
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
886 {
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
887 printUsage();
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
888 return EXIT_SUCCESS;
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
889 }
d6fedc09b052 [svn] * src/noffle.c: Rearrange initialisation so that a requested usage
bears
parents: 255
diff changeset
890
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
891 noffle.lockAtStartup = ! ( c == 'r' );
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
892
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
893 if ( ! initNoffle() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
894 return EXIT_FAILURE;
288
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
895
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
896 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
897 {
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
898 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
899 return EXIT_FAILURE;
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
900 }
c02c4eb95f95 [svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
bears
parents: 281
diff changeset
901
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
902 result = EXIT_SUCCESS;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
903 switch ( c )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
904 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
905 case 'a':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
906 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
907 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
908 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
909 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
910 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
911 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
912 doArt( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
913 break;
255
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
914 case 'B':
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
915 doRebuild();
52f467c7213b [svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents: 250
diff changeset
916 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
917 case 'c':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
918 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
919 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
920 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
921 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
922 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
923 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
924 doCancel( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
925 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
926 case 'C':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
927 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
928 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
929 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
930 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
931 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
932 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
933 doCreateLocalGroup( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
934 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
935 case 'd':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
936 doDb();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
937 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
938 case 'D':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
939 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
940 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
941 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
942 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
943 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
944 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
945 doDeleteLocalGroup( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
946 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
947 case 'e':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
948 doExpire();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
949 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
950 case 'f':
208
mirkol
parents: 192
diff changeset
951 noffle.serverPattern = *argv;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
952 doFetch();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
953 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
954 case 'g':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
955 doGrps();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
956 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
957 case 'l':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
958 doList();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
959 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
960 case 'm':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
961 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
962 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
963 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
964 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
965 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
966 else
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
967 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
968 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
969 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
970 case 'n':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
971 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
972 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
973 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
974 Online_set( TRUE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
975 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
976 case 'o':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
977 if ( ! Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
978 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
979 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
980 Online_set( FALSE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
981 break;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
982 case 'p':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
983 if ( ! doPost( stdin, 0 ) )
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
984 result = EXIT_FAILURE;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
985 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
986 case 'q':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
987 if ( *argv == NULL )
43
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 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
990 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
991 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
992 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
993 {
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
994 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
995 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
996 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
997 noffle.queryDsc = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
998 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
999 {
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1000 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
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 }
208
mirkol
parents: 192
diff changeset
1003 argv++;
mirkol
parents: 192
diff changeset
1004 argc--;
mirkol
parents: 192
diff changeset
1005 noffle.serverPattern = *argv;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1006 doQuery();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1007 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1008 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1009 case 'r':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1010 Log_inf( "Starting as server" );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
1011 Server_run();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1012 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1013 case 'R':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1014 doRequested( *argv );
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 's':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1017 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1018 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1019 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
1020 result = EXIT_FAILURE;
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 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1023 result = doSubscribe( *argv, OVER );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1024 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1025 case 'S':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1026 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1027 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1028 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
1029 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1030 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1031 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1032 doSubscribe( *argv, FULL );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1033 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1034 case 't':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1035 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1036 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1037 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
1038 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1039 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1040 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1041 result = doSubscribe( *argv, THREAD );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1042 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1043 case 'u':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1044 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1045 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1046 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
1047 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1048 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1049 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
1050 doUnsubscribe( *argv );
43
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 '?':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1053 /* 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
1054 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1055 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1056 case 'v':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1057 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
1058 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1059 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1060 abort(); /* Never reached */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1061 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1062 return result;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1063 }