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