annotate src/noffle.c @ 192:b9ef99708d1c noffle

[svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way. Auto-unsubscribe when the last access time is more than the threshold number of days behind the time the last article arrived.
author bears
date Sun, 21 Oct 2001 12:00:12 +0100
parents 28488e0e3630
children 61a0f1e13916
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
192
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
13 $Id: noffle.c 311 2001-10-21 11:00:12Z 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>
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
23 #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
24 #include <sys/resource.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include <syslog.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <unistd.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include "client.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 #include "common.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 #include "content.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 #include "control.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
31 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 #include "database.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "fetch.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 #include "fetchlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 #include "group.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
36 #include "itemlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
37 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 #include "online.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 #include "outgoing.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 #include "over.h"
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
41 #include "post.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42 #include "pseudo.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
43 #include "util.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
44 #include "server.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
45 #include "request.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46 #include "lock.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
47 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 struct Noffle
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
50 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51 Bool queryGrps;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 Bool queryDsc;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
53 Bool queryTimes;
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
54 Bool lockAtStartup;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
55 } noffle = { FALSE, FALSE, FALSE, TRUE };
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
56
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
58 doArt( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60 const char *id;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
61
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62 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
63 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 if ( ! Db_first( &id ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
65 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
66 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
67 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
68 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
69 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
70 "%s\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
71 "%s\n",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
72 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
73 Db_header( id ),
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
74 Db_body( id ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
75 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
76 while ( Db_next( &id ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
78 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
80 if ( ! Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
81 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
82 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
83 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
84 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
88 doCancel( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
89 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
90 switch( Ctrl_cancel( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
91 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 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
93 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
94 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
95
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
96 case CANCEL_OK:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
97 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
98 break;
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_NEEDS_MSG:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
101 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
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
105
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106 /* 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
107 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
108 listRequested1( const char* serv )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
109 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
110 Str msgid;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
111
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
112 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
113 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
115 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
116 while ( Req_next( msgid ) );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
119 /* 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
120 NULL. */
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
121 static void
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
122 doRequested( const char *arg )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
123 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
124 Str serv;
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 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
127 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
129 while ( Cfg_nextServ( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
130 listRequested1( serv );
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 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 listRequested1( arg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
134 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
137 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
138 doDb( void )
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 const char *msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
141
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
142 if ( ! Db_first( &msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
143 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
144 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
145 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
146 printf( "%s\n", msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
147 while ( Db_next( &msgId ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
148 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151 doFetch( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
152 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
153 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
155 if ( ! Lock_getFetchLock( LOCK_NOWAIT ) )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
156 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
157 Log_err( "Another 'noffle --fetch' is in progress" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
158 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
159 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
160
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
161 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
162 while ( Cfg_nextServ( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
163 if ( Fetch_init( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
164 {
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
165 Bool connOK;
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
166
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
167 connOK = Fetch_postArts();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
168
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
169 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
170
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
171 /* 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
172 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
173 request database. */
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
174 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
175
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
176 /* get requested articles */
180
09ca6eb5c7ff [svn] * TODO,src/client.c,src/client.h,src/fetch.c,src/fetch.h,src/noffle.c:
bears
parents: 168
diff changeset
177 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
178
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
179 Fetch_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
180 }
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
181
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
182 Lock_releaseFetchLock();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
183 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
184
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
185 static Bool
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
186 doPost( FILE *f, unsigned flags )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
187 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
188 Str line;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
189 DynStr *s;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
190 Bool res;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
191
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
192 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
193 while ( fgets( line, MAXCHAR, f ) != NULL )
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
194 DynStr_app( s, line );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
195
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
196 res = TRUE;
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
197 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
198 {
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
199 fprintf( stderr, "Post failed: Malformed article.\n" );
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
200 res = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
201 }
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
202 else if ( ! Post_post() )
88
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 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
205 res = FALSE;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
206 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
207 Post_close();
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
208 return res;
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
209 }
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
210
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
211 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
212 doQuery( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
213 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
214 Str serv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
215
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
216 Cfg_beginServEnum();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
217 while ( Cfg_nextServ( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
218 if ( Fetch_init( serv ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
219 {
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
220 int stat = 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
221
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
222 if ( noffle.queryGrps )
188
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
223 stat = Client_getGrps();
f1bacee93ca6 [svn] * src/client.c,src/client.h,src/fetch.c,src/noffle.c,src/server.c:
bears
parents: 185
diff changeset
224 if ( stat == STAT_OK && noffle.queryDsc )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
225 Client_getDsc();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
226 Fetch_close();
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
230 /* Expire all overviews not in database */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
231 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
232 expireContents( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
233 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
234 const Over *ov;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
235 int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
236 int cntDel, cntLeft;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
237 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
238 Bool autoUnsubscribe;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
239 int autoUnsubscribeDays;
192
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
240 time_t maxAge = 0;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
241 const char *msgId;
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 autoUnsubscribe = Cfg_autoUnsubscribe();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
244 autoUnsubscribeDays = Cfg_autoUnsubscribeDays();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
245 maxAge = Cfg_autoUnsubscribeDays() * 24 * 3600;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
246 if ( ! Cont_firstGrp( grp ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
247 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
248 Log_inf( "Expiring overviews not in database" );
132
a740dac296bc [svn] Fix repeated auto-unsubscribe bug & sync to 1.0pre7
bears
parents: 127
diff changeset
249 Fetchlist_read();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
250 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
251 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
252 if ( ! Grp_exists( grp ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
253 Log_err( "Overview file for unknown group %s exists", grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
254 else
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 cntDel = cntLeft = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
257 Cont_read( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
258 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
259 if ( ( ov = Cont_get( i ) ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
260 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
261 msgId = Ov_msgId( ov );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
262 if ( ! Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
263 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
264 Cont_delete( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
265 ++cntDel;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
266 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
267 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
268 ++cntLeft;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
269 }
192
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
270
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
271 /*
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
272 * Auto unsubscribe where applicable if last article arrival
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
273 * time is maxAge newer than the last access time. This ensures
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
274 * the low traffic groups don't get expired simply because
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
275 * there's been nothing to read.
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
276 */
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
277 if ( ! Grp_local( grp )
132
a740dac296bc [svn] Fix repeated auto-unsubscribe bug & sync to 1.0pre7
bears
parents: 127
diff changeset
278 && Fetchlist_contains( grp )
a740dac296bc [svn] Fix repeated auto-unsubscribe bug & sync to 1.0pre7
bears
parents: 127
diff changeset
279 && autoUnsubscribe
192
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
280 && difftime( Grp_lastPostTime(grp),
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
281 Grp_lastAccess( grp ) ) > maxAge )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
282 {
192
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
283 Log_ntc( "Auto-unsubscribing from %s after %d "
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
284 "days without access",
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
285 grp, autoUnsubscribeDays );
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
286 Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays );
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
287 Fetchlist_remove( grp );
b9ef99708d1c [svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way.
bears
parents: 191
diff changeset
288 Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED );
43
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 Cont_write();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
291 Grp_setFirstLast( grp, Cont_first(), Cont_last() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
292 Log_inf( "%ld overviews deleted from group %s, %ld left (%ld-%ld)",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
293 cntDel, grp, cntLeft, Grp_first( grp ), Grp_last( grp ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
294 }
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 while ( Cont_nextGrp( grp ) );
132
a740dac296bc [svn] Fix repeated auto-unsubscribe bug & sync to 1.0pre7
bears
parents: 127
diff changeset
297 Fetchlist_write();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
298 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
299
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
300 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
301 doExpire( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
302 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
303 Db_close();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
304 Db_expire();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
305 if ( ! Db_open() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
306 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
307 expireContents();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
308 }
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 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
311 doCreateLocalGroup( const char * name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
312 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
313 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
314
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
315 Utl_cpyStr( grp, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
316 Utl_toLower( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
317 name = Utl_stripWhiteSpace( grp );
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 if ( Grp_exists( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
320 fprintf( stderr, "'%s' already exists.\n", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
321 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
322 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
323 Log_inf( "Creating new local group '%s'", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
324 Grp_create( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
325 Grp_setLocal( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
326 printf( "New local group '%s' created.\n", name );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
327
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
328 snprintf( grp, MAXCHAR, "%s/groupinfo.lastupdate", Cfg_spoolDir() );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 122
diff changeset
329 Utl_stamp( grp );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
330 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
331 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
332
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
333 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
334 doDeleteLocalGroup( const char * name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
335 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
336 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
337
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
338 Utl_cpyStr( grp, name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
339 Utl_toLower( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
340 name = Utl_stripWhiteSpace( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
341
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
342 if ( ! Grp_exists( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
343 fprintf( stderr, "'%s' does not exist.\n", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
344 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
345 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
346 int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
347
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
348 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
349
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
350 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
351 Delete all articles that are only in the group. Check the
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
352 article Xref for more than one group.
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
353 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
354 Cont_read( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
355 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
356 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
357 const Over *over;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
358 Bool toDelete;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
359 Str msgId;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
360
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
361 over = Cont_get( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
362 toDelete = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
363 if ( over != NULL )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
364 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
365 ItemList * xref;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
366
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
367 Utl_cpyStr( msgId, Ov_msgId( over ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
368 xref = new_Itl( Db_xref( msgId ), " " );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
369 if ( Itl_count( xref ) > 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
370 toDelete = FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
371 del_Itl( xref );
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 Cont_delete( i );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
374 if ( toDelete )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
375 Db_delete( msgId );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
376 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
377 Cont_write();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
378 Grp_delete( name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
379 printf( "Group '%s' deleted.\n", name );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
380 }
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
383 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
384 doList( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
385 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
386 FetchMode mode;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
387 int i, size;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
388 const char *name, *modeStr = "";
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
389
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
390 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
391 size = Fetchlist_size();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
392 if ( size == 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
393 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
394 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
395 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
396 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
397 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
398 switch ( mode )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
399 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
400 case FULL:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
401 modeStr = "full"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
402 case THREAD:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
403 modeStr = "thread"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
404 case OVER:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
405 modeStr = "over"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
406 }
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
407 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
408 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
409 }
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 /* 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
412 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
413 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
414 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
415 const char *grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
416
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
417 if ( argc < 2 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
418 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
419 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
420 return FALSE;
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
423 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
424 && strcmp( cmd, "post" ) != 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
425 {
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
426 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
427 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
428 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
429
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
430 grp = argv[ 0 ];
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
431 argv++;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
432 argc--;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
433
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
434 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
435 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
436 Str desc;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
437
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
438 Utl_cpyStr( desc, *( argv++ ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
439 while ( --argc > 0 )
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 Utl_catStr( desc, " " );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
442 Utl_catStr( desc, *( argv++ ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
443 }
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 Grp_setDsc( grp, desc );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
446 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
447 else
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 char c;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
450
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
451 if ( ! Grp_local( grp ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
452 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
453 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
454 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
455 }
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 c = **argv;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
458 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
459 Grp_setPostAllow( grp, c );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
461 {
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
462 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
463 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
464 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
465 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
470 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
471 doGrps( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
472 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
473 const char *g;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474 Str dateLastAccess, dateCreated;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
475 time_t lastAccess, created;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
476
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
477 if ( Grp_firstGrp( &g ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
478 do
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
479 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
480 lastAccess = Grp_lastAccess( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
481 created = Grp_created( g );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
482 ASSERT( lastAccess >= 0 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
483 ASSERT( created >= 0 );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
484 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
485 localtime( &lastAccess ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
486 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
487 localtime( &created ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
488 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
489 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
490 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
491 dateLastAccess, Grp_dsc( g ) );
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 while ( Grp_nextGrp( &g ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
494 }
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 static Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
497 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
498 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
499 if ( ! Grp_exists( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
500 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
501 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
502 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
503 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
504 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
505 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
506 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
507 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
508 "thread" : "overview" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
509 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
510 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
511 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
512 "thread" : "overview" );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
513 if ( ! Fetchlist_write() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
514 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
515 Grp_setLastAccess( name );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
516 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
517 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
518
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
519 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
520 doUnsubscribe( const char *name )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
521 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
522 Fetchlist_read();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
523 if ( ! Fetchlist_remove( name ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
524 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
525 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
526 printf( "%s removed from fetch list.\n", name );
102
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
527 if ( Fetchlist_write() )
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
528 Grp_setRmtNext( name, GRP_RMT_NEXT_NOT_SUBSCRIBED );
38b0a1532a37 [svn] Only track remote message no when subscribed
bears
parents: 98
diff changeset
529 else
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
530 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
531 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
532
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
533 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
534 printUsage( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
535 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
536 static const char *msg =
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
537 "Usage: noffle <option>\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
538 "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
539 " -a | --article <msg id>|all Show article(s) in database\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
540 " -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
541 " -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
542 " -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
543 " -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
544 " -e | --expire Expire articles\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
545 " -f | --fetch Get newsfeed from server/post articles\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
546 " -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
547 " -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
548 " -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
549 " -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
550 " -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
551 " -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
552 " -o | --offline Switch to offline mode\n"
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
553 " -p | --post Post article on stdin\n"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
554 " -q | --query groups Get group list from server\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
555 " -q | --query desc Get group descriptions from server\n"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
556 " -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
557 " -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
558 " -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
559 " -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
560 " -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
561 " -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
562 " -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
563 fprintf( stderr, "%s", msg );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
564 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
565
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
566 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
567 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
568 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
569 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
570 static void
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
571 enableCorefiles( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
572 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
573 struct rlimit lim;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
574
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
575 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
576 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
577 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
578 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
579 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
580 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
581 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
582 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
583 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
584 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
585 }
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
586 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
587 if ( chdir( Cfg_spoolDir() ) != 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
588 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
589 Log_err( "Cannot change to directory '%s'", Cfg_spoolDir() );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
590 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
591 }
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
592 Log_dbg( LOG_DBG_NOFFLE, "Changed to directory '%s'", Cfg_spoolDir() );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
593 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
594
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
595 static Bool
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
596 initNoffle( void )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
597 {
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
598 Log_init( "noffle", noffle.lockAtStartup, LOG_NEWS );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
599 Cfg_read();
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 180
diff changeset
600 Log_dbg( LOG_DBG_NOFFLE, "NOFFLE version %s", Cfg_version() );
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
601 if ( noffle.lockAtStartup )
98
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
602 if ( ! Lock_openDatabases() )
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
603 return FALSE;
0428aed4f9d0 [svn] Always enable core files.
enz
parents: 88
diff changeset
604 enableCorefiles();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
605 return TRUE;
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
608 static void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
609 closeNoffle( void )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
610 {
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
611 if ( noffle.lockAtStartup )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
612 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
613 Lock_syncDatabases();
43
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
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
616 static RETSIGTYPE
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
617 bugReport( int sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
618 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
619 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
620 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
621
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
622 /* 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
623 Lock_syncDatabases();
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
624
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
625 raise( sig );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
626 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
627
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
628 static RETSIGTYPE
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
629 logSignal( int sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
630 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
631 const char *name;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
632 Bool err = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
633
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
634 switch ( sig )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
635 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
636 case SIGABRT:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
637 name = "SIGABRT"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
638 case SIGFPE:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
639 name = "SIGFPE"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
640 case SIGILL:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
641 name = "SIGILL"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
642 case SIGINT:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
643 name = "SIGINT"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
644 case SIGTERM:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
645 name = "SIGTERM"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
646 case SIGPIPE:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
647 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
648 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
649 name = "?"; break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
650 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
651 if ( err )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
652 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
653 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
654 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
655 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
656
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
657 /* 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
658 Lock_syncDatabases();
8ea6b5ddc5a5 [svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release
bears
parents: 150
diff changeset
659
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
660 raise( sig );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
661 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
662
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
663 static void
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
664 printInewsUsage( void )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
665 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
666 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
667 "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
668 " -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
669 " -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
670 " -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
671 " 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
672 "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
673 "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
674 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
675 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
676
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
677 static int
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
678 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
679 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
680 int result;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
681 int flags;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
682 FILE *f;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
683
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
684 UNUSED( argc );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
685
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
686 noffle.lockAtStartup = TRUE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
687
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
688 /* Process options */
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
689 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
690 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
691 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
692 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
693 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
694 printInewsUsage();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
695 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
696 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
697
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
698 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
699 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
700 case 'h':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
701 case 'A':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
702 case 'V':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
703 case 'W':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
704 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
705 case 'N':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
706 case 'D':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
707 flags |= POST_DEBUG;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
708 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
709 case 'O':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
710 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
711 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
712 case 'S':
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
713 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
714 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
715 default:
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
716 printInewsUsage();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
717 return EXIT_FAILURE;
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 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
720
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
721 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
722 f = stdin;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
723 else
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
724 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
725 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
726 if ( f == NULL )
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 Log_err( "Can't access %s (%s).", argv[0], strerror( errno ) );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
729 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
730 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
731 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
732
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
733 if ( ! initNoffle() )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
734 return EXIT_FAILURE;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
735 result = EXIT_SUCCESS;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
736
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
737 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
738 result = EXIT_FAILURE;
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 if ( f != stdin )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
741 fclose( f );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
742
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
743 closeNoffle();
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
744 return result;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
745 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
746
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
747 static int
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
748 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
749 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
750 int res;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
751 struct option
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
752 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
753 const char *longOpt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
754 const char *opt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
755 } options[] =
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
756 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
757 { "--article", "-a" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
758 { "--cancel", "-c" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
759 { "--create", "-C" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
760 { "--database", "-d" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
761 { "--delete", "-D" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
762 { "--expire", "-e" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
763 { "--fetch", "-f" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
764 { "--groups", "-g" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
765 { "--help", "-h" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
766 { "--list", "-l" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
767 { "--modify", "-m" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
768 { "--offline", "-o" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
769 { "--online", "-n" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
770 { "--post", "-p" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
771 { "--query", "-q" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
772 { "--server", "-r" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
773 { "--requested", "-R" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
774 { "--subscribe-over", "-s" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
775 { "--subscribe-full", "-S" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
776 { "--subscribe-thread", "-t" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
777 { "--unsubscribe", "-u" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
778 { "--version", "-v" },
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
779 { NULL, NULL }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
780
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 struct option *opt;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
783
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
784 res = -1;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
785 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
786 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
787 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
788 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
789 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
790 break;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
791 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
792
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
793 return res;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
794 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
795
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
796 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
797 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
798 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
799 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
800
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
801 signal( SIGSEGV, bugReport );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
802 signal( SIGABRT, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
803 signal( SIGFPE, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
804 signal( SIGILL, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
805 signal( SIGINT, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
806 signal( SIGTERM, logSignal );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
807 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
808
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
809 /* 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
810 cmdname = argv[0];
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
811 p = strrchr( cmdname, '/' );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
812 if ( p != NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
813 cmdname = ++p;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
814
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
815 argv++;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
816 argc--;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
817
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
818 /* 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
819 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
820 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
821
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
822 c = -1;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
823 if ( *argv != NULL )
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
824 {
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
825 c = getArgLetter( *argv );
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
826 argv++;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
827 argc--;
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
828 }
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
829
122
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
830 noffle.lockAtStartup = ! ( c == 'r' || c == 'h' );
d00adc26d77a [svn] Do not acquire global lock for prniting help
enz
parents: 117
diff changeset
831 if ( ! initNoffle() )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
832 return EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
833 result = EXIT_SUCCESS;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
834 switch ( c )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
835 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
836 case 'a':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
837 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
838 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
839 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
840 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
841 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
842 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
843 doArt( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
844 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
845 case 'c':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
846 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
847 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
848 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
849 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
850 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
851 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
852 doCancel( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
853 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
854 case 'C':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
855 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
856 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
857 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
858 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
859 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
860 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
861 doCreateLocalGroup( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
862 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
863 case 'd':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
864 doDb();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
865 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
866 case 'D':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
867 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
868 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
869 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
870 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
871 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
872 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
873 doDeleteLocalGroup( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
874 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
875 case 'e':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
876 doExpire();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
877 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
878 case 'f':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
879 doFetch();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
880 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
881 case 'g':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
882 doGrps();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
883 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
884 case -1:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
885 case 'h':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
886 printUsage();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
887 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
888 case 'l':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
889 doList();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
890 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
891 case 'm':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
892 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
893 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
894 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
895 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
896 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
897 else
168
cf2274194d38 [svn] small option parsing fix
mnalis
parents: 165
diff changeset
898 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
899 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
900 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
901 case 'n':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
902 if ( Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
903 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
904 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
905 Online_set( TRUE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
906 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
907 case 'o':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
908 if ( ! Online_true() )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
909 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
910 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
911 Online_set( FALSE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
912 break;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
diff changeset
913 case 'p':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
914 if ( ! doPost( stdin, 0 ) )
114
af7bea7515b2 [svn] --post simplification.
bears
parents: 102
diff changeset
915 result = EXIT_FAILURE;
88
1fcdced0246e [svn] Move posting code to post.c, add command line posting
bears
parents: 61
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 'q':
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 -q 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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
924 {
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
925 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
926 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
927 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
928 noffle.queryDsc = TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
929 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
930 {
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
931 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
932 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
933 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
934 doQuery();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
935 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
936 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
937 case 'r':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
938 Log_inf( "Starting as server" );
61
adf0af5152f7 [svn] Renamed some variables and function names, because they caused compiler
enz
parents: 54
diff changeset
939 Server_run();
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
940 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
941 case 'R':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
942 doRequested( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
943 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
944 case 's':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
945 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
946 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
947 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
948 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
949 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
950 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
951 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
952 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
953 case 'S':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
954 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
955 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
956 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
957 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
958 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
959 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
960 doSubscribe( *argv, FULL );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
961 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
962 case 't':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
963 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
964 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
965 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
966 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
967 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
968 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
969 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
970 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
971 case 'u':
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
972 if ( *argv == NULL )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
973 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
974 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
975 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
976 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
977 else
150
1c7303c71f66 [svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
bears
parents: 132
diff changeset
978 doUnsubscribe( *argv );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
979 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
980 case '?':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
981 /* 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
982 result = EXIT_FAILURE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
983 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
984 case 'v':
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
985 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
986 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
987 default:
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
988 abort(); /* Never reached */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
989 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
990 closeNoffle();
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
991 return result;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
992 }