* parse-packet.c (parse_signature): No need to reserve 8 bytes for the
[gnupg.git] / g10 / tdbio.c
index 993cb06..07e64a2 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 );
@@ -474,9 +479,18 @@ tdbio_set_dbname( const char *new_dbname, int create )
        atexit( cleanup );
        initialized = 1;
     }
-    fname = new_dbname? m_strdup( new_dbname )
-                     : make_filename(opt.homedir,
-                                     "trustdb" EXTSEP_S "gpg", NULL );
+
+    if(new_dbname==NULL)
+      fname=make_filename(opt.homedir,"trustdb" EXTSEP_S "gpg", NULL);
+    else if (*new_dbname != DIRSEP_C )
+      {
+       if (strchr(new_dbname, DIRSEP_C) )
+         fname = make_filename (new_dbname, NULL);
+       else
+         fname = make_filename (opt.homedir, new_dbname, NULL);
+      }
+    else
+      fname = m_strdup (new_dbname);
 
     if( access( fname, R_OK ) ) {
        if( errno != ENOENT ) {
@@ -660,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.
@@ -1210,14 +1236,16 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
        memcpy( rec->r.trust.fingerprint, p, 20); p+=20;
         rec->r.trust.ownertrust = *p++;
         rec->r.trust.depth = *p++;
-        p += 2;
-       rec->r.trust.validlist  = buftoulong(p); p += 4;
         rec->r.trust.min_ownertrust = *p++;
+        p++;
+       rec->r.trust.validlist = buftoulong(p); p += 4;
        break;
       case RECTYPE_VALID:
        memcpy( rec->r.valid.namehash, p, 20); p+=20;
         rec->r.valid.validity = *p++;
        rec->r.valid.next = buftoulong(p); p += 4;
+       rec->r.valid.full_count = *p++;
+       rec->r.valid.marginal_count = *p++;
        break;
       default:
        log_error( "%s: invalid record type %d at recnum %lu\n",
@@ -1290,15 +1318,17 @@ tdbio_write_record( TRUSTREC *rec )
        memcpy( p, rec->r.trust.fingerprint, 20); p += 20;
        *p++ = rec->r.trust.ownertrust;
        *p++ = rec->r.trust.depth;
-        p += 2;
-       ulongtobuf( p, rec->r.trust.validlist); p += 4;
        *p++ = rec->r.trust.min_ownertrust;
+        p++;
+       ulongtobuf( p, rec->r.trust.validlist); p += 4;
        break;
 
       case RECTYPE_VALID:
        memcpy( p, rec->r.valid.namehash, 20); p += 20;
        *p++ = rec->r.valid.validity;
        ulongtobuf( p, rec->r.valid.next); p += 4;
+       *p++ = rec->r.valid.full_count;
+       *p++ = rec->r.valid.marginal_count;
        break;
 
       default: