aboutsummaryrefslogtreecommitdiffstats
path: root/help.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-12-24 20:35:13 +0100
committerJelmer Vernooij <jelmer@samba.org>2006-12-24 20:35:13 +0100
commitc227706bc921c3bb426eb315c0d097df30aa9d16 (patch)
tree1af13b2b2fd26691691e2f802ca85514b1a2b925 /help.c
parent9225e08f377026e653e31468d53df9d328dd7951 (diff)
Refactor the help code to take a filename rather than using the global struct.
Diffstat (limited to 'help.c')
-rw-r--r--help.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/help.c b/help.c
index 7c6d2dda..756eb12a 100644
--- a/help.c
+++ b/help.c
@@ -30,7 +30,7 @@
#define BUFSIZE 1100
-help_t *help_init( help_t **help )
+help_t *help_init( help_t **help, const char *helpfile )
{
int i, buflen = 0;
help_t *h;
@@ -40,7 +40,7 @@ help_t *help_init( help_t **help )
*help = h = g_new0 ( help_t, 1 );
- h->fd = open( global.helpfile, O_RDONLY
+ h->fd = open( helpfile, O_RDONLY
#ifdef _WIN32
| O_BINARY
#endif
@@ -108,12 +108,11 @@ char *help_get( help_t **help, char *string )
struct stat stat[1];
help_t *h;
- h=*help;
-
- while( h )
+ for( h = *help; h; h = h->next )
{
- if( g_strcasecmp( h->string, string ) == 0 ) break;
- h = h->next;
+ if( h->string != NULL &&
+ g_strcasecmp( h->string, string ) == 0 )
+ break;
}
if( h && h->length > 0 )
{