Changeset View
Changeset View
Standalone View
Standalone View
util/iobuf.c
/* iobuf.c - file handling | /* iobuf.c - file handling | ||||
* Copyright (C) 1998, 1999, 2000, 2001, 2003, | * Copyright (C) 1998, 1999, 2000, 2001, 2003, | ||||
* 2004 Free Software Foundation, Inc. | * 2004, 2008 Free Software Foundation, Inc. | ||||
* | * | ||||
* This file is part of GnuPG. | * This file is part of GnuPG. | ||||
* | * | ||||
Context not available. | |||||
(byte*)&desc, &dummy_len ); | (byte*)&desc, &dummy_len ); | ||||
log_debug("iobuf chain: %d.%d `%s' filter_eof=%d start=%d len=%d\n", | log_debug("iobuf chain: %d.%d `%s' filter_eof=%d start=%d len=%d\n", | ||||
a->no, a->subno, desc, a->filter_eof, | a->no, a->subno, desc?desc:"?", a->filter_eof, | ||||
(int)a->d.start, (int)a->d.len ); | (int)a->d.start, (int)a->d.len ); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
log_error("iobuf_flush failed on close: %s\n", g10_errstr(rc)); | log_error("iobuf_flush failed on close: %s\n", g10_errstr(rc)); | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: close `%s'\n", a->no, a->subno, a->desc ); | log_debug("iobuf-%d.%d: close `%s'\n", a->no, a->subno, | ||||
a->desc?a->desc:"?"); | |||||
if( a->filter && (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, | if( a->filter && (rc = a->filter(a->filter_ov, IOBUFCTRL_FREE, | ||||
a->chain, NULL, &dummy_len)) ) | a->chain, NULL, &dummy_len)) ) | ||||
log_error("IOBUFCTRL_FREE failed on close: %s\n", g10_errstr(rc) ); | log_error("IOBUFCTRL_FREE failed on close: %s\n", g10_errstr(rc) ); | ||||
Context not available. | |||||
file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); | file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); | ||||
file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); | file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: create `%s'\n", a->no, a->subno, a->desc ); | log_debug("iobuf-%d.%d: create `%s'\n", a->no, a->subno, | ||||
a->desc?a->desc:"?" ); | |||||
return a; | return a; | ||||
} | } | ||||
Context not available. | |||||
file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); | file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); | ||||
file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); | file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: append `%s'\n", a->no, a->subno, a->desc ); | log_debug("iobuf-%d.%d: append `%s'\n", a->no, a->subno, | ||||
a->desc?a->desc:"?" ); | |||||
return a; | return a; | ||||
} | } | ||||
Context not available. | |||||
file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); | file_filter( fcx, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &len ); | ||||
file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); | file_filter( fcx, IOBUFCTRL_INIT, NULL, NULL, &len ); | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno, a->desc ); | log_debug("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno, | ||||
a->desc?a->desc:"?"); | |||||
return a; | return a; | ||||
} | } | ||||
Context not available. | |||||
if ( cmd == 1 ) { /* keep system filepointer/descriptor open */ | if ( cmd == 1 ) { /* keep system filepointer/descriptor open */ | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: ioctl `%s' keep=%d\n", | log_debug("iobuf-%d.%d: ioctl `%s' keep=%d\n", | ||||
a? a->no:-1, a?a->subno:-1, a?a->desc:"?", intval ); | a? a->no:-1, a?a->subno:-1, | ||||
a&&a->desc?a->desc:"?", intval ); | |||||
for( ; a; a = a->chain ) | for( ; a; a = a->chain ) | ||||
if( !a->chain && a->filter == file_filter ) { | if( !a->chain && a->filter == file_filter ) { | ||||
file_filter_ctx_t *b = a->filter_ov; | file_filter_ctx_t *b = a->filter_ov; | ||||
Context not available. | |||||
else if ( cmd == 3 ) { /* disallow/allow caching */ | else if ( cmd == 3 ) { /* disallow/allow caching */ | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: ioctl `%s' no_cache=%d\n", | log_debug("iobuf-%d.%d: ioctl `%s' no_cache=%d\n", | ||||
a? a->no:-1, a?a->subno:-1, a?a->desc:"?", intval ); | a? a->no:-1, a?a->subno:-1, | ||||
a&&a->desc?a->desc:"?", intval ); | |||||
for( ; a; a = a->chain ) | for( ; a; a = a->chain ) | ||||
if( !a->chain && a->filter == file_filter ) { | if( !a->chain && a->filter == file_filter ) { | ||||
file_filter_ctx_t *b = a->filter_ov; | file_filter_ctx_t *b = a->filter_ov; | ||||
Context not available. | |||||
f( ov, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &dummy_len ); | f( ov, IOBUFCTRL_DESC, NULL, (byte*)&a->desc, &dummy_len ); | ||||
if( DBG_IOBUF ) { | if( DBG_IOBUF ) { | ||||
log_debug("iobuf-%d.%d: push `%s'\n", a->no, a->subno, a->desc ); | log_debug("iobuf-%d.%d: push `%s'\n", a->no, a->subno, | ||||
a->desc?a->desc:"?" ); | |||||
print_chain( a ); | print_chain( a ); | ||||
} | } | ||||
Context not available. | |||||
BUG(); | BUG(); | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: pop `%s'\n", a->no, a->subno, a->desc ); | log_debug("iobuf-%d.%d: pop `%s'\n", a->no, a->subno, | ||||
a->desc?a->desc:"?" ); | |||||
if( !a->filter ) { /* this is simple */ | if( !a->filter ) { /* this is simple */ | ||||
b = a->chain; | b = a->chain; | ||||
assert(b); | assert(b); | ||||
Context not available. | |||||
IOBUF b = a->chain; | IOBUF b = a->chain; | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: pop `%s' in underflow\n", | log_debug("iobuf-%d.%d: pop `%s' in underflow\n", | ||||
a->no, a->subno, a->desc ); | a->no, a->subno, a->desc?a->desc:"?" ); | ||||
xfree(a->d.buf); | xfree(a->d.buf); | ||||
xfree(a->real_fname); | xfree(a->real_fname); | ||||
memcpy(a, b, sizeof *a); | memcpy(a, b, sizeof *a); | ||||
Context not available. | |||||
if( !len && a->chain ) { | if( !len && a->chain ) { | ||||
IOBUF b = a->chain; | IOBUF b = a->chain; | ||||
if( DBG_IOBUF ) | if( DBG_IOBUF ) | ||||
log_debug("iobuf-%d.%d: pop `%s' in underflow (!len)\n", | log_debug("iobuf-%d.%d: pop in underflow (!len)\n", | ||||
a->no, a->subno, a->desc ); | a->no, a->subno); | ||||
xfree(a->d.buf); | xfree(a->d.buf); | ||||
xfree(a->real_fname); | xfree(a->real_fname); | ||||
memcpy(a,b, sizeof *a); | memcpy(a,b, sizeof *a); | ||||
Context not available. |