aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2000-11-15 21:22:49 +0000
committerWerner Koch <[email protected]>2000-11-15 21:22:49 +0000
commitd0af3b25d2cac63e6375e1fb4429519197325305 (patch)
tree2798e33b7022299c17fcbb58fbf06cdcc0db76ce
parentPaul's LFS pacthes and started with pipemode (diff)
downloadgnupg-d0af3b25d2cac63e6375e1fb4429519197325305.tar.gz
gnupg-d0af3b25d2cac63e6375e1fb4429519197325305.zip
Some new features for use with gpgme
-rw-r--r--THANKS1
-rw-r--r--doc/DETAILS8
-rw-r--r--g10/ChangeLog15
-rw-r--r--g10/mainproc.c3
-rw-r--r--g10/sign.c8
-rw-r--r--g10/status.c143
-rw-r--r--g10/status.h6
7 files changed, 144 insertions, 40 deletions
diff --git a/THANKS b/THANKS
index 700e0ae6d..1d9559ed3 100644
--- a/THANKS
+++ b/THANKS
@@ -121,6 +121,7 @@ R�mi Guyomarch [email protected]
Reuben Sumner [email protected]
Richard Outerbridge [email protected]
Roddy Strachan [email protected]
+Roger Sondermann [email protected]
Roland Rosenfeld [email protected]
Ross Golder [email protected]
Sam Roberts [email protected]
diff --git a/doc/DETAILS b/doc/DETAILS
index 015049a70..ba66248ec 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -233,6 +233,14 @@ more arguments in future versions.
is used. The format is suitable to be passed to the option
--override-session-key
+ NOTATION_NAME <name>
+ NOTATION_DATA <string>
+ name and string are %XX escaped; the data may be spliited
+ among several notation_data lines.
+
+ POLICY_URL <string>
+ string is %XX escaped
+
Key generation
==============
diff --git a/g10/ChangeLog b/g10/ChangeLog
index a37eac868..412331d33 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,18 @@
+2000-11-15 Werner Koch <[email protected]>
+
+ * status.c (write_status_text): Moved the big switch to ...
+ (get_status_string): ... new function.
+ (write_status_buffer): New.
+
+ * status.c (mywrite): New and replaced all write() by this.
+
+ * status.c, status.h: Add 3 status lcodes for notaions and policy.
+ * mainproc.c (print_notation_data): Do status output of notations.
+
+2000-11-13 Werner Koch <[email protected]>
+
+ * sign.c (clearsign_file): Use LF macro to print linefeed.
+
2000-11-11 Paul Eggert <[email protected]>
Clean up the places in the code that incorrectly use "long" or
diff --git a/g10/mainproc.c b/g10/mainproc.c
index dc2d66d5e..1433ec860 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -675,11 +675,14 @@ print_notation_data( PKT_signature *sig )
putc( '=', log_stream() );
print_string( log_stream(), p+n1, n2, 0 );
putc( '\n', log_stream() );
+ write_status_buffer ( STATUS_NOTATION_NAME, p , n1, 0 );
+ write_status_buffer ( STATUS_NOTATION_DATA, p+n1, n2, 20 );
}
if( (p = parse_sig_subpkt( sig->hashed_data, SIGSUBPKT_POLICY, &n ) )) {
log_info(_("Policy: ") );
print_string( log_stream(), p, n, 0 );
putc( '\n', log_stream() );
+ write_status_buffer ( STATUS_POLICY_URL, p, n, 0 );
}
/* Now check wheter the key of this signature has some
diff --git a/g10/sign.c b/g10/sign.c
index 588b70372..00ef1d710 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -630,7 +630,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
}
if( old_style && only_md5 )
- iobuf_writestr(out, "\n" );
+ iobuf_writestr(out, LF );
else {
const char *s;
int any = 0;
@@ -654,11 +654,11 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
}
}
assert(any);
- iobuf_writestr(out, "\n" );
+ iobuf_writestr(out, LF );
if( opt.not_dash_escaped )
iobuf_writestr( out,
- "NotDashEscaped: You need GnuPG to verify this message\n" );
- iobuf_writestr(out, "\n" );
+ "NotDashEscaped: You need GnuPG to verify this message" LF );
+ iobuf_writestr(out, LF );
}
diff --git a/g10/status.c b/g10/status.c
index 6c1388316..1c9b8a36a 100644
--- a/g10/status.c
+++ b/g10/status.c
@@ -72,38 +72,11 @@ progress_cb ( void *ctx, int c )
write_status_text ( STATUS_PROGRESS, buf );
}
-
-void
-set_status_fd ( int newfd )
-{
- fd = newfd;
- if ( fd != -1 ) {
- register_primegen_progress ( progress_cb, "primegen" );
- register_pk_dsa_progress ( progress_cb, "pk_dsa" );
- register_pk_elg_progress ( progress_cb, "pk_elg" );
- }
-}
-
-int
-is_status_enabled()
-{
- return fd != -1;
-}
-
-void
-write_status ( int no )
-{
- write_status_text( no, NULL );
-}
-
-void
-write_status_text ( int no, const char *text)
+static const char *
+get_status_string ( int no )
{
const char *s;
- if( fd == -1 )
- return; /* not enabled */
-
switch( no ) {
case STATUS_ENTER : s = "ENTER\n"; break;
case STATUS_LEAVE : s = "LEAVE\n"; break;
@@ -157,18 +130,118 @@ write_status_text ( int no, const char *text)
case STATUS_PROGRESS : s = "PROGRESS\n"; break;
case STATUS_SIG_CREATED : s = "SIG_CREATED\n"; break;
case STATUS_SESSION_KEY : s = "SESSION_KEY\n"; break;
+ case STATUS_NOTATION_NAME : s = "NOTATION_NAME\n" ; break;
+ case STATUS_NOTATION_DATA : s = "NOTATION_DATA\n" ; break;
+ case STATUS_POLICY_URL : s = "POLICY_URL\n" ; break;
default: s = "?\n"; break;
}
+ return s;
+}
+
+void
+set_status_fd ( int newfd )
+{
+ fd = newfd;
+ if ( fd != -1 ) {
+ register_primegen_progress ( progress_cb, "primegen" );
+ register_pk_dsa_progress ( progress_cb, "pk_dsa" );
+ register_pk_elg_progress ( progress_cb, "pk_elg" );
+ }
+}
+
+int
+is_status_enabled()
+{
+ return fd != -1;
+}
+
+void
+write_status ( int no )
+{
+ write_status_text( no, NULL );
+}
+
+static void
+mywrite ( int fd, const char *buffer, size_t len )
+{
+ int nwritten;
+
+ do {
+ nwritten = write (fd, buffer, len );
+ } while (nwritten == -1 && errno == EINTR );
+}
+
+void
+write_status_text ( int no, const char *text)
+{
+ const char *s;
+
+ if( fd == -1 )
+ return; /* not enabled */
+
+ s = get_status_string (no);
- write( fd, "[GNUPG:] ", 9 );
+ mywrite( fd, "[GNUPG:] ", 9 );
if( text ) {
- write( fd, s, strlen(s)-1 );
- write( fd, " ", 1 );
- write( fd, text, strlen(text) );
- write( fd, "\n", 1 );
+ mywrite( fd, s, strlen(s)-1 );
+ mywrite( fd, " ", 1 );
+ mywrite( fd, text, strlen(text) );
+ mywrite( fd, "\n", 1 );
}
else
- write( fd, s, strlen(s) );
+ mywrite( fd, s, strlen(s) );
+}
+
+
+/*
+ * Write a status line with a buffer using %XX escapes.
+ * If WRAP is > 0 wrap the line after this length.
+ */
+void
+write_status_buffer ( int no, const char *buffer, size_t len, int wrap )
+{
+ const char *s, *text;
+ int esc;
+ size_t n, count, dowrap;
+
+ if( fd == -1 )
+ return; /* not enabled */
+
+ text = get_status_string (no);
+ count = dowrap = 1;
+ do {
+ if (dowrap) {
+ mywrite( fd, "[GNUPG:] ", 9 );
+ mywrite( fd, text, strlen(text)-1 );
+ mywrite( fd, " ", 1 );
+ count = dowrap = 0;
+ }
+ for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) {
+ if ( *s == '%' || *(const byte*)s <= ' ' )
+ esc = 1;
+ if ( wrap && ++count > wrap ) {
+ dowrap=1;
+ break;
+ }
+ }
+ if (esc) {
+ s--; n++;
+ }
+ if (s != buffer)
+ mywrite ( fd, buffer, s-buffer );
+ if ( esc ) {
+ char buf[5];
+ sprintf (buf, "%%%02X", *(const byte*)s );
+ mywrite (fd, buf, 3 );
+ s++; n--;
+ }
+ buffer = s;
+ len = n;
+ if ( dowrap && len )
+ mywrite( fd, "\n", 1 );
+ } while ( len );
+
+ mywrite( fd, "\n", 1 );
}
diff --git a/g10/status.h b/g10/status.h
index 0f65c22d5..2c946ad65 100644
--- a/g10/status.h
+++ b/g10/status.h
@@ -82,13 +82,17 @@
#define STATUS_PROGRESS 50
#define STATUS_SIG_CREATED 51
#define STATUS_SESSION_KEY 52
-
+#define STATUS_NOTATION_NAME 53
+#define STATUS_NOTATION_DATA 54
+#define STATUS_POLICY_URL 55
/*-- status.c --*/
void set_status_fd ( int fd );
int is_status_enabled ( void );
void write_status ( int no );
void write_status_text ( int no, const char *text );
+void write_status_buffer ( int no,
+ const char *buffer, size_t len, int wrap );
#ifdef USE_SHM_COPROCESSING
void init_shm_coprocessing ( ulong requested_shm_size, int lock_mem );