Mercurial > noffle
annotate src/database.c @ 278:a0497ffac49b noffle
[svn] I'm not very good at automake. Redo with automake2.13.
author | bears |
---|---|
date | Sun, 10 Nov 2002 18:49:41 +0000 |
parents | 16dad3488e9d |
children | 5eece4dfd945 |
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 |
276
16dad3488e9d
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
275
diff
changeset
|
4 $Id: database.c 408 2002-11-10 18:31:25Z 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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
82 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, NULL ) ) ) |
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 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
149 if ( ! p || sscanf( t, "%lu", &db.lastAccess ) != 1 ) |
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 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
278 if ( lineEx[ 0 ] == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
279 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
280 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
|
281 break; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
282 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
283 /* 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
|
284 headers correctly in case of cascading NOFFLEs */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
285 if ( Prt_getField( field, value, lineEx ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
286 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
287 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
|
288 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
289 if ( strstr( value, "NOT_DOWNLOADED" ) != 0 ) |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
290 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
|
291 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
292 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
|
293 && strcmp( field, "xref" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
294 && strcmp( field, "references" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
295 && strcmp( field, "subject" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
296 && strcmp( field, "from" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
297 && strcmp( field, "date" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
298 && strcmp( field, "bytes" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
299 && strcmp( field, "lines" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
300 && 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
|
301 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
|
302 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
303 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
304 |
109 | 305 if ( artTxt == NULL ) |
306 { | |
307 Log_err( "Article %s malformed: missing body", msgId ); | |
308 return FALSE; | |
309 } | |
310 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
311 /* Read body */ |
109 | 312 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
|
313 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
|
314 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
|
315 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
316 return saveArt(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
317 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
318 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
319 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
|
320 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
|
321 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
322 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
323 { |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
324 db.status = status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
325 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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
329 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
330 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
|
331 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
332 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
333 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
334 db.lastAccess = time( NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
335 saveArt(); |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
339 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
340 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
|
341 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
342 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
343 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
344 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
|
345 saveArt(); |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
349 /* 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
|
350 static const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
351 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
|
352 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
353 const char *lastSpace = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
354 Bool lastWasSpace = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
355 int len = 0; |
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 while ( *line != '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
358 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
359 if ( isspace( *line ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
360 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
361 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
|
362 return lastSpace; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
363 if ( ! lastWasSpace ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
364 lastSpace = line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
365 lastWasSpace = TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
366 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
367 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
368 lastWasSpace = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
369 ++len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
370 ++line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
371 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
372 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
|
373 return lastSpace; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
374 return line; |
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 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
377 /* 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
|
378 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
379 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
|
380 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
381 const int wantedLength = 78; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
382 const char *breakPos, *old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
383 int len; |
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 len = strlen( field ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
386 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
|
387 DynStr_appN( target, " ", 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
388 old = value; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
389 while ( isspace( *old ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
390 ++old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
391 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
|
392 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
|
393 if ( *breakPos == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
394 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
395 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
|
396 return; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
397 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
398 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
|
399 while ( TRUE ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
400 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
401 old = breakPos; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
402 while ( isspace( *old ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
403 ++old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
404 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
|
405 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
|
406 if ( *breakPos == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
407 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
408 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
|
409 return; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
410 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
411 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
|
412 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
413 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
414 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
415 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
416 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
|
417 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
418 static DynStr *s = NULL; |
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 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
|
421 unsigned status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
422 const char *p; |
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 if ( s == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
425 s = new_DynStr( 5000 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
426 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
427 DynStr_clear( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
428 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
429 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
430 return NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
431 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
|
432 localtime( &db.lastAccess ) ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
433 status = db.status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
434 snprintf( t, MAXCHAR, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
435 "Message-ID: %s\n" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
436 "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
|
437 "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
|
438 msgId, |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
439 status & DB_INTERESTING ? " INTERESTING" : "", |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
440 status & DB_NOT_DOWNLOADED ? " NOT_DOWNLOADED" : "", |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
441 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
|
442 date ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
443 DynStr_app( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
444 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
|
445 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
|
446 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
|
447 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
|
448 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
|
449 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
|
450 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
451 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
|
452 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
|
453 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
454 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
|
455 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
|
456 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
457 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
|
458 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
459 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
|
460 return DynStr_str( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
461 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
462 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
463 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
464 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
|
465 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
466 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
467 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
468 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
469 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
470 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
|
471 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
472 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
473 return ( p + 2 ); |
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 |
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
|
476 unsigned |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
477 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
|
478 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
479 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
480 return 0; |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
481 return db.status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
482 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
483 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
484 time_t |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
485 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
|
486 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
487 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
488 return -1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
489 return db.lastAccess; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
490 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
491 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
492 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
493 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
|
494 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
495 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
496 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
497 return db.ref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
498 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
499 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
500 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
501 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
|
502 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
503 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
504 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
505 return db.xref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
506 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
507 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
508 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
509 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
|
510 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
511 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
512 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
513 return db.from; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
514 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
515 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
516 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
517 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
|
518 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
519 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
520 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
521 return db.date; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
522 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
523 |
127 | 524 Over * |
525 Db_over( const char *msgId ) | |
526 { | |
527 if ( ! loadArt( msgId ) ) | |
528 return NULL; | |
529 return new_Over( db.subj, db.from, db.date, msgId, | |
530 db.ref, db.bytes, db.lines ); | |
531 } | |
532 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
533 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
534 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
|
535 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
536 datum key; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
537 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
538 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
539 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
|
540 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
541 key.dptr = (void*)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
542 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
|
543 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
|
544 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
545 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
546 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
547 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
|
548 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
549 datum key; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
550 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
551 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
552 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
|
553 db.msgId[ 0 ] = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
554 key.dptr = (void*)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
555 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
|
556 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
|
557 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
558 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
559 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
|
560 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
561 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
562 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
|
563 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
564 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
565 if ( cursor.dptr != NULL ) |
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 free( cursor.dptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
568 cursor.dptr = NULL; |
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 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
|
571 *msgId = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
572 return ( cursor.dptr != NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
573 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
574 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
575 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
576 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
|
577 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
578 void *oldDptr = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
579 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
580 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
581 if ( cursor.dptr == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
582 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
583 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
|
584 free( oldDptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
585 *msgId = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
586 return ( cursor.dptr != NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
587 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
588 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
589 void |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
590 Db_compact( void ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
591 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
592 ASSERT( db.dbf ); |
257
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
593 |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
594 /* |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
595 * 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
|
596 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
597 * if ( gdbm_reorganize( db.dbf ) != 0 ) |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
598 * 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
|
599 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
600 * 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
|
601 * which is what Db_rebuild() does. |
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 * 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
|
604 */ |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
605 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
606 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
607 /* |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
608 Helper functions for database rebuild. |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
609 */ |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
610 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
611 static struct DbNew |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
612 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
613 GDBM_FILE dbf; |
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 } dbNew = { NULL }; |
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 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
618 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
619 newOpen( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
620 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
621 Str name; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
622 int flags; |
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 ASSERT( dbNew.dbf == NULL ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
625 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
|
626 flags = GDBM_WRCREAT | GDBM_FAST; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
627 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
628 if ( ! ( dbNew.dbf = gdbm_open( name, 512, flags, 0644, NULL ) ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
629 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
630 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
|
631 return FALSE; |
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 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
|
634 return TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
635 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
636 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
637 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
638 newClose( Bool makeMain ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
639 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
640 Str newName; |
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 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
643 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
|
644 gdbm_close( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
645 dbNew.dbf = NULL; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
646 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
647 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
|
648 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
649 if ( makeMain ) |
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 Str name; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
652 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
653 ASSERT( db.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
654 Db_close(); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
655 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
|
656 if ( rename( newName, name ) != 0 ) |
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 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
|
659 newName, name, strerror( errno ) ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
660 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
661 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
662 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
|
663 return Db_open(); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
664 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
665 else |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
666 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
667 if ( unlink( newName ) != 0 ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
668 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
669 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
|
670 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
671 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
672 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
|
673 return TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
674 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
675 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
676 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
677 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
678 newCopyArt( const char *msgId ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
679 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
680 datum key, val; |
105 | 681 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
682 ASSERT( db.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
683 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
684 key.dptr = (void *)msgId; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
685 key.dsize = strlen( msgId ) + 1; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
686 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
687 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
|
688 if ( val.dptr != NULL ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
689 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
690 Bool res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
691 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
692 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
|
693 if ( ! res ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
694 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
|
695 msgId, errMsg() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
696 free( val.dptr ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
697 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
698 } |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
699 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
|
700 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
701 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
702 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
703 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
704 newContains( const char *msgId ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
705 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
706 datum key; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
707 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
708 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
709 key.dptr = (void*)msgId; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
710 key.dsize = strlen( msgId ) + 1; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
711 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
|
712 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
713 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
714 Bool |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
715 Db_rebuild( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
716 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
717 const Over *ov; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
718 int i; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
719 Str grp; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
720 const char *msgId; |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
721 Bool err; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
722 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
723 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
|
724 return FALSE; |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
725 if ( ! newOpen() ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
726 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
727 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
728 Log_inf( "Rebuilding article database" ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
729 err = FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
730 do |
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 ( ! Grp_exists( grp ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
733 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
|
734 else |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
735 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
736 Cont_read( grp ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
737 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
|
738 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
739 if ( ! Cont_validNumb( i ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
740 continue; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
741 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
742 if ( ( ov = Cont_get( i ) ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
743 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
744 msgId = Ov_msgId( ov ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
745 if ( msgId == NULL ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
746 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
747 err = TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
748 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
|
749 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
750 else if ( ! newContains( msgId ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
751 err |= ! newCopyArt( msgId ); |
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 else |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
754 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
755 err = TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
756 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
|
757 } |
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 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
760 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
761 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
|
762 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
763 return newClose( ! err ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
764 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
765 |