aboutsummaryrefslogtreecommitdiffstats
path: root/util/iobuf.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2000-07-14 17:34:53 +0000
committerWerner Koch <[email protected]>2000-07-14 17:34:53 +0000
commit92cd25550836198cf1e3a6aac239eef98364359d (patch)
tree4fad355126fae79c93535e0e7c6afd91e384552a /util/iobuf.c
parentSee ChangeLog: Thu May 25 18:39:11 CEST 2000 Werner Koch (diff)
downloadgnupg-92cd25550836198cf1e3a6aac239eef98364359d.tar.gz
gnupg-92cd25550836198cf1e3a6aac239eef98364359d.zip
See ChangeLog: Fri Jul 14 19:38:23 CEST 2000 Werner Koch
Diffstat (limited to '')
-rw-r--r--util/iobuf.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/util/iobuf.c b/util/iobuf.c
index ec5cfefbd..d4900f416 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -1,5 +1,5 @@
/* iobuf.c - file handling
- * Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -81,6 +81,8 @@ static int underflow(IOBUF a);
* IOBUFCTRL_FLUSH: called by iobuf_flush() to write out the collected stuff.
* *RET_LAN is the number of bytes in BUF.
*
+ * IOBUFCTRL_CANCEL: send to all filters on behalf of iobuf_cancel. The
+ * filter may take appropriate action on this message.
*/
static int
file_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
@@ -494,19 +496,47 @@ iobuf_close( IOBUF a )
return rc;
}
+
int
iobuf_cancel( IOBUF a )
{
const char *s;
+ IOBUF a2;
+ int rc;
+ #ifdef HAVE_DOSISH_SYSTEM
+ char *remove_name = NULL;
+ #endif
if( a && a->use == 2 ) {
s = iobuf_get_real_fname(a);
- if( s && *s )
- remove(s); /* remove the file. Fixme: this will fail for MSDOZE*/
- } /* because the file is still open */
- return iobuf_close(a);
-}
+ if( s && *s ) {
+ #ifdef HAVE_DOSISH_SYSTEM
+ remove_name = m_strdup ( s );
+ #else
+ remove(s);
+ #endif
+ }
+ }
+
+ /* send a cancel message to all filters */
+ for( a2 = a; a2 ; a2 = a2->chain ) {
+ size_t dummy;
+ if( a2->filter )
+ a2->filter( a2->filter_ov, IOBUFCTRL_CANCEL, a2->chain,
+ NULL, &dummy );
+ }
+ rc = iobuf_close(a);
+ #ifdef HAVE_DOSISH_SYSTEM
+ if ( remove_name ) {
+ /* Argg, MSDOS does not allow to remove open files. So
+ * we have to do it here */
+ remove ( remove_name );
+ m_free ( remove_name );
+ }
+ #endif
+ return rc;
+}
/****************
* create a temporary iobuf, which can be used to collect stuff