Mercurial > noffle
annotate src/database.c @ 282:baa6408d1bbc noffle
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
check the article for those headers that are specified in section
5 of the IETF draft and ensure they only occur once.
* src/post.c: Clean up a conditional.
author | bears |
---|---|
date | Mon, 06 Jan 2003 18:16:18 +0000 |
parents | 5eece4dfd945 |
children | 994e9ab2c24f |
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 |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
4 $Id: database.c 414 2003-01-06 18:16:18Z bears $ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
5 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
6 Uses GNU gdbm library. Using Berkeley db (included in libc6) was |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
7 cumbersome. It is based on Berkeley db 1.85, which has severe bugs |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
8 (e.g. it is not recommended to delete or overwrite entries with |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
9 overflow pages). |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
10 */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
11 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
12 #if HAVE_CONFIG_H |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
13 #include <config.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
14 #endif |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
15 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
16 #include <stdio.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
17 #include <ctype.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
18 #include <errno.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
19 #include <gdbm.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
20 #include <unistd.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
21 #include <sys/types.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
22 #include <sys/stat.h> |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
23 #include "configfile.h" |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
24 #include "content.h" |
197
24d4cd032da5
[svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents:
185
diff
changeset
|
25 #include "database.h" |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
26 #include "group.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
27 #include "log.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
28 #include "protocol.h" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
29 #include "util.h" |
54
125d79c9e586
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents:
43
diff
changeset
|
30 #include "portable.h" |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
31 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
32 static const char ARTICLE_FILENAME_FMT[] = "%s/data/articles.gdbm"; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
33 static const char ARTICLE_NEW_FILENAME_FMT[] = "%s/data/articles.gdbm.new"; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
34 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
35 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
36 static struct Db |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
37 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
38 GDBM_FILE dbf; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
39 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
40 /* Start string for Xref header line: "Xref: <host>" */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
41 Str xrefHost; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
42 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
43 /* Msg Id of presently loaded article, empty if none loaded */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
44 Str msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
45 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
46 /* Status of loaded article */ |
271
3477050e8d10
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
bears
parents:
257
diff
changeset
|
47 unsigned status; /* Flags */ |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
48 time_t lastAccess; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
49 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
50 /* Overview of loaded article */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
51 Str subj; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
52 Str from; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
53 Str date; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
54 Str ref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
55 Str xref; |
276
16dad3488e9d
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
275
diff
changeset
|
56 unsigned long bytes; |
16dad3488e9d
[svn] * src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
bears
parents:
275
diff
changeset
|
57 unsigned long lines; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
58 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
59 /* Article text (except for overview header lines) */ |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
60 DynStr *txt; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
61 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
62 } db = { NULL, "(unknown)", "", 0, 0, "", "", "", "", "", 0, 0, NULL }; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
63 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
64 static const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
65 errMsg( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
66 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
67 if ( gdbm_errno == GDBM_NO_ERROR ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
68 return strerror( errno ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
69 return gdbm_strerror( gdbm_errno ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
70 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
71 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
72 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
73 Db_open( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
74 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
75 Str name, host; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
76 int flags; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
77 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
78 ASSERT( db.dbf == NULL ); |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
79 snprintf( name, MAXCHAR, ARTICLE_FILENAME_FMT, Cfg_spoolDir() ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
80 flags = GDBM_WRCREAT | GDBM_FAST; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
81 |
281
5eece4dfd945
[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents:
276
diff
changeset
|
82 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, Log_gdbm_fatal ) ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
83 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
84 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
85 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
86 } |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
87 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
88 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
89 if ( db.txt == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
90 db.txt = new_DynStr( 5000 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
91 |
244
4e69e9b722ae
[svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF
bears
parents:
240
diff
changeset
|
92 if ( ! Utl_getFQDN( host ) ) |
4e69e9b722ae
[svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF
bears
parents:
240
diff
changeset
|
93 Utl_cpyStr( host, "localhost.localdomain" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
94 snprintf( db.xrefHost, MAXCHAR, "Xref: %s", host ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
95 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
96 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
97 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
98 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
99 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
100 Db_close( void ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
101 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
102 ASSERT( db.dbf ); |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
103 Log_dbg( LOG_DBG_NEWSBASE, "Closing database" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
104 gdbm_close( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
105 db.dbf = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
106 del_DynStr( db.txt ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
107 db.txt = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
108 Utl_cpyStr( db.msgId, "" ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
109 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
110 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
111 static Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
112 loadArt( const char *msgId ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
113 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
114 static void *dptr = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
115 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
116 datum key, val; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
117 Str t = ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
118 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
119 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
120 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
121 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
122 if ( strcmp( msgId, db.msgId ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
123 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
124 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
125 key.dptr = (void *)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
126 key.dsize = strlen( msgId ) + 1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
127 if ( dptr != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
128 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
129 free( dptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
130 dptr = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
131 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
132 val = gdbm_fetch( db.dbf, key ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
133 dptr = val.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
134 if ( dptr == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
135 { |
185
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
136 Log_dbg( LOG_DBG_NEWSBASE, |
fed1334d766b
[svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents:
170
diff
changeset
|
137 "database.c loadArt: gdbm_fetch found no entry" ); |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
138 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
139 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
140 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
141 Utl_cpyStr( db.msgId, msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
142 p = Utl_getLn( t, (char *)dptr ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
143 if ( ! p || sscanf( t, "%x", &db.status ) != 1 ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
144 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
145 Log_err( "Entry in database '%s' is corrupt (status)", msgId ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
146 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
147 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
148 p = Utl_getLn( t, p ); |
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 { |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
278 Bool continuation; |
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
279 |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
280 if ( lineEx[ 0 ] == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
281 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
282 DynStr_appLn( db.txt, lineEx ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
283 break; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
284 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
285 /* Remove fields already in overview and handle x-noffle |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
286 headers correctly in case of cascading NOFFLEs */ |
282
baa6408d1bbc
[svn] * src/database.c,src/post.c,src/protocol.h,src/protocol.c: When posting,
bears
parents:
281
diff
changeset
|
287 if ( Prt_getField( field, value, &continuation, lineEx ) ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
288 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
289 if ( strcmp( field, "x-noffle-status" ) == 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
290 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
291 if ( strstr( value, "NOT_DOWNLOADED" ) != 0 ) |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
292 db.status |= DB_NOT_DOWNLOADED; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
293 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
294 else if ( strcmp( field, "message-id" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
295 && strcmp( field, "xref" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
296 && strcmp( field, "references" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
297 && strcmp( field, "subject" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
298 && strcmp( field, "from" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
299 && strcmp( field, "date" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
300 && strcmp( field, "bytes" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
301 && strcmp( field, "lines" ) != 0 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
302 && strcmp( field, "x-noffle-lastaccess" ) != 0 ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
303 DynStr_appLn( db.txt, lineEx ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
304 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
305 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
306 |
109 | 307 if ( artTxt == NULL ) |
308 { | |
309 Log_err( "Article %s malformed: missing body", msgId ); | |
310 return FALSE; | |
311 } | |
312 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
313 /* Read body */ |
109 | 314 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
|
315 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
|
316 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
|
317 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
318 return saveArt(); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
319 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
320 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
321 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
|
322 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
|
323 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
324 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
325 { |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
326 db.status = status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
327 saveArt(); |
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 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
330 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
331 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
332 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
|
333 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
334 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
335 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
336 db.lastAccess = time( NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
337 saveArt(); |
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 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
340 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
341 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
342 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
|
343 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
344 if ( loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
345 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
346 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
|
347 saveArt(); |
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 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
350 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
351 /* 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
|
352 static const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
353 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
|
354 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
355 const char *lastSpace = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
356 Bool lastWasSpace = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
357 int len = 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 while ( *line != '\0' ) |
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 ( isspace( *line ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
362 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
363 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
|
364 return lastSpace; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
365 if ( ! lastWasSpace ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
366 lastSpace = line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
367 lastWasSpace = TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
368 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
369 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
370 lastWasSpace = FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
371 ++len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
372 ++line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
373 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
374 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
|
375 return lastSpace; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
376 return line; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
377 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
378 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
379 /* 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
|
380 static void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
381 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
|
382 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
383 const int wantedLength = 78; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
384 const char *breakPos, *old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
385 int len; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
386 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
387 len = strlen( field ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
388 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
|
389 DynStr_appN( target, " ", 1 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
390 old = value; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
391 while ( isspace( *old ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
392 ++old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
393 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
|
394 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
|
395 if ( *breakPos == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
396 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
397 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
|
398 return; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
399 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
400 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
|
401 while ( TRUE ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
402 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
403 old = breakPos; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
404 while ( isspace( *old ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
405 ++old; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
406 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
|
407 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
|
408 if ( *breakPos == '\0' ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
409 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
410 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
|
411 return; |
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 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
|
414 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
415 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
416 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
417 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
418 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
|
419 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
420 static DynStr *s = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
421 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
422 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
|
423 unsigned status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
424 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
425 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
426 if ( s == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
427 s = new_DynStr( 5000 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
428 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
429 DynStr_clear( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
430 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
431 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
432 return NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
433 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
|
434 localtime( &db.lastAccess ) ); |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
435 status = db.status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
436 snprintf( t, MAXCHAR, |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
437 "Message-ID: %s\n" |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
438 "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
|
439 "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
|
440 msgId, |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
441 status & DB_INTERESTING ? " INTERESTING" : "", |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
442 status & DB_NOT_DOWNLOADED ? " NOT_DOWNLOADED" : "", |
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
443 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
|
444 date ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
445 DynStr_app( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
453 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
|
454 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
|
455 DynStr_appLn( s, t ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
456 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
|
457 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
|
458 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
459 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
|
460 else |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
461 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
|
462 return DynStr_str( s ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
463 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
464 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
465 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
466 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
|
467 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
468 const char *p; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
469 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
470 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
471 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
472 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
|
473 if ( ! p ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
474 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
475 return ( p + 2 ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
476 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
477 |
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
|
478 unsigned |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
479 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
|
480 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
481 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
482 return 0; |
61
adf0af5152f7
[svn] Renamed some variables and function names, because they caused compiler
enz
parents:
54
diff
changeset
|
483 return db.status; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
484 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
485 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
486 time_t |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
487 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
|
488 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
489 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
490 return -1; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
491 return db.lastAccess; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
492 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
493 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
494 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
495 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
|
496 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
497 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
498 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
499 return db.ref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
500 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
501 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
502 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
503 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
|
504 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
505 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
506 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
507 return db.xref; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
508 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
509 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
510 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
511 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
|
512 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
513 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
514 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
515 return db.from; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
516 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
517 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
518 const char * |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
519 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
|
520 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
521 if ( ! loadArt( msgId ) ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
522 return ""; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
523 return db.date; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
524 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
525 |
127 | 526 Over * |
527 Db_over( const char *msgId ) | |
528 { | |
529 if ( ! loadArt( msgId ) ) | |
530 return NULL; | |
531 return new_Over( db.subj, db.from, db.date, msgId, | |
532 db.ref, db.bytes, db.lines ); | |
533 } | |
534 | |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
535 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
536 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
|
537 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
538 datum key; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
539 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
540 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
541 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
|
542 return TRUE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
543 key.dptr = (void*)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
544 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
|
545 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
|
546 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
547 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
548 void |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
549 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
|
550 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
551 datum key; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
552 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
553 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
554 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
|
555 db.msgId[ 0 ] = '\0'; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
556 key.dptr = (void*)msgId; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
557 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
|
558 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
|
559 } |
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 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
|
562 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
563 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
564 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
|
565 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
566 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
567 if ( cursor.dptr != NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
568 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
569 free( cursor.dptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
570 cursor.dptr = NULL; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
571 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
572 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
|
573 *msgId = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
574 return ( cursor.dptr != NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
575 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
576 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
577 Bool |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
578 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
|
579 { |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
580 void *oldDptr = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
581 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
582 ASSERT( db.dbf ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
583 if ( cursor.dptr == NULL ) |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
584 return FALSE; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
585 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
|
586 free( oldDptr ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
587 *msgId = cursor.dptr; |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
588 return ( cursor.dptr != NULL ); |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
589 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
590 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
591 void |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
592 Db_compact( void ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
593 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
594 ASSERT( db.dbf ); |
257
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
595 |
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 * 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
|
598 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
599 * if ( gdbm_reorganize( db.dbf ) != 0 ) |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
600 * 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
|
601 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
602 * 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
|
603 * which is what Db_rebuild() does. |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
604 * |
087e7039b569
[svn] * src/database.c: DB_compact() now does nothing. It was calling
bears
parents:
255
diff
changeset
|
605 * 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
|
606 */ |
255
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 |
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 Helper functions for database rebuild. |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
611 */ |
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 static struct DbNew |
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 GDBM_FILE dbf; |
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 } dbNew = { NULL }; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
618 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
619 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
620 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
621 newOpen( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
622 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
623 Str name; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
624 int flags; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
625 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
626 ASSERT( dbNew.dbf == NULL ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
627 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
|
628 flags = GDBM_WRCREAT | GDBM_FAST; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
629 |
281
5eece4dfd945
[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
bears
parents:
276
diff
changeset
|
630 if ( ! ( dbNew.dbf = gdbm_open( name, 512, flags, 0644, Log_gdbm_fatal ) ) ) |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
631 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
632 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
|
633 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
634 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
635 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
|
636 return TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
637 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
638 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
639 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
640 newClose( Bool makeMain ) |
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 Str newName; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
643 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
644 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
645 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
|
646 gdbm_close( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
647 dbNew.dbf = NULL; |
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 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
|
650 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
651 if ( makeMain ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
652 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
653 Str name; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
654 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
655 ASSERT( db.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
656 Db_close(); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
657 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
|
658 if ( rename( newName, name ) != 0 ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
659 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
660 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
|
661 newName, name, strerror( errno ) ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
662 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
663 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
664 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
|
665 return Db_open(); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
666 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
667 else |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
668 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
669 if ( unlink( newName ) != 0 ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
670 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
671 Log_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
|
672 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
673 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
674 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
|
675 return TRUE; |
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 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
678 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
679 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
680 newCopyArt( const char *msgId ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
681 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
682 datum key, val; |
105 | 683 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
684 ASSERT( db.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
685 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
686 key.dptr = (void *)msgId; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
687 key.dsize = strlen( msgId ) + 1; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
688 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
689 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
|
690 if ( val.dptr != NULL ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
691 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
692 Bool res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
693 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
694 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
|
695 if ( ! res ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
696 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
|
697 msgId, errMsg() ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
698 free( val.dptr ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
699 return res; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
700 } |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
701 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
|
702 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
703 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
704 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
705 static Bool |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
706 newContains( const char *msgId ) |
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 datum key; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
709 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
710 ASSERT( dbNew.dbf ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
711 key.dptr = (void*)msgId; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
712 key.dsize = strlen( msgId ) + 1; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
713 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
|
714 } |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
715 |
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
716 Bool |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
717 Db_rebuild( void ) |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
718 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
719 const Over *ov; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
720 int i; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
721 Str grp; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
722 const char *msgId; |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
723 Bool err; |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
724 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
725 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
|
726 return FALSE; |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
727 if ( ! newOpen() ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
728 return FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
729 |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
730 Log_inf( "Rebuilding article database" ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
731 err = FALSE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
732 do |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
733 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
734 if ( ! Grp_exists( grp ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
735 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
|
736 else |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
737 { |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
738 Cont_read( grp ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
739 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
|
740 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
741 if ( ! Cont_validNumb( i ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
742 continue; |
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 if ( ( ov = Cont_get( i ) ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
745 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
746 msgId = Ov_msgId( ov ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
747 if ( msgId == NULL ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
748 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
749 err = TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
750 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
|
751 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
752 else if ( ! newContains( msgId ) ) |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
753 err |= ! newCopyArt( msgId ); |
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 else |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
756 { |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
757 err = TRUE; |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
758 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
|
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 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
762 } |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
763 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
|
764 |
255
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
765 return newClose( ! err ); |
52f467c7213b
[svn] * docs/noffle.1,src/Makefile.am,src/Makefile.in,src/content.c,
bears
parents:
247
diff
changeset
|
766 } |
43
2842f50feb55
[svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff
changeset
|
767 |