lib/eggdrop/help.h File Reference

Go to the source code of this file.

Data Structures

struct  help_file_t
struct  help_summary_t
struct  help_section_t
struct  help_search_t

Functions

int help_init ()
int help_shutdown ()
int help_set_default_path (const char *path)
int help_set_default_lang (const char *lang)
int help_count_sections ()
int help_count_entries ()
int help_load (const char *filename)
int help_unload (const char *filename)
int help_load_by_module (const char *name)
int help_unload_by_module (const char *name)
help_summary_thelp_lookup_summary (const char *name)
help_section_thelp_lookup_section (const char *name)
xml_node_thelp_lookup_entry (help_summary_t *entry)
help_search_thelp_search_new (const char *searchstr)
int help_search_end (help_search_t *search)
help_summary_thelp_search_result (help_search_t *search)


Function Documentation

int help_count_entries (  ) 

int help_count_sections (  ) 

int help_init (  ) 

Definition at line 36 of file help.c.

References help_lang_default, and help_path.

Referenced by eggdrop_init().

00037 {
00038   help_path = strdup("help/");
00039   help_lang_default = strdup("en_US");
00040   return(0);
00041 }

int help_load ( const char *  filename  ) 

int help_load_by_module ( const char *  name  ) 

Definition at line 210 of file help.c.

References help_lang_fallback, help_parse_file(), help_path, and localized_help_fname().

Referenced by core_init().

00211 {
00212   char fullname[256], buf[256];
00213 
00214   snprintf(fullname, sizeof(fullname), "%s-commands.xml", name);
00215   localized_help_fname(buf, sizeof(buf), fullname);
00216   if (help_parse_file(buf)) {
00217     snprintf(buf, sizeof(buf), "%s/%s/%s", help_path, help_lang_fallback, fullname);
00218     help_parse_file(buf);
00219   }
00220   return(0);
00221 }

xml_node_t* help_lookup_entry ( help_summary_t entry  ) 

Definition at line 171 of file help.c.

References help_summary_t::file, help_summary_t::name, help_file_t::name, xml_node::next_sibling, xml_node_get_str(), xml_node_lookup(), xml_node_unlink(), and xml_parse_file().

Referenced by party_help().

00172 {
00173   xml_node_t *root = xml_parse_file(entry->file->name);
00174   xml_node_t *node;
00175   char *name;
00176 
00177   node = xml_node_lookup(root, 0, "help", 0, 0);
00178   for (; node; node = node->next_sibling) {
00179     xml_node_get_str(&name, node, "name", 0, 0);
00180     if (name && !strcasecmp(name, entry->name)) {
00181       xml_node_unlink(node);
00182       break;
00183     }
00184   }
00185   return(node);
00186 }

help_section_t* help_lookup_section ( const char *  name  ) 

help_summary_t* help_lookup_summary ( const char *  name  ) 

Definition at line 155 of file help.c.

References help_section_t::entries, help_summary_t::name, help_section_t::nentries, nsections, and NULL.

Referenced by party_help().

00156 {
00157   int i, j;
00158   help_section_t *section;
00159 
00160   for (i = 0; i < nsections; i++) {
00161     section = sections+i;
00162     for (j = 0; j < section->nentries; j++) {
00163       if (!strcasecmp(section->entries[j]->name, name)) {
00164           return(section->entries[j]);
00165       }
00166     }
00167   }
00168   return(NULL);
00169 }

int help_search_end ( help_search_t search  ) 

Definition at line 232 of file help.c.

References help_search_t::search.

Referenced by party_help().

00233 {
00234   free(search->search);
00235   free(search);
00236   return(0);
00237 }

help_search_t* help_search_new ( const char *  searchstr  ) 

Definition at line 223 of file help.c.

References help_search_t::search.

Referenced by party_help().

00224 {
00225   help_search_t *search;
00226 
00227   search = calloc(1, sizeof(*search));
00228   search->search = strdup(searchstr);
00229   return(search);
00230 }

help_summary_t* help_search_result ( help_search_t search  ) 

Definition at line 239 of file help.c.

References help_search_t::curentry, help_search_t::cursection, help_section_t::entries, help_summary_t::name, help_section_t::nentries, nsections, NULL, help_search_t::search, and wild_match().

Referenced by party_help().

00240 {
00241   help_section_t *section;
00242   help_summary_t *entry;
00243 
00244   if (search->cursection < 0 || search->curentry < 0 || !search->search) return(NULL);
00245 
00246   while (search->cursection < nsections) {
00247     section = sections+search->cursection;
00248     while (search->curentry < section->nentries) {
00249       entry = section->entries[search->curentry++];
00250       if (wild_match(search->search, entry->name)) return(entry);
00251     }
00252     search->cursection++;
00253     search->curentry = 0;
00254   }
00255   search->cursection = search->curentry = -1;
00256   return(NULL);
00257 }

int help_set_default_lang ( const char *  lang  ) 

Definition at line 54 of file help.c.

References help_lang_default, and str_redup().

00055 {
00056   str_redup(&help_lang_default, lang);
00057   return(0);
00058 }

int help_set_default_path ( const char *  path  ) 

Definition at line 48 of file help.c.

References help_path, and str_redup().

Referenced by core_init().

00049 {
00050   str_redup(&help_path, path);
00051   return(0);
00052 }

int help_shutdown (  ) 

Definition at line 43 of file help.c.

00044 {
00045   return(0);
00046 }

int help_unload ( const char *  filename  ) 

int help_unload_by_module ( const char *  name  ) 


Generated on Sun Nov 30 18:43:34 2008 for eggdrop1.9 by  doxygen 1.5.6