diff options
author | Werner Koch <[email protected]> | 2007-06-06 18:12:30 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2007-06-06 18:12:30 +0000 |
commit | 2c9791db555cc571eaedfa71444da05454bd052a (patch) | |
tree | 9566d22f85e562e0c7b35dacc1697c9a58fcff1a /common/iobuf.c | |
parent | Print passphrase encoding info only in PEM mode. (diff) | |
download | gnupg-2c9791db555cc571eaedfa71444da05454bd052a.tar.gz gnupg-2c9791db555cc571eaedfa71444da05454bd052a.zip |
First steps towards supporting W32.
This is mainly source code reorganization.
Update gnulib.
g10/ does currently not build.
Diffstat (limited to 'common/iobuf.c')
-rw-r--r-- | common/iobuf.c | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/common/iobuf.c b/common/iobuf.c index c01702696..40af196da 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -271,7 +271,7 @@ fd_cache_close (const char *fname, FILEP_OR_FD fp) close (fp); #endif if (DBG_IOBUF) - log_debug ("fd_cache_close (%d) real\n", fp); + log_debug ("fd_cache_close (%d) real\n", (int)fp); return; } /* try to reuse a slot */ @@ -2006,78 +2006,79 @@ iobuf_set_limit (iobuf_t a, off_t nlimit) off_t iobuf_get_filelength (iobuf_t a, int *overflow) { - struct stat st; + struct stat st; - if (overflow) - *overflow = 0; - - if( a->directfp ) { - FILE *fp = a->directfp; - - if( !fstat(fileno(fp), &st) ) - return st.st_size; - log_error("fstat() failed: %s\n", strerror(errno) ); - return 0; + if (overflow) + *overflow = 0; + + if ( a->directfp ) + { + FILE *fp = a->directfp; + + if ( !fstat(fileno(fp), &st) ) + return st.st_size; + log_error("fstat() failed: %s\n", strerror(errno) ); + return 0; } - - /* Hmmm: file_filter may have already been removed */ - for( ; a; a = a->chain ) - if( !a->chain && a->filter == file_filter ) { - file_filter_ctx_t *b = a->filter_ov; - FILEP_OR_FD fp = b->fp; - + + /* Hmmm: file_filter may have already been removed */ + for ( ; a; a = a->chain ) + if ( !a->chain && a->filter == file_filter ) + { + file_filter_ctx_t *b = a->filter_ov; + FILEP_OR_FD fp = b->fp; + #if defined(HAVE_DOSISH_SYSTEM) && !defined(FILE_FILTER_USES_STDIO) - ulong size; - static int (* __stdcall get_file_size_ex) - (void *handle, LARGE_INTEGER *size); - static int get_file_size_ex_initialized; - - if (!get_file_size_ex_initialized) + ulong size; + static int (* __stdcall get_file_size_ex) (void *handle, + LARGE_INTEGER *r_size); + static int get_file_size_ex_initialized; + + if (!get_file_size_ex_initialized) + { + void *handle; + + handle = dlopen ("kernel32.dll", RTLD_LAZY); + if (handle) { - void *handle; - - handle = dlopen ("kernel32.dll", RTLD_LAZY); - if (handle) - { - get_file_size_ex = dlsym (handle, "GetFileSizeEx"); - if (!get_file_size_ex) - dlclose (handle); - } - get_file_size_ex_initialized = 1; + get_file_size_ex = dlsym (handle, "GetFileSizeEx"); + if (!get_file_size_ex) + dlclose (handle); } - - if (get_file_size_ex) + get_file_size_ex_initialized = 1; + } + + if (get_file_size_ex) + { + /* This is a newer system with GetFileSizeEx; we use this + then because it seem that GetFileSize won't return a + proper error in case a file is larger than 4GB. */ + LARGE_INTEGER exsize; + + if (get_file_size_ex (fp, &exsize)) { - /* This is a newer system with GetFileSizeEx; we use - this then becuase it seem that GetFileSize won't - return a proper error in case a file is larger than - 4GB. */ - LARGE_INTEGER size; - - if (get_file_size_ex (fp, &size)) - { - if (!size.u.HighPart) - return size.u.LowPart; - if (overflow) - *overflow = 1; - return 0; - } + if (!exsize.u.HighPart) + return exsize.u.LowPart; + if (overflow) + *overflow = 1; + return 0; } - else - { - if ((size=GetFileSize (fp, NULL)) != 0xffffffff) - return size; - } - log_error ("GetFileSize for handle %p failed: %s\n", - fp, w32_strerror (0)); + } + else + { + if ((size=GetFileSize (fp, NULL)) != 0xffffffff) + return size; + } + log_error ("GetFileSize for handle %p failed: %s\n", + fp, w32_strerror (0)); #else - if( !fstat(my_fileno(fp), &st) ) - return st.st_size; - log_error("fstat() failed: %s\n", strerror(errno) ); + if ( !fstat(my_fileno(fp), &st) ) + return st.st_size; + log_error("fstat() failed: %s\n", strerror(errno) ); #endif - break; - } - + break/*the for loop*/; + } + return 0; } |