[ekg2-commit] r4109 - trunk/ekg: trunk/ekg/plugins.c trunk/ekg/plugins.h

SVN commit svn w toxygen.net
Wto, 15 Lip 2008, 21:48:36 CEST


Author: darkjames
Date: 2008-07-15 21:48:35 +0200 (Tue, 15 Jul 2008)
New Revision: 4109

Modified:
   trunk/ekg/plugins.c
   trunk/ekg/plugins.h
Log:
- new function query_emit_id_ro()



Modified: trunk/ekg/plugins.c
===================================================================
--- trunk/ekg/plugins.c	2008-07-15 19:31:26 UTC (rev 4108)
+++ trunk/ekg/plugins.c	2008-07-15 19:48:35 UTC (rev 4109)
@@ -779,6 +779,46 @@
 	return result != -1 ? 0 : -1;
 }
 
+/**
+ * query_emit_id_ro()
+ *
+ * Like query_emit_id() 
+ * It was created to avoid manual strdup()'s && xmemdup()'s in code.
+ * where stuff is read-only (we don't want query handlers to replace params)	[scripts for instance, but cause scripts don't work, this function is not finished :>]
+ */
+
+int query_emit_id_ro(plugin_t *plugin, const int id, ...) {
+	int result = -2;
+	va_list ap;
+	query_t *q;
+
+	if (id >= QUERY_EXTERNAL) {
+		debug_error("%s", ID_AND_QUERY_EXTERNAL);
+		return -2;
+	}
+
+	/* XXX:
+	 * 	- for each param at query_list[id])
+	 * 		- if it's string, strdup() it. otherwise xmemdup() is enough (like /window clear does)
+	 * 		- if integer, just pass it to another variable
+	 * 	- call everything.
+	 * 	- free stuff
+	 *
+	 * for now it's not very unnecessary,
+	 */
+
+	va_start(ap, id);
+	for (q = queries[id]; q; q = q->next) {
+		if ((!plugin || (plugin == q->plugin))) {
+			result = query_emit_common(q, ap);
+
+			if (result == -1) break;
+		}
+	}
+	va_end(ap);
+	return result;
+}
+
 int query_emit_id(plugin_t *plugin, const int id, ...) {
 	int result = -2;
 	va_list ap;
@@ -788,7 +828,7 @@
 		debug_error("%s", ID_AND_QUERY_EXTERNAL);
 		return -2;
 	}
-		
+
 	va_start(ap, id);
 	for (q = queries[id]; q; q = q->next) {
 		if ((!plugin || (plugin == q->plugin))) {

Modified: trunk/ekg/plugins.h
===================================================================
--- trunk/ekg/plugins.h	2008-07-15 19:31:26 UTC (rev 4108)
+++ trunk/ekg/plugins.h	2008-07-15 19:48:35 UTC (rev 4109)
@@ -131,6 +131,7 @@
 void query_external_free();
 
 int query_emit_id(plugin_t *, const int, ...);
+int query_emit_id_ro(plugin_t *plugin, const int id, ...);
 int query_emit(plugin_t *, const char *, ...);
 void queries_reconnect();
 



Więcej informacji o liście dyskusyjnej ekg2-commit