aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog5
-rw-r--r--util/iobuf.c23
2 files changed, 25 insertions, 3 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 3b9be0161..2f5609d84 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+2000-11-30 Werner Koch <[email protected]>
+
+ * iobuf.c (iobuf_translate_file_handle): New.
+ (iobuf_open, iobuf_create): Use it for special filenames
+
2000-11-11 Paul Eggert <[email protected]>
* iobuf.c (iobuf_get_filelength): Now returns off_t, not u32.
diff --git a/util/iobuf.c b/util/iobuf.c
index 7cf780f89..12ca89fc2 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.
*
@@ -620,7 +620,7 @@ iobuf_open( const char *fname )
print_only = 1;
}
else if ( (fd = check_special_filename ( fname )) != -1 )
- return iobuf_fdopen ( fd, "rb" );
+ return iobuf_fdopen ( iobuf_translate_file_handle (fd,0), "rb" );
else if( !(fp = fopen(fname, "rb")) )
return NULL;
a = iobuf_alloc(1, 8192 );
@@ -692,7 +692,7 @@ iobuf_create( const char *fname )
print_only = 1;
}
else if ( (fd = check_special_filename ( fname )) != -1 )
- return iobuf_fdopen ( fd, "wb" );
+ return iobuf_fdopen ( iobuf_translate_file_handle (fd, 1), "wb" );
else if( !(fp = fopen(fname, "wb")) )
return NULL;
a = iobuf_alloc(2, 8192 );
@@ -1620,3 +1620,20 @@ iobuf_read_line( IOBUF a, byte **addr_of_buffer,
return nbytes;
}
+
+int
+iobuf_translate_file_handle ( int fd, int for_write )
+{
+ #ifdef __MINGW32__
+ {
+ int x = _open_osfhandle ( (void*)fd, for_write? 1:0 );
+ if (x==-1 )
+ log_error ("failed to translate osfhandle %p\n", (void*)fd );
+ else {
+ log_info ("_open_osfhandle %p yields %d\n", (void*)fd, x );
+ fd = x;
+ }
+ }
+ #endif
+ return fd;
+}