[cvslog] (2004-09-29 18:04:03 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Wed Sep 29 12:04:03 CST 2004


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2004-09-29 18:04:03 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     lib/eggdrop/help.c lib/eggdrop/help.h lib/eggdrop/xml.c
     lib/eggdrop/xml.h modules/server/help/en_US/commands.xml
     src/core_party.c

Log message:



---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/help.c
diff -u eggdrop1.9/lib/eggdrop/help.c:1.17 eggdrop1.9/lib/eggdrop/help.c:1.18
--- eggdrop1.9/lib/eggdrop/help.c:1.17	Wed Sep 29 10:38:39 2004
+++ eggdrop1.9/lib/eggdrop/help.c	Wed Sep 29 13:03:53 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: help.c,v 1.17 2004/09/29 15:38:39 stdarg Exp $";
+static const char rcsid[] = "$Id: help.c,v 1.18 2004/09/29 18:03:53 stdarg Exp $";
 #endif
 
 #include <stdio.h>
@@ -120,7 +120,10 @@
 	if (!root) return(-1);
 
 	xml_node_get_vars(root, "sn", "section", &secname, "help", &node);
-	if (!secname || !node) return(-1);
+	if (!secname || !node) {
+		xml_node_delete(root);
+		return(-1);
+	}
 
 	for (i = 0; i < nsections; i++) {
 		if (!strcasecmp(sections[i].name, secname)) break;
@@ -149,6 +152,7 @@
 		section->nentries++;
 	}
 	nhelp_files++;
+	xml_node_delete(root);
 	return(0);
 }
 
@@ -168,9 +172,21 @@
 	return(NULL);
 }
 
-help_entry_t *help_lookup_entry(const char *name)
+xml_node_t *help_lookup_entry(help_summary_t *entry)
 {
-	return(NULL);
+	xml_node_t *root = xml_parse_file(entry->file->name);
+	xml_node_t *node;
+	char *name;
+
+	node = xml_node_lookup(root, 0, "help", 0, 0);
+	for (; node; node = node->next_sibling) {
+		xml_node_get_str(&name, node, "name", 0, 0);
+		if (name && !strcasecmp(name, entry->name)) {
+			xml_node_unlink(node);
+			break;
+		}
+	}
+	return(node);
 }
 
 static void localized_help_fname(char *buf, size_t size, const char *filename)
Index: eggdrop1.9/lib/eggdrop/help.h
diff -u eggdrop1.9/lib/eggdrop/help.h:1.4 eggdrop1.9/lib/eggdrop/help.h:1.5
--- eggdrop1.9/lib/eggdrop/help.h:1.4	Wed Sep 29 10:38:39 2004
+++ eggdrop1.9/lib/eggdrop/help.h	Wed Sep 29 13:03:53 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: help.h,v 1.4 2004/09/29 15:38:39 stdarg Exp $
+ * $Id: help.h,v 1.5 2004/09/29 18:03:53 stdarg Exp $
  */
 
 #ifndef _EGG_HELP_H_
@@ -60,6 +60,7 @@
 
 help_summary_t *help_lookup_summary(const char *name);
 help_section_t *help_lookup_section(const char *name);
+int help_print_entry(partymember_t *p, const char *name);
 
 help_search_t *help_search_new(const char *searchstr);
 int help_search_end(help_search_t *search);
Index: eggdrop1.9/lib/eggdrop/xml.c
diff -u eggdrop1.9/lib/eggdrop/xml.c:1.21 eggdrop1.9/lib/eggdrop/xml.c:1.22
--- eggdrop1.9/lib/eggdrop/xml.c:1.21	Wed Sep 29 10:38:39 2004
+++ eggdrop1.9/lib/eggdrop/xml.c	Wed Sep 29 13:03:53 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: xml.c,v 1.21 2004/09/29 15:38:39 stdarg Exp $";
+static const char rcsid[] = "$Id: xml.c,v 1.22 2004/09/29 18:03:53 stdarg Exp $";
 #endif
 
 #include <stdio.h>
@@ -71,20 +71,12 @@
 	if (node->attributes) free(node->attributes);
 }
 
-void xml_node_delete(xml_node_t *node)
-{
-	xml_node_delete_callbacked(node, NULL);
-}
-
-void xml_node_delete_callbacked(xml_node_t *node, void (*callback)(void *))
+void xml_node_unlink(xml_node_t *node)
 {
-	xml_node_t *child;
-
-	if (node->client_data && callback) callback(node->client_data);
-
-	if (node->parent) {
-		xml_node_t *parent = node->parent;
+	xml_node_t *parent = node->parent;
 
+	/* Unlink from parent. */
+	if (parent) {
 		parent->nchildren--;
 		if (parent->children == node) parent->children = node->next;
 		if (parent->last_child == node) parent->last_child = node->prev;
@@ -99,6 +91,20 @@
 	/* Unlink from sibling list. */
 	if (node->prev_sibling) node->prev_sibling->next_sibling = node->next_sibling;
 	if (node->next_sibling) node->next_sibling->prev_sibling = node->prev_sibling;
+}
+
+void xml_node_delete(xml_node_t *node)
+{
+	xml_node_delete_callbacked(node, NULL);
+}
+
+void xml_node_delete_callbacked(xml_node_t *node, void (*callback)(void *))
+{
+	xml_node_t *child;
+
+	if (node->client_data && callback) callback(node->client_data);
+
+	xml_node_unlink(node);
 
 	/* Delete children. */
 	for (child = node->children; child; child = child->next) {
Index: eggdrop1.9/lib/eggdrop/xml.h
diff -u eggdrop1.9/lib/eggdrop/xml.h:1.20 eggdrop1.9/lib/eggdrop/xml.h:1.21
--- eggdrop1.9/lib/eggdrop/xml.h:1.20	Wed Sep 29 10:38:39 2004
+++ eggdrop1.9/lib/eggdrop/xml.h	Wed Sep 29 13:03:53 2004
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: xml.h,v 1.20 2004/09/29 15:38:39 stdarg Exp $
+ * $Id: xml.h,v 1.21 2004/09/29 18:03:53 stdarg Exp $
  */
 
 #ifndef _EGG_XML_H_
@@ -92,6 +92,7 @@
 
 xml_node_t *xml_node_new(void);
 void xml_node_free(xml_node_t *node);
+void xml_node_unlink(xml_node_t *node);
 void xml_node_delete(xml_node_t *node);
 void xml_node_delete_callbacked(xml_node_t *node, void (*callback)(void *));
 void xml_node_append(xml_node_t *parent, xml_node_t *child);
Index: eggdrop1.9/modules/server/help/en_US/commands.xml
diff -u eggdrop1.9/modules/server/help/en_US/commands.xml:1.1 eggdrop1.9/modules/server/help/en_US/commands.xml:1.2
--- eggdrop1.9/modules/server/help/en_US/commands.xml:1.1	Wed Sep 29 10:38:39 2004
+++ eggdrop1.9/modules/server/help/en_US/commands.xml	Wed Sep 29 13:03:53 2004
@@ -19,11 +19,92 @@
 				<desc>the password to use for the new server</desc>
 			</arg>
 		</args>
-		<desc>This command ...</desc>
+		<desc>
+<line>The +server command adds a new server to the server list according</line>
+<line>to the given arguments. The only required argument, hostname,</line>
+<line>specifies the host or ip address that the bot will try to connect</line>
+<line>to. If no value for port is given, the default port (set in the</line>
+<line>config file) will be used. If no value for pass is given, then</line>
+<line>the bot will not attempt to send any password when it connects</line>
+<line>to the server.</line>
+<line/>
+<line>Note that if you want to specify a password, you must also specify</line>
+<line>a port, since the order of arguments is important.</line>
+		</desc>
 		<seealso>
 			<see>-server</see>
 			<see>servers</see>
 			<see>jump</see>
 		</seealso>
 	</help>
+	<help>
+		<name>-server</name>
+		<summary>remove a server from the server list</summary>
+		<args>
+			<arg>
+				<name>hostname</name>
+				<desc>the host (or ip address) of the server to remove</desc>
+			</arg>
+			<arg>
+				<name>port</name>
+				<optional>1</optional>
+				<desc>the port of the server to remove</desc>
+			</arg>
+			<arg>
+				<name>pass</name>
+				<optional>1</optional>
+				<desc>the password of the server to remove</desc>
+			</arg>
+		</args>
+		<desc>
+<line>The -server command removes a server from the server list according</line>
+<line>to the given arguments. The only required argument, hostname,</line>
+<line>specifies the host or ip address of the server to remove. In the</line>
+<line>event that more than one server uses the same hostname, you can</line>
+<line>narrow down the choices by specifying the target server's port and</line>
+<line>even password.</line>
+<line/>
+<line>If more than one server matches the given criteria, the first match</line>
+<line>will be the one deleted.</line>
+		</desc>
+		<seealso>
+			<see>+server</see>
+			<see>servers</see>
+			<see>jump</see>
+		</seealso>
+	</help>
+	<help>
+		<name>jump</name>
+		<summary>connect to a new server</summary>
+		<args>
+			<arg>
+				<name>hostname</name>
+				<optional>1</optional>
+				<desc>the host (or ip address) of the server to jump to</desc>
+			</arg>
+			<arg>
+				<name>port</name>
+				<optional>1</optional>
+				<desc>the port of the server to jump to</desc>
+			</arg>
+			<arg>
+				<name>pass</name>
+				<optional>1</optional>
+				<desc>the password of the server to jump to</desc>
+			</arg>
+		</args>
+		<desc>
+<line>The jump command disconnects from the current server (if connected)</line>
+<line>and begins a new connection. If no server is specified, then the</line>
+<line>bot will jump to the next position on the server list. If a server</line>
+<line>is specified, the bot will search for the first matching server on</line>
+<line>the server list and connect to it. If the server is not found, a</line>
+<line>new entry is created and the bot begins connecting to it.</line>
+		</desc>
+		<seealso>
+			<see>+server</see>
+			<see>-server</see>
+			<see>servers</see>
+		</seealso>
+	</help>
 </helpfile>
Index: eggdrop1.9/src/core_party.c
diff -u eggdrop1.9/src/core_party.c:1.41 eggdrop1.9/src/core_party.c:1.42
--- eggdrop1.9/src/core_party.c:1.41	Wed Sep 29 10:38:39 2004
+++ eggdrop1.9/src/core_party.c	Wed Sep 29 13:03:53 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: core_party.c,v 1.41 2004/09/29 15:38:39 stdarg Exp $";
+static const char rcsid[] = "$Id: core_party.c,v 1.42 2004/09/29 18:03:53 stdarg Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -47,6 +47,10 @@
 	help_summary_t *entry;
 	help_search_t *search;
 	int hits = 0;
+	xml_node_t *node, *arg, *desc, *see;
+	char *argname, *argdesc;
+	int optional;
+
 
 	if (!text || !*text) {
 		partymember_printf(p, "Syntax: help <command|variable|*search*>");
@@ -55,11 +59,43 @@
 	/* First try to look up an exact match. */
 	entry = help_lookup_summary(text);
 	if (entry) {
-		partymember_printf(p, "Full help! (not done)\n");
+		node = help_lookup_entry(entry);
+		partymember_printf(p, "Syntax:");
+		partymember_printf(p, "    %s", entry->syntax);
+		partymember_printf(p, "");
+		partymember_printf(p, "Summary:");
+		partymember_printf(p, "    %s", entry->summary);
+		partymember_printf(p, "");
+		xml_node_get_vars(node, "nnn", "desc.line", &desc, "args.arg", &arg, "seealso.see", &see);
+		if (arg) {
+			partymember_printf(p, "Arguments:");
+			for (; arg; arg = arg->next_sibling) {
+				xml_node_get_vars(arg, "sis", "name", &argname, "optional", &optional, "desc", &argdesc);
+				partymember_printf(p, "    %s%s - %s", argname, optional ? " (optional)" : "", argdesc);
+			}
+			partymember_printf(p, "");
+		}
+		partymember_printf(p, "Description:");
+		for (; desc; desc = desc->next_sibling) {
+			partymember_printf(p, "    %s", xml_node_str(desc, ""));
+		}
+		partymember_printf(p, "");
+		if (see) {
+			partymember_printf(p, "See also:");
+			for (; see; see = see->next_sibling) {
+				partymember_printf(p, "    %s", xml_node_str(see, ""));
+			}
+		}
+		xml_node_delete(node);
 		return(0);
 	}
 
 	/* No, do a search. */
+	if (!strchr(text, '*') && !strchr(text, '?')) {
+		partymember_printf(p, "No help was found! Try searching with wildcards, e.g. *%s*", text);
+		return(0);
+	}
+
 	search = help_search_new(text);
 	while ((entry = help_search_result(search))) {
 		partymember_printf(p, "%s - %s", entry->syntax, entry->summary);
----------------------- End of diff -----------------------



More information about the Changes mailing list