diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/argparse.c | 6 | ||||
-rw-r--r-- | util/logger.c | 12 | ||||
-rw-r--r-- | util/secmem.c | 22 | ||||
-rw-r--r-- | util/strgutil.c | 22 |
4 files changed, 55 insertions, 7 deletions
diff --git a/util/argparse.c b/util/argparse.c index 795e87648..0c8ad8f0b 100644 --- a/util/argparse.c +++ b/util/argparse.c @@ -221,10 +221,10 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno, arg->r_opt = -arg->r_opt; if( !opts[index].short_opt ) arg->r_opt = -2; /* unknown option */ - else if( (opts[index].flags & 8) ) /* no optional argument */ - arg->r_type = 0; /* okay */ - else /* no required argument */ + else if( (opts[index].flags & 8) ) /* no argument */ arg->r_opt = -3; /* error */ + else /* no or optiona argument */ + arg->r_type = 0; /* okay */ break; } else if( state == 3 ) { /* no argument found */ diff --git a/util/logger.c b/util/logger.c index 04dac2ce6..7d101c29a 100644 --- a/util/logger.c +++ b/util/logger.c @@ -129,11 +129,19 @@ log_bug( const char *fmt, ... ) abort(); } +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) void -log_bug0() +log_bug0( const char *file, int line, const char *func ) { - log_bug("Ohhhh jeeee ...\n"); + log_bug("Ohhhh jeeee ... (%s:%d:%s)\n", file, line, func ); } +#else +void +log_bug0( const char *file, int line ) +{ + log_bug("Ohhhh jeeee ... (%s:%d)\n", file, line); +} +#endif void log_debug( const char *fmt, ... ) diff --git a/util/secmem.c b/util/secmem.c index 2777ca8ca..a54848d54 100644 --- a/util/secmem.c +++ b/util/secmem.c @@ -61,6 +61,8 @@ static unsigned cur_alloced; static unsigned max_blocks; static unsigned cur_blocks; static int disable_secmem; +static int show_warning; +static int no_warning; static void lock_pool( void *p, size_t n ) @@ -82,7 +84,7 @@ lock_pool( void *p, size_t n ) if( err ) { if( errno != EPERM ) log_error("can�t lock memory: %s\n", strerror(err)); - log_info(_("Warning: using insecure memory!\n")); + show_warning = 1; } #else @@ -132,6 +134,17 @@ compress_pool(void) } +void +secmem_set_flags( unsigned flags ) +{ + no_warning = flags & 1; +} + +unsigned +secmem_get_flags(void) +{ + return no_warning ? 1:0; +} void secmem_init( size_t n ) @@ -156,7 +169,12 @@ secmem_malloc( size_t size ) int compressed=0; if( !pool_okay ) - init_pool(DEFAULT_POOLSIZE); + log_bug("secmem not initialized\n"); + if( show_warning ) { + show_warning = 0; + if( !no_warning ) + log_info(_("Warning: using insecure memory!\n")); + } /* blocks are always a multiple of 32 */ size += sizeof(MEMBLOCK); diff --git a/util/strgutil.c b/util/strgutil.c index a687d0af3..e04367a7e 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -50,6 +50,28 @@ add_to_strlist( STRLIST *list, const char *string ) *list = sl; } + + +STRLIST +strlist_prev( STRLIST head, STRLIST node ) +{ + STRLIST n; + + for(n=NULL; head && head != node; head = head->next ) + n = head; + return n; +} + +STRLIST +strlist_last( STRLIST node ) +{ + if( node ) + for( ; node->next ; node = node->next ) + ; + return node; +} + + /**************** * look for the substring SUB in buffer and return a pointer to that * substring in BUF or NULL if not found. |