Changeset c227706


Ignore:
Timestamp:
2006-12-24T19:35:13Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
7bee5af
Parents:
9225e08
Message:

Refactor the help code to take a filename rather than using the global struct.

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • help.c

    r9225e08 rc227706  
    3131#define BUFSIZE 1100
    3232
    33 help_t *help_init( help_t **help )
     33help_t *help_init( help_t **help, const char *helpfile )
    3434{
    3535        int i, buflen = 0;
     
    4141        *help = h = g_new0 ( help_t, 1 );
    4242       
    43         h->fd = open( global.helpfile, O_RDONLY
     43        h->fd = open( helpfile, O_RDONLY
    4444#ifdef _WIN32
    4545                                  | O_BINARY
     
    109109        help_t *h;
    110110
    111         h=*help;       
    112 
    113         while( h )
     111        for( h = *help; h; h = h->next )
    114112        {
    115                 if( g_strcasecmp( h->string, string ) == 0 ) break;
    116                 h = h->next;
     113                if( h->string != NULL &&
     114                        g_strcasecmp( h->string, string ) == 0 )
     115                        break;
    117116        }
    118117        if( h && h->length > 0 )
  • help.h

    r9225e08 rc227706  
    4343} help_t;
    4444
    45 help_t *help_init( help_t **help );
     45help_t *help_init( help_t **help, const char *helpfile );
    4646char *help_get( help_t **help, char *string );
    4747
  • tests/Makefile

    r9225e08 rc227706  
    1111main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o
    1212
    13 test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o
     13test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o
    1414
    1515check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o
  • tests/check.c

    r9225e08 rc227706  
    4141Suite *irc_suite(void);
    4242
     43/* From check_help.c */
     44Suite *help_suite(void);
     45
    4346int main (int argc, char **argv)
    4447{
     
    8184        srunner_add_suite(sr, md5_suite());
    8285        srunner_add_suite(sr, irc_suite());
     86        srunner_add_suite(sr, help_suite());
    8387        if (no_fork)
    8488                srunner_set_fork_status(sr, CK_NOFORK);
  • unix.c

    r9225e08 rc227706  
    112112        if( !getuid() || !geteuid() )
    113113                log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" );
    114         if( help_init( &(global.help) ) == NULL )
     114        if( help_init( &(global.help), global.helpfile ) == NULL )
    115115                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
    116116       
Note: See TracChangeset for help on using the changeset viewer.