1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

See ChangeLog: Tue Feb 16 14:10:02 CET 1999 Werner Koch

This commit is contained in:
Werner Koch 1999-02-16 13:16:33 +00:00
parent 6e5bc13878
commit e1a1b3fc90
53 changed files with 359 additions and 279 deletions

View file

@ -1,3 +1,10 @@
Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* strgutil.c (add_to_strglist): Clear the new flags field
(append_to_strglist): Ditto.
* dotlock.c (read_lockfile): terminate pidstr (Michael).
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c (remove_lockfiles): Add cleanup function.

View file

@ -49,7 +49,7 @@
* char *ret_str;
* } r; Return values
* struct {
* int index;
* int idx;
* const char *last;
* void *aliases;
* } internal; DO NOT CHANGE
@ -143,7 +143,7 @@ static void
initialize( ARGPARSE_ARGS *arg, const char *filename, unsigned *lineno )
{
if( !(arg->flags & (1<<15)) ) { /* initialize this instance */
arg->internal.index = 0;
arg->internal.idx = 0;
arg->internal.last = NULL;
arg->internal.inarg = 0;
arg->internal.stopped = 0;
@ -230,7 +230,7 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
{
int state, i, c;
int index=0;
int idx=0;
char keyword[100];
char *buffer = NULL;
size_t buflen = 0;
@ -256,13 +256,13 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
for(i=0; opts[i].short_opt; i++ )
if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
break;
index = i;
arg->r_opt = opts[index].short_opt;
idx = i;
arg->r_opt = opts[idx].short_opt;
if( inverse ) /* this does not have an effect, hmmm */
arg->r_opt = -arg->r_opt;
if( !opts[index].short_opt ) /* unknown command/option */
arg->r_opt = (opts[index].flags & 256)? -7:-2;
else if( (opts[index].flags & 8) ) /* no argument */
if( !opts[idx].short_opt ) /* unknown command/option */
arg->r_opt = (opts[idx].flags & 256)? -7:-2;
else if( (opts[idx].flags & 8) ) /* no argument */
arg->r_opt = -3; /* error */
else /* no or optional argument */
arg->r_type = 0; /* okay */
@ -271,9 +271,9 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
else if( state == 3 ) { /* no argument found */
if( in_alias )
arg->r_opt = -3; /* error */
else if( !(opts[index].flags & 7) ) /* does not take an arg */
else if( !(opts[idx].flags & 7) ) /* does not take an arg */
arg->r_type = 0; /* okay */
else if( (opts[index].flags & 8) ) /* no optional argument */
else if( (opts[idx].flags & 8) ) /* no optional argument */
arg->r_type = 0; /* okay */
else /* no required argument */
arg->r_opt = -3; /* error */
@ -301,7 +301,7 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
}
}
}
else if( !(opts[index].flags & 7) ) /* does not take an arg */
else if( !(opts[idx].flags & 7) ) /* does not take an arg */
arg->r_opt = -6; /* error */
else {
if( !buffer ) {
@ -312,7 +312,7 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
buffer[i] = 0;
trim_spaces( buffer );
if( !set_opt_arg(arg, opts[index].flags, buffer) )
if( !set_opt_arg(arg, opts[idx].flags, buffer) )
m_free(buffer);
}
break;
@ -340,15 +340,15 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
for(i=0; opts[i].short_opt; i++ )
if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
break;
index = i;
arg->r_opt = opts[index].short_opt;
if( !opts[index].short_opt ) {
idx = i;
arg->r_opt = opts[idx].short_opt;
if( !opts[idx].short_opt ) {
if( !strcmp( keyword, "alias" ) ) {
in_alias = 1;
state = 3;
}
else {
arg->r_opt = (opts[index].flags & 256)? -7:-2;
arg->r_opt = (opts[idx].flags & 256)? -7:-2;
state = -1; /* skip rest of line and leave */
}
}
@ -445,7 +445,7 @@ find_long_option( ARGPARSE_ARGS *arg,
int
arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
{
int index;
int idx;
int argc;
char **argv;
char *s, *s2;
@ -454,10 +454,10 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
initialize( arg, NULL, NULL );
argc = *arg->argc;
argv = *arg->argv;
index = arg->internal.index;
idx = arg->internal.idx;
if( !index && argc && !(arg->flags & (1<<4)) ) { /* skip the first entry */
argc--; argv++; index++;
if( !idx && argc && !(arg->flags & (1<<4)) ) { /* skip the first entry */
argc--; argv++; idx++;
}
next_one:
@ -473,7 +473,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
arg->r_opt = -1; /* not an option but a argument */
arg->r_type = 2;
arg->r.ret_str = s;
argc--; argv++; index++; /* set to next one */
argc--; argv++; idx++; /* set to next one */
}
else if( arg->internal.stopped ) { /* ready */
arg->r_opt = 0;
@ -485,7 +485,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
arg->internal.inarg = 0;
if( !s[2] && !(arg->flags & (1<<3)) ) { /* stop option processing */
arg->internal.stopped = 1;
argc--; argv++; index++;
argc--; argv++; idx++;
goto next_one;
}
@ -548,7 +548,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
else {
set_opt_arg(arg, opts[i].flags, s2);
if( !argpos ) {
argc--; argv++; index++; /* skip one */
argc--; argv++; idx++; /* skip one */
}
}
}
@ -558,7 +558,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
else
arg->r_type = 0;
}
argc--; argv++; index++; /* set to next one */
argc--; argv++; idx++; /* set to next one */
}
else if( (*s == '-' && s[1]) || arg->internal.inarg ) { /* short option */
int dash_kludge = 0;
@ -611,7 +611,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
}
else {
set_opt_arg(arg, opts[i].flags, s2);
argc--; argv++; index++; /* skip one */
argc--; argv++; idx++; /* skip one */
}
}
s = "x"; /* so that !s[1] yields false */
@ -622,14 +622,14 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
}
if( !s[1] || dash_kludge ) { /* no more concatenated short options */
arg->internal.inarg = 0;
argc--; argv++; index++;
argc--; argv++; idx++;
}
}
else if( arg->flags & (1<<2) ) {
arg->r_opt = -1; /* not an option but a argument */
arg->r_type = 2;
arg->r.ret_str = s;
argc--; argv++; index++; /* set to next one */
argc--; argv++; idx++; /* set to next one */
}
else {
arg->internal.stopped = 1; /* stop option processing */
@ -639,7 +639,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
leave:
*arg->argc = argc;
*arg->argv = argv;
arg->internal.index = index;
arg->internal.idx = idx;
return arg->r_opt;
}

View file

@ -85,7 +85,7 @@ create_dotlock( const char *file_to_lock )
h = m_alloc_clear( sizeof *h );
#ifndef HAVE_DOSISH_SYSTEM
sprintf( pidstr, "%10d\n", getpid() );
sprintf( pidstr, "%10d\n", (int)getpid() );
/* fixme: add the hostname to the second line (FQDN or IP addr?) */
/* create a temporary file */
@ -298,12 +298,13 @@ read_lockfile( const char *name )
errno = e;
return -1;
}
if( read(fd, pidstr, 10 ) != 10 ) {
if( read(fd, pidstr, 10 ) != 10 ) { /* Read 10 digits w/o newline */
log_debug("error reading lockfile `%s'", name );
close(fd);
errno = 0;
return -1;
}
pidstr[10] = 0; /* terminate pid string */
close(fd);
pid = atoi(pidstr);
if( !pid || pid == -1 ) {

View file

@ -61,7 +61,7 @@ static byte *build_rel_path( PARSED_URI uri );
static int parse_response( HTTP_HD hd );
static int connect_server( const char *server, ushort port );
static int write_server( int socket, const char *data, size_t length );
static int write_server( int sock, const char *data, size_t length );
int
@ -75,7 +75,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
/* initialize the handle */
memset( hd, 0, sizeof *hd );
hd->socket = -1;
hd->sock = -1;
hd->initialized = 1;
hd->req_type = reqtype;
@ -83,15 +83,15 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
if( !rc ) {
rc = send_request( hd );
if( !rc ) {
hd->fp_write = iobuf_fdopen( hd->socket , "w" );
hd->fp_write = iobuf_fdopen( hd->sock , "w" );
if( hd->fp_write )
return 0;
rc = G10ERR_GENERAL;
}
}
if( !hd->fp_read && !hd->fp_write && hd->socket != -1 )
close( hd->socket );
if( !hd->fp_read && !hd->fp_write && hd->sock != -1 )
close( hd->sock );
iobuf_close( hd->fp_read );
iobuf_close( hd->fp_write);
release_parsed_uri( hd->uri );
@ -119,15 +119,15 @@ http_wait_response( HTTP_HD hd, unsigned int *ret_status )
http_start_data( hd ); /* make sure that we are in the data */
iobuf_flush( hd->fp_write );
hd->socket = dup( hd->socket );
if( hd->socket == -1 )
hd->sock = dup( hd->sock );
if( hd->sock == -1 )
return G10ERR_GENERAL;
iobuf_close( hd->fp_write );
hd->fp_write = NULL;
shutdown( hd->socket, 1 );
shutdown( hd->sock, 1 );
hd->in_data = 0;
hd->fp_read = iobuf_fdopen( hd->socket , "r" );
hd->fp_read = iobuf_fdopen( hd->sock , "r" );
if( !hd->fp_read )
return G10ERR_GENERAL;
@ -166,8 +166,8 @@ http_close( HTTP_HD hd )
{
if( !hd || !hd->initialized )
return;
if( !hd->fp_read && !hd->fp_write && hd->socket != -1 )
close( hd->socket );
if( !hd->fp_read && !hd->fp_write && hd->sock != -1 )
close( hd->sock );
iobuf_close( hd->fp_read );
iobuf_close( hd->fp_write );
release_parsed_uri( hd->uri );
@ -427,8 +427,8 @@ send_request( HTTP_HD hd )
server = *hd->uri->host? hd->uri->host : "localhost";
port = hd->uri->port? hd->uri->port : 80;
hd->socket = connect_server( server, port );
if( hd->socket == -1 )
hd->sock = connect_server( server, port );
if( hd->sock == -1 )
return G10ERR_NETWORK;
p = build_rel_path( hd->uri );
@ -440,7 +440,7 @@ send_request( HTTP_HD hd )
*p == '/'? "":"/", p );
m_free(p);
rc = write_server( hd->socket, request, strlen(request) );
rc = write_server( hd->sock, request, strlen(request) );
m_free( request );
return rc;
@ -656,13 +656,13 @@ connect_server( const char *server, ushort port )
static int
write_server( int socket, const char *data, size_t length )
write_server( int sock, const char *data, size_t length )
{
int nleft, nwritten;
nleft = length;
while( nleft > 0 ) {
nwritten = write( socket, data, nleft );
nwritten = write( sock, data, nleft );
if( nwritten == -1 ) {
if( errno == EINTR )
continue;

View file

@ -46,7 +46,7 @@ typedef struct {
#define OP_MIN_PARTIAL_CHUNK_2POW 9
typedef struct {
int usage;
int use;
size_t size;
size_t count;
int partial; /* 1 = partial header, 2 in last partial packet */
@ -340,7 +340,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
log_debug("init block_filter %p\n", a );
if( a->partial )
a->count = 0;
else if( a->usage == 1 )
else if( a->use == 1 )
a->count = a->size = 0;
else
a->count = a->size; /* force first length bytes */
@ -352,7 +352,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
*(char**)buf = "block_filter";
}
else if( control == IOBUFCTRL_FREE ) {
if( a->usage == 2 ) { /* write the end markers */
if( a->use == 2 ) { /* write the end markers */
if( a->partial ) {
u32 len;
/* write out the remaining bytes without a partial header
@ -426,17 +426,17 @@ print_chain( IOBUF a )
/****************
* Allocate a new io buffer, with no function assigned.
* Usage is the desired usage: 1 for input, 2 for output, 3 for temp buffer
* Use is the desired usage: 1 for input, 2 for output, 3 for temp buffer
* BUFSIZE is a suggested buffer size.
*/
IOBUF
iobuf_alloc(int usage, size_t bufsize)
iobuf_alloc(int use, size_t bufsize)
{
IOBUF a;
static int number=0;
a = m_alloc_clear(sizeof *a);
a->usage = usage;
a->use = use;
a->d.buf = m_alloc( bufsize );
a->d.size = bufsize;
a->no = ++number;
@ -462,7 +462,7 @@ iobuf_close( IOBUF a )
for( ; a && !rc ; a = a2 ) {
a2 = a->chain;
if( a->usage == 2 && (rc=iobuf_flush(a)) )
if( a->use == 2 && (rc=iobuf_flush(a)) )
log_error("iobuf_flush failed on close: %s\n", g10_errstr(rc));
if( DBG_IOBUF )
@ -481,7 +481,7 @@ iobuf_cancel( IOBUF a )
{
const char *s;
if( a && a->usage == 2 ) {
if( a && a->use == 2 ) {
s = get_real_fname(a);
if( s && *s )
remove(s); /* remove the file. Fixme: this will fail for MSDOZE*/
@ -720,7 +720,7 @@ iobuf_push_filter( IOBUF a,
if( a->directfp )
BUG();
if( a->usage == 2 && (rc=iobuf_flush(a)) )
if( a->use == 2 && (rc=iobuf_flush(a)) )
return rc;
/* make a copy of the current stream, so that
* A is the new stream and B the original one.
@ -733,10 +733,10 @@ iobuf_push_filter( IOBUF a,
a->filter = NULL;
a->filter_ov = NULL;
a->filter_eof = 0;
if( a->usage == 3 )
a->usage = 2; /* make a write stream from a temp stream */
if( a->use == 3 )
a->use = 2; /* make a write stream from a temp stream */
if( a->usage == 2 ) { /* allocate a fresh buffer for the original stream */
if( a->use == 2 ) { /* allocate a fresh buffer for the original stream */
b->d.buf = m_alloc( a->d.size );
b->d.len = 0;
b->d.start = 0;
@ -805,7 +805,7 @@ pop_filter( IOBUF a, int (*f)(void *opaque, int control,
log_bug("iobuf_pop_filter(): filter function not found\n");
/* flush this stream if it is an output stream */
if( a->usage == 2 && (rc=iobuf_flush(b)) ) {
if( a->use == 2 && (rc=iobuf_flush(b)) ) {
log_error("iobuf_flush failed in pop_filter: %s\n", g10_errstr(rc));
return rc;
}
@ -853,7 +853,7 @@ underflow(IOBUF a)
int rc;
assert( a->d.start == a->d.len );
if( a->usage == 3 )
if( a->use == 3 )
return -1; /* EOF because a temp buffer can't do an underflow */
if( a->filter_eof ) {
@ -909,7 +909,7 @@ underflow(IOBUF a)
#endif
}
if( a->usage == 1 && rc == -1 ) { /* EOF: we can remove the filter */
if( a->use == 1 && rc == -1 ) { /* EOF: we can remove the filter */
size_t dummy_len;
/* and tell the filter to free itself */
@ -965,7 +965,7 @@ iobuf_flush(IOBUF a)
return 0;
/*log_debug("iobuf-%d.%d: flush\n", a->no, a->subno );*/
if( a->usage == 3 ) { /* increase the temp buffer */
if( a->use == 3 ) { /* increase the temp buffer */
char *newbuf;
size_t newsize = a->d.size + 8192;
@ -978,7 +978,7 @@ iobuf_flush(IOBUF a)
a->d.size = newsize;
return 0;
}
else if( a->usage != 2 )
else if( a->use != 2 )
log_bug("flush on non-output iobuf\n");
else if( !a->filter )
log_bug("iobuf_flush: no filter\n");
@ -1332,15 +1332,15 @@ iobuf_set_block_mode( IOBUF a, size_t n )
{
block_filter_ctx_t *ctx = m_alloc_clear( sizeof *ctx );
assert( a->usage == 1 || a->usage == 2 );
ctx->usage = a->usage;
assert( a->use == 1 || a->use == 2 );
ctx->use = a->use;
if( !n ) {
if( a->usage == 1 )
if( a->use == 1 )
log_debug("pop_filter called in set_block_mode - please report\n");
pop_filter(a, block_filter, NULL );
}
else {
ctx->size = n; /* only needed for usage 2 */
ctx->size = n; /* only needed for use 2 */
iobuf_push_filter(a, block_filter, ctx );
}
}
@ -1354,10 +1354,10 @@ iobuf_set_partial_block_mode( IOBUF a, size_t len )
{
block_filter_ctx_t *ctx = m_alloc_clear( sizeof *ctx );
assert( a->usage == 1 || a->usage == 2 );
ctx->usage = a->usage;
assert( a->use == 1 || a->use == 2 );
ctx->use = a->use;
if( !len ) {
if( a->usage == 1 )
if( a->use == 1 )
log_debug("pop_filter called in set_partial_block_mode"
" - please report\n");
pop_filter(a, block_filter, NULL );

View file

@ -71,7 +71,7 @@ static int suspend_warning;
static void
print_warn()
print_warn(void)
{
if( !no_warning )
log_info(_("Warning: using insecure memory!\n"));

View file

@ -67,6 +67,7 @@ add_to_strlist( STRLIST *list, const char *string )
STRLIST sl;
sl = m_alloc( sizeof *sl + strlen(string));
sl->flags = 0;
strcpy(sl->d, string);
sl->next = *list;
*list = sl;
@ -79,6 +80,7 @@ append_to_strlist( STRLIST *list, const char *string )
STRLIST r, sl;
sl = m_alloc( sizeof *sl + strlen(string));
sl->flags = 0;
strcpy(sl->d, string);
sl->next = NULL;
if( !*list )

View file

@ -76,7 +76,7 @@ cleanup(void)
#endif
static void
init_ttyfp()
init_ttyfp(void)
{
if( initialized )
return;