1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

*** empty log message ***

This commit is contained in:
Werner Koch 1998-09-11 05:47:32 +00:00
parent 1b368847f5
commit 48da5f940b
34 changed files with 650 additions and 377 deletions

View file

@ -1,3 +1,12 @@
Wed Sep 9 13:52:28 1998 Werner Koch (wk@(none))
* ttyio.c (do_get): Ctrl-D is now a valid but special character
Mon Sep 7 13:52:41 1998 Werner Koch (wk@(none))
* iobuf.c (get_real_fname): New and changed file_filter datastructures
and their initialization.
Tue Aug 11 15:12:35 1998 Werner Koch (wk@(none))
* miscutil.c (answer_is_yes): i18ned

View file

@ -34,6 +34,7 @@
typedef struct {
FILE *fp; /* open file handle */
int print_only_name; /* flags indicating that fname is not a real file*/
char fname[1]; /* name of the file */
} file_filter_ctx_t ;
@ -56,6 +57,7 @@ typedef struct {
static int underflow(IOBUF a);
static const char *get_real_fname( IOBUF a );
/****************
* Read data from a file into buf which has an allocated length of *LEN.
@ -451,7 +453,7 @@ iobuf_cancel( IOBUF a )
const char *s;
if( a && a->usage == 2 ) {
s = iobuf_get_fname(a);
s = get_real_fname(a);
if( s && *s )
remove(s); /* remove the file. Fixme: this will fail for MSDOZE*/
} /* because the file is still open */
@ -486,16 +488,19 @@ iobuf_open( const char *fname )
FILE *fp;
file_filter_ctx_t *fcx;
size_t len;
int print_only = 0;
if( !fname || (*fname=='-' && !fname[1]) ) {
fp = stdin; /* fixme: set binary mode for msdoze */
fname = "[stdin]";
print_only = 1;
}
else if( !(fp = fopen(fname, "rb")) )
return NULL;
a = iobuf_alloc(1, 8192 );
fcx = m_alloc( sizeof *fcx + strlen(fname) );
fcx->fp = fp;
fcx->print_only_name = print_only;
strcpy(fcx->fname, fname );
a->filter = file_filter;
a->filter_ov = fcx;
@ -517,16 +522,19 @@ iobuf_create( const char *fname )
FILE *fp;
file_filter_ctx_t *fcx;
size_t len;
int print_only = 0;
if( !fname || (*fname=='-' && !fname[1]) ) {
fp = stdout;
fname = "[stdout]";
print_only = 1;
}
else if( !(fp = fopen(fname, "wb")) )
return NULL;
a = iobuf_alloc(2, 8192 );
fcx = m_alloc( sizeof *fcx + strlen(fname) );
fcx->fp = fp;
fcx->print_only_name = print_only;
strcpy(fcx->fname, fname );
a->filter = file_filter;
a->filter_ov = fcx;
@ -1085,6 +1093,21 @@ iobuf_seek( IOBUF a, ulong newpos )
/****************
* Retrieve the real filename
*/
static const char *
get_real_fname( IOBUF a )
{
for( ; a; a = a->chain )
if( !a->chain && a->filter == file_filter ) {
file_filter_ctx_t *b = a->filter_ov;
return b->print_only_name? NULL : b->fname;
}
return NULL;
}
/****************
* Retrieve the filename
*/

View file

@ -39,6 +39,8 @@
#include "memory.h"
#include "ttyio.h"
#define CONTROL_D ('D' - 'A' + 1)
#ifdef __MINGW32__ /* use the odd Win32 functions */
static struct {
@ -279,6 +281,8 @@ do_get( const char *prompt, int hidden )
if( !hidden )
last_prompt_len++;
c = *cbuf;
if( c == CONTROL_D )
log_info("control d found\n");
if( c == '\t' )
c = ' ';
else if( c > 0xa0 )
@ -292,6 +296,10 @@ do_get( const char *prompt, int hidden )
}
buf[i++] = c;
}
if( *cbuf != '\n' ) {
buf[0] = CONTROL_D;
i = 1;
}
if( hidden ) {