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