annotate src/noffle.c @ 278:a0497ffac49b noffle

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