[Pkg-gnupg-commit] [gnupg2] 39/102: gpg: New status code NOTATION_FLAGS.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Jun 17 00:14:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gnupg2.

commit 67a4bc8d536f6997f14daff4c039abd48a172100
Author: Werner Koch <wk at gnupg.org>
Date:   Tue May 31 15:43:51 2016 +0200

    gpg: New status code NOTATION_FLAGS.
    
    * common/status.h (STATUS_NOTATION_FLAGS: New.
    * g10/packet.h (struct notation): Add flags.human.
    (notation_t): New typedef.
    * g10/build-packet.c (sig_to_notation): Set flags.human.
    * g10/keylist.c (show_notation): Write STATUS_NOTATION_FLAGS.
---
 common/status.h    | 1 +
 doc/DETAILS        | 9 ++++++---
 g10/build-packet.c | 6 ++++--
 g10/keylist.c      | 6 +++++-
 g10/packet.h       | 9 +++++++--
 5 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/common/status.h b/common/status.h
index 966489f..f9771c2 100644
--- a/common/status.h
+++ b/common/status.h
@@ -96,6 +96,7 @@ enum
     STATUS_SIG_CREATED,
     STATUS_SESSION_KEY,
     STATUS_NOTATION_NAME,
+    STATUS_NOTATION_FLAGS,
     STATUS_NOTATION_DATA,
     STATUS_POLICY_URL,
     STATUS_KEY_CREATED,
diff --git a/doc/DETAILS b/doc/DETAILS
index 59f8d56..d2df9ac 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -520,14 +520,17 @@ pkd:0:1024:B665B1435F4C2 .... FF26ABB:
     letter 'T'.
 
 *** NOTATION_
-    There are actually two related status codes to convey notation
+    There are actually three related status codes to convey notation
     data:
 
     - NOTATION_NAME <name>
+    - NOTATION_FLAGS <critical> <human_readable>
     - NOTATION_DATA <string>
 
-    <name> and <string> are %XX escaped; the data may be split among
-    several NOTATION_DATA lines.
+    <name> and <string> are %XX escaped.  The data may be split among
+    several NOTATION_DATA lines.  NOTATION_FLAGS is emitted after
+    NOTATION_NAME and gives the critical and human readable flags;
+    the flag values are either 0 or 1.
 
 *** POLICY_URL <string>
     Note that URL in <string> is %XX escaped.
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 9b64967..4bfc2ac 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -1277,8 +1277,9 @@ sig_to_notation(PKT_signature *sig)
 {
   const byte *p;
   size_t len;
-  int seq=0,crit;
-  struct notation *list=NULL;
+  int seq = 0;
+  int crit;
+  notation_t list = NULL;
 
   /* See RFC 4880, 5.2.3.16 for the format of notation data.  In
      short, a notation has:
@@ -1323,6 +1324,7 @@ sig_to_notation(PKT_signature *sig)
 	  n->value=xmalloc(n2+1);
 	  memcpy(n->value,&p[8+n1],n2);
 	  n->value[n2]='\0';
+          n->flags.human = 1;
 	}
       else
         /* Binary data.  */
diff --git a/g10/keylist.c b/g10/keylist.c
index cbde0bb..2a1ef2e 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -401,7 +401,7 @@ void
 show_notation (PKT_signature * sig, int indent, int mode, int which)
 {
   estream_t fp = mode ? log_get_stream () : es_stdout;
-  struct notation *nd, *notations;
+  notation_t nd, notations;
 
   if (which == 0)
     which = 3;
@@ -448,6 +448,10 @@ show_notation (PKT_signature * sig, int indent, int mode, int which)
 	{
 	  write_status_buffer (STATUS_NOTATION_NAME,
 			       nd->name, strlen (nd->name), 0);
+          if (nd->flags.critical || nd->flags.human)
+            write_status_text (STATUS_NOTATION_FLAGS,
+                               nd->flags.critical && nd->flags.human? "1 1" :
+                               nd->flags.critical? "1 0" : "0 1");
 	  write_status_buffer (STATUS_NOTATION_DATA,
 			       nd->value, strlen (nd->value), 50);
 	}
diff --git a/g10/packet.h b/g10/packet.h
index 194c134..6ea2f83 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -531,12 +531,14 @@ struct notation
   /* The notation's name.  */
   char *name;
   /* If the notation is human readable, then the value is stored here
-     as a NUL-terminated string.  */
+     as a NUL-terminated string.  If it is not human readable a human
+     readable approximation of the binary value _may_ be stored
+     here.  */
   char *value;
   /* Sometimes we want to %-expand the value.  In these cases, we save
      that transformed value here.  */
   char *altvalue;
-  /* If the notation is not human readable, then the value is strored
+  /* If the notation is not human readable, then the value is stored
      here.  */
   unsigned char *bdat;
   /* The amount of data stored in BDAT.
@@ -552,6 +554,8 @@ struct notation
   {
     /* The notation is critical.  */
     unsigned int critical:1;
+    /* The notation is human readable.  */
+    unsigned int human:1;
     /* The notation should be deleted.  */
     unsigned int ignore:1;
   } flags;
@@ -559,6 +563,7 @@ struct notation
   /* A field to facilitate creating a list of notations.  */
   struct notation *next;
 };
+typedef struct notation *notation_t;
 
 /*-- mainproc.c --*/
 void reset_literals_seen(void);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list