1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-01 16:33:02 +01:00

(read_parameter_file): Changed to use iobuf based file

reading to allow the special file name feature to work.
This commit is contained in:
Werner Koch 2004-10-12 16:41:17 +00:00
parent bf079613b7
commit ca6dcb7258
2 changed files with 24 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2004-10-12 Werner Koch <wk@g10code.com>
* keygen.c (read_parameter_file): Changed to use iobuf based file
reading to allow the special file name feature to work.
2004-10-11 David Shaw <dshaw@jabberwocky.com>
* pkclist.c (do_edit_ownertrust): Use the same translated string

View File

@ -2154,8 +2154,10 @@ read_parameter_file( const char *fname )
{ "Revoker", pREVOKER },
{ NULL, 0 }
};
FILE *fp;
char line[1024], *p;
IOBUF fp;
unsigned char *line;
unsigned int maxlen, nline;
char *p;
int lnr;
const char *err = NULL;
struct para_data_s *para, *r;
@ -2164,26 +2166,26 @@ read_parameter_file( const char *fname )
memset( &outctrl, 0, sizeof( outctrl ) );
if( !fname || !*fname || !strcmp(fname,"-") ) {
fp = stdin;
fname = "-";
}
else {
fp = fopen( fname, "r" );
if( !fp ) {
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
return;
}
if( !fname || !*fname)
fname = "-";
fp = iobuf_open (fname);
if (!fp) {
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
return;
}
iobuf_ioctl (fp, 3, 1, NULL); /* No file caching. */
lnr = 0;
err = NULL;
para = NULL;
while( fgets( line, DIM(line)-1, fp ) ) {
maxlen = 1024;
line = NULL;
while ( iobuf_read_line (fp, &line, &nline, &maxlen) ) {
char *keyword, *value;
lnr++;
if( *line && line[strlen(line)-1] != '\n' ) {
if( !maxlen ) {
err = "line too long";
break;
}
@ -2290,8 +2292,8 @@ read_parameter_file( const char *fname )
}
if( err )
log_error("%s:%d: %s\n", fname, lnr, err );
else if( ferror(fp) ) {
log_error("%s:%d: read error: %s\n", fname, lnr, strerror(errno) );
else if( iobuf_error (fp) ) {
log_error("%s:%d: read error\n", fname, lnr);
}
else if( para ) {
outctrl.lnr = lnr;
@ -2315,8 +2317,7 @@ read_parameter_file( const char *fname )
}
release_parameter_list( para );
if( strcmp( fname, "-" ) )
fclose(fp);
iobuf_close (fp);
}