[xmppd-dev] commit r1522 - in trunk/jabberd14: . dialback dnsrv jabberd jabberd/base jabberd/lib jsm jsm/modules xdb_file

mail at jabberd.org mail at jabberd.org
Tue Apr 29 14:26:28 UTC 2008


Author: mawis
Date: Tue Apr 29 14:25:02 2008
New Revision: 1522

Log:
removing string spool functions, using C++ standard std::ostringstream instead


Modified:
   trunk/jabberd14/ChangeLog
   trunk/jabberd14/configure.ac
   trunk/jabberd14/dialback/dialback.cc
   trunk/jabberd14/dialback/dialback.h
   trunk/jabberd14/dialback/dialback_in.cc
   trunk/jabberd14/dialback/dialback_out.cc
   trunk/jabberd14/dnsrv/srv_resolv.cc
   trunk/jabberd14/jabberd/base/base_accept.cc
   trunk/jabberd14/jabberd/base/base_connect.cc
   trunk/jabberd14/jabberd/base/base_dir.cc
   trunk/jabberd14/jabberd/base/base_format.cc
   trunk/jabberd14/jabberd/base/base_importspool.cc
   trunk/jabberd14/jabberd/base/base_to.cc
   trunk/jabberd14/jabberd/jabberd.h
   trunk/jabberd14/jabberd/lib/expat.cc
   trunk/jabberd14/jabberd/lib/hash.cc
   trunk/jabberd14/jabberd/lib/jabberdlib.h
   trunk/jabberd14/jabberd/lib/jutil.cc
   trunk/jabberd14/jabberd/lib/str.cc
   trunk/jabberd14/jabberd/lib/xmlnode.cc
   trunk/jabberd14/jabberd/lib/xstream.cc
   trunk/jabberd14/jabberd/xdb.cc
   trunk/jabberd14/jsm/modules/mod_admin.cc
   trunk/jabberd14/jsm/modules/mod_auth_digest.cc
   trunk/jabberd14/jsm/modules/mod_browse.cc
   trunk/jabberd14/jsm/modules/mod_disco.cc
   trunk/jabberd14/jsm/modules/mod_offline.cc
   trunk/jabberd14/jsm/modules/mod_privacy.cc
   trunk/jabberd14/jsm/modules/mod_register.cc
   trunk/jabberd14/jsm/modules/mod_roster.cc
   trunk/jabberd14/jsm/modules/mod_version.cc
   trunk/jabberd14/jsm/modules/mod_xml.cc
   trunk/jabberd14/jsm/serialization.cc
   trunk/jabberd14/xdb_file/xdb_file.cc

Modified: trunk/jabberd14/ChangeLog
==============================================================================
--- trunk/jabberd14/ChangeLog	(original)
+++ trunk/jabberd14/ChangeLog	Tue Apr 29 14:25:02 2008
@@ -1,3 +1,39 @@
+2008-04-29  Matthias Wimmer  <m at tthias.eu>
+
+    * jsm/serialization.cc: removing string spool functions, using
+	C++ standard std::ostringstream instead
+    * jsm/modules/mod_xml.cc: same
+    * jsm/modules/mod_auth_digest.cc: same
+    * jsm/modules/mod_browse.cc: same
+    * jsm/modules/mod_disco.cc: same
+    * jsm/modules/mod_privacy.cc: same
+    * jsm/modules/mod_roster.cc: same
+    * jsm/modules/mod_offline.cc: same
+    * jsm/modules/mod_register.cc: same
+    * jsm/modules/mod_version.cc: same
+    * jsm/modules/mod_admin.cc: same
+    * jabberd/jabberd.h: same
+    * jabberd/xdb.cc: same
+    * jabberd/lib/xmlnode.cc: same
+    * jabberd/lib/str.cc: same
+    * jabberd/lib/expat.cc: same
+    * jabberd/lib/jabberdlib.h: same
+    * jabberd/lib/hash.cc: same
+    * jabberd/lib/xstream.cc: same
+    * jabberd/lib/jutil.cc: same
+    * jabberd/base/base_dir.cc: same
+    * jabberd/base/base_to.cc: same
+    * jabberd/base/base_importspool.cc: same
+    * jabberd/base/base_format.cc: same
+    * jabberd/base/base_connect.cc: same
+    * jabberd/base/base_accept.cc: same
+    * dialback/dialback.h: same
+    * dialback/dialback_in.cc: same
+    * dialback/dialback_out.cc: same
+    * dialback/dialback.cc: same
+    * dnsrv/srv_resolv.cc: same
+    * xdb_file/xdb_file.cc: same
+
 2008-04-26  Matthias Wimmer  <m at tthias.eu>
 
     * jabberd/lib/jabberid.cc: new class for JabberID handling

Modified: trunk/jabberd14/configure.ac
==============================================================================
--- trunk/jabberd14/configure.ac	(original)
+++ trunk/jabberd14/configure.ac	Tue Apr 29 14:25:02 2008
@@ -6,7 +6,7 @@
 
 
 AC_INIT(jabberd/jabberd.h)
-AM_INIT_AUTOMAKE(jabberd14,1.9.0-alpha-20080426)
+AM_INIT_AUTOMAKE(jabberd14,1.9.0-alpha-20080429)
 AM_CONFIG_HEADER(config.h)
 AC_LANG(C++)
 

Modified: trunk/jabberd14/dialback/dialback.cc
==============================================================================
--- trunk/jabberd14/dialback/dialback.cc	(original)
+++ trunk/jabberd14/dialback/dialback.cc	Tue Apr 29 14:25:02 2008
@@ -177,7 +177,6 @@
  */
 char *dialback_merlin(pool p, char const* secret, char const* to, char const* from, char const* challenge) {
     char *result = NULL;
-    char *message = NULL;
 
     /* sanity check */
     if (p == NULL)
@@ -187,10 +186,11 @@
     result = static_cast<char*>(pmalloco(p, 41));
 
     /* generate the message, that has to be signed */
-    message = spools(p, to, " ", from, " ", challenge, p);
+    std::ostringstream message;
+    message << to << " " << from << " " << challenge;
 
     /* sign the message */
-    hmac_sha1_ascii_r(secret, reinterpret_cast<unsigned char*>(message), j_strlen(message), result);
+    hmac_sha1_ascii_r(secret, reinterpret_cast<unsigned char const*>(message.str().c_str()), message.str().length(), result);
 
     log_debug2(ZONE, LOGT_AUTH, "merlin casts his spell (%s - %s %s %s) %s", secret, to, from, challenge, result);
 
@@ -574,81 +574,139 @@
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Pending IPs: ")), dc->ip ? dc->ip : messages_get(lang, N_("no more other IPs will be tried")), xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Pending IPs: ")) << (dc->ip ? dc->ip : messages_get(lang, N_("no more other IPs will be tried")));
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "id") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Stream ID: ")), dc->stream_id, xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Stream ID: ")) << dc->stream_id;
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "dbstate") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Dialback state: ")),
-			dc->db_state == not_requested ? messages_get(lang, N_("no dialback request, just sending verifies")) :
-			dc->db_state == could_request ? messages_get(lang, N_("we could send dialback requests, if we want to")) :
-			dc->db_state == want_request ? messages_get(lang, N_("we want to send dialback requests, but cannot do that yet")) :
-			dc->db_state == sent_request ? messages_get(lang, N_("we have sent a dialback request")) : messages_get(lang, N_("invalid")), xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Dialback state: "));
+	    switch (dc->db_state) {
+		case not_requested:
+		    name << messages_get(lang, N_("no dialback request, just sending verifies"));
+		    break;
+		case could_request:
+		    name << messages_get(lang, N_("we could send dialback requests, if we want to"));
+		    break;
+		case want_request:
+		    name << messages_get(lang, N_("we want to send dialback requests, but cannot do that yet"));
+		    break;
+		case sent_request:
+		    name << messages_get(lang, N_("we have sent a dialback request"));
+		    break;
+		default:
+		    name << messages_get(lang, N_("invalid"));
+	    }
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "connstate") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Connection state: ")),
-			dc->connection_state == created ? messages_get(lang, N_("created, not yet started to connect")) :
-			dc->connection_state == connecting ? messages_get(lang, N_("we started to connect, no connection yet")) :
-			dc->connection_state == connected ? messages_get(lang, N_("connected to the other host")) :
-			dc->connection_state == got_streamroot ? messages_get(lang, N_("we got peer's stream root")) :
-			dc->connection_state == waiting_features ? messages_get(lang, N_("we are waiting for stream features")) :
-			dc->connection_state == got_features ? messages_get(lang, N_("we got the stream features")) :
-			dc->connection_state == sent_db_request ? messages_get(lang, N_("we sent out a dialback request")) :
-			dc->connection_state == db_succeeded ? messages_get(lang, N_("we had success with our dialback request")) :
-			dc->connection_state == db_failed ? messages_get(lang, N_("dialback failed")) :
-			dc->connection_state == sasl_started ? messages_get(lang, N_("we started to authenticate using sasl")) :
-			dc->connection_state == sasl_fail ? messages_get(lang, N_("there was a SASL authentication failure")) :
-			dc->connection_state == sasl_success ? messages_get(lang, N_("successfully authenticated using SASL")) : messages_get(lang, N_("invalid")), xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Connection state: "));
+	    switch (dc->connection_state) {
+		case created:
+		    name << messages_get(lang, N_("created, not yet started to connect"));
+		    break;
+		case connecting:
+		    name << messages_get(lang, N_("we started to connect, no connection yet"));
+		    break;
+		case connected:
+		    name << messages_get(lang, N_("connected to the other host"));
+		    break;
+		case got_streamroot:
+		    name << messages_get(lang, N_("we got peer's stream root"));
+		    break;
+		case waiting_features:
+		    name << messages_get(lang, N_("we are waiting for stream features"));
+		    break;
+		case got_features:
+		    name << messages_get(lang, N_("we got the stream features"));
+		    break;
+		case sent_db_request:
+		    name << messages_get(lang, N_("we sent out a dialback request"));
+		    break;
+		case db_succeeded:
+		    name << messages_get(lang, N_("we had success with our dialback request"));
+		    break;
+		case db_failed:
+		    name << messages_get(lang, N_("dialback failed"));
+		    break;
+		case sasl_started:
+		    name << messages_get(lang, N_("we started to authenticate using sasl"));
+		    break;
+		case sasl_fail:
+		    name << messages_get(lang, N_("there was a SASL authentication failure"));
+		    break;
+		case sasl_success:
+		    name << messages_get(lang, N_("successfully authenticated using SASL"));
+		    break;
+		default:
+		    name << messages_get(lang, N_("invalid"));
+	    }
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "dialback") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools( xmlnode_pool(result), messages_get(lang, N_("Dialback: ")), dc->flags.db ?  messages_get(lang, N_("supported by peer")) : messages_get(lang, N_("unsupported by peer")), xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Dialback: ")) << (dc->flags.db ?  messages_get(lang, N_("supported by peer")) : messages_get(lang, N_("unsupported by peer")));
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "connectresults") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Connection results: ")), spool_print(dc->connect_results), xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Connection results: "));
+	    if (dc && dc->connect_results)
+		name << dc->connect_results->str();
+	    else
+		name << (dc ? "dc->connect_results is NULL" : "dc is NULL");
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "failedsettings") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Dropped because of settings: ")), dc->settings_failed ? messages_get(lang, N_("yes")) : messages_get(lang, N_("no")), xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Dropped because of settings: ")) << (dc->settings_failed ? messages_get(lang, N_("yes")) : messages_get(lang, N_("no")));
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "verifies") == 0) {
 	    int count = 0;
 	    xmlnode iter = NULL;
-	    char count_str[16];
 
 	    for (iter = xmlnode_get_firstchild(dc->verifies); iter != NULL; iter = xmlnode_get_nextsibling(iter)) {
 		count++;
 	    }
-	    snprintf(count_str, sizeof(count_str), "%d", count);
 
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Pending verifies: ")), count_str, xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Pending verifies: ")) << count;
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "pendingstanzas") == 0) {
 	    int count = 0;
 	    dboq iter = NULL;
-	    char count_str[16];
 
 	    for (iter = dc->q; iter != NULL; iter = iter->next) {
 		count++;
 	    }
-	    snprintf(count_str, sizeof(count_str), "%d", count);
 
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Pending stanzas: ")), count_str, xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Pending stanzas: ")) << count;
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	}
     } else if (s2s_right && to->get_node() == "in-established" && to->has_resource() && node == NULL) {
 	x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
@@ -760,12 +818,25 @@
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, spools(xmlnode_pool(result), messages_get(lang, N_("Addresses:")), " ", messages_get(lang, N_("local")), "=", c->we_domain, ", ", messages_get(lang, N_("peer")), "=", c->other_domain, xmlnode_pool(result)));
+	    std::ostringstream name;
+	    name << messages_get(lang, N_("Addresses:")) << " " << messages_get(lang, N_("local")) << "=" << c->we_domain << ", " << messages_get(lang, N_("peer")) << "=" << c->other_domain;
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "xmppversion") == 0) {
 	    x = xmlnode_insert_tag_ns(result, "identity", NULL, NS_DISCO_INFO);
 	    xmlnode_put_attrib_ns(x, "category", NULL, NULL, "hierarchy");
 	    xmlnode_put_attrib_ns(x, "type", NULL, NULL, "leaf");
-	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, c->xmpp_version < 0 ? messages_get(lang, N_("XMPP version: unknown")) : c->xmpp_version ? messages_get(lang, N_("XMPP version: 1.0")) : messages_get(lang, N_("XMPP version: 0.9")));
+	    std::ostringstream name;
+	    switch (c->xmpp_version) {
+		case 1:
+		    name << messages_get(lang, N_("XMPP version: 1.0"));
+		    break;
+		case 0:
+		    name << messages_get(lang, N_("XMPP version: 0.9"));
+		    break;
+		default:
+		    name << messages_get(lang, N_("XMPP version: unknown")) << " (" << c->xmpp_version << ")";
+	    }
+	    xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
 	} else if (j_strcmp(node, "last") == 0) {
 	    struct tm last_utc;
 	    time_t last = c->stamp;

Modified: trunk/jabberd14/dialback/dialback.h
==============================================================================
--- trunk/jabberd14/dialback/dialback.h	(original)
+++ trunk/jabberd14/dialback/dialback.h	Tue Apr 29 14:25:02 2008
@@ -146,7 +146,7 @@
     char *stream_id; /**< the stream id the connected entity assigned */
     db_request db_state; /**< if we want to send a <db:result/> and if we already did */
     db_connection_state connection_state; /**< how far did we proceed in connecting to the other host */
-    spool connect_results; /**< result messages for the connection attempts */
+    std::ostringstream* connect_results; /**< result messages for the connection attempts */
     struct {
 	int db:1;	/**< if the peer supports dialback */
     } flags;

Modified: trunk/jabberd14/dialback/dialback_in.cc
==============================================================================
--- trunk/jabberd14/dialback/dialback_in.cc	(original)
+++ trunk/jabberd14/dialback/dialback_in.cc	Tue Apr 29 14:25:02 2008
@@ -122,13 +122,13 @@
 
     /* incoming stream error? */
     if (j_strcmp(xmlnode_get_localname(x), "error") == 0 && j_strcmp(xmlnode_get_namespace(x), NS_STREAM) == 0) {
-        spool s = spool_new(x->p);
+	std::ostringstream errs;
         streamerr errstruct = static_cast<streamerr>(pmalloco(x->p, sizeof(_streamerr)));
         char *errmsg = NULL;
 
         xstream_parse_error(x->p, x, errstruct);
-        xstream_format_error(s, errstruct);
-        errmsg = spool_print(s);
+        xstream_format_error(errs, errstruct);
+	errmsg = pstrdup(x->p, errs.str().c_str());
 
         switch (errstruct->severity) {
             case normal:
@@ -519,7 +519,9 @@
     jid_set(key, xmlnode_get_attrib_ns(x, "from", NULL),JID_RESOURCE);
     jid_set(key, c->id, JID_USER); /* special user of the id attrib makes this key unique */
 
-    x2 = xmlnode_get_list_item(xmlnode_get_tags(c->results, spools(xmlnode_pool(x), "*[@key='", jid_full(key), "']", xmlnode_pool(x)), d->std_ns_prefixes), 0);
+    std::ostringstream xpath;
+    xpath << "*[@key='" << jid_full(key) << "']";
+    x2 = xmlnode_get_list_item(xmlnode_get_tags(c->results, xpath.str().c_str(), d->std_ns_prefixes), 0);
     if (x2 == NULL) {
 	log_warn(d->i->id, "Dropping a db:verify answer, we don't have a waiting incoming <db:result/> query (anymore?) for this to/from pair: %s", xmlnode_serialize_string(x, xmppd::ns_decl_list(), 0));
         xmlnode_free(x);

Modified: trunk/jabberd14/dialback/dialback_out.cc
==============================================================================
--- trunk/jabberd14/dialback/dialback_out.cc	(original)
+++ trunk/jabberd14/dialback/dialback_out.cc	Tue Apr 29 14:25:02 2008
@@ -81,8 +81,7 @@
 
     /* to which IP we connect, for logging */
     if (c->connect_results != NULL) {
-	spool_add(c->connect_results, ip);
-	spool_add(c->connect_results, ": ");
+	*c->connect_results << ip << ": ";
     }
 
     /* get the ip/port for io_select */
@@ -121,6 +120,16 @@
 }
 
 /**
+ * helper function used to register deleting a std::ostringstream as a pool_cleaner function
+ *
+ * @param arg pointer to the std::ostringstream to delete
+ */
+static void delete_ostringstream(void *arg) {
+    std::ostringstream* os = static_cast<std::ostringstream*>(arg);
+    delete os;
+}
+
+/**
  * make a new outgoing connect(ion) object, and start to connect to the peer
  *
  * @param d the dialback instance
@@ -167,7 +176,8 @@
     c->ip = pstrdup(p,ip);
     c->db_state = db_state;
     c->connection_state = created;
-    c->connect_results = spool_new(p);
+    c->connect_results = new std::ostringstream();
+    pool_cleanup(p, delete_ostringstream, c->connect_results);
     c->xmpp_version = -1;
 
     /* insert in the hash */
@@ -226,21 +236,22 @@
 {
     dboq cur, next;
     xmlnode x;
-    spool errmsg = NULL;
-    char *connect_results = NULL;
     char *bounce_reason = NULL;
     const char* lang = NULL;
 
     xhash_zap(c->d->out_connecting,jid_full(c->key));
 
     /* get the results of connection attempts */
+    Glib::ustring connect_results;
     if (c->connect_results != NULL) {
-	connect_results = spool_print(c->connect_results);
+	connect_results = c->connect_results->str();
+    } else {
+	connect_results = "(NULL)";
     }
 
     /* if there was never any ->m set but there's a queue yet, then we probably never got connected, just make a note of it */
     if(c->m == NULL && c->q != NULL) {
-	log_notice(c->d->i->id, "failed to establish connection to %s, %s: %s", c->key->get_domain().c_str(), dialback_out_connection_state_string(c->connection_state), connect_results);
+	log_notice(c->d->i->id, "failed to establish connection to %s, %s: %s", c->key->get_domain().c_str(), dialback_out_connection_state_string(c->connection_state), connect_results.c_str());
     }
 
     /* if there's any packets in the queue, flush them! */
@@ -248,16 +259,14 @@
     if (cur != NULL) {
 	lang = xmlnode_get_lang(cur->x);
 	/* generate bounce message, but only if there are queued messages */
-	errmsg = spool_new(c->p);
+	std::ostringstream errmsg;
 	if (c->settings_failed) {
-	    spool_add(errmsg, messages_get(lang, N_("Failed to deliver stanza to other server because of configured stream parameters.")));
+	    errmsg << messages_get(lang, N_("Failed to deliver stanza to other server because of configured stream parameters."));
 	} else {
-	    spool_add(errmsg, messages_get(lang, N_("Failed to deliver stanza to other server while ")));
-	    spool_add(errmsg, messages_get(lang, N_(dialback_out_connection_state_string(c->connection_state))));
-	    spool_add(errmsg, ": ");
-	    spool_add(errmsg, connect_results);
+	    errmsg << messages_get(lang, N_("Failed to deliver stanza to other server while "));
+	    errmsg << messages_get(lang, N_(dialback_out_connection_state_string(c->connection_state))) << ": " << connect_results;
 	}
-	bounce_reason = spool_print(errmsg);
+	bounce_reason = pstrdup(c->p, errmsg.str().c_str());
     }
     while(cur != NULL) {
         next = cur->next;
@@ -397,28 +406,26 @@
     }
 
     if (j_strcmp(xmlnode_get_localname(x),"error") == 0 && j_strcmp(xmlnode_get_namespace(x), NS_STREAM) == 0) {
-	spool s = spool_new(x->p);
+	std::ostringstream errmsg;
 	streamerr errstruct = static_cast<streamerr>(pmalloco(x->p, sizeof(_streamerr)));
-	char *errmsg = NULL;
 
 	/* generate the error message */
 	xstream_parse_error(x->p, x, errstruct);
-	xstream_format_error(s, errstruct);
-	errmsg = spool_print(s);
+	xstream_format_error(errmsg, errstruct);
 
 	/* logging */
 	switch (errstruct->severity) {
 	    case normal:
-		log_debug2(ZONE, LOGT_IO, "stream error on outgoing db conn to %s: %s", mio_ip(m), errmsg);
+		log_debug2(ZONE, LOGT_IO, "stream error on outgoing db conn to %s: %s", mio_ip(m), errmsg.str().c_str());
 		break;
 	    case configuration:
 	    case feature_lack:
 	    case unknown:
-		log_warn(d->i->id, "received stream error on outgoing db conn to %s: %s", mio_ip(m), errmsg);
+		log_warn(d->i->id, "received stream error on outgoing db conn to %s: %s", mio_ip(m), errmsg.str().c_str());
 		break;
 	    case error:
 	    default:
-		log_error(d->i->id, "received stream error on outgoing db conn to %s: %s", mio_ip(m), errmsg);
+		log_error(d->i->id, "received stream error on outgoing db conn to %s: %s", mio_ip(m), errmsg.str().c_str());
 	}
     } else {
         mio_write(m, NULL, "<stream:error><undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Received data on a send-only socket. You are not Allowed to send data on this socket!</text></stream:error>", -1);
@@ -491,7 +498,7 @@
 	    /* add to the connect result messages */
 	    if (c->connection_state != sasl_success) {
 		if (c->connect_results != NULL && c->connection_state != connected) {
-		    spool_add(c->connect_results, "Connected");
+		    *c->connect_results << "Connected";
 		}
 		c->connection_state = connected;
 	    }
@@ -601,35 +608,31 @@
 	case MIO_XML_NODE:
 	    /* watch for stream errors */
 	    if (j_strcmp(xmlnode_get_localname(x), "error") == 0 && j_strcmp(xmlnode_get_namespace(x), NS_STREAM) == 0) {
-		spool s = spool_new(x->p);
+		std::ostringstream errmsg;
 		streamerr errstruct = static_cast<streamerr>(pmalloco(x->p, sizeof(_streamerr)));
-		char *errmsg = NULL;
 
 		/* generate error message */
 		xstream_parse_error(x->p, x, errstruct);
-		xstream_format_error(s, errstruct);
-		errmsg = spool_print(s);
+		xstream_format_error(errmsg, errstruct);
 
 		/* append error message to connect_results */
 		if (c->connect_results != NULL && errmsg != NULL) {
-		    spool_add(c->connect_results, " (");
-		    spool_add(c->connect_results, pstrdup(c->connect_results->p, errmsg));
-		    spool_add(c->connect_results, ")");
+		    *c->connect_results << " (" << errmsg.str() << ")";
 		}
 
 		/* logging */
 		switch (errstruct->severity) {
 		    case normal:
-			log_debug2(ZONE, LOGT_IO, "stream error on outgoing%s conn to %s (%s): %s", c->xmpp_version < 0 ? "" : c->xmpp_version == 0 ? " preXMPP" : " XMPP1.0", mio_ip(m), jid_full(c->key), errmsg);
+			log_debug2(ZONE, LOGT_IO, "stream error on outgoing%s conn to %s (%s): %s", c->xmpp_version < 0 ? "" : c->xmpp_version == 0 ? " preXMPP" : " XMPP1.0", mio_ip(m), jid_full(c->key), errmsg.str().c_str());
 			break;
 		    case configuration:
 		    case feature_lack:
 		    case unknown:
-			log_warn(c->d->i->id, "received stream error on outgoing%s conn to %s (%s): %s", c->xmpp_version < 0 ? "" : c->xmpp_version == 0 ? " preXMPP" : " XMPP1.0", mio_ip(m), jid_full(c->key), errmsg);
+			log_warn(c->d->i->id, "received stream error on outgoing%s conn to %s (%s): %s", c->xmpp_version < 0 ? "" : c->xmpp_version == 0 ? " preXMPP" : " XMPP1.0", mio_ip(m), jid_full(c->key), errmsg.str().c_str());
 			break;
 		    case error:
 		    default:
-			log_error(c->d->i->id, "received stream error on outgoing%s conn to %s (%s): %s", c->xmpp_version < 0 ? "" : c->xmpp_version == 0 ? " preXMPP" : " XMPP1.0", mio_ip(m), jid_full(c->key), errmsg);
+			log_error(c->d->i->id, "received stream error on outgoing%s conn to %s (%s): %s", c->xmpp_version < 0 ? "" : c->xmpp_version == 0 ? " preXMPP" : " XMPP1.0", mio_ip(m), jid_full(c->key), errmsg.str().c_str());
 		}
 		mio_close(m);
 		break;
@@ -794,9 +797,7 @@
 		/* something went wrong, we were invalid? */
 		c->connection_state = sasl_fail;
 		if (c->connect_results != NULL) {
-		    spool_add(c->connect_results, " (SASL EXTERNAL auth failed: ");
-		    spool_add(c->connect_results, xmlnode_serialize_string(x, xmppd::ns_decl_list(), 0));
-		    spool_add(c->connect_results, ")");
+		    *c->connect_results << " (SASL EXTERNAL auth failed: " << xmlnode_serialize_string(x, xmppd::ns_decl_list(), 0) << ")";
 		}
 		log_alert(c->d->i->id, "SASL EXTERNAL authentication failed on authenticating ourselfs to %s (sending name: %s)", c->key->get_domain().c_str(), c->key->get_resource().c_str());
 		/* close the stream (in former times we sent a stream error, but I think we shouldn't. There is stream fault by the other entity!) */ 
@@ -834,10 +835,8 @@
 		/* something went wrong, we were invalid? */
 		c->connection_state = db_failed;
 		if (c->connect_results != NULL) {
-		    char *type_attribute = pstrdup(c->connect_results->p, xmlnode_get_attrib_ns(x, "type", NULL));
-		    spool_add(c->connect_results, " (dialback result: ");
-		    spool_add(c->connect_results, type_attribute ? type_attribute : "no type attribute");
-		    spool_add(c->connect_results, ")");
+		    char const* type_attribute = xmlnode_get_attrib_ns(x, "type", NULL);
+		    *c->connect_results << " (dialback result: " << (type_attribute ? type_attribute : "no type attribute") << ")";
 		}
 		log_alert(c->d->i->id, "We were told by %s that our sending name %s is invalid, either something went wrong on their end, we tried using that name improperly, or dns does not resolve to us", c->key->get_domain().c_str(), c->key->get_resource().c_str());
 		/* close the stream (in former times we sent a stream error, but I think we shouldn't. There is stream fault by the other entity!) */ 
@@ -860,13 +859,13 @@
 	case MIO_CLOSED:
 	    /* add the connect error message to the list of messages for the tried hosts */
 	    if (c->connect_results != NULL) {
-		spool_add(c->connect_results, mio_connect_errmsg(m));
+		*c->connect_results << mio_connect_errmsg(m);
 	    }
 	    if(c->ip == NULL) {
 		dialback_out_connection_cleanup(c); /* buh bye! */
 	    } else {
 		if (c->connect_results != NULL) {
-		    spool_add(c->connect_results, " / ");
+		    *c->connect_results << " / ";
 		}
 		dialback_out_connect(c); /* this one failed, try another */
 	    }
@@ -913,14 +912,13 @@
             last->next = next;
 
 	if (bounce_reason == NULL) {
-	    spool errmsg = spool_new(c->p);
-	    spool_add(errmsg, messages_get(lang, N_("Server connect timeout while ")));
-	    spool_add(errmsg, messages_get(lang, dialback_out_connection_state_string(c->connection_state)));
-	    if (c->connect_results != NULL) {
-		spool_add(errmsg, ": ");
-		spool_add(errmsg, spool_print(c->connect_results));
+	    std::ostringstream errmsg;
+	    errmsg << messages_get(lang, N_("Server connect timeout while "));
+	    errmsg << messages_get(lang, dialback_out_connection_state_string(c->connection_state));
+	    if (c->connect_results) {
+		errmsg << ": " << c->connect_results->str();
 	    }
-	    bounce_reason = spool_print(errmsg);
+	    bounce_reason = pstrdup(c->p, errmsg.str().c_str());
 	}
 
         deliver_fail(dpacket_new(cur->x), bounce_reason ? bounce_reason : messages_get(lang, N_("Server Connect Timeout")));

Modified: trunk/jabberd14/dnsrv/srv_resolv.cc
==============================================================================
--- trunk/jabberd14/dnsrv/srv_resolv.cc	(original)
+++ trunk/jabberd14/dnsrv/srv_resolv.cc	Tue Apr 29 14:25:02 2008
@@ -126,7 +126,9 @@
 	xhash_put(ht, key, value);
 	return;
     }
-    xhash_put(ht, key, spools(p, value, ",", (char*)old, p));
+    std::ostringstream join;
+    join << value << "," << static_cast<char*>(old);
+    xhash_put(ht, key, pstrdup(p, join.str().c_str()));
 }
 
 /**
@@ -136,7 +138,7 @@
  *
  * @return 0 in case of success, non zero on error
  */
-int srv_lookup_aaaa_a(spool result, const char* domain) {
+static int srv_lookup_aaaa_a(std::ostream& result, const char* domain) {
     int			first_result = 1;
 #ifdef WITH_IPV6
     int			error_code;
@@ -174,19 +176,19 @@
 	    case PF_INET:
 		inet_ntop(AF_INET, (char *)&((struct sockaddr_in*)addr_iter->ai_addr)->sin_addr, addr_str, sizeof(addr_str));
 		if (!first_result) {
-		    spooler(result, ",", addr_str, result);
+		    result << "," << addr_str;
 		} else {
 		    first_result = 0;
-		    spool_add(result, addr_str);
+		    result << addr_str;
 		}
 		break;
 	    case PF_INET6:
 		inet_ntop(AF_INET6, (char *)&((struct sockaddr_in6*)addr_iter->ai_addr)->sin6_addr, addr_str, sizeof(addr_str));
 		if (!first_result) {
-		    spooler(result, ",", addr_str, result);
+		    result << "," << addr_str;
 		} else {
 		    first_result = 0;
-		    spool_add(result, addr_str);
+		    result << addr_str;
 		}
 	}
     }
@@ -205,7 +207,7 @@
     }
     
     snprintf(addr_str, sizeof(addr_str), "%u.%u.%u.%u", (unsigned char)(hp->h_addr[0]), (unsigned char)hp->h_addr[1], (unsigned char)hp->h_addr[2], (unsigned char)hp->h_addr[3]);
-    spooler(result, addr_str, result);
+    result << addr_str;
     return 0;
 #endif
 }
@@ -237,7 +239,6 @@
      srv_list       tempnode = NULL;
      srv_list       iternode = NULL;
      xht	      arr_table;	   /* Hash of A records (name, ip) */
-     spool            result;
      int	      result_is_empty = 1;
      char*            ipname;
      char*            ipaddr;
@@ -251,9 +252,9 @@
 
     /* If no service is specified, use a standard gethostbyname call */
     if (service == NULL) {
-	result = spool_new(p);
+	std::ostringstream result;
 	if (srv_lookup_aaaa_a(result, domain) == 0) {
-	    return spool_print(result);
+	    return pstrdup(p, result.str().c_str());
 	} else {
 	    return NULL;
 	}
@@ -410,7 +411,7 @@
 
 	/* Now, walk the nicely sorted list and resolve the target's A records, sticking the resolved name in
 	 * a spooler -- hopefully these have been pre-cached, and arrived along with the SRV reply */
-	result = spool_new(p);
+	std::ostringstream result;
 
 	iternode = svrlist;
 	while (iternode != NULL) {
@@ -421,11 +422,11 @@
 
 	    /* it hasn't been in the additional section, we have to lookup the IP address */
 	    if (ipaddr == NULL) {
-		spool temp_result = spool_new(p);
+		std::ostringstream temp_result;
 
 		log_debug2(ZONE, LOGT_IO, "'%s' not in additional section of DNS reply, looking it up using AAAA/A query", iternode->host);
 		srv_lookup_aaaa_a(temp_result, iternode->host);
-		ipaddr = spool_print(temp_result);
+		ipaddr = pstrdup(p, temp_result.str().c_str());
 	    }
 	   
 	    if (j_strlen(ipaddr) > 0) {
@@ -434,7 +435,7 @@
 
 		/* if there has been a result already, we have to separate by a "," */
 		if (!result_is_empty) {
-		    spool_add(result, ",");
+		    result << ",";
 		} else {
 		    result_is_empty = 0;
 		}
@@ -444,15 +445,15 @@
 		while (token != NULL) {
 		    if (strchr(token, ':')) {
 			/* IPv6 format */
-			spooler(result, "[", token, "]:", iternode->port, result);
+			result << "[" << token << "]:" << iternode->port;
 		    } else {
 			/* IPv4 format */
-			spooler(result, token, ":", iternode->port, result);
+			result << token << ":" << iternode->port;
 		    }
 		    /* get next token */
 		    token = strtok_r(NULL, ",", &ptrptr);
 		    if (token) {
-			spool_add(result, ","); /* separate results by ',' */
+			result << ","; // separate results by ','
 		    }
 		}
 		/* free our tokenized copy */
@@ -461,7 +462,7 @@
 	    iternode = iternode->next;
 	}
 	/* Finally, turn the fully resolved list into a string <ip>:<host>,... */
-	return spool_print(result);
+	return pstrdup(p, result.str().c_str());
     }
     /* Otherwise, return NULL -- it's for the caller to finish up by using
      * standard A records */

Modified: trunk/jabberd14/jabberd/base/base_accept.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_accept.cc	(original)
+++ trunk/jabberd14/jabberd/base/base_accept.cc	Tue Apr 29 14:25:02 2008
@@ -100,8 +100,9 @@
     accept_instance ai = (accept_instance)arg;
     xmlnode cur, off;
     queue q, q2;
-    char hashbuf[41];
     jpacket jp;
+    char const* pwdsent;
+    xmppd::sha1 pwdcheck;
 
     log_debug2(ZONE, LOGT_XML, "process XML: m:%X state:%d, arg:%X, x:%X", m, state, arg, x);
 
@@ -148,8 +149,12 @@
             }
 
             /* Create and check a SHA hash of this instance's password & SID */
-            shahash_r(spools(xmlnode_pool(x), ai->id, ai->secret, xmlnode_pool(x)), hashbuf);
-            if (j_strcmp(hashbuf, xmlnode_get_data(x)) != 0) {
+	    if (ai->id)
+		pwdcheck.update(ai->id);
+	    if (ai->secret)
+		pwdcheck.update(ai->secret);
+	    pwdsent = xmlnode_get_data(x);
+	    if (!pwdsent || pwdcheck.final_hex() != std::string(pwdsent)) {
                 mio_write(m, NULL, "<stream:error><not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Invalid handshake</text></stream:error>", -1);
                 mio_close(m);
 		break;

Modified: trunk/jabberd14/jabberd/base/base_connect.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_connect.cc	(original)
+++ trunk/jabberd14/jabberd/base/base_connect.cc	Tue Apr 29 14:25:02 2008
@@ -135,7 +135,8 @@
 static void base_connect_process_xml(mio m, int state, void* arg, xmlnode x, char* unused1, int unused2) {
     conn_info ci = (conn_info)arg;
     xmlnode cur;
-    char  hashbuf[41];
+    xmppd::sha1 pwdhash;
+    char const* tmp = NULL;
 
     log_debug2(ZONE, LOGT_XML, "process XML: m:%X state:%d, arg:%X, x:%X", m, state, arg, x);
 
@@ -155,11 +156,15 @@
 
         case MIO_XML_ROOT:
             /* Extract stream ID and generate a key to hash */
-            shahash_r(spools(x->p, xmlnode_get_attrib_ns(x, "id", NULL), ci->secret, x->p), hashbuf);
+	    tmp = xmlnode_get_attrib_ns(x, "id", NULL);
+	    if (tmp)
+		pwdhash.update(tmp);
+	    if (ci->secret)
+		pwdhash.update(ci->secret);
 
             /* Build a handshake packet */
             cur = xmlnode_new_tag_ns("handshake", NULL, NS_SERVER);
-            xmlnode_insert_cdata(cur, hashbuf, -1);
+            xmlnode_insert_cdata(cur, pwdhash.final_hex().c_str(), -1);
 
             /* Transmit handshake */
 	    mio_write(m, cur, NULL, 0);

Modified: trunk/jabberd14/jabberd/base/base_dir.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_dir.cc	(original)
+++ trunk/jabberd14/jabberd/base/base_dir.cc	Tue Apr 29 14:25:02 2008
@@ -57,7 +57,6 @@
     struct dirent *dir_ent = NULL;
     DIR *dir = NULL;
     pool p = NULL;
-    char *filename = NULL;
     xmlnode x = NULL;
     jpacket jp = NULL;
 
@@ -83,22 +82,23 @@
 	}
 
 	/* get the full filename */
-	filename = spools(p, conf_data->in_dir, "/", dir_ent->d_name, p);
+	std::ostringstream filename;
+	filename << conf_data->in_dir << "/" << dir_ent->d_name;
 
 	/* process the stanza file */
-	x = xmlnode_file(filename);
+	x = xmlnode_file(filename.str().c_str());
 	jp = jpacket_new(x);
 	if (jp != NULL && (jp->type != JPACKET_UNKNOWN || j_strcmp(xmlnode_get_localname(x), "route") == 0 && j_strcmp(xmlnode_get_namespace(x), NS_SERVER) == 0)) {
 	    deliver(dpacket_new(x), conf_data->id);
 	} else {
-	    log_warn(conf_data->id->id, "deleted invalid stanza %s", filename);
+	    log_warn(conf_data->id->id, "deleted invalid stanza %s", filename.str().c_str());
 	    xmlnode_free(x);
 	}
 
 	/* delete the file */
-	unlink(filename);
+	unlink(filename.str().c_str());
 
-	log_debug2(ZONE, LOGT_IO, "found file %s", filename);
+	log_debug2(ZONE, LOGT_IO, "found file %s", filename.str().c_str());
     }
 
     /* close directory, free memory and return */
@@ -130,7 +130,9 @@
     shahash_r(jid_full(p->id), jid_hash);
 
     /* write to file */
-    int res = xmlnode2file(spools(p->p, conf_data->out_dir, "/", id->id, "-", jid_hash, "-", jutil_timestamp_ms(timestamp), "-", serial, ".out", p->p), p->x) > 0 ? r_DONE : r_ERR;
+    std::ostringstream filename;
+    filename << conf_data->out_dir << "/" << id->id << "-" << jid_hash << "-" << jutil_timestamp_ms(timestamp) << "-" << serial << ".out";
+    int res = xmlnode2file(filename.str().c_str(), p->x) > 0 ? r_DONE : r_ERR;
 
     // if we consumed the dpacket, we have to free the xmlnode now
     if (res) {

Modified: trunk/jabberd14/jabberd/base/base_format.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_format.cc	(original)
+++ trunk/jabberd14/jabberd/base/base_format.cc	Tue Apr 29 14:25:02 2008
@@ -38,7 +38,8 @@
 static result base_format_modify(instance id, dpacket p, void *arg) {
     char  *cur, *nxt, *f;
     pool  sp;
-    spool log_result;
+    std::ostringstream log_result;
+    char const* tmp = NULL;
 
     if(id == NULL || p == NULL) 
         return r_ERR;
@@ -53,34 +54,45 @@
     sp=pool_new();
 
     f = pstrdup(sp, (char*)arg);
-    log_result = spool_new(sp);
 
     cur = f;
     nxt = strchr(f, '%');
     
     if (nxt == NULL)
-        spooler(log_result, f, log_result);
+	log_result << f;
     
     while (nxt != NULL) {
         nxt[0] = '\0'; 
         
         if(cur != nxt)
-            spooler(log_result, cur, log_result);
+	    log_result << cur;
         
         nxt++;
         
         switch(nxt[0]) {
 	    case 'h':
-		spooler(log_result, xmlnode_get_attrib_ns(p->x, "from", NULL), log_result);
+		tmp = xmlnode_get_attrib_ns(p->x, "from", NULL);
+		if (tmp)
+		    log_result << tmp;
+		else
+		    log_result << "(null)";
 		break;
 	    case 't':
-		spooler(log_result, xmlnode_get_attrib_ns(p->x, "type", NULL), log_result);
+		tmp = xmlnode_get_attrib_ns(p->x, "type", NULL);
+		if (tmp)
+		    log_result << tmp;
+		else
+		    log_result << "(null)";
 		break;
 	    case 'd':
-		spooler(log_result, jutil_timestamp(), log_result);
+		log_result << jutil_timestamp();
 		break;
 	    case 's':
-		spooler(log_result, xmlnode_get_data(p->x), log_result);
+		tmp = xmlnode_get_data(p->x);
+		if (tmp)
+		    log_result << tmp;
+		else
+		    log_result << "(null)";
 		break;
 	    default:
 		log_debug2(ZONE, LOGT_CONFIG|LOGT_STRANGE, "Invalid argument: %s", nxt[0]);
@@ -91,7 +103,7 @@
     }
 
     xmlnode_hide(xmlnode_get_firstchild(p->x));
-    xmlnode_insert_cdata(p->x, spool_print(log_result), -1);
+    xmlnode_insert_cdata(p->x, log_result.str().c_str(), -1);
 
     pool_free(sp);
     return r_PASS;

Modified: trunk/jabberd14/jabberd/base/base_importspool.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_importspool.cc	(original)
+++ trunk/jabberd14/jabberd/base/base_importspool.cc	Tue Apr 29 14:25:02 2008
@@ -184,7 +184,9 @@
 		if (request->type != NTYPE_TAG)
 		    continue;
 
-		xdb_act_path(xc, userid, NS_JABBERD_STOREDREQUEST, "insert", spools(p, "presence[@from='", xmlnode_get_attrib_ns(request, "from", NULL), "']", p), std_namespace_prefixes, request);
+		std::ostringstream xpath;
+		xpath << "presence[@from='" << xmlnode_get_attrib_ns(request, "from", NULL) << "']";
+		xdb_act_path(xc, userid, NS_JABBERD_STOREDREQUEST, "insert", xpath.str().c_str(), std_namespace_prefixes, request);
 	    }
 	    continue;
 	}
@@ -226,7 +228,9 @@
 		if (item->type != NTYPE_TAG)
 		    continue;
 
-		xdb_act_path(xc, userid, NS_PRIVATE, "insert", spools(p, "private:query[@jabberd:ns='", xmlnode_get_namespace(item), "']", p), std_namespace_prefixes, item);
+		std::ostringstream xpath;
+		xpath << "private:query[@jabberd:ns='" << xmlnode_get_namespace(item) << "']";
+		xdb_act_path(xc, userid, NS_PRIVATE, "insert", xpath.str().c_str(), std_namespace_prefixes, item);
 	    }
 	    continue;
 	}
@@ -240,7 +244,9 @@
 		if (list->type != NTYPE_TAG)
 		    continue;
 
-		xdb_act_path(xc, userid, NS_PRIVACY, "insert", spools(p, "privacy:list[@name='", xmlnode_get_attrib_ns(list, "name", NULL), "']", p), std_namespace_prefixes, list);
+		std::ostringstream xpath;
+		xpath << "privacy:list[@name='" << xmlnode_get_attrib_ns(list, "name", NULL) << "']";
+		xdb_act_path(xc, userid, NS_PRIVACY, "insert", xpath.str().c_str(), std_namespace_prefixes, list);
 
 	    }
 	    continue;
@@ -251,7 +257,9 @@
 	    continue;
 
 	/* all other data gets stored in the private namespace */
-	xdb_act_path(xc, userid, NS_PRIVATE, "insert", spools(p, "private:query[@jabberd:ns='", xmlnode_get_namespace(data_element), "']", p), std_namespace_prefixes, data_element);
+	std::ostringstream xpath;
+	xpath << "private:query[@jabberd:ns='" << xmlnode_get_namespace(data_element) << "']";
+	xdb_act_path(xc, userid, NS_PRIVATE, "insert", xpath.str().c_str(), std_namespace_prefixes, data_element);
     }
 
     /* free memory */

Modified: trunk/jabberd14/jabberd/base/base_to.cc
==============================================================================
--- trunk/jabberd14/jabberd/base/base_to.cc	(original)
+++ trunk/jabberd14/jabberd/base/base_to.cc	Tue Apr 29 14:25:02 2008
@@ -37,7 +37,6 @@
 
 static result base_to_deliver(instance id,dpacket p,void* arg) {
     char* log_data = xmlnode_get_data(p->x);
-    char* subject;
     xmlnode message;
 
     if (log_data == NULL)
@@ -46,9 +45,10 @@
     message = xmlnode_new_tag_ns("message", NULL, NS_SERVER);
     
     xmlnode_insert_cdata(xmlnode_insert_tag_ns(message, "body", NULL, NS_SERVER), log_data, -1);
-    subject=spools(xmlnode_pool(message), "Log Packet from ", xmlnode_get_attrib_ns(p->x, "from", NULL), xmlnode_pool(message));
-    xmlnode_insert_cdata(xmlnode_insert_tag_ns(message, "thread", NULL, NS_SERVER), shahash(subject), -1);
-    xmlnode_insert_cdata(xmlnode_insert_tag_ns(message, "subject", NULL, NS_SERVER), subject, -1);
+    std::ostringstream subject;
+    subject << "Log Packet from " << xmlnode_get_attrib_ns(p->x, "from", NULL);
+    xmlnode_insert_cdata(xmlnode_insert_tag_ns(message, "thread", NULL, NS_SERVER), shahash(subject.str().c_str()), -1);
+    xmlnode_insert_cdata(xmlnode_insert_tag_ns(message, "subject", NULL, NS_SERVER), subject.str().c_str(), subject.str().length());
     xmlnode_put_attrib_ns(message, "from", NULL, NULL, xmlnode_get_attrib_ns(p->x, "from", NULL));
     xmlnode_put_attrib_ns(message, "to", NULL, NULL, (char*)arg);
 

Modified: trunk/jabberd14/jabberd/jabberd.h
==============================================================================
--- trunk/jabberd14/jabberd/jabberd.h	(original)
+++ trunk/jabberd14/jabberd/jabberd.h	Tue Apr 29 14:25:02 2008
@@ -264,9 +264,9 @@
     int id;
     const char *ns;
     int set; /**< flag that this is a set */
-    char *act; /**< for set */
-    char *match; /**< for set */
-    char *matchpath; /**< for set, namespace aware version of match */
+    char const* act; /**< for set */
+    char const* match; /**< for set */
+    char const* matchpath; /**< for set, namespace aware version of match */
     xht namespaces; /**< for set, namespace prefix declarations for matchpath */
     xmlnode data; /**< for set */
     jid owner;
@@ -281,7 +281,7 @@
 xdbcache xdb_cache(instance i); /**< create a new xdb cache for this instance */
 xmlnode xdb_get(xdbcache xc,  jid owner, const char *ns); /**< blocks until namespace is retrieved, returns xmlnode or NULL if failed */
 int xdb_act(xdbcache xc, jid owner, const char *ns, char *act, char *match, xmlnode data); /**< sends new xml action, returns non-zero if failure */
-int xdb_act_path(xdbcache xc, jid owner, const char *ns, char *act, char *matchpath, xht namespaces, xmlnode data); /**< sends new xml action, returns non-zero if failure */
+int xdb_act_path(xdbcache xc, jid owner, const char *ns, char const *act, char const* matchpath, xht namespaces, xmlnode data); /**< sends new xml action, returns non-zero if failure */
 int xdb_set(xdbcache xc, jid owner, const char *ns, xmlnode data); /**< sends new xml to replace old, returns non-zero if failure */
 
 /* Error messages */

Modified: trunk/jabberd14/jabberd/lib/expat.cc
==============================================================================
--- trunk/jabberd14/jabberd/lib/expat.cc	(original)
+++ trunk/jabberd14/jabberd/lib/expat.cc	Tue Apr 29 14:25:02 2008
@@ -322,7 +322,7 @@
  * @param node the xmlnode that should be written
  * @return 1 on success, -1 on failure
  */
-int xmlnode2file(char *file, xmlnode node)
+int xmlnode2file(char const* file, xmlnode node)
 {
     return xmlnode2file_limited(file, node, 0);
 }
@@ -335,8 +335,8 @@
  * @param sizelimit the maximum length of the file to be written
  * @return 1 on success, 0 if failed due to size limit, -1 on failure
  */
-int xmlnode2file_limited(char *file, xmlnode node, size_t sizelimit) {
-    char *doc, *ftmp;
+int xmlnode2file_limited(char const* file, xmlnode node, size_t sizelimit) {
+    char *doc;
     int fd, i;
     size_t doclen;
 
@@ -354,8 +354,9 @@
 	return 0;
     }
 
-    ftmp = spools(xmlnode_pool(node),file,".t.m.p",xmlnode_pool(node));
-    fd = open(ftmp, O_CREAT | O_WRONLY | O_TRUNC, 0600);
+    std::ostringstream ftmp;
+    ftmp << file << ".t.m.p";
+    fd = open(ftmp.str().c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0600);
     if (fd < 0)
         return -1;
 
@@ -363,7 +364,7 @@
     i = write(fd, "<?xml version='1.0'?>\n", 22);
     if (i < 0) {
 	close(fd);
-	unlink(ftmp);
+	unlink(ftmp.str().c_str());
 	return -1;
     }
 
@@ -371,7 +372,7 @@
     i = write(fd, doc, doclen);
     if (i < 0) {
 	close(fd);
-	unlink(ftmp);
+	unlink(ftmp.str().c_str());
         return -1;
     }
 
@@ -379,7 +380,7 @@
     i = write(fd, "\n", 1);
     if (i < 0) {
 	close(fd);
-	unlink(ftmp);
+	unlink(ftmp.str().c_str());
         return -1;
     }
 
@@ -387,8 +388,8 @@
     close(fd);
 
     /* replace the old file with the new one */
-    if(rename(ftmp,file) < 0) {
-        unlink(ftmp);
+    if(rename(ftmp.str().c_str(), file) < 0) {
+        unlink(ftmp.str().c_str());
         return -1;
     }
 

Modified: trunk/jabberd14/jabberd/lib/hash.cc
==============================================================================
--- trunk/jabberd14/jabberd/lib/hash.cc	(original)
+++ trunk/jabberd14/jabberd/lib/hash.cc	Tue Apr 29 14:25:02 2008
@@ -253,7 +253,7 @@
     snprintf(hashbuf, 41, "%s", result.c_str());
 }
 
-char *shahash(char *str) {
+char *shahash(char const* str) {
     static char resultbuffer[41];
 
     shahash_r(str, resultbuffer);

Modified: trunk/jabberd14/jabberd/lib/jabberdlib.h
==============================================================================
--- trunk/jabberd14/jabberd/lib/jabberdlib.h	(original)
+++ trunk/jabberd14/jabberd/lib/jabberdlib.h	Tue Apr 29 14:25:02 2008
@@ -493,7 +493,7 @@
 typedef unsigned int uint32;
 #endif /* HAVEUINT32 */
 
-char *shahash(char *str);	/* NOT THREAD SAFE */
+char *shahash(char const* str);	/* NOT THREAD SAFE */
 void shahash_r(const char* str, char hashbuf[41]); /* USE ME */
 void shaBlock(unsigned char *dataIn, int len, unsigned char hashout[20]);
 
@@ -568,32 +568,6 @@
 
 /* --------------------------------------------------------- */
 /*                                                           */
-/* String pools (spool) functions                            */
-/*                                                           */
-/* --------------------------------------------------------- */
-struct spool_node
-{
-    char *c;
-    struct spool_node *next;
-};
-
-typedef struct spool_struct
-{
-    pool p;
-    int len;
-    struct spool_node *last;
-    struct spool_node *first;
-} *spool;
-
-spool spool_new(pool p); /* create a string pool */
-void spooler(spool s, ...); /* append all the char * args to the pool, terminate args with s again */
-char *spool_print(spool s); /* return a big string */
-void spool_add(spool s, const char *str); /* add a single char to the pool */
-char *spools(pool p, ...); /* wrap all the spooler stuff in one function, the happy fun ball! */
-
-
-/* --------------------------------------------------------- */
-/*                                                           */
 /* xmlnodes - Document Object Model                          */
 /*                                                           */
 /* --------------------------------------------------------- */
@@ -730,8 +704,8 @@
 /* Node-to-string translation */
 char*	 xmlnode_serialize_string(xmlnode_t const* node, const xmppd::ns_decl_list& nslist, int stream_type);
 
-int      xmlnode2file(char *file, xmlnode node); /* writes node to file */
-int	 xmlnode2file_limited(char *file, xmlnode node, size_t sizelimit);
+int      xmlnode2file(char const* file, xmlnode node); /* writes node to file */
+int	 xmlnode2file_limited(char const* file, xmlnode node, size_t sizelimit);
 
 /* Expat callbacks */
 void expat_startElement(void* userdata, const char* name, const char** atts);
@@ -826,7 +800,7 @@
     streamerr_severity severity;/**< something that admin needs to care about? */
 } *streamerr, _streamerr;
 
-void xstream_format_error(spool s, streamerr errstruct);
+void xstream_format_error(std::ostream& out, streamerr errstruct);
 streamerr_severity xstream_parse_error(pool p, xmlnode errnode, streamerr errstruct);
 
 typedef struct {
@@ -1336,7 +1310,7 @@
 /* --------------------------------------------------------- */
 xmlnode jutil_presnew(int type, char *to, const char *status); /* Create a skeleton presence packet */
 xmlnode jutil_iqnew(int type, char *ns);		 /* Create a skeleton iq packet */
-xmlnode jutil_msgnew(char *type, char const* to, char *subj, char *body);
+xmlnode jutil_msgnew(char const* type, char const* to, char const* subj, char const* body);
 							 /* Create a skeleton message packet */
 int     jutil_priority(xmlnode x);			 /* Determine priority of this packet */
 void    jutil_tofrom(xmlnode x);			 /* Swaps to/from fields on a packet */

Modified: trunk/jabberd14/jabberd/lib/jutil.cc
==============================================================================
--- trunk/jabberd14/jabberd/lib/jutil.cc	(original)
+++ trunk/jabberd14/jabberd/lib/jutil.cc	Tue Apr 29 14:25:02 2008
@@ -122,7 +122,7 @@
  * @param body the body of the message
  * @return the xmlnode containing the new message stanza
  */
-xmlnode jutil_msgnew(char *type, char const* to, char *subj, char *body) {
+xmlnode jutil_msgnew(char const* type, char const* to, char const* subj, char const* body) {
     xmlnode msg;
 
     msg = xmlnode_new_tag_ns("message", NULL, NS_SERVER);

Modified: trunk/jabberd14/jabberd/lib/str.cc
==============================================================================
--- trunk/jabberd14/jabberd/lib/str.cc	(original)
+++ trunk/jabberd14/jabberd/lib/str.cc	Tue Apr 29 14:25:02 2008
@@ -179,115 +179,6 @@
         return atoi(a);
 }
 
-spool spool_new(pool p)
-{
-    spool s;
-
-    s = static_cast<spool>(pmalloc(p, sizeof(struct spool_struct)));
-    s->p = p;
-    s->len = 0;
-    s->last = NULL;
-    s->first = NULL;
-    return s;
-}
-
-void spool_add(spool s, const char *str) {
-    struct spool_node *sn;
-    int len;
-
-    if(str == NULL)
-        return;
-
-    len = strlen(str);
-    if(len == 0)
-        return;
-
-    sn = static_cast<struct spool_node*>(pmalloc(s->p, sizeof(struct spool_node)));
-    sn->c = pstrdup(s->p, str);
-    sn->next = NULL;
-
-    s->len += len;
-    if(s->last != NULL)
-        s->last->next = sn;
-    s->last = sn;
-    if(s->first == NULL)
-        s->first = sn;
-}
-
-void spooler(spool s, ...)
-{
-    va_list ap;
-    char *arg = NULL;
-
-    if(s == NULL)
-        return;
-
-    va_start(ap, s);
-
-    /* loop till we hit our end flag, the first arg */
-    while(1)
-    {
-        arg = va_arg(ap,char *);
-        if((spool)arg == s)
-            break;
-        else
-            spool_add(s, arg);
-    }
-
-    va_end(ap);
-}
-
-char *spool_print(spool s)
-{
-    char *ret,*tmp;
-    struct spool_node *next;
-
-    if(s == NULL || s->len == 0 || s->first == NULL)
-        return NULL;
-
-    ret = static_cast<char*>(pmalloc(s->p, s->len + 1));
-    *ret = '\0';
-
-    next = s->first;
-    tmp = ret;
-    while(next != NULL)
-    {
-        tmp = j_strcat(tmp,next->c);
-        next = next->next;
-    }
-
-    return ret;
-}
-
-/* convenience :) */
-char *spools(pool p, ...)
-{
-    va_list ap;
-    spool s;
-    char *arg = NULL;
-
-    if(p == NULL)
-        return NULL;
-
-    s = spool_new(p);
-
-    va_start(ap, p);
-
-    /* loop till we hit our end flag, the first arg */
-    while(1)
-    {
-        arg = va_arg(ap,char *);
-        if((pool)arg == p)
-            break;
-        else
-            spool_add(s, arg);
-    }
-
-    va_end(ap);
-
-    return spool_print(s);
-}
-
 
 char *strunescape(pool p, char *buf)
 {

Modified: trunk/jabberd14/jabberd/lib/xmlnode.cc
==============================================================================
--- trunk/jabberd14/jabberd/lib/xmlnode.cc	(original)
+++ trunk/jabberd14/jabberd/lib/xmlnode.cc	Tue Apr 29 14:25:02 2008
@@ -1316,7 +1316,9 @@
     if (node->prefix == NULL)
 	return node->name;
 
-    return spools(node->p, node->prefix, ":", node->name, node->p);
+    std::ostringstream result;
+    result << node->prefix << ":" << node->name;
+    return pstrdup(node->p, result.str().c_str());
 }
 
 /**

Modified: trunk/jabberd14/jabberd/lib/xstream.cc
==============================================================================
--- trunk/jabberd14/jabberd/lib/xstream.cc	(original)
+++ trunk/jabberd14/jabberd/lib/xstream.cc	Tue Apr 29 14:25:02 2008
@@ -410,107 +410,103 @@
 /**
  * format a stream error for logging
  *
- * @param s where to spool the result
+ * @param out where to write the result
  * @param errstruct the information about the error
  */
-void xstream_format_error(spool s, streamerr errstruct) {
+void xstream_format_error(std::ostream& out, streamerr errstruct) {
     /* sanity checks */
-    if (s == NULL)
-	return;
     if (errstruct == NULL) {
-	spool_add(s, "stream:error=(NULL)");
+	out << "stream:error=(NULL)";
 	return;
     }
 
     switch (errstruct->reason) {
 	case unknown_error_type:
-	    spool_add(s, "unknown error type / legacy stream error");
+	    out << "unknown error type / legacy stream error";
 	    break;
 	case bad_format:
-	    spool_add(s, "sent XML that cannot be processed");
+	    out << "sent XML that cannot be processed";
 	    break;
 	case bad_namespace_prefix:
-	    spool_add(s, "sent a namespace prefix that is unsupported");
+	    out << "sent a namespace prefix that is unsupported";
 	    break;
 	case conflict:
-	    spool_add(s, "new stream has been initiated that confilicts with the existing one");
+	    out << "new stream has been initiated that confilicts with the existing one";
 	    break;
 	case connection_timeout:
-	    spool_add(s, "not generated any traffic over some time");
+	    out << "not generated any traffic over some time";
 	    break;
 	case host_gone:
-	    spool_add(s, "hostname is no longer hosted by the server");
+	    out << "hostname is no longer hosted by the server";
 	    break;
 	case host_unknown:
-	    spool_add(s, "hostname is not hosted by the server");
+	    out << "hostname is not hosted by the server";
 	    break;
 	case improper_addressing:
-	    spool_add(s, "stanza lacks a 'to' or 'from' attribute");
+	    out << "stanza lacks a 'to' or 'from' attribute";
 	    break;
 	case internal_server_error:
-	    spool_add(s, "internal server error: maybe missconfiguration");
+	    out << "internal server error: maybe missconfiguration";
 	    break;
 	case invalid_from:
-	    spool_add(s, "from address does not match an authorized JID or validated domain");
+	    out << "from address does not match an authorized JID or validated domain";
 	    break;
 	case invalid_id:
-	    spool_add(s, "stream or dialback id is invalid or does not match a previous one");
+	    out << "stream or dialback id is invalid or does not match a previous one";
 	    break;
 	case invalid_namespace:
-	    spool_add(s, "invalid namespace");
+	    out << "invalid namespace";
 	    break;
 	case invalid_xml:
-	    spool_add(s, "sent invalid XML, did not pass validation");
+	    out << "sent invalid XML, did not pass validation";
 	    break;
 	case not_authorized:
-	    spool_add(s, "tried to send data before stream has been authed");
+	    out << "tried to send data before stream has been authed";
 	    break;
 	case policy_violation:
-	    spool_add(s, "policy violation");
+	    out << "policy violation";
 	    break;
 	case remote_connection_failed:
-	    spool_add(s, "remote connection failed");
+	    out << "remote connection failed";
 	    break;
 	case resource_constraint:
-	    spool_add(s, "server lacks resources to service the stream");
+	    out << "server lacks resources to service the stream";
 	    break;
 	case restricted_xml:
-	    spool_add(s, "sent XML features that are forbidden by RFC3920");
+	    out << "sent XML features that are forbidden by RFC3920";
 	    break;
 	case see_other_host:
-	    spool_add(s, "redirected to other host");
+	    out << "redirected to other host";
 	    break;
 	case system_shutdown:
-	    spool_add(s, "system is being shut down");
+	    out << "system is being shut down";
 	    break;
 	case undefined_condition:
-	    spool_add(s, "undefined condition");
+	    out << "undefined condition";
 	    break;
 	case unsupported_encoding:
-	    spool_add(s, "unsupported encoding");
+	    out << "unsupported encoding";
 	    break;
 	case unsupported_stanza_type:
-	    spool_add(s, "sent a first-level child element (stanza) that is not supported");
+	    out << "sent a first-level child element (stanza) that is not supported";
 	    break;
 	case unsupported_version:
-	    spool_add(s, "unsupported stream version");
+	    out << "unsupported stream version";
 	    break;
 	case xml_not_well_formed:
-	    spool_add(s, "sent XML that is not well-formed");
+	    out << "sent XML that is not well-formed";
 	    break;
 	default:
-	    spool_add(s, "something else (shut not happen)");
+	    out << "something else (shut not happen)";
 	    break;
     }
 
     if (errstruct->text != NULL) {
-	spool_add(s, ": ");
+	out << ": ";
 	if (errstruct->lang != NULL) {
-	    spool_add(s, "[");
-	    spool_add(s, errstruct->lang);
-	    spool_add(s, "]");
+	    out << "[" << errstruct->lang << "]";
 	}
-	spool_add(s, errstruct->text);
+	out << errstruct->text;
     }
 }
 

Modified: trunk/jabberd14/jabberd/xdb.cc
==============================================================================
--- trunk/jabberd14/jabberd/xdb.cc	(original)
+++ trunk/jabberd14/jabberd/xdb.cc	Tue Apr 29 14:25:02 2008
@@ -280,7 +280,7 @@
 /* act must be NULL, "check", or "insert" for now, insert will either blindly insert data into the parent (creating one if needed) or use match */
 /* match will find a child in the parent, and either replace (if it's an insert) or remove (if data is NULL) */
 /* XXX for the check action, read the comment in xdb_file/xdb_file.c, it might be buggy and not needed anyway */
-static int _xdb_act(xdbcache xc, jid owner, const char *ns, char *act, char *match, char *matchpath, xht namespaces, xmlnode data) {
+static int _xdb_act(xdbcache xc, jid owner, const char *ns, char const* act, char const* match, char const* matchpath, xht namespaces, xmlnode data) {
     _xdbcache newx;
 
     if (xc == NULL || owner == NULL || ns == NULL) {
@@ -336,7 +336,7 @@
     return _xdb_act(xc, owner, ns, act, match, NULL, NULL, data);
 }
 
-int xdb_act_path(xdbcache xc, jid owner, const char *ns, char *act, char *matchpath, xht namespaces, xmlnode data) {
+int xdb_act_path(xdbcache xc, jid owner, const char *ns, char const* act, char const* matchpath, xht namespaces, xmlnode data) {
     return _xdb_act(xc, owner, ns, act, NULL, matchpath, namespaces, data);
 }
 

Modified: trunk/jabberd14/jsm/modules/mod_admin.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_admin.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_admin.cc	Tue Apr 29 14:25:02 2008
@@ -67,20 +67,17 @@
     /* for all sessions of this user */
     for (session_iter = u->sessions; session_iter != NULL; session_iter = session_iter->next) {
 	xmlnode item = xmlnode_insert_tag_ns(query, "item", NULL, NS_DISCO_ITEMS);
-	spool sp = spool_new(xmlnode_pool(query));
+	std::ostringstream name;
 
 	/* generate text for this item */
-	spooler(sp, jid_full(session_iter->id), " (", messages_get(lang, N_("dur")), ": ", sp);
-	snprintf(buffer, sizeof(buffer), "%d", (int)(t - session_iter->started));
-	spooler(sp, buffer, " ", messages_get(lang, N_("s")), ", ", messages_get(lang, N_("in")), ": ", sp);
-	snprintf(buffer, sizeof(buffer), "%d", session_iter->c_out);
-	spooler(sp, buffer, " ", messages_get(lang, N_("stnz")), ", ", messages_get(lang, N_("out")), ": ", sp);
-	snprintf(buffer, sizeof(buffer), "%d", session_iter->c_in);
-	spooler(sp, buffer, " ", messages_get(lang, N_("stnz")), ")", sp);
+	name << jid_full(session_iter->id) << " (" << messages_get(lang, N_("dur")) << ": ";
+	name << static_cast<int>(t - session_iter->started) << " " << messages_get(lang, N_("s")) << ", " << messages_get(lang, N_("in")) << ": ";
+	name << session_iter->c_out << " " << messages_get(lang, N_("stnz")) << ", " << messages_get(lang, N_("out")) << ": ";
+	name << session_iter->c_in << " " << messages_get(lang, N_("stnz")) << ")";
 
 	/* add attributes for this item */
 	xmlnode_put_attrib_ns(item, "jid", NULL, NULL, jid_full(session_iter->id));
-	xmlnode_put_attrib_ns(item, "name", NULL, NULL, spool_print(sp));
+	xmlnode_put_attrib_ns(item, "name", NULL, NULL, name.str().c_str());
     }
 }
 
@@ -187,7 +184,6 @@
 static mreturn mod_admin_message(mapi m, void *arg) {
     jpacket p;
     xmlnode cur;
-    char *subject;
     const char *element_name;
     static char jidlist[1024] = "";
     jid admins = NULL;
@@ -209,9 +205,13 @@
     log_debug2(ZONE, LOGT_DELIVER, "delivering admin message from %s",jid_full(m->packet->from));
 
     /* update the message */
-    subject=spools(m->packet->p, messages_get(xmlnode_get_lang(m->packet->x), N_("Admin: ")), xmlnode_get_data(xmlnode_get_list_item(xmlnode_get_tags(m->packet->x, "subject", m->si->std_namespace_prefixes) ,0)), " (", m->packet->to->get_domain().c_str(), ")", m->packet->p);
+    std::ostringstream subject;
+    subject << messages_get(xmlnode_get_lang(m->packet->x), N_("Admin: "));
+    char const* orig_subject = xmlnode_get_data(xmlnode_get_list_item(xmlnode_get_tags(m->packet->x, "subject", m->si->std_namespace_prefixes) ,0));
+    subject << (orig_subject ? orig_subject : messages_get(xmlnode_get_lang(m->packet->x), N_("no subject")));
+    subject << " (" << m->packet->to->get_domain() << ")";
     xmlnode_hide(xmlnode_get_list_item(xmlnode_get_tags(m->packet->x, "subject", m->si->std_namespace_prefixes), 0));
-    xmlnode_insert_cdata(xmlnode_insert_tag_ns(m->packet->x, "subject", NULL, NS_SERVER), subject, -1);
+    xmlnode_insert_cdata(xmlnode_insert_tag_ns(m->packet->x, "subject", NULL, NS_SERVER), subject.str().c_str(), -1);
     jutil_delay(m->packet->x, "admin");
 
     /* forward the message to every configured admin */

Modified: trunk/jabberd14/jsm/modules/mod_auth_digest.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_auth_digest.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_auth_digest.cc	Tue Apr 29 14:25:02 2008
@@ -46,10 +46,8 @@
  * @return M_HANDLED if the request was handled using digest authentication, M_PASS else
  */
 static mreturn mod_auth_digest_yum(mapi m, void *arg) {
-    spool s;
     char *sid;
     char *digest;
-    char *mydigest;
     const char *pass = NULL;
     xmlnode xmlpass = NULL;
 
@@ -77,16 +75,18 @@
     /* Concat the stream id and password */
     /* SHA it up */
     log_debug2(ZONE, LOGT_AUTH, "Got SID: %s", sid);
-    s = spool_new(m->packet->p);
-    spooler(s,sid,pass,s);
 
-    mydigest = shahash(spool_print(s));
+    xmppd::sha1 mydigest;
+    if (sid)
+	mydigest.update(sid);
+    if (pass)
+	mydigest.update(pass);
 
-    log_debug2(ZONE, LOGT_AUTH, "comparing %s %s",digest,mydigest);
+    log_debug2(ZONE, LOGT_AUTH, "comparing %s %s", digest, mydigest.final_hex().c_str());
 
-    if (pass == NULL || sid == NULL || mydigest == NULL)
+    if (pass == NULL || sid == NULL)
         jutil_error_xmpp(m->packet->x, XTERROR_NOTIMPL);
-    else if (j_strcasecmp(digest, mydigest) != 0)
+    else if (j_strcasecmp(digest, mydigest.final_hex().c_str()) != 0)
         jutil_error_xmpp(m->packet->x, XTERROR_AUTH);
     else
         jutil_iqresult(m->packet->x);

Modified: trunk/jabberd14/jsm/modules/mod_browse.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_browse.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_browse.cc	Tue Apr 29 14:25:02 2008
@@ -112,7 +112,9 @@
         xmlnode_hide_attrib_ns(browse, "xmlns", NS_XMLNS); /* don't need a ns as a child */
         for (cur = xmlnode_get_firstchild(browse); cur != NULL; cur = xmlnode_get_nextsibling(cur))
             xmlnode_hide(cur); /* erase all children */
-        xdb_act_path(m->si->xc, m->user->id, NS_BROWSE, "insert", spools(m->packet->p,"*[@jid='", jid_full(to), "']", m->packet->p), m->si->std_namespace_prefixes, browse); /* insert and match replace */
+	std::ostringstream xpath;
+	xpath << "*[@jid='" << jid_full(to) << "']";
+        xdb_act_path(m->si->xc, m->user->id, NS_BROWSE, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, browse); /* insert and match replace */
         xmlnode_free(browse);
     }
 
@@ -124,7 +126,9 @@
 
     /* insert the new item into the resource it was sent to */
     xmlnode_hide_attrib_ns(cur, "xmlns", NS_XMLNS); /* just in case, to make sure it inserts */
-    if (xdb_act_path(m->si->xc, to, NS_BROWSE, "insert", spools(m->packet->p, "*[@jid='", jid_full(id), "']", m->packet->p), m->si->std_namespace_prefixes, cur)) {
+    std::ostringstream xpath;
+    xpath << "*[@jid='" << jid_full(id) << "']";
+    if (xdb_act_path(m->si->xc, to, NS_BROWSE, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, cur)) {
         js_bounce_xmpp(m->si, m->s, m->packet->x, XTERROR_UNAVAIL);
         return M_HANDLED;
     }
@@ -206,7 +210,9 @@
     if (js_trust(m->user, m->packet->from)) {
         for (s = m->user->sessions; s != NULL; s = s->next) {
             /* if(s->priority < 0) continue; *** include all resources I guess */
-            if (xmlnode_get_list_item(xmlnode_get_tags(browse, spools(m->packet->p,"*[@jid='",jid_full(s->id), "']'", m->packet->p), m->si->std_namespace_prefixes), 0) != NULL)
+	    std::ostringstream xpath;
+	    xpath << "*[@jid='" << jid_full(s->id) << "']'";
+            if (xmlnode_get_list_item(xmlnode_get_tags(browse, xpath.str().c_str(), m->si->std_namespace_prefixes), 0) != NULL)
 		continue; /* already in the browse result */
             cur = xmlnode_insert_tag_ns(browse, "user", NULL, NS_BROWSE);
             xmlnode_put_attrib_ns(cur, "type", NULL, NULL, "client");

Modified: trunk/jabberd14/jsm/modules/mod_disco.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_disco.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_disco.cc	Tue Apr 29 14:25:02 2008
@@ -243,7 +243,9 @@
     if (js_trust(m->user, m->packet->from)) {
         for (s = m->user->sessions; s != NULL; s = s->next) {
             /* if(s->priority < 0) continue; *** include all resources I guess */
-            if (xmlnode_get_list_item(xmlnode_get_tags(m->packet->iq, spools(m->packet->p,"*[@jid='",jid_full(s->id), "']'", m->packet->p), m->si->std_namespace_prefixes), 0) != NULL)
+	    std::ostringstream xpath;
+	    xpath << "*[@jid='" << jid_full(s->id) << "']'";
+            if (xmlnode_get_list_item(xmlnode_get_tags(m->packet->iq, xpath.str().c_str(), m->si->std_namespace_prefixes), 0) != NULL)
 		continue; /* already in the browse result */
             x = xmlnode_insert_tag_ns(m->packet->iq, "item", NULL, NS_BROWSE);
             xmlnode_put_attrib_ns(x, "jid", NULL, NULL, jid_full(s->id));
@@ -288,7 +290,11 @@
     vcard = xdb_get(m->si->xc, m->user->id, NS_VCARD);
     vcard_fn = xmlnode_get_tags(vcard, "vcard:FN", m->si->std_namespace_prefixes);
     if (vcard_fn.size() > 0) {
-	xmlnode_put_attrib_ns(x, "name", NULL, NULL, is_admin ? spools(m->packet->p, xmlnode_get_data(vcard_fn[0]), messages_get(xmlnode_get_lang(m->packet->x), N_(" (administrator)")), m->packet->p) : xmlnode_get_data(vcard_fn[0]));
+	std::ostringstream name;
+	name << xmlnode_get_data(vcard_fn[0]);
+	if (is_admin)
+	    name << messages_get(xmlnode_get_lang(m->packet->x), N_(" (administrator)"));
+	xmlnode_put_attrib_ns(x, "name", NULL, NULL, name.str().c_str());
     } else {
 	xmlnode_put_attrib_ns(x, "name", NULL, NULL, messages_get(xmlnode_get_lang(m->packet->x), is_admin ? N_("Administrator") : N_("User")));
     }

Modified: trunk/jabberd14/jsm/modules/mod_offline.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_offline.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_offline.cc	Tue Apr 29 14:25:02 2008
@@ -214,8 +214,6 @@
  * @param filter which message to remove, NULL for all messages
  */
 static void mod_offline_remove_message(mapi m, const char *filter) {
-    spool s = NULL;
-
     if (m == NULL)
 	return;
 
@@ -225,15 +223,13 @@
     }
 
     /* generate the node path for the message to delete */
-    s = spool_new(m->packet->p);
-    spool_add(s, "message[@node='");
-    spool_add(s, filter);
-    spool_add(s, "']");
+    std::ostringstream xpath;
+    xpath << "message[@node='" << filter << "']";
 
-    log_debug2(ZONE, LOGT_STORAGE, "removing message by matched xdb: %s", spool_print(s));
+    log_debug2(ZONE, LOGT_STORAGE, "removing message by matched xdb: %s", xpath.str().c_str());
 
     /* replace this message with nothing */
-    xdb_act_path(m->si->xc, m->user->id, NS_OFFLINE, "insert", spool_print(s), m->si->std_namespace_prefixes, NULL);
+    xdb_act_path(m->si->xc, m->user->id, NS_OFFLINE, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, NULL);
 }
 
 /**

Modified: trunk/jabberd14/jsm/modules/mod_privacy.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_privacy.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_privacy.cc	Tue Apr 29 14:25:02 2008
@@ -812,7 +812,9 @@
 	}
     } else {
 	pool p = pool_new();
-	named_list = xmlnode_get_tags(all_lists, spools(p, "*[@name='", name, "']", p), s->si->std_namespace_prefixes);
+	std::ostringstream xpath;
+	xpath << "*[@name='" << name << "']";
+	named_list = xmlnode_get_tags(all_lists, xpath.str().c_str(), s->si->std_namespace_prefixes);
 	pool_free(p);
 
 	if (named_list.size() == 0) {
@@ -1018,7 +1020,9 @@
 
     /* is there any list with the requested name? */
     if (new_default_list != NULL) {
-	xmlnode_vector default_list_new = xmlnode_get_tags(all_lists, spools(m->packet->p, "privacy:list[@name='", new_default_list, "']", m->packet->p), m->si->std_namespace_prefixes);
+	std::ostringstream xpath;
+	xpath << "privacy:list[@name='" << new_default_list << "']";
+	xmlnode_vector default_list_new = xmlnode_get_tags(all_lists, xpath.str().c_str(), m->si->std_namespace_prefixes);
 	if (default_list_new.size() == 0) {
 	    /* requested list does not exist */
 	    js_bounce_xmpp(m->si, m->s, m->packet->x, XTERROR_NOTFOUND);
@@ -1028,13 +1032,15 @@
 
 	/* set the new list to be the default */
 	xmlnode_put_attrib_ns(default_list_new[0], "default", "jabberd", NS_JABBERD_WRAPPER, "default");
-	xdb_act_path(m->si->xc, m->user->id, NS_PRIVACY, "insert", spools(m->packet->p, "privacy:list[@name='", new_default_list, "']", m->packet->p), m->si->std_namespace_prefixes, default_list_new[0]);
+	xdb_act_path(m->si->xc, m->user->id, NS_PRIVACY, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, default_list_new[0]);
     }
 
     /* unselect the old default list */
     if (default_list.size() > 0) {
 	xmlnode_hide_attrib_ns(default_list[0], "default", NS_JABBERD_WRAPPER);
-	xdb_act_path(m->si->xc, m->user->id, NS_PRIVACY, "insert", spools(m->packet->p, "privacy:list[@name='", old_default_list, "']", m->packet->p), m->si->std_namespace_prefixes, default_list[0]);
+	std::ostringstream xpath;
+	xpath << "privacy:list[@name='" << old_default_list << "']";
+	xdb_act_path(m->si->xc, m->user->id, NS_PRIVACY, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, default_list[0]);
     }
 
     /* update the active list for the current session, if the default list was in use */
@@ -1066,7 +1072,6 @@
  */
 static mreturn mod_privacy_out_iq_set_list(mapi m, xmlnode new_list) {
     const char* edited_list = NULL;
-    char* edited_list_path = NULL;
     int xdb_result = 0;
     xmlnode previous_lists = NULL;
     int is_default_update = 0;
@@ -1102,8 +1107,9 @@
 
     /* is the edited list the default list? */
     previous_lists = xdb_get(m->si->xc, m->user->id, NS_PRIVACY);
-    edited_list_path = spools(m->packet->p, "privacy:list[@name='", edited_list, "']", m->packet->p);
-    xmlnode_vector previous_list = xmlnode_get_tags(previous_lists, edited_list_path, m->si->std_namespace_prefixes);
+    std::ostringstream edited_list_xpath;
+    edited_list_xpath << "privacy:list[@name='" << edited_list << "']";
+    xmlnode_vector previous_list = xmlnode_get_tags(previous_lists, edited_list_xpath.str().c_str(), m->si->std_namespace_prefixes);
     if (previous_list.size() > 0 && xmlnode_get_attrib_ns(previous_list[0], "default", NS_JABBERD_WRAPPER) != NULL) {
 	is_default_update = 1;
 	xmlnode_put_attrib_ns(new_list, "default", "jabberd", NS_JABBERD_WRAPPER, "default");
@@ -1170,7 +1176,7 @@
     }
 
     /* save the new list */
-    xdb_result = xdb_act_path(m->si->xc, m->user->id, NS_PRIVACY, "insert", edited_list_path, m->si->std_namespace_prefixes, list_items > 0 ? new_list : NULL);
+    xdb_result = xdb_act_path(m->si->xc, m->user->id, NS_PRIVACY, "insert", edited_list_xpath.str().c_str(), m->si->std_namespace_prefixes, list_items > 0 ? new_list : NULL);
     if (xdb_result) {
 	xmlnode_free(previous_lists);
 	log_debug2(ZONE, LOGT_STORAGE, "Error updating stored data.");
@@ -1316,7 +1322,9 @@
     log_debug2(ZONE, LOGT_EXECFLOW, "Client requested privacy list: %s", requested_list);
 
     /* get the requested list */
-    xmlnode_vector lists = xmlnode_get_tags(storedlists, spools(m->packet->p, "privacy:list[@name='", requested_list, "']", m->packet->p), m->si->std_namespace_prefixes);
+    std::ostringstream xpath;
+    xpath << "privacy:list[@name='" << requested_list << "']";
+    xmlnode_vector lists = xmlnode_get_tags(storedlists, xpath.str().c_str(), m->si->std_namespace_prefixes);
 
     /* no such list? */
     if (lists.size() == 0) {

Modified: trunk/jabberd14/jsm/modules/mod_register.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_register.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_register.cc	Tue Apr 29 14:25:02 2008
@@ -187,16 +187,13 @@
 	    /* if configured to, send admins a notice */
 	    if (xmlnode_get_attrib_ns(reg, "notify", NULL) != NULL) {
 		char *email = xmlnode_get_data(xmlnode_get_list_item(xmlnode_get_tags(m->packet->iq, "register:email", m->si->std_namespace_prefixes), 0));
-		spool msg_body = spool_new(m->packet->p);
+		std::ostringstream msg_body;
 
-		spool_add(msg_body, "A new user has just been created!\n");
-		spool_add(msg_body, "User: ");
-		spool_add(msg_body, jid_full(m->packet->to));
-		spool_add(msg_body, "\n");
-		spool_add(msg_body, "E-Mail: ");
-		spool_add(msg_body, email ? email : "no address provided");
+		msg_body << "A new user has just been created!" << std::endl;
+		msg_body << "User: " << jid_full(m->packet->to) << std::endl;
+		msg_body << "E-Mail: " << (email ? email : "no address provided");
 
-		x = jutil_msgnew("chat", m->packet->to->get_domain().c_str(), "Registration Notice", spool_print(msg_body));
+		x = jutil_msgnew("chat", m->packet->to->get_domain().c_str(), "Registration Notice", msg_body.str().c_str());
 		xmlnode_put_attrib_ns(x, "from", NULL, NULL, m->packet->to->get_domain().c_str());
 		js_deliver(m->si, jpacket_new(x), m->s);
 	    }

Modified: trunk/jabberd14/jsm/modules/mod_roster.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_roster.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_roster.cc	Tue Apr 29 14:25:02 2008
@@ -244,7 +244,9 @@
 		mod_roster_push(m->user, item); /* new roster to the user's other sessions */
 
 		/* delete stored subscription request from xdb */
-		xdb_act_path(m->si->xc, m->user->id, NS_JABBERD_STOREDREQUEST, "insert", spools(m->packet->p, "presence[@from='", jid_full(m->packet->to), "']", m->packet->p), m->si->std_namespace_prefixes, NULL);
+		std::ostringstream xpath;
+		xpath << "presence[@from='" << jid_full(m->packet->to) << "']";
+		xdb_act_path(m->si->xc, m->user->id, NS_JABBERD_STOREDREQUEST, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, NULL);
 	    } else {
 		/* XMPP IM, sect. 9 other states */
 		route = 0;
@@ -367,7 +369,9 @@
 		if (xmlnode_get_attrib_ns(*iter, "subscribe", NULL) != NULL) {
 		    /* is there a stored version of the subscription request in xdb? */
 		    xmlnode stored_subscribes = xdb_get(m->si->xc, m->user->id, NS_JABBERD_STOREDREQUEST);
-		    pres =  xmlnode_dup(xmlnode_get_list_item(xmlnode_get_tags(stored_subscribes, spools(xmlnode_pool(*iter), "presence[@from='", xmlnode_get_attrib_ns(*iter, "jid", NULL), "']", xmlnode_pool(*iter)), m->si->std_namespace_prefixes), 0));
+		    std::ostringstream xpath;
+		    xpath << "presence[@from='" << xmlnode_get_attrib_ns(*iter, "jid", NULL) << "']";
+		    pres =  xmlnode_dup(xmlnode_get_list_item(xmlnode_get_tags(stored_subscribes, xpath.str().c_str(), m->si->std_namespace_prefixes), 0));
 
 		    /* if there is nothing in xdb, create a subscription request */
 		    if (pres == NULL) {
@@ -625,7 +629,9 @@
     if (store_request) {
 	xmlnode request = xmlnode_dup(m->packet->x);
 	jutil_delay(request, N_("Offline Storage"));
-	xdb_act_path(m->si->xc, m->user->id, NS_JABBERD_STOREDREQUEST, "insert", spools(m->packet->p, "presence[@from='", jid_full(m->packet->from), "']", m->packet->p), m->si->std_namespace_prefixes, request);
+	std::ostringstream xpath;
+	xpath << "presence[@from='" << jid_full(m->packet->from) << "']";
+	xdb_act_path(m->si->xc, m->user->id, NS_JABBERD_STOREDREQUEST, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, request);
     }
 
     /* these are delayed until after we check the roster back in, avoid rancid race conditions */

Modified: trunk/jabberd14/jsm/modules/mod_version.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_version.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_version.cc	Tue Apr 29 14:25:02 2008
@@ -191,9 +191,11 @@
 	mi->os = pstrdup(p, xmlnode_get_data(os));
     else if (xmlnode_get_list_item(xmlnode_get_tags(config, "jsm:no_os_version", si->std_namespace_prefixes), 0))
 	mi->os = pstrdup(p, un.sysname);
-    else
-	mi->os = spools(p, un.sysname, " ", un.release, p);
-
+    else {
+	std::ostringstream system;
+	system << un.sysname << " " << un.release;
+	mi->os = pstrdup(p, system.str().c_str());
+    }
 
     js_mapi_register(si,e_SERVER,mod_version_iq_server,(void *)mi);
     js_mapi_register(si,e_SHUTDOWN,mod_version_shutdown,(void *)mi);

Modified: trunk/jabberd14/jsm/modules/mod_xml.cc
==============================================================================
--- trunk/jabberd14/jsm/modules/mod_xml.cc	(original)
+++ trunk/jabberd14/jsm/modules/mod_xml.cc	Tue Apr 29 14:25:02 2008
@@ -78,6 +78,7 @@
     ns = xmlnode_get_namespace(inx);
 
     xmlnode_vector result_items;
+    std::ostringstream xpath;
     switch (jpacket_subtype(m->packet)) {
 	case JPACKET__GET:
 	    log_debug2(ZONE, LOGT_DELIVER|LOGT_STORAGE, "handling get request for %s", ns);
@@ -86,7 +87,8 @@
 	    storedx = xdb_get(m->si->xc, m->user->id, NS_PRIVATE);
 
 	    /* get the relevant items */
-	    result_items = xmlnode_get_tags(storedx, spools(m->packet->p, "private:query[@jabberd:ns='", ns, "']", m->packet->p), m->si->std_namespace_prefixes);
+	    xpath << "private:query[@jabberd:ns='" << ns << "']";
+	    result_items = xmlnode_get_tags(storedx, xpath.str().c_str(), m->si->std_namespace_prefixes);
 	    for (xmlnode_vector::iterator result_item = result_items.begin(); result_item != result_items.end(); ++result_item) {
 		if (!got_result) {
 		    got_result = 1;
@@ -131,7 +133,8 @@
 
 	    /* save the changes */
 	    xmlnode_put_attrib_ns(m->packet->iq, "ns", "jabberd", NS_JABBERD_WRAPPER, ns);
-	    if (xdb_act_path(m->si->xc, m->user->id, NS_PRIVATE, "insert", spools(m->packet->p, "private:query[@jabberd:ns='", ns, "']", m->packet->p), m->si->std_namespace_prefixes, is_delete ? NULL : m->packet->iq))
+	    xpath << "private:query[@jabberd:ns='" << ns << "']";
+	    if (xdb_act_path(m->si->xc, m->user->id, NS_PRIVATE, "insert", xpath.str().c_str(), m->si->std_namespace_prefixes, is_delete ? NULL : m->packet->iq))
 		jutil_error_xmpp(m->packet->x, XTERROR_UNAVAIL);
 
 	    /* build result and send back */

Modified: trunk/jabberd14/jsm/serialization.cc
==============================================================================
--- trunk/jabberd14/jsm/serialization.cc	(original)
+++ trunk/jabberd14/jsm/serialization.cc	Tue Apr 29 14:25:02 2008
@@ -291,7 +291,9 @@
 
     /* get the right XML tree fragment */
     p = xmlnode_pool(file);
-    xmlnode_vector jsm_host = xmlnode_get_tags(file, spools(p, "state:jsm[@host='", host, "']", p), si->std_namespace_prefixes);
+    std::ostringstream xpath;
+    xpath << "state:jsm[@host='" << host << "']";
+    xmlnode_vector jsm_host = xmlnode_get_tags(file, xpath.str().c_str(), si->std_namespace_prefixes);
 
     if (jsm_host.size() == 0) {
 	log_notice(si->i->id, "There is no state for '%s' in %s: not deserializing previous jsm state", host, si->statefile);

Modified: trunk/jabberd14/xdb_file/xdb_file.cc
==============================================================================
--- trunk/jabberd14/xdb_file/xdb_file.cc	(original)
+++ trunk/jabberd14/xdb_file/xdb_file.cc	Tue Apr 29 14:25:02 2008
@@ -192,9 +192,9 @@
  * @param use_subdirs true if file should be located in subdirectories
  * @return 1 on success, 0 on failure
  */
-int _xdb_gen_dirs(spool sp, const char *spoolroot, char const* host, const char *hash1, const char *hash2, int use_subdirs) {
+static int _xdb_gen_dirs(const char *spoolroot, char const* host, const char *hash1, const char *hash2, int use_subdirs) {
+    std::ostringstream folder;
     struct stat s;
-    char *tmp;
 
     /* check that the root of the spool structure exists */
     if (stat(spoolroot, &s) < 0) {
@@ -203,27 +203,24 @@
     }
 
     /* check and create the host-named folder */
-    spooler(sp, spoolroot, "/", host, sp);
-    tmp = spool_print(sp);
-    if(stat(tmp,&s) < 0 && mkdir(tmp, S_IRWXU) < 0) {
-	log_error(host, "could not create spool folder %s: %s", tmp, strerror(errno));
+    folder << spoolroot << "/" << host;
+    if(stat(folder.str().c_str(),&s) < 0 && mkdir(folder.str().c_str(), S_IRWXU) < 0) {
+	log_error(host, "could not create spool folder %s: %s", folder.str().c_str(), strerror(errno));
 	return 0;
     }
 
     if (use_subdirs) {
 	/* check or create the first level subdirectory */
-	spooler(sp, "/", hash1, sp);
-	tmp = spool_print(sp);
-	if(stat(tmp,&s) < 0 && mkdir(tmp, S_IRWXU) < 0) {
-	    log_error(host, "could not create spool folder %s: %s", tmp, strerror(errno));
+	folder << "/" << hash1;
+	if(stat(folder.str().c_str(),&s) < 0 && mkdir(folder.str().c_str(), S_IRWXU) < 0) {
+	    log_error(host, "could not create spool folder %s: %s", folder.str().c_str(), strerror(errno));
 	    return 0;
 	}
 
 	/* check or create the second level subdirectory */
-	spooler(sp, "/", hash2, sp);
-	tmp = spool_print(sp);
-	if(stat(tmp,&s) < 0 && mkdir(tmp, S_IRWXU) < 0) {
-	    log_error(host, "could not create spool folder %s: %s", tmp, strerror(errno));
+	folder << "/" << hash2;
+	if(stat(folder.str().c_str(),&s) < 0 && mkdir(folder.str().c_str(), S_IRWXU) < 0) {
+	    log_error(host, "could not create spool folder %s: %s", folder.str().c_str(), strerror(errno));
 	    return 0;
 	}
     }
@@ -244,32 +241,32 @@
  * @return concatenated string of the form spl+"/"+somehashes+"/"+file+"."+ext
  */
 char *xdb_file_full(int create, pool p, const char *spl, char const* host, const char *file, char const* ext, int use_subdirs) {
-    spool sp = spool_new(p);
+    std::ostringstream filepath;
+    std::ostringstream filename;
     char digit01[3], digit23[3];
-    char *ret;
-    char *filename;
 
-    filename = spools(p, file, ".", ext, p);
+    filename << file << "." << ext;
 
-    _xdb_get_hashes(filename, digit01, digit23);
+    _xdb_get_hashes(filename.str().c_str(), digit01, digit23);
 
     /* is the creation of the folder requested? */
     if(create) {
-	if (!_xdb_gen_dirs(sp, spl, host, digit01, digit23, use_subdirs)) {
+	if (!_xdb_gen_dirs(spl, host, digit01, digit23, use_subdirs)) {
 	    log_error(host, "xdb request failed, necessary directory was not created");
 	    return NULL;
 	}
-    } else if (use_subdirs) {
-	spooler(sp, spl, "/", host, "/", digit01, "/", digit23, sp);
-    } else {
-	spooler(sp, spl, "/", host, sp);
+    }
+
+    filepath << spl << "/" << host;
+
+    if (use_subdirs) {
+	filepath << "/" << digit01 << "/" << digit23;
     }
 
     /* full path to file */
-    spooler(sp,"/",filename, sp);
-    ret = spool_print(sp);
+    filepath << "/" << filename.str();
 
-    return ret;
+    return pstrdup(p, filepath.str().c_str());
 }
 
 /**
@@ -317,7 +314,9 @@
 
     /* if we're dealing w/ a resource, just get that element <res id='resource'/> inside <xdb/> */
     if (p->id->has_resource()) {
-	top = xmlnode_get_list_item(xmlnode_get_tags(top, spools(p->p, "res[@id='", p->id->get_resource().c_str(), "']", p->p), xf->std_ns_prefixes), 0);
+	std::ostringstream xpath;
+	xpath << "res[@id='" << p->id->get_resource() << "']";
+	top = xmlnode_get_list_item(xmlnode_get_tags(top, xpath.str().c_str(), xf->std_ns_prefixes), 0);
 	if (top == NULL) {
             top = xmlnode_insert_tag_ns(file, "res", NULL, NS_JABBERD_XDB);
             xmlnode_put_attrib_ns(top, "id", NULL, NULL, p->id->get_resource().c_str());
@@ -325,7 +324,9 @@
     }
 
     /* just query the relevant namespace */
-    data = xmlnode_get_list_item(xmlnode_get_tags(top, spools(p->p, "*[@xdbns='", ns, "']", p->p), xf->std_ns_prefixes), 0);
+    std::ostringstream xpath;
+    xpath << "*[@xdbns='" << ns << "']";
+    data = xmlnode_get_list_item(xmlnode_get_tags(top, xpath.str().c_str(), xf->std_ns_prefixes), 0);
 
     if (flag_set) {
 	act = xmlnode_get_attrib_ns(p->x, "action", NULL);
@@ -492,17 +493,17 @@
     DIR *sdir;
     struct dirent *dent;
     char digit01[3], digit23[3];
-    char *hostspool;
 
     /* get the dir location */
-    hostspool = spools(p, spoolroot, "/", host, p);
+    std::ostringstream hostspool;
+    hostspool << spoolroot << "/" << host;
 
-    log_notice(host, "trying to convert spool %s (this may take some time)", hostspool);
+    log_notice(host, "trying to convert spool %s (this may take some time)", hostspool.str().c_str());
 
     /* we have to convert the spool */
-    sdir = opendir(hostspool);
+    sdir = opendir(hostspool.str().c_str());
     if (sdir == NULL) {
-	log_error(host, "failed to open directory %s for conversion: %s", hostspool, strerror(errno));
+	log_error(host, "failed to open directory %s for conversion: %s", hostspool.str().c_str(), strerror(errno));
 	return;
     }
 
@@ -517,16 +518,17 @@
 
 	/* do we have to convert this file? */
 	if (j_strcmp(str_ptr, ".xml") == 0) {
-	    char *oldname, *newname;
 	    _xdb_get_hashes(dent->d_name, digit01, digit23);
 
-	    oldname = spools(p, hostspool, "/", dent->d_name, p);
-	    newname = spools(p, hostspool, "/", digit01, "/", digit23, "/", dent->d_name, p);
+	    std::ostringstream oldname;
+	    oldname << hostspool.str() << "/" << dent->d_name;
+	    std::ostringstream newname;
+	    newname << hostspool.str() << "/" << digit01 << "/" << digit23 << "/" << dent->d_name;
 
-	    if (!_xdb_gen_dirs(spool_new(p), spoolroot, host, digit01, digit23, 1))
+	    if (!_xdb_gen_dirs(spoolroot, host, digit01, digit23, 1))
 		log_error(host, "failed to create necessary directory for conversion");
-	    else if (rename(oldname, newname) < 0)
-		log_error(host, "failed to move %s to %s while converting spool: %s", oldname, newname, strerror(errno));
+	    else if (rename(oldname.str().c_str(), newname.str().c_str()) < 0)
+		log_error(host, "failed to move %s to %s while converting spool: %s", oldname.str().c_str(), newname.str().c_str(), strerror(errno));
 	}
     }
 
@@ -544,7 +546,6 @@
     DIR *sdir;
     struct dirent *dent;
     pool p;
-    char *flagfile;
     struct stat s;
     FILE *flagfileh;
 
@@ -552,8 +553,9 @@
     p = pool_new();
 
     /* check if we already converted this spool */
-    flagfile = spools(p, spoolroot, "/.hashspool", p);
-    if (stat(flagfile, &s) == 0) {
+    std::ostringstream flagfile;
+    flagfile << spoolroot << "/.hashspool";
+    if (stat(flagfile.str().c_str(), &s) == 0) {
 	log_debug2(ZONE, LOGT_STORAGE, "there is already a new hashspool");
 	pool_free(p);
 	return;
@@ -569,9 +571,10 @@
 
     while ((dent = readdir(sdir)) != NULL) {
 	struct stat s;
-	char *dirname = spools(p, spoolroot, "/", dent->d_name, p);
+	std::ostringstream dirname;
+	dirname << spoolroot << "/" << dent->d_name;
 
-	if (stat(dirname, &s)<0)
+	if (stat(dirname.str().c_str(), &s)<0)
 	    continue;
 
 	/* we only care about directories */
@@ -584,7 +587,7 @@
     closedir(sdir);
 
     /* write the flag that we converted the spool */
-    flagfileh = fopen(flagfile, "w");
+    flagfileh = fopen(flagfile.str().c_str(), "w");
     if (flagfileh != NULL) {
 	fwrite("Please do not delete this file.\n", 1, 32, flagfileh);
 	fclose(flagfileh);


More information about the dev mailing list