- if(args[1]) {
- admin_out(h, "Details for command %s:", args[1]);
- } else {
- admin_out(h, "The following commands are available:");
- }
- while(gl) {
- struct admin_command *cmd = (struct admin_command *)gl->data;
- if(args[1]) {
- if(!g_strcasecmp(args[1], cmd->name)) {
- if(cmd->help_details != NULL) {
- details = g_strsplit(cmd->help_details, "\n", 0);
- for(i = 0; details[i] != NULL; i++) {
- admin_out(h, details[i]);
- }
- return;
- } else {
- admin_out(h, "Sorry, no help for %s available", args[1]);
- }
- }
- } else {
- if(cmd->help != NULL) {
- tmp = g_strdup_printf("%s%s %s",cmd->name,g_strnfill(longest_command - strlen(cmd->name),' '),cmd->help);
- admin_out(h, tmp);
- g_free(tmp);
- } else {
- admin_out(h, cmd->name);
- }
+GHashTable *help_build_hash(char *data, gsize len)
+{
+ GHashTable *h = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+ gsize i;
+ char *p;
+
+ i = 0;
+ while (i < len) {
+ if (data[i] != '?') {
+ log_global(LOG_WARNING, "Unknown character '0x%02x' in help file",
+ data[i]);
+ g_hash_table_destroy(h);
+ return NULL;
+ }
+ /* Key starts here */
+ p = g_strstr_len(data+i, len-i, "\n");
+ if (p == NULL) {
+ log_global(LOG_WARNING, "Error parsing help file");
+ g_hash_table_destroy(h);
+ return NULL;