summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-09-11 07:47:32 +0200
committerWerner Koch <wk@gnupg.org>1998-09-11 07:47:32 +0200
commit48da5f940b537b09b1fd6a5023922bd792d5954c (patch)
treed0b99173fc76c70960ace7d372d4adeff969652b /util
parentChnages. (diff)
downloadgnupg2-48da5f940b537b09b1fd6a5023922bd792d5954c.tar.xz
gnupg2-48da5f940b537b09b1fd6a5023922bd792d5954c.zip
*** empty log message ***
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog9
-rw-r--r--util/iobuf.c25
-rw-r--r--util/ttyio.c8
3 files changed, 41 insertions, 1 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 9ef232582..8644bb7d6 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -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
diff --git a/util/iobuf.c b/util/iobuf.c
index 6ad001334..b7ccd1ecd 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -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;
@@ -1086,6 +1094,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
*/
const char *
diff --git a/util/ttyio.c b/util/ttyio.c
index 38143cba5..9f095d86e 100644
--- a/util/ttyio.c
+++ b/util/ttyio.c
@@ -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 ) {