1998-07-09 13:37:17 +00:00
|
|
|
/* tdbio.h - Trust database I/O functions
|
2001-03-08 14:33:24 +00:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
1998-07-09 13:37:17 +00:00
|
|
|
*
|
1998-12-23 12:41:40 +00:00
|
|
|
* This file is part of GnuPG.
|
1998-07-09 13:37:17 +00:00
|
|
|
*
|
1998-12-23 12:41:40 +00:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
1998-07-09 13:37:17 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
1998-12-23 12:41:40 +00:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
1998-07-09 13:37:17 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef G10_TDBIO_H
|
|
|
|
#define G10_TDBIO_H
|
|
|
|
|
1998-10-21 17:34:36 +00:00
|
|
|
#include "host2net.h"
|
1998-07-09 13:37:17 +00:00
|
|
|
|
|
|
|
#define TRUST_RECORD_LEN 40
|
|
|
|
#define SIGS_PER_RECORD ((TRUST_RECORD_LEN-10)/5)
|
|
|
|
#define ITEMS_PER_HTBL_RECORD ((TRUST_RECORD_LEN-2)/4)
|
|
|
|
#define ITEMS_PER_HLST_RECORD ((TRUST_RECORD_LEN-6)/5)
|
1998-08-05 16:51:59 +00:00
|
|
|
#define ITEMS_PER_PREF_RECORD (TRUST_RECORD_LEN-10)
|
|
|
|
#if ITEMS_PER_PREF_RECORD % 2
|
|
|
|
#error ITEMS_PER_PREF_RECORD must be even
|
|
|
|
#endif
|
1998-07-09 13:37:17 +00:00
|
|
|
#define MAX_LIST_SIGS_DEPTH 20
|
|
|
|
|
|
|
|
|
|
|
|
#define RECTYPE_VER 1
|
1998-07-14 17:10:28 +00:00
|
|
|
#define RECTYPE_HTBL 10
|
|
|
|
#define RECTYPE_HLST 11
|
2001-09-24 16:03:14 +00:00
|
|
|
#define RECTYPE_TRUST 12
|
|
|
|
#define RECTYPE_VALID 13
|
1998-10-07 13:30:43 +00:00
|
|
|
#define RECTYPE_FREE 254
|
1998-07-09 13:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct trust_record {
|
|
|
|
int rectype;
|
1998-07-15 18:05:01 +00:00
|
|
|
int mark;
|
1998-10-12 20:16:38 +00:00
|
|
|
int dirty; /* for now only used internal by functions */
|
1998-10-07 13:30:43 +00:00
|
|
|
struct trust_record *next; /* help pointer to build lists in memory */
|
1998-07-15 18:05:01 +00:00
|
|
|
ulong recnum;
|
1998-07-09 13:37:17 +00:00
|
|
|
union {
|
1998-07-29 19:35:05 +00:00
|
|
|
struct { /* version record: */
|
2001-09-24 16:03:14 +00:00
|
|
|
byte version; /* should be 3 */
|
1998-11-13 19:41:41 +00:00
|
|
|
byte marginals;
|
|
|
|
byte completes;
|
|
|
|
byte cert_depth;
|
1998-07-09 13:37:17 +00:00
|
|
|
ulong created; /* timestamp of trustdb creation */
|
2001-09-24 16:03:14 +00:00
|
|
|
ulong nextcheck; /* timestamp of next scheduled check */
|
|
|
|
ulong reserved;
|
|
|
|
ulong reserved2;
|
1998-10-07 13:30:43 +00:00
|
|
|
ulong firstfree;
|
2001-09-24 16:03:14 +00:00
|
|
|
ulong reserved3;
|
|
|
|
ulong trusthashtbl;
|
1998-07-09 13:37:17 +00:00
|
|
|
} ver;
|
1998-10-07 13:30:43 +00:00
|
|
|
struct { /* free record */
|
|
|
|
ulong next;
|
|
|
|
} free;
|
1998-07-09 13:37:17 +00:00
|
|
|
struct {
|
|
|
|
ulong item[ITEMS_PER_HTBL_RECORD];
|
|
|
|
} htbl;
|
|
|
|
struct {
|
1998-07-14 17:10:28 +00:00
|
|
|
ulong next;
|
1998-10-12 20:16:38 +00:00
|
|
|
ulong rnum[ITEMS_PER_HLST_RECORD]; /* of another record */
|
1998-07-09 13:37:17 +00:00
|
|
|
} hlst;
|
2001-09-24 16:03:14 +00:00
|
|
|
struct {
|
|
|
|
byte fingerprint[20];
|
|
|
|
byte ownertrust;
|
|
|
|
byte depth;
|
|
|
|
ulong validlist;
|
|
|
|
} trust;
|
|
|
|
struct {
|
|
|
|
byte namehash[20];
|
|
|
|
ulong next;
|
|
|
|
byte validity;
|
|
|
|
} valid;
|
1998-07-09 13:37:17 +00:00
|
|
|
} r;
|
|
|
|
};
|
|
|
|
typedef struct trust_record TRUSTREC;
|
|
|
|
|
|
|
|
/*-- tdbio.c --*/
|
|
|
|
int tdbio_set_dbname( const char *new_dbname, int create );
|
|
|
|
const char *tdbio_get_dbname(void);
|
1998-07-21 12:53:38 +00:00
|
|
|
void tdbio_dump_record( TRUSTREC *rec, FILE *fp );
|
1998-07-09 13:37:17 +00:00
|
|
|
int tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected );
|
1998-07-15 18:05:01 +00:00
|
|
|
int tdbio_write_record( TRUSTREC *rec );
|
1998-11-13 19:41:41 +00:00
|
|
|
int tdbio_db_matches_options(void);
|
2001-09-24 16:03:14 +00:00
|
|
|
ulong tdbio_read_nextcheck (void);
|
2002-04-19 09:18:57 +00:00
|
|
|
int tdbio_write_nextcheck (ulong stamp);
|
1998-10-25 19:00:01 +00:00
|
|
|
int tdbio_is_dirty(void);
|
1998-10-16 16:00:17 +00:00
|
|
|
int tdbio_sync(void);
|
1998-10-25 19:00:01 +00:00
|
|
|
int tdbio_begin_transaction(void);
|
|
|
|
int tdbio_end_transaction(void);
|
|
|
|
int tdbio_cancel_transaction(void);
|
1998-07-21 12:53:38 +00:00
|
|
|
int tdbio_delete_record( ulong recnum );
|
1998-07-09 13:37:17 +00:00
|
|
|
ulong tdbio_new_recnum(void);
|
2001-09-24 16:03:14 +00:00
|
|
|
int tdbio_search_trust_byfpr(const byte *fingerprint, TRUSTREC *rec );
|
|
|
|
int tdbio_search_trust_bypk(PKT_public_key *pk, TRUSTREC *rec );
|
1998-07-09 13:37:17 +00:00
|
|
|
|
1999-03-11 15:42:06 +00:00
|
|
|
void tdbio_invalid(void);
|
1998-07-09 13:37:17 +00:00
|
|
|
|
|
|
|
#endif /*G10_TDBIO_H*/
|