* main.h, keylist.c (print_subpackets_colon): Make a public function.
[gnupg.git] / g10 / tdbio.c
index 47dc51e..b245da0 100644 (file)
@@ -332,7 +332,9 @@ tdbio_sync()
     return 0;
 }
 
-
+#if 0
+/* The transaction code is disabled in the 1.2.x branch, as it is not
+   yet used.  It will be enabled in 1.3.x. */
 
 /****************
  * Simple transactions system:
@@ -402,7 +404,7 @@ tdbio_cancel_transaction()
     in_transaction = 0;
     return 0;
 }
-
+#endif
 
 \f
 /********************************************************
@@ -453,7 +455,10 @@ create_version_record (void)
   rec.r.ver.marginals   = opt.marginals_needed;
   rec.r.ver.completes   = opt.completes_needed;
   rec.r.ver.cert_depth  = opt.max_cert_depth;
-  rec.r.ver.trust_model = opt.trust_model;
+  if(opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC)
+    rec.r.ver.trust_model = opt.trust_model;
+  else
+    rec.r.ver.trust_model = TM_PGP;
   rec.rectype = RECTYPE_VER;
   rec.recnum = 0;
   rc = tdbio_write_record( &rec );
@@ -669,6 +674,18 @@ tdbio_db_matches_options()
   return yes_no;
 }
 
+byte
+tdbio_read_model(void)
+{
+  TRUSTREC vr;
+  int rc;
+  rc = tdbio_read_record( 0, &vr, RECTYPE_VER );
+  if( rc )
+    log_fatal( _("%s: error reading version record: %s\n"),
+              db_name, g10_errstr(rc) );
+  return vr.r.ver.trust_model;
+}
 
 /****************
  * Return the nextstamp value.
@@ -757,8 +774,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum )
     hashrec += msb / ITEMS_PER_HTBL_RECORD;
     rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL );
     if( rc ) {
-       log_error( db_name, "upd_hashtable: read failed: %s\n",
-                                                       g10_errstr(rc) );
+       log_error("upd_hashtable: read failed: %s\n",   g10_errstr(rc) );
        return rc;
     }
 
@@ -767,7 +783,7 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum )
        rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD] = newrecnum;
        rc = tdbio_write_record( &rec );
        if( rc ) {
-           log_error( db_name, "upd_hashtable: write htbl failed: %s\n",
+           log_error("upd_hashtable: write htbl failed: %s\n",
                                                            g10_errstr(rc) );
            return rc;
        }
@@ -906,7 +922,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
     hashrec += msb / ITEMS_PER_HTBL_RECORD;
     rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL );
     if( rc ) {
-       log_error( db_name, "drop_from_hashtable: read failed: %s\n",
+       log_error("drop_from_hashtable: read failed: %s\n",
                                                        g10_errstr(rc) );
        return rc;
     }
@@ -919,7 +935,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
        rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD] = 0;
        rc = tdbio_write_record( &rec );
        if( rc )
-           log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n",
+           log_error("drop_from_hashtable: write htbl failed: %s\n",
                                                            g10_errstr(rc) );
        return rc;
     }
@@ -948,7 +964,7 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
                    rec.r.hlst.rnum[i] = 0; /* drop */
                    rc = tdbio_write_record( &rec );
                    if( rc )
-                       log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n",
+                       log_error("drop_from_hashtable: write htbl failed: %s\n",
                                                                        g10_errstr(rc) );
                    return rc;
                }
@@ -995,7 +1011,7 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen,
     hashrec += msb / ITEMS_PER_HTBL_RECORD;
     rc = tdbio_read_record( hashrec, rec, RECTYPE_HTBL );
     if( rc ) {
-       log_error( db_name, "lookup_hashtable failed: %s\n", g10_errstr(rc) );
+       log_error("lookup_hashtable failed: %s\n", g10_errstr(rc) );
        return rc;
     }
 
@@ -1005,14 +1021,14 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen,
 
     rc = tdbio_read_record( item, rec, 0 );
     if( rc ) {
-       log_error( db_name, "hashtable read failed: %s\n", g10_errstr(rc) );
+       log_error( "hashtable read failed: %s\n", g10_errstr(rc) );
        return rc;
     }
     if( rec->rectype == RECTYPE_HTBL ) {
        hashrec = item;
        level++;
        if( level >= keylen ) {
-           log_error( db_name, "hashtable has invalid indirections\n");
+           log_error("hashtable has invalid indirections\n");
            return G10ERR_TRUSTDB;
        }
        goto next_level;
@@ -1604,6 +1620,3 @@ migrate_from_v2 ()
   log_info ("migrated %d version 2 ownertrusts\n", count);
   m_free (ottable);
 }
-
-
-