Embedded filenames and --status-fd

David Shaw dshaw at jabberwocky.com
Sun May 23 16:35:12 CEST 2004


On Sun, May 23, 2004 at 01:42:33PM +0200, Andreas John wrote:

> I've played around a bit with GPG and aim to integrate some
> file-decoding mechanism into my program using GPG.
> 
> Well, to put it short: I'm interessted in the embedded filename of a
> decrypted file (possibly set with "--set-filename" to hide a real
> filename when sent as attachment "gpg.asc"), unfortunately the only
> way to get the embedded filename from an encrypted file seems to be
> "-v" and parse the verbose infostrings printed then (with the
> additional complexity of them being strings possibly be translated
> to different languages?).
> 
> So I'd like to know if it's possible (say, if not already done, for
> 1.2.5?) to add a status-fd-message showing this information when
> decrypting? Maybe only show when "--use-embedded-filename" is
> specified at the command-line if you fear to break some programs
> relying on the --status-fd as it currently is.

As it happens, I have code to do this already.  I haven't checked it
in yet for 1.2.5 as there is some discussion about the details of
embedded filenames and character set encoding going on for the updated
OpenPGP draft.  I'm reluctant to check it in and have people start
using it before the standard is set (running the risk of being forced
to change it later and break things).

David
-------------- next part --------------
Index: plaintext.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/plaintext.c,v
retrieving revision 1.39.2.9
diff -u -r1.39.2.9 plaintext.c
--- plaintext.c	1 Apr 2004 04:02:27 -0000	1.39.2.9
+++ plaintext.c	23 May 2004 14:30:48 -0000
@@ -58,6 +58,19 @@
     int c;
     int convert = (pt->mode == 't' || pt->mode == 'u');
 
+    /* While it might be nice to put this at the end so we could
+       include the number of bytes written, it's more important that
+       this status tag is output before any plaintext is written.
+       This allows the receiving program to try and so something
+       different based on the plaintext format code. */
+    if(!nooutput && is_status_enabled())
+      {
+	char status[14];
+	sprintf(status,"%d %u ",pt->mode,pt->timestamp);
+	write_status_text_and_buffer(STATUS_PLAINTEXT,
+				     status,pt->name,pt->namelen,0);
+      }
+
     /* create the filename as C string */
     if( nooutput )
 	;
Index: status.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/status.c,v
retrieving revision 1.35.2.5
diff -u -r1.35.2.5 status.c
--- status.c	1 Mar 2004 20:00:39 -0000	1.35.2.5
+++ status.c	23 May 2004 14:30:48 -0000
@@ -1,6 +1,6 @@
 /* status.c
- * Copyright (C) 1998, 1999, 2000, 2001, 2002,
- *               2004  Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
+ *               2004 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -151,6 +151,7 @@
       case STATUS_EXPKEYSIG      : s = "EXPKEYSIG"; break;
       case STATUS_REVKEYSIG      : s = "REVKEYSIG"; break;
       case STATUS_ATTRIBUTE      : s = "ATTRIBUTE"; break;
+      case STATUS_PLAINTEXT      : s = "PLAINTEXT"; break;
       default: s = "?"; break;
     }
     return s;
Index: status.h
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/status.h,v
retrieving revision 1.23.2.2
diff -u -r1.23.2.2 status.h
--- status.h	28 Jul 2003 00:49:20 -0000	1.23.2.2
+++ status.h	23 May 2004 14:30:49 -0000
@@ -1,5 +1,6 @@
 /* status.h
- * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
+ *               2004 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -20,7 +21,6 @@
 #ifndef G10_STATUS_H
 #define G10_STATUS_H
 
-
 #define STATUS_ENTER	 1
 #define STATUS_LEAVE	 2
 #define STATUS_ABORT	 3
@@ -29,7 +29,6 @@
 #define STATUS_BADSIG	 5
 #define STATUS_ERRSIG	 6
 
-
 #define STATUS_BADARMOR  7
 
 #define STATUS_RSA_OR_IDEA 8
@@ -100,6 +99,7 @@
 #define STATUS_IMPORT_OK 	68
 #define STATUS_IMPORT_CHECK     69
 #define STATUS_REVKEYSIG        70
+#define STATUS_PLAINTEXT        71
 
 /*-- status.c --*/
 void set_status_fd ( int fd );
@@ -123,6 +123,5 @@
 void cpr_kill_prompt(void);
 int  cpr_get_answer_is_yes( const char *keyword, const char *prompt );
 int  cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt );
-
 
 #endif /*G10_STATUS_H*/


More information about the Gnupg-devel mailing list