mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02: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:
parent
bf079613b7
commit
ca6dcb7258
@ -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>
|
2004-10-11 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* pkclist.c (do_edit_ownertrust): Use the same translated string
|
* pkclist.c (do_edit_ownertrust): Use the same translated string
|
||||||
|
29
g10/keygen.c
29
g10/keygen.c
@ -2154,8 +2154,10 @@ read_parameter_file( const char *fname )
|
|||||||
{ "Revoker", pREVOKER },
|
{ "Revoker", pREVOKER },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
FILE *fp;
|
IOBUF fp;
|
||||||
char line[1024], *p;
|
unsigned char *line;
|
||||||
|
unsigned int maxlen, nline;
|
||||||
|
char *p;
|
||||||
int lnr;
|
int lnr;
|
||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
struct para_data_s *para, *r;
|
struct para_data_s *para, *r;
|
||||||
@ -2164,26 +2166,26 @@ read_parameter_file( const char *fname )
|
|||||||
|
|
||||||
memset( &outctrl, 0, sizeof( outctrl ) );
|
memset( &outctrl, 0, sizeof( outctrl ) );
|
||||||
|
|
||||||
if( !fname || !*fname || !strcmp(fname,"-") ) {
|
if( !fname || !*fname)
|
||||||
fp = stdin;
|
|
||||||
fname = "-";
|
fname = "-";
|
||||||
}
|
|
||||||
else {
|
fp = iobuf_open (fname);
|
||||||
fp = fopen( fname, "r" );
|
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
|
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
iobuf_ioctl (fp, 3, 1, NULL); /* No file caching. */
|
||||||
|
|
||||||
lnr = 0;
|
lnr = 0;
|
||||||
err = NULL;
|
err = NULL;
|
||||||
para = 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;
|
char *keyword, *value;
|
||||||
|
|
||||||
lnr++;
|
lnr++;
|
||||||
if( *line && line[strlen(line)-1] != '\n' ) {
|
if( !maxlen ) {
|
||||||
err = "line too long";
|
err = "line too long";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2290,8 +2292,8 @@ read_parameter_file( const char *fname )
|
|||||||
}
|
}
|
||||||
if( err )
|
if( err )
|
||||||
log_error("%s:%d: %s\n", fname, lnr, err );
|
log_error("%s:%d: %s\n", fname, lnr, err );
|
||||||
else if( ferror(fp) ) {
|
else if( iobuf_error (fp) ) {
|
||||||
log_error("%s:%d: read error: %s\n", fname, lnr, strerror(errno) );
|
log_error("%s:%d: read error\n", fname, lnr);
|
||||||
}
|
}
|
||||||
else if( para ) {
|
else if( para ) {
|
||||||
outctrl.lnr = lnr;
|
outctrl.lnr = lnr;
|
||||||
@ -2315,8 +2317,7 @@ read_parameter_file( const char *fname )
|
|||||||
}
|
}
|
||||||
|
|
||||||
release_parameter_list( para );
|
release_parameter_list( para );
|
||||||
if( strcmp( fname, "-" ) )
|
iobuf_close (fp);
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user