Mercurial > noffle
annotate src/database.c @ 488:c96af06667cb noffle
[svn] * Added Debian Czech translation from Martin Sin.
author | bears |
---|---|
date | Tue, 17 May 2005 09:48:42 +0100 |
parents | a04c52f87b6e |
children |
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 database.c |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
3 |
482
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
4 $Id: database.c 629 2004-10-13 23:26:48Z bears $ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
5 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
6 Uses GNU gdbm library. Using Berkeley db (included in libc6) was |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
7 cumbersome. It is based on Berkeley db 1.85, which has severe bugs |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
8 (e.g. it is not recommended to delete or overwrite entries with |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
9 overflow pages). |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
10 */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
11 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
12 #if HAVE_CONFIG_H |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
13 #include <config.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
14 #endif |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
15 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #include <stdio.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
17 #include <ctype.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
18 #include <errno.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
19 #include <gdbm.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
20 #include <unistd.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
21 #include <sys/types.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
22 #include <sys/stat.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
23 #include "configfile.h" |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
24 #include "content.h" |
197
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
185
diff
changeset
|
25 #include "database.h" |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
26 #include "group.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
27 #include "log.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
28 #include "protocol.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
29 #include "util.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
30 #include "portable.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
32 static const char ARTICLE_FILENAME_FMT[] = "%s/data/articles.gdbm"; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
33 static const char ARTICLE_NEW_FILENAME_FMT[] = "%s/data/articles.gdbm.new"; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
34 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
35 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 static struct Db |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
37 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
38 GDBM_FILE dbf; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
39 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
40 /* Start string for Xref header line: "Xref: <host>" */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 Str xrefHost; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
42 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
43 /* Msg Id of presently loaded article, empty if none loaded */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
44 Str msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
45 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
46 /* Status of loaded article */ |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
257
diff
changeset
|
47 unsigned status; /* Flags */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
48 time_t lastAccess; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
49 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
50 /* Overview of loaded article */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
51 Str subj; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
52 Str from; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
53 Str date; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
54 Str ref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
55 Str xref; |
276
16dad3488e9d
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
275
diff
changeset
|
56 unsigned long bytes; |
16dad3488e9d
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
275
diff
changeset
|
57 unsigned long lines; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
58 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
59 /* Article text (except for overview header lines) */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
60 DynStr *txt; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
61 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
62 } db = { NULL, "(unknown)", "", 0, 0, "", "", "", "", "", 0, 0, NULL }; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
63 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
64 static const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
65 errMsg( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
66 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
67 if ( gdbm_errno == GDBM_NO_ERROR ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
68 return strerror( errno ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
69 return gdbm_strerror( gdbm_errno ); |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
72 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
73 Db_open( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
74 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
75 Str name, host; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
76 int flags; |
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 ASSERT( db.dbf == NULL ); |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
79 snprintf( name, MAXCHAR, ARTICLE_FILENAME_FMT, Cfg_spoolDir() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
80 flags = GDBM_WRCREAT | GDBM_FAST; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
81 |
281
5eece4dfd945
[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents:
276
diff
changeset
|
82 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, Log_gdbm_fatal ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
83 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
84 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
85 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
86 } |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
87 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
88 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
89 if ( db.txt == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
90 db.txt = new_DynStr( 5000 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
91 |
244
4e69e9b722ae
[svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF
bears
parents:
240
diff
changeset
|
92 if ( ! Utl_getFQDN( host ) ) |
4e69e9b722ae
[svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF
bears
parents:
240
diff
changeset
|
93 Utl_cpyStr( host, "localhost.localdomain" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
94 snprintf( db.xrefHost, MAXCHAR, "Xref: %s", host ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
95 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
96 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
97 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
98 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
99 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
100 Db_close( void ) |
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 ASSERT( db.dbf ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
103 Log_dbg( LOG_DBG_NEWSBASE, "Closing database" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
104 gdbm_close( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
105 db.dbf = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
106 del_DynStr( db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
107 db.txt = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
108 Utl_cpyStr( db.msgId, "" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
109 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
110 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
111 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
112 loadArt( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
113 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
114 static void *dptr = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
115 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
116 datum key, val; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
117 Str t = ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
118 const char *p; |
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 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
121 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
122 if ( strcmp( msgId, db.msgId ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
123 return TRUE; |
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 key.dptr = (void *)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
126 key.dsize = strlen( msgId ) + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
127 if ( dptr != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
128 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
129 free( dptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
130 dptr = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
131 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
132 val = gdbm_fetch( db.dbf, key ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
133 dptr = val.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
134 if ( dptr == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
135 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
136 Log_dbg( LOG_DBG_NEWSBASE, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
137 "database.c loadArt: gdbm_fetch found no entry" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
138 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
139 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
140 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
141 Utl_cpyStr( db.msgId, msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
142 p = Utl_getLn( t, (char *)dptr ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
143 if ( ! p || sscanf( t, "%x", &db.status ) != 1 ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
144 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
145 Log_err( "Entry in database '%s' is corrupt (status)", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
146 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
147 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
148 p = Utl_getLn( t, p ); |
300
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
149 if ( ! p || sscanf( t, "%lu", (unsigned long *)&db.lastAccess ) != 1 ) |
43
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 Log_err( "Entry in database '%s' is corrupt (lastAccess)", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
152 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
153 } |
247 | 154 p = Utl_getHeaderLn( db.subj, p ); |
155 p = Utl_getHeaderLn( db.from, p ); | |
156 p = Utl_getHeaderLn( db.date, p ); | |
157 p = Utl_getHeaderLn( db.ref, p ); | |
158 p = Utl_getHeaderLn( db.xref, p ); | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
159 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
160 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
161 Log_err( "Entry in database '%s' is corrupt (overview)", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
162 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
163 } |
247 | 164 p = Utl_getHeaderLn( t, p ); |
275
0880d6edaaa5
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
271
diff
changeset
|
165 if ( ! p || sscanf( t, "%lu", &db.bytes ) != 1 ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
166 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
167 Log_err( "Entry in database '%s' is corrupt (bytes)", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
168 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
169 } |
247 | 170 p = Utl_getHeaderLn( t, p ); |
275
0880d6edaaa5
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
271
diff
changeset
|
171 if ( ! p || sscanf( t, "%lu", &db.lines ) != 1 ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
172 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
173 Log_err( "Entry in database '%s' is corrupt (lines)", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
174 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
175 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
176 DynStr_clear( db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
177 DynStr_app( db.txt, p ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
178 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
179 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
180 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
181 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
182 saveArt( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
183 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
184 DynStr *s; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
185 Str t = ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
186 datum key, val; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
187 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
188 if ( strcmp( db.msgId, "" ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
189 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
190 s = new_DynStr( 5000 ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
191 snprintf( t, MAXCHAR, "%x", db.status ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
192 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
193 snprintf( t, MAXCHAR, "%lu", db.lastAccess ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
194 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
195 DynStr_appLn( s, db.subj ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
196 DynStr_appLn( s, db.from ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
197 DynStr_appLn( s, db.date ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
198 DynStr_appLn( s, db.ref ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
199 DynStr_appLn( s, db.xref ); |
275
0880d6edaaa5
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
271
diff
changeset
|
200 snprintf( t, MAXCHAR, "%lu", db.bytes ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
201 DynStr_appLn( s, t ); |
275
0880d6edaaa5
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
271
diff
changeset
|
202 snprintf( t, MAXCHAR, "%lu", db.lines ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
203 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
204 DynStr_appDynStr( s, db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
205 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
206 key.dptr = (void *)db.msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
207 key.dsize = strlen( db.msgId ) + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
208 val.dptr = (void *)DynStr_str( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
209 val.dsize = DynStr_len( s ) + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
210 if ( gdbm_store( db.dbf, key, val, GDBM_REPLACE ) != 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
211 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
212 Log_err( "Could not store %s in database (%s)", errMsg() ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
213 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
214 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
215 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
216 del_DynStr( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
217 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
218 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
219 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
220 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
221 Db_prepareEntry( const Over *ov, const char *grp, int numb ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
222 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
223 const char *msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
224 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
225 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
226 ASSERT( ov ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
227 ASSERT( grp ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
228 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
229 msgId = Ov_msgId( ov ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
230 Log_dbg( LOG_DBG_NEWSBASE, "Preparing entry %s", msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
231 if ( Db_contains( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
232 Log_err( "Preparing article twice: %s", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
233 |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
234 db.status = DB_NOT_DOWNLOADED; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
235 db.lastAccess = time( NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
236 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
237 Utl_cpyStr( db.msgId, msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
238 Utl_cpyStr( db.subj, Ov_subj( ov ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
239 Utl_cpyStr( db.from, Ov_from( ov ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
240 Utl_cpyStr( db.date, Ov_date( ov ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
241 Utl_cpyStr( db.ref, Ov_ref( ov ) ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
242 snprintf( db.xref, MAXCHAR, "%s:%i", grp, numb ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
243 db.bytes = Ov_bytes( ov ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
244 db.lines = Ov_lines( ov ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
245 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
246 DynStr_clear( db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
247 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
248 return saveArt(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
249 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
250 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
251 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
252 Db_storeArt( const char *msgId, const char *artTxt ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
253 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
254 Str line, lineEx, field, value; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
255 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
256 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
257 |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
258 Log_dbg( LOG_DBG_NEWSBASE, "Store article %s", msgId ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
259 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
260 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
261 Log_err( "Cannot find info about '%s' in database", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
262 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
263 } |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
264 if ( ! ( db.status & DB_NOT_DOWNLOADED ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
265 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
266 Log_err( "Trying to store already retrieved article '%s'", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
267 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
268 } |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
269 db.status &= ~DB_NOT_DOWNLOADED; |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
270 db.status &= ~DB_RETRIEVING_FAILED; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
271 db.lastAccess = time( NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
272 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
273 DynStr_clear( db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
274 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
275 /* Read header */ |
109 | 276 while ( ( artTxt = Utl_getHeaderLn( lineEx, artTxt ) ) != NULL ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
277 { |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
278 Bool continuation; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
279 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
280 if ( lineEx[ 0 ] == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
281 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
282 DynStr_appLn( db.txt, lineEx ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
283 break; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
284 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
285 /* Remove fields already in overview and handle x-noffle |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
286 headers correctly in case of cascading NOFFLEs */ |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
287 if ( Prt_getField( field, value, &continuation, lineEx ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
288 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
289 if ( strcmp( field, "x-noffle-status" ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
290 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
291 if ( strstr( value, "NOT_DOWNLOADED" ) != 0 ) |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
292 db.status |= DB_NOT_DOWNLOADED; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
293 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
294 else if ( strcmp( field, "message-id" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
295 && strcmp( field, "xref" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
296 && strcmp( field, "references" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
297 && strcmp( field, "subject" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
298 && strcmp( field, "from" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
299 && strcmp( field, "date" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
300 && strcmp( field, "bytes" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
301 && strcmp( field, "lines" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
302 && strcmp( field, "x-noffle-lastaccess" ) != 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
303 DynStr_appLn( db.txt, lineEx ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
304 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
305 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
306 |
109 | 307 if ( artTxt == NULL ) |
308 { | |
300
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
309 /* |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
310 * This article has no body. Bereft of text it lies... |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
311 * |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
312 * I'm not completely sure how surprising the rest of |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
313 * Noffle would find a body-less article, so substitute |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
314 * an empty line. |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
315 */ |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
316 Log_inf( "Article %s malformed: missing body", msgId ); |
994e9ab2c24f
[svn] * src/database.c: Accept articles with no body, substituting a body of a
bears
parents:
282
diff
changeset
|
317 artTxt = "\n"; |
109 | 318 } |
319 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
320 /* Read body */ |
109 | 321 while ( ( artTxt = Utl_getLn( line, artTxt ) ) != NULL ) |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
322 if ( ! ( db.status & DB_NOT_DOWNLOADED ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
323 DynStr_appLn( db.txt, line ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
324 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
325 return saveArt(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
326 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
327 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
328 void |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
257
diff
changeset
|
329 Db_setStatus( const char *msgId, unsigned status ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
330 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
331 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
332 { |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
333 db.status = status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
334 saveArt(); |
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 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
337 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
338 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
339 Db_updateLastAccess( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
340 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
341 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
342 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
343 db.lastAccess = time( NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
344 saveArt(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
345 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
346 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
347 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
348 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
349 Db_setXref( const char *msgId, const char *xref ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
350 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
351 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
352 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
353 Utl_cpyStr( db.xref, xref ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
354 saveArt(); |
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 } |
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 /* Search best position for breaking a line */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
359 static const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
360 searchBreakPos( const char *line, int wantedLength ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
361 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
362 const char *lastSpace = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
363 Bool lastWasSpace = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
364 int len = 0; |
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 while ( *line != '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
367 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
368 if ( isspace( *line ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
369 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
370 if ( len > wantedLength && lastSpace != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
371 return lastSpace; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
372 if ( ! lastWasSpace ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
373 lastSpace = line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
374 lastWasSpace = TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
375 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
376 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
377 lastWasSpace = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
378 ++len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
379 ++line; |
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 if ( len > wantedLength && lastSpace != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
382 return lastSpace; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
383 return line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
384 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
385 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
386 /* Append header line by breaking long line into multiple lines */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
387 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
388 appendLongHeader( DynStr *target, const char *field, const char *value ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
389 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
390 const int wantedLength = 78; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
391 const char *breakPos, *old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
392 int len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
393 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
394 len = strlen( field ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
395 DynStr_appN( target, field, len ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
396 DynStr_appN( target, " ", 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
397 old = value; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
398 while ( isspace( *old ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
399 ++old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
400 breakPos = searchBreakPos( old, wantedLength - len - 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
401 DynStr_appN( target, old, breakPos - old ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
402 if ( *breakPos == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
403 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
404 DynStr_appN( target, "\n", 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
405 return; |
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 DynStr_appN( target, "\n ", 2 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
408 while ( TRUE ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
409 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
410 old = breakPos; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
411 while ( isspace( *old ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
412 ++old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
413 breakPos = searchBreakPos( old, wantedLength - 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
414 DynStr_appN( target, old, breakPos - old ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
415 if ( *breakPos == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
416 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
417 DynStr_appN( target, "\n", 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
418 return; |
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 DynStr_appN( target, "\n ", 2 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
421 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
422 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
423 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
424 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
425 Db_header( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
426 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
427 static DynStr *s = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
428 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
429 Str date, t; |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
257
diff
changeset
|
430 unsigned status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
431 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
432 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
433 if ( s == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
434 s = new_DynStr( 5000 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
435 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
436 DynStr_clear( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
437 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
438 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
439 return NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
440 strftime( date, 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
|
441 localtime( &db.lastAccess ) ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
442 status = db.status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
443 snprintf( t, MAXCHAR, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
444 "Message-ID: %s\n" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
445 "X-NOFFLE-Status:%s%s%s\n" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
446 "X-NOFFLE-LastAccess: %s\n", |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
447 msgId, |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
448 status & DB_INTERESTING ? " INTERESTING" : "", |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
449 status & DB_NOT_DOWNLOADED ? " NOT_DOWNLOADED" : "", |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
450 status & DB_RETRIEVING_FAILED ? " RETRIEVING_FAILED" : "", |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
451 date ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
452 DynStr_app( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
453 appendLongHeader( s, "Subject:", db.subj ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
454 appendLongHeader( s, "From:", db.from ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
455 appendLongHeader( s, "Date:", db.date ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
456 appendLongHeader( s, "References:", db.ref ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
457 DynStr_app( s, "Bytes: " ); |
275
0880d6edaaa5
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
271
diff
changeset
|
458 snprintf( t, MAXCHAR, "%lu", db.bytes ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
459 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
460 DynStr_app( s, "Lines: " ); |
275
0880d6edaaa5
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
271
diff
changeset
|
461 snprintf( t, MAXCHAR, "%lu", db.lines ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
462 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
463 appendLongHeader( s, db.xrefHost, db.xref ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
464 p = strstr( DynStr_str( db.txt ), "\n\n" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
465 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
466 DynStr_appDynStr( s, db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
467 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
468 DynStr_appN( s, DynStr_str( db.txt ), p - DynStr_str( db.txt ) + 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
469 return DynStr_str( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
470 } |
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 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
473 Db_body( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
474 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
475 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
476 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
477 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
478 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
479 p = strstr( DynStr_str( db.txt ), "\n\n" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
480 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
481 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
482 return ( p + 2 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
483 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
484 |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
257
diff
changeset
|
485 unsigned |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
486 Db_status( const char *msgId ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
487 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
488 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
489 return 0; |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
490 return db.status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
491 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
492 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
493 time_t |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
494 Db_lastAccess( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
495 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
496 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
497 return -1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
498 return db.lastAccess; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
499 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
500 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
501 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
502 Db_ref( const char *msgId ) |
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 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
505 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
506 return db.ref; |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
509 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
510 Db_xref( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
511 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
512 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
513 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
514 return db.xref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
515 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
516 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
517 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
518 Db_from( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
519 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
520 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
521 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
522 return db.from; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
523 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
524 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
525 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
526 Db_date( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
527 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
528 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
529 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
530 return db.date; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
531 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
532 |
127 | 533 Over * |
534 Db_over( const char *msgId ) | |
535 { | |
536 if ( ! loadArt( msgId ) ) | |
537 return NULL; | |
538 return new_Over( db.subj, db.from, db.date, msgId, | |
539 db.ref, db.bytes, db.lines ); | |
540 } | |
541 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
542 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
543 Db_contains( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
544 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
545 datum key; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
546 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
547 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
548 if ( strcmp( msgId, db.msgId ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
549 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
550 key.dptr = (void*)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
551 key.dsize = strlen( msgId ) + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
552 return gdbm_exists( db.dbf, key ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
553 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
554 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
555 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
556 Db_delete( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
557 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
558 datum key; |
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 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
561 if ( strcmp( msgId, db.msgId ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
562 db.msgId[ 0 ] = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
563 key.dptr = (void*)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
564 key.dsize = strlen( msgId ) + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
565 gdbm_delete( db.dbf, key ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
566 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
567 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
568 static datum cursor = { NULL, 0 }; |
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 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
571 Db_first( const char** msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
572 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
573 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
574 if ( cursor.dptr != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
575 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
576 free( cursor.dptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
577 cursor.dptr = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
578 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
579 cursor = gdbm_firstkey( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
580 *msgId = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
581 return ( cursor.dptr != NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
582 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
583 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
584 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
585 Db_next( const char** msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
586 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
587 void *oldDptr = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
588 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
589 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
590 if ( cursor.dptr == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
591 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
592 cursor = gdbm_nextkey( db.dbf, cursor ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
593 free( oldDptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
594 *msgId = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
595 return ( cursor.dptr != NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
596 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
597 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
598 void |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
599 Db_compact( void ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
600 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
601 ASSERT( db.dbf ); |
257
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
602 |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
603 /* |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
604 * You'd think it would be sensible to do something like |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
605 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
606 * if ( gdbm_reorganize( db.dbf ) != 0 ) |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
607 * Log_err( "Error compacting article base: %s", errMsg() ); |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
608 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
609 * here. But this just copies the database to a new one and renames, |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
610 * which is what Db_rebuild() does. |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
611 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
612 * So do nothing. We don't want expire to chew disc space. |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
613 */ |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
614 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
615 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
616 /* |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
617 Helper functions for database rebuild. |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
618 */ |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
619 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
620 static struct DbNew |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
621 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
622 GDBM_FILE dbf; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
623 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
624 } dbNew = { NULL }; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
625 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
626 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
627 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
628 newOpen( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
629 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
630 Str name; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
631 int flags; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
632 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
633 ASSERT( dbNew.dbf == NULL ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
634 snprintf( name, MAXCHAR, ARTICLE_NEW_FILENAME_FMT, Cfg_spoolDir() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
635 flags = GDBM_WRCREAT | GDBM_FAST; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
636 |
281
5eece4dfd945
[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents:
276
diff
changeset
|
637 if ( ! ( dbNew.dbf = gdbm_open( name, 512, flags, 0644, Log_gdbm_fatal ) ) ) |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
638 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
639 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
640 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
641 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
642 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
643 return TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
644 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
645 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
646 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
647 newClose( Bool makeMain ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
648 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
649 Str newName; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
650 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
651 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
652 Log_dbg( LOG_DBG_NEWSBASE, "Closing new database" ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
653 gdbm_close( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
654 dbNew.dbf = NULL; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
655 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
656 snprintf( newName, MAXCHAR, ARTICLE_NEW_FILENAME_FMT, Cfg_spoolDir() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
657 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
658 if ( makeMain ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
659 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
660 Str name; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
661 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
662 ASSERT( db.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
663 Db_close(); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
664 snprintf( name, MAXCHAR, ARTICLE_FILENAME_FMT, Cfg_spoolDir() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
665 if ( rename( newName, name ) != 0 ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
666 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
667 Log_err( "Rename %s to %s failed: %s", |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
668 newName, name, strerror( errno ) ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
669 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
670 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
671 Log_dbg( LOG_DBG_NEWSBASE, "Renamed %s to %s", newName, name ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
672 return Db_open(); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
673 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
674 else |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
675 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
676 if ( unlink( newName ) != 0 ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
677 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
678 Log_err( "Unlink %s failed: %s", newName, strerror( errno ) ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
679 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
680 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
681 Log_dbg( LOG_DBG_NEWSBASE, "Deleted %s", newName ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
682 return TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
683 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
684 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
685 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
686 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
687 newCopyArt( const char *msgId ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
688 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
689 datum key, val; |
105 | 690 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
691 ASSERT( db.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
692 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
693 key.dptr = (void *)msgId; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
694 key.dsize = strlen( msgId ) + 1; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
695 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
696 val = gdbm_fetch( db.dbf, key ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
697 if ( val.dptr != NULL ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
698 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
699 Bool res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
700 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
701 res = ( gdbm_store( dbNew.dbf, key, val, GDBM_INSERT ) == 0 ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
702 if ( ! res ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
703 Log_err( "Could not store %s in new database (%s)", |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
704 msgId, errMsg() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
705 free( val.dptr ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
706 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
707 } |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
708 Log_err( "%s not found in database", msgId ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
709 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
710 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
711 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
712 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
713 newContains( const char *msgId ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
714 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
715 datum key; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
716 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
717 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
718 key.dptr = (void*)msgId; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
719 key.dsize = strlen( msgId ) + 1; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
720 return gdbm_exists( dbNew.dbf, key ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
721 } |
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 Bool |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
724 Db_rebuild( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
725 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
726 const Over *ov; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
727 int i; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
728 Str grp; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
729 const char *msgId; |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
730 Bool err; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
731 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
732 if ( ! Cont_firstGrp( grp ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
733 return FALSE; |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
734 if ( ! newOpen() ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
735 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
736 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
737 Log_inf( "Rebuilding article database" ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
738 err = FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
739 do |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
740 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
741 if ( ! Grp_exists( grp ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
742 Log_err( "Overview file for unknown group %s exists", grp ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
743 else |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
744 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
745 Cont_read( grp ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
746 for ( i = Cont_first(); i <= Cont_last(); ++i ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
747 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
748 if ( ! Cont_validNumb( i ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
749 continue; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
750 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
751 if ( ( ov = Cont_get( i ) ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
752 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
753 msgId = Ov_msgId( ov ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
754 if ( msgId == NULL ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
755 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
756 err = TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
757 Log_err( "Overview in %s has no msg id", grp ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
758 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
759 else if ( ! newContains( msgId ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
760 err |= ! newCopyArt( msgId ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
761 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
762 else |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
763 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
764 err = TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
765 Log_err( "Overview %d not available in group %s", i, grp ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
766 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
767 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
768 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
769 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
770 while ( Cont_nextGrp( grp ) ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
771 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
772 return newClose( ! err ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
773 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
774 |
482
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
775 /* Utility function. Find the upstream server for a particular message. */ |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
776 Bool |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
777 Db_findServer( const char *msgId, Str server ) |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
778 { |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
779 const char *p, *pColon, *srv; |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
780 Str s, grp; |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
781 Bool res = FALSE; |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
782 |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
783 if ( Db_contains( msgId ) ) |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
784 { |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
785 Utl_cpyStr( s, Db_xref( msgId ) ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
786 p = strtok( s, " \t" ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
787 if ( p ) |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
788 do |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
789 { |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
790 pColon = strstr( p, ":" ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
791 if ( pColon ) |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
792 { |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
793 Utl_cpyStrN( grp, p, pColon - p ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
794 srv = Grp_server( grp ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
795 if ( Cfg_servIsPreferential( srv, server ) ) |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
796 { |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
797 Utl_cpyStr( server, srv ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
798 res = TRUE; |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
799 } |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
800 } |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
801 } |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
802 while ( ( p = strtok( NULL, " \t" ) ) ); |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
803 } |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
804 |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
805 return res; |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
806 } |
a04c52f87b6e
[svn] * docs/noffle.1,src/database.h,src/database.c,src/noffle.c,src/server.c:
bears
parents:
300
diff
changeset
|
807 |