1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-24 10:39:57 +01:00

Some new features for use with gpgme

This commit is contained in:
Werner Koch 2000-11-15 21:22:49 +00:00
parent 99e70f7ac7
commit d0af3b25d2
7 changed files with 144 additions and 40 deletions

1
THANKS
View File

@ -121,6 +121,7 @@ R
Reuben Sumner rasumner@wisdom.weizmann.ac.il Reuben Sumner rasumner@wisdom.weizmann.ac.il
Richard Outerbridge outer@interlog.com Richard Outerbridge outer@interlog.com
Roddy Strachan roddy@satlink.com.au Roddy Strachan roddy@satlink.com.au
Roger Sondermann r.so@bigfoot.com
Roland Rosenfeld roland@spinnaker.rhein.de Roland Rosenfeld roland@spinnaker.rhein.de
Ross Golder rossigee@bigfoot.com Ross Golder rossigee@bigfoot.com
Sam Roberts sam@cogent.ca Sam Roberts sam@cogent.ca

View File

@ -233,6 +233,14 @@ more arguments in future versions.
is used. The format is suitable to be passed to the option is used. The format is suitable to be passed to the option
--override-session-key --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 Key generation
============== ==============

View File

@ -1,3 +1,18 @@
2000-11-15 Werner Koch <wk@gnupg.org>
* 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 <wk@gnupg.org>
* sign.c (clearsign_file): Use LF macro to print linefeed.
2000-11-11 Paul Eggert <eggert@twinsun.com> 2000-11-11 Paul Eggert <eggert@twinsun.com>
Clean up the places in the code that incorrectly use "long" or Clean up the places in the code that incorrectly use "long" or

View File

@ -675,11 +675,14 @@ print_notation_data( PKT_signature *sig )
putc( '=', log_stream() ); putc( '=', log_stream() );
print_string( log_stream(), p+n1, n2, 0 ); print_string( log_stream(), p+n1, n2, 0 );
putc( '\n', log_stream() ); 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 ) )) { if( (p = parse_sig_subpkt( sig->hashed_data, SIGSUBPKT_POLICY, &n ) )) {
log_info(_("Policy: ") ); log_info(_("Policy: ") );
print_string( log_stream(), p, n, 0 ); print_string( log_stream(), p, n, 0 );
putc( '\n', log_stream() ); putc( '\n', log_stream() );
write_status_buffer ( STATUS_POLICY_URL, p, n, 0 );
} }
/* Now check wheter the key of this signature has some /* Now check wheter the key of this signature has some

View File

@ -630,7 +630,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
} }
if( old_style && only_md5 ) if( old_style && only_md5 )
iobuf_writestr(out, "\n" ); iobuf_writestr(out, LF );
else { else {
const char *s; const char *s;
int any = 0; int any = 0;
@ -654,11 +654,11 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
} }
} }
assert(any); assert(any);
iobuf_writestr(out, "\n" ); iobuf_writestr(out, LF );
if( opt.not_dash_escaped ) if( opt.not_dash_escaped )
iobuf_writestr( out, iobuf_writestr( out,
"NotDashEscaped: You need GnuPG to verify this message\n" ); "NotDashEscaped: You need GnuPG to verify this message" LF );
iobuf_writestr(out, "\n" ); iobuf_writestr(out, LF );
} }

View File

@ -72,38 +72,11 @@ progress_cb ( void *ctx, int c )
write_status_text ( STATUS_PROGRESS, buf ); write_status_text ( STATUS_PROGRESS, buf );
} }
static const char *
void get_status_string ( int no )
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)
{ {
const char *s; const char *s;
if( fd == -1 )
return; /* not enabled */
switch( no ) { switch( no ) {
case STATUS_ENTER : s = "ENTER\n"; break; case STATUS_ENTER : s = "ENTER\n"; break;
case STATUS_LEAVE : s = "LEAVE\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_PROGRESS : s = "PROGRESS\n"; break;
case STATUS_SIG_CREATED : s = "SIG_CREATED\n"; break; case STATUS_SIG_CREATED : s = "SIG_CREATED\n"; break;
case STATUS_SESSION_KEY : s = "SESSION_KEY\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; default: s = "?\n"; break;
} }
return s;
}
write( fd, "[GNUPG:] ", 9 ); 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);
mywrite( fd, "[GNUPG:] ", 9 );
if( text ) { if( text ) {
write( fd, s, strlen(s)-1 ); mywrite( fd, s, strlen(s)-1 );
write( fd, " ", 1 ); mywrite( fd, " ", 1 );
write( fd, text, strlen(text) ); mywrite( fd, text, strlen(text) );
write( fd, "\n", 1 ); mywrite( fd, "\n", 1 );
} }
else 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 );
} }

View File

@ -82,13 +82,17 @@
#define STATUS_PROGRESS 50 #define STATUS_PROGRESS 50
#define STATUS_SIG_CREATED 51 #define STATUS_SIG_CREATED 51
#define STATUS_SESSION_KEY 52 #define STATUS_SESSION_KEY 52
#define STATUS_NOTATION_NAME 53
#define STATUS_NOTATION_DATA 54
#define STATUS_POLICY_URL 55
/*-- status.c --*/ /*-- status.c --*/
void set_status_fd ( int fd ); void set_status_fd ( int fd );
int is_status_enabled ( void ); int is_status_enabled ( void );
void write_status ( int no ); void write_status ( int no );
void write_status_text ( int no, const char *text ); 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 #ifdef USE_SHM_COPROCESSING
void init_shm_coprocessing ( ulong requested_shm_size, int lock_mem ); void init_shm_coprocessing ( ulong requested_shm_size, int lock_mem );