Przeglądaj źródła

Merge branch 'update-bdlib'

* update-bdlib:
  * Remove unused buffers from String::printf changes
  * Update String += to use required size_t
  * Update bd::String::printf syntax
  * Update Stream::gets() -> Stream::read()
  * Update bdlib
Bryan Drewery 15 lat temu
rodzic
commit
378f2962d0

+ 1 - 1
lib/bdlib

@@ -1 +1 @@
-Subproject commit 31a63ca04ea800d25b4b3a07aa2872e7dfa1e4fa
+Subproject commit d32981dd6d0a440ed1c5061b310a4fb23c1cd825

+ 2 - 2
src/botnet.c

@@ -658,7 +658,7 @@ void tell_bottree(int idx)
           else
             color_str = (char *) NULL;
 
-          s.printf("%c%s%s%s (%s)", bot->share ? bot->share : '-', color_str ? color_str : "",
+          s = bd::String::printf("%c%s%s%s (%s)", bot->share ? bot->share : '-', color_str ? color_str : "",
                                                 bot->bot,
                                                 color_str ? COLOR_END(idx) : "",
                                                 bot->version);
@@ -700,7 +700,7 @@ void tell_bottree(int idx)
                   color_str = (char *) NULL;
 
 		bot2 = bot;
-                s.printf("%c%s%s%s (%s)", bot->share ? bot->share : '-', color_str ? color_str : "",
+                s = bd::String::printf("%c%s%s%s (%s)", bot->share ? bot->share : '-', color_str ? color_str : "",
                                                       bot->bot,
                                                       color_str ? COLOR_END(idx) : "",
                                                       bot->version);

+ 1 - 1
src/cmds.c

@@ -3933,7 +3933,7 @@ static void cmd_netrelease (int idx, char* par) {
   // so instead, tell all bots to release the specified nick.
   // Any bots trying to get it will stop for 7 seconds, and any bot on it will release it.
   bd::String str;
-  str.printf("rn %s", par);
+  str = bd::String::printf("rn %s", par);
   putallbots(str.c_str());
 }
 

+ 18 - 19
src/conf.c

@@ -694,7 +694,6 @@ writeconf(char *filename, int fd, int bits)
   int autowrote = 0;
 
   bd::Stream* stream;
-  bd::String buf;
 
   if (bits & CONF_ENC) {
     const char salt1[] = SALT1;
@@ -704,7 +703,7 @@ writeconf(char *filename, int fd, int bits)
 
 #define comment(text)	do {		\
 	if (bits & CONF_COMMENT)	\
-	  *stream << buf.printf(STR("%s\n"), text);	\
+	  *stream << bd::String::printf(STR("%s\n"), text);	\
 } while(0)
 
   char *p = NULL;
@@ -721,26 +720,26 @@ writeconf(char *filename, int fd, int bits)
 
   if ((bits & CONF_COMMENT) && conf.uid != (signed) myuid) {
     conf_com();
-    *stream << buf.printf(STR("%s! uid %d\n"), do_confedit == CONF_AUTO ? "" : "#", myuid);
-    *stream << buf.printf(STR("%s! uid %d\n"), do_confedit == CONF_STATIC ? "" : "#", conf.uid);
+    *stream << bd::String::printf(STR("%s! uid %d\n"), do_confedit == CONF_AUTO ? "" : "#", myuid);
+    *stream << bd::String::printf(STR("%s! uid %d\n"), do_confedit == CONF_STATIC ? "" : "#", conf.uid);
   } else
-    *stream << buf.printf(STR("! uid %d\n"), conf.uid);
+    *stream << bd::String::printf(STR("! uid %d\n"), conf.uid);
 
   comment("");
 
   if (conf.username && my_username() && strcmp(conf.username, my_username())) {
     conf_com();
-    *stream << buf.printf(STR("%s! username %s\n"), do_confedit == CONF_AUTO ? "" : "#", my_username());
-    *stream << buf.printf(STR("%s! username %s\n"), do_confedit == CONF_STATIC ? "" : "#", conf.username);
+    *stream << bd::String::printf(STR("%s! username %s\n"), do_confedit == CONF_AUTO ? "" : "#", my_username());
+    *stream << bd::String::printf(STR("%s! username %s\n"), do_confedit == CONF_STATIC ? "" : "#", conf.username);
   } else
-    *stream << buf.printf(STR("! username %s\n"), conf.username ? conf.username : my_username() ? my_username() : "");
+    *stream << bd::String::printf(STR("! username %s\n"), conf.username ? conf.username : my_username() ? my_username() : "");
 
   if (conf.homedir && homedir(0) && strcmp(conf.homedir, homedir(0))) {
     conf_com();
-    *stream << buf.printf(STR("%s! homedir %s\n"), do_confedit == CONF_AUTO ? "" : "#", homedir(0));
-    *stream << buf.printf(STR("%s! homedir %s\n"), do_confedit == CONF_STATIC ? "" : "#", conf.homedir);
+    *stream << bd::String::printf(STR("%s! homedir %s\n"), do_confedit == CONF_AUTO ? "" : "#", homedir(0));
+    *stream << bd::String::printf(STR("%s! homedir %s\n"), do_confedit == CONF_STATIC ? "" : "#", conf.homedir);
   } else 
-    *stream << buf.printf(STR("! homedir %s\n"), conf.homedir ? conf.homedir : homedir(0) ? homedir(0) : "");
+    *stream << bd::String::printf(STR("! homedir %s\n"), conf.homedir ? conf.homedir : homedir(0) ? homedir(0) : "");
 
   comment("");
 
@@ -749,20 +748,20 @@ writeconf(char *filename, int fd, int bits)
 
     if (homedir() && strstr(conf.datadir, homedir())) {
       p = replace(conf.datadir, homedir(), "~");
-      *stream << buf.printf(STR("! datadir %s\n"), p);
+      *stream << bd::String::printf(STR("! datadir %s\n"), p);
     } else if (conf.homedir && strstr(conf.datadir, conf.homedir)) { /* Could be an older homedir */
       p = replace(conf.datadir, conf.homedir, "~");
-      *stream << buf.printf(STR("! datadir %s\n"), p);
+      *stream << bd::String::printf(STR("! datadir %s\n"), p);
     } else
-      *stream << buf.printf(STR("! datadir %s\n"), conf.datadir);
+      *stream << bd::String::printf(STR("! datadir %s\n"), conf.datadir);
 
     comment("");
   }
 
   if (conf.portmin || conf.portmax) {
     comment("# portmin/max are for incoming connections (DCC) [0 for any] (These only make sense for HUBS)");
-    *stream << buf.printf(STR("! portmin %d\n"), conf.portmin);
-    *stream << buf.printf(STR("! portmax %d\n"), conf.portmax);
+    *stream << bd::String::printf(STR("! portmin %d\n"), conf.portmin);
+    *stream << bd::String::printf(STR("! portmax %d\n"), conf.portmax);
 
     comment("");
   }
@@ -770,7 +769,7 @@ writeconf(char *filename, int fd, int bits)
 
   if (conf.autocron == 0) {
     comment("# Automatically add the bot to crontab?");
-    *stream << buf.printf(STR("! autocron %d\n"), conf.autocron);
+    *stream << bd::String::printf(STR("! autocron %d\n"), conf.autocron);
 
     comment("");
   }
@@ -787,12 +786,12 @@ writeconf(char *filename, int fd, int bits)
   comment("### Hubs should have their own binary ###");
 
   for (bot = conf.bots; bot && bot->nick; bot = bot->next) {
-    *stream << buf.printf(STR("%s%s %s %s%s"),
+    *stream << bd::String::printf(STR("%s%s %s %s%s"),
              bot->disabled ? "/" : "", bot->nick,
              bot->net.ip ? bot->net.ip : "*", bot->net.host6 ? "+" : "",
              bot->net.host ? bot->net.host : (bot->net.host6 ? bot->net.host6 : "*"));
     if (bot->net.ip6)
-      *stream << buf.printf(STR(" %s"), bot->net.ip6 ? bot->net.ip6 : "");
+      *stream << bd::String::printf(STR(" %s"), bot->net.ip6 ? bot->net.ip6 : "");
     *stream << "\n";
   }
 

+ 11 - 11
src/dccutil.c

@@ -556,24 +556,24 @@ dcc_write(bd::Stream &stream, int idx)
   if (dcc[idx].sock > 0) {
     bd::String buf;
 
-    stream << buf.printf(STR("-dcc\n"));
+    stream << bd::String::printf(STR("-dcc\n"));
     if (dcc[idx].type)
-      stream << buf.printf(STR("type %s\n"), dcc[idx].type->name);
+      stream << bd::String::printf(STR("type %s\n"), dcc[idx].type->name);
 //  if (user)
-//  stream << buf.printf(STR("user %s\n"), dcc[idx].user->handle);
+//  stream << bd::String::printf(STR("user %s\n"), dcc[idx].user->handle);
     if (dcc[idx].addr)
-      stream << buf.printf(STR("addr %u\n"), dcc[idx].addr);
+      stream << bd::String::printf(STR("addr %u\n"), dcc[idx].addr);
     if (dcc[idx].status)
-      stream << buf.printf(STR("status %lu\n"), dcc[idx].status);
-    stream << buf.printf(STR("sock %d\n"), dcc[idx].sock);
-//  stream << buf.printf(STR("simul %d\n"), dcc[idx].simul);
+      stream << bd::String::printf(STR("status %lu\n"), dcc[idx].status);
+    stream << bd::String::printf(STR("sock %d\n"), dcc[idx].sock);
+//  stream << bd::String::printf(STR("simul %d\n"), dcc[idx].simul);
     if (dcc[idx].port)
-      stream << buf.printf(STR("port %d\n"), dcc[idx].port);
+      stream << bd::String::printf(STR("port %d\n"), dcc[idx].port);
     if (dcc[idx].nick[0])
-      stream << buf.printf(STR("nick %s\n"), dcc[idx].nick);
+      stream << bd::String::printf(STR("nick %s\n"), dcc[idx].nick);
     if (dcc[idx].host[0])
-      stream << buf.printf(STR("host %s\n"), dcc[idx].host);
-    stream << buf.printf(STR("+dcc\n"));
+      stream << bd::String::printf(STR("host %s\n"), dcc[idx].host);
+    stream << bd::String::printf(STR("+dcc\n"));
   }
 }
 

+ 1 - 1
src/log.c

@@ -348,7 +348,7 @@ irc_log(struct chanset_t *chan, const char *format, ...)
 
   if ((chan && strcasecmp(chan->dname, relay_chan)) || !chan) {
     bd::String msg;
-    msg.printf("[%s] %s", chan ? chan->dname : "*" , va_out);
+    msg = bd::String::printf("[%s] %s", chan ? chan->dname : "*" , va_out);
     privmsg(relay_chan, msg.c_str(), DP_HELP);
   }
 /*

+ 3 - 3
src/makehelp.c

@@ -34,7 +34,7 @@ int parse_help(bd::String infile, bd::String outfile) {
 
   in.loadFile(infile);
   printf("Parsing help file '%s'", infile.c_str());
-  out <<  buf.printf("/* DO NOT EDIT THIS FILE, EDIT doc/help.txt INSTEAD */\n#ifndef HELP_H\n\
+  out <<  bd::String::printf("/* DO NOT EDIT THIS FILE, EDIT doc/help.txt INSTEAD */\n#ifndef HELP_H\n\
 #define HELP_H\n\
 #include \"cmds.h\"\n\
 \n\
@@ -79,12 +79,12 @@ help_t help[] = \n\
         printf(".");
         if ((pos = cmd.find(':')) != bd::String::npos)
           cmd = cmd(0, pos);
-        out << buf.printf("  {%d, \"%s\", 0, \"", type(dohub, doleaf), cmd.c_str());
+        out << bd::String::printf("  {%d, \"%s\", 0, \"", type(dohub, doleaf), cmd.c_str());
       } else {			/* END */
         out << "  {0, NULL, 0, NULL}\n};\n";
       }
     } else {				/* CMD HELP INFO */
-      out << buf.printf("%s\\n", buffer.sub("\"", "\\\"").c_str());
+      out << bd::String::printf("%s\\n", buffer.sub("\"", "\\\"").c_str());
     }
   }
   out << "#endif /* HELP_H */\n";

+ 11 - 11
src/makeres.c

@@ -34,14 +34,14 @@ int parse_res(const bd::String& inFile, const bd::String& outFile, const bd::Str
   in.loadFile(inFile);
   printf("Parsing res file '%s'", inFile.c_str());
 
-  out << buf.printf( "/* DO NOT EDIT THIS FILE. */\n\
+  out << bd::String::printf( "/* DO NOT EDIT THIS FILE. */\n\
 #ifndef _RESPONSE_H\n\
 #define _RESPONSE_H\n\
 \n\
 typedef unsigned int response_t;\n\n\
 enum {\n");
 
-  outs << buf.printf("/* DO NOT EDIT THIS FILE. */\n\
+  outs << bd::String::printf("/* DO NOT EDIT THIS FILE. */\n\
 #ifndef _RESPONSES_H\n\
 #define _RESPONSES_H\n\
 \n\
@@ -64,19 +64,19 @@ typedef const char * res_t;\n\n");
 
         bd::String cmdUpper(cmd);
         std::transform(cmdUpper.begin(), cmdUpper.end(), cmdUpper.mdata(), (int(*)(int)) toupper);
-        out << buf.printf("\tRES_%s", cmdUpper.c_str());
+        out << bd::String::printf("\tRES_%s", cmdUpper.c_str());
         if (total_responses == 1)
           out << " = 1";
-        outs << buf.printf("static res_t res_%s[] = {\n", cmd.c_str());
-        lower_resps += buf.printf(",\n\tres_%s", cmd.c_str());
+        outs << bd::String::printf("static res_t res_%s[] = {\n", cmd.c_str());
+        lower_resps += bd::String::printf(",\n\tres_%s", cmd.c_str());
       } else {			/* END */
-        out << buf.printf("\tRES_END\n};\n\n#define RES_TYPES %d\n", total_responses);
-        out << buf.printf("const char *response(response_t);\nvoid init_responses();\nconst char *r_banned(struct chanset_t* chan);\n\n#endif /* !_RESPONSE_H */\n");
-        outs << buf.printf("static res_t *res[] = {\n\tNULL%s\n};\n#endif /* !_RESPONSES_H */\n", lower_resps.c_str());
+        out << bd::String::printf("\tRES_END\n};\n\n#define RES_TYPES %d\n", total_responses);
+        out << bd::String::printf("const char *response(response_t);\nvoid init_responses();\nconst char *r_banned(struct chanset_t* chan);\n\n#endif /* !_RESPONSE_H */\n");
+        outs << bd::String::printf("static res_t *res[] = {\n\tNULL%s\n};\n#endif /* !_RESPONSES_H */\n", lower_resps.c_str());
       }
     } else {				/* NEXT RES TEXT */
       ++buffer;
-      outs << buf.printf("\t\"%s\",\n", buffer.c_str());
+      outs << bd::String::printf("\t\"%s\",\n", buffer.c_str());
     }
   }
 
@@ -100,7 +100,7 @@ int main(int argc, char **argv) {
 
   bd::String in(argv[1]), out, outs;
 
-  out.printf("%s/response.h%s", argv[2], argc == 4 ? "~" : "");
-  outs.printf("%s/responses.h%s", argv[2], argc == 4 ? "~" : "");
+  out = bd::String::printf("%s/response.h%s", argv[2], argc == 4 ? "~" : "");
+  outs = bd::String::printf("%s/responses.h%s", argv[2], argc == 4 ? "~" : "");
   return parse_res(in, out, outs);
 }

+ 15 - 17
src/misc.c

@@ -784,36 +784,34 @@ restart(int idx)
     if (socklist[fd].sock != STDOUT)
       sock_write(stream, fd);
 
-  bd::String buf;
-
   if (server_online) {
     if (botname[0])
-      stream << buf.printf(STR("+botname %s\n"), botname);
+      stream << bd::String::printf(STR("+botname %s\n"), botname);
     if (rolls)
-      stream << buf.printf(STR("+rolls %d\n"), rolls);
+      stream << bd::String::printf(STR("+rolls %d\n"), rolls);
     if (altnick_char)
-      stream << buf.printf(STR("+altnick_char %c\n"), altnick_char);
+      stream << bd::String::printf(STR("+altnick_char %c\n"), altnick_char);
     if (burst)
-      stream << buf.printf(STR("+burst %d\n"), burst);
+      stream << bd::String::printf(STR("+burst %d\n"), burst);
     if (flood_count)
-      stream << buf.printf(STR("+flood_count %d\n"), flood_count);
+      stream << bd::String::printf(STR("+flood_count %d\n"), flood_count);
     if (my_cookie_counter)
-      stream << buf.printf(STR("+my_cookie_counter %lu\n"), my_cookie_counter);
-    stream << buf.printf(STR("+server_online %li\n"), server_online);
+      stream << bd::String::printf(STR("+my_cookie_counter %lu\n"), my_cookie_counter);
+    stream << bd::String::printf(STR("+server_online %li\n"), server_online);
   }
-  stream << buf.printf(STR("+online_since %li\n"), online_since);
+  stream << bd::String::printf(STR("+online_since %li\n"), online_since);
   if (floodless)
-    stream << buf.printf(STR("+server_floodless %d\n"), floodless);
+    stream << bd::String::printf(STR("+server_floodless %d\n"), floodless);
   if (in_deaf)
-    stream << buf.printf(STR("+in_deaf\n"));
+    stream << bd::String::printf(STR("+in_deaf\n"));
   if (in_callerid)
-    stream << buf.printf(STR("+in_callerid\n"));
+    stream << bd::String::printf(STR("+in_callerid\n"));
   for (struct chanset_t *chan = chanset; chan; chan = chan->next)
     if (shouldjoin(chan) && (channel_active(chan) || channel_pending(chan)))
-      stream << buf.printf(STR("+chan %s\n"), chan->dname);
-  stream << buf.printf(STR("+buildts %li\n"), buildts);
-  stream << buf.printf(STR("+ip4 %s\n"), myipstr(AF_INET));
-  stream << buf.printf(STR("+ip6 %s\n"), myipstr(AF_INET6));
+      stream << bd::String::printf(STR("+chan %s\n"), chan->dname);
+  stream << bd::String::printf(STR("+buildts %li\n"), buildts);
+  stream << bd::String::printf(STR("+ip4 %s\n"), myipstr(AF_INET));
+  stream << bd::String::printf(STR("+ip6 %s\n"), myipstr(AF_INET6));
   replay_cache(-1, &stream);
 
   stream.writeFile(socks->fd);

+ 21 - 34
src/mod/channels.mod/userchan.c

@@ -572,16 +572,15 @@ static void tell_masks(const char type, int idx, bool show_inact, char *match, b
  */
 void write_bans(bd::Stream& stream, int idx)
 {
-  bd::String buf;
   if (global_ign)
-    stream << buf.printf(IGNORE_NAME " - -\n");
+    stream << bd::String::printf(IGNORE_NAME " - -\n");
 
   char *mask = NULL;
 
   for (struct igrec *i = global_ign; i; i = i->next) {
     mask = str_escape(i->igmask, ':', '\\');
     if (mask) {
-	stream << buf.printf("- %s:%s%li:%s:%li:%s\n", mask,
+	stream << bd::String::printf("- %s:%s%li:%s:%li:%s\n", mask,
 		(i->flags & IGREC_PERM) ? "+" : "", (long) i->expire,
 		i->user ? i->user : conf.bot->nick, (long) i->added,
 		i->msg ? i->msg : "");
@@ -589,14 +588,14 @@ void write_bans(bd::Stream& stream, int idx)
     }
   }
   if (global_bans)
-    stream << buf.printf(BAN_NAME " - -\n");
+    stream << bd::String::printf(BAN_NAME " - -\n");
 
   maskrec *b = NULL;
 
   for (b = global_bans; b; b = b->next) {
     mask = str_escape(b->mask, ':', '\\');
     if (mask) {
-	stream << buf.printf("- %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+	stream << bd::String::printf("- %s:%s%li%s:+%li:%li:%s:%s\n", mask,
 		(b->flags & MASKREC_PERM) ? "+" : "", (long) b->expire,
 		(b->flags & MASKREC_STICKY) ? "*" : "", (long) b->added,
 		(long) b->lastactive, b->user ? b->user : conf.bot->nick,
@@ -605,12 +604,12 @@ void write_bans(bd::Stream& stream, int idx)
     }
   }
   for (struct chanset_t *chan = chanset; chan; chan = chan->next) {
-    stream << buf.printf("::%s bans\n", chan->dname);
+    stream << bd::String::printf("::%s bans\n", chan->dname);
 
     for (b = chan->bans; b; b = b->next) {
       mask = str_escape(b->mask, ':', '\\');
       if (mask) {
-        stream << buf.printf("- %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+        stream << bd::String::printf("- %s:%s%li%s:+%li:%li:%s:%s\n", mask,
 	        (b->flags & MASKREC_PERM) ? "+" : "", (long) b->expire,
 	        (b->flags & MASKREC_STICKY) ? "*" : "", (long) b->added,
 	        (long) b->lastactive, b->user ? b->user : conf.bot->nick,
@@ -624,10 +623,8 @@ void write_bans(bd::Stream& stream, int idx)
  */
 void write_exempts(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   if (global_exempts)
-    stream << buf.printf(EXEMPT_NAME " - -\n");
+    stream << bd::String::printf(EXEMPT_NAME " - -\n");
 
   maskrec *e = NULL;
   char *mask = NULL;
@@ -635,7 +632,7 @@ void write_exempts(bd::Stream& stream, int idx)
   for (e = global_exempts; e; e = e->next) {
     mask = str_escape(e->mask, ':', '\\');
     if (mask) {
-        stream << buf.printf("%s %s:%s%li%s:+%li:%li:%s:%s\n", "%", mask,
+        stream << bd::String::printf("%s %s:%s%li%s:+%li:%li:%s:%s\n", "%", mask,
 		(e->flags & MASKREC_PERM) ? "+" : "", (long) e->expire,
 		(e->flags & MASKREC_STICKY) ? "*" : "", (long) e->added,
 		(long) e->lastactive, e->user ? e->user : conf.bot->nick,
@@ -644,11 +641,11 @@ void write_exempts(bd::Stream& stream, int idx)
     }
   }
   for (struct chanset_t *chan = chanset;chan ;chan = chan->next) {
-    stream << buf.printf("&&%s exempts\n", chan->dname);
+    stream << bd::String::printf("&&%s exempts\n", chan->dname);
     for (e = chan->exempts; e; e = e->next) {
       mask = str_escape(e->mask, ':', '\\');
       if (mask) {
-	stream << buf.printf("%s %s:%s%li%s:+%li:%li:%s:%s\n","%", mask,
+	stream << bd::String::printf("%s %s:%s%li%s:+%li:%li:%s:%s\n","%", mask,
 		(e->flags & MASKREC_PERM) ? "+" : "", (long) e->expire,
 		(e->flags & MASKREC_STICKY) ? "*" : "", (long) e->added,
 		(long) e->lastactive, e->user ? e->user : conf.bot->nick,
@@ -663,10 +660,8 @@ void write_exempts(bd::Stream& stream, int idx)
  */
 void write_invites(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   if (global_invites)
-    stream << buf.printf(INVITE_NAME " - -\n");
+    stream << bd::String::printf(INVITE_NAME " - -\n");
 
   maskrec *ir = NULL;
   char *mask = NULL;
@@ -674,7 +669,7 @@ void write_invites(bd::Stream& stream, int idx)
   for (ir = global_invites; ir; ir = ir->next)  {
     mask = str_escape(ir->mask, ':', '\\');
     if (mask) {
-      stream << buf.printf("@ %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+      stream << bd::String::printf("@ %s:%s%li%s:+%li:%li:%s:%s\n", mask,
 		(ir->flags & MASKREC_PERM) ? "+" : "", (long) ir->expire,
 		(ir->flags & MASKREC_STICKY) ? "*" : "", (long) ir->added,
 		(long) ir->lastactive, ir->user ? ir->user : conf.bot->nick,
@@ -683,12 +678,12 @@ void write_invites(bd::Stream& stream, int idx)
     }
   }
   for (struct chanset_t *chan = chanset; chan; chan = chan->next) {
-    stream << buf.printf("$$%s invites\n", chan->dname);
+    stream << bd::String::printf("$$%s invites\n", chan->dname);
 
     for (ir = chan->invites; ir; ir = ir->next) {
       mask = str_escape(ir->mask, ':', '\\');
       if (mask) {
-        stream << buf.printf("@ %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+        stream << bd::String::printf("@ %s:%s%li%s:+%li:%li:%s:%s\n", mask,
 		      (ir->flags & MASKREC_PERM) ? "+" : "", (long) ir->expire,
 		      (ir->flags & MASKREC_STICKY) ? "*" : "", (long) ir->added,
 		      (long) ir->lastactive, ir->user ? ir->user : conf.bot->nick,
@@ -703,8 +698,6 @@ void write_invites(bd::Stream& stream, int idx)
  */
 static void write_chan(bd::Stream& stream, int idx, struct chanset_t* chan)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "*", "writing channel %s to userfile..", chan->dname);
 
   bool force_inactive = 0;
@@ -712,19 +705,18 @@ static void write_chan(bd::Stream& stream, int idx, struct chanset_t* chan)
   if (idx >= 0 && !botshouldjoin(dcc[idx].user, chan))
     force_inactive = 1;
 
-  stream << buf.printf("+ channel add %s { ", chan->dname);
+  stream << bd::String::printf("+ channel add %s { ", chan->dname);
   if (chan != chanset_default)
-    stream << buf.printf("addedby %s addedts %li ", chan->added_by, (long)chan->added_ts);
+    stream << bd::String::printf("addedby %s addedts %li ", chan->added_by, (long)chan->added_ts);
   stream << channel_to_string(chan, force_inactive);
-  stream << buf.printf("}\n");
+  stream << bd::String::printf("}\n");
 }
 
 bd::String channel_to_string(struct chanset_t* chan, bool force_inactive) {
-  bd::String buf;
   char w[1024] = "";
 
   get_mode_protect(chan, w, sizeof(w));
-  buf.printf("\
+  return bd::String::printf("\
 chanmode { %s } bad-cookie %d manop %d mdop %d mop %d limit %d ban-type %d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
@@ -799,18 +791,15 @@ flood-exempt %d flood-lock-time %d knock %d \
  *      PLSMNS(channel_temp(chan)),
  */
   );
-  return buf;
 }
 
 /* Write the channels to the userfile
  */
 void write_chans(bd::Stream& stream, int idx, bool old)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
-  stream << buf.printf(CHANS_NAME " - -\n");
+  stream << bd::String::printf(CHANS_NAME " - -\n");
 
   /* FIXME: Remove after 1.2.15 */
   if (!old)
@@ -824,11 +813,9 @@ void write_chans(bd::Stream& stream, int idx, bool old)
  */
 void write_chans_compat(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
-  stream << buf.printf(CHANS_NAME " - -\n");
+  stream << bd::String::printf(CHANS_NAME " - -\n");
 
   char w[1024] = "";
 
@@ -845,7 +832,7 @@ void write_chans_compat(bd::Stream& stream, int idx)
     else
       inactive = PLSMNS(channel_inactive(chan));
 
-    stream << buf.printf("\
+    stream << bd::String::printf("\
 + channel add %s { chanmode { %s } addedby %s addedts %li \
 bad-cookie %d manop %d mdop %d mop %d limit %d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \

+ 1 - 2
src/mod/console.mod/console.c

@@ -108,9 +108,8 @@ console_write_userfile(bd::Stream& stream, const struct userrec *u, const struct
     return;
 
   struct console_info *i = (struct console_info *) e->u.extra;
-  bd::String buf;
 
-  stream << buf.printf("--CONSOLE %s %s %s %d %d %d %d %d %d %d %d\n",
+  stream << bd::String::printf("--CONSOLE %s %s %s %d %d %d %d %d %d %d %d\n",
                i->channel, masktype(i->conflags),
                stripmasktype(i->stripflags), i->echoflags,
                i->page, i->conchan, i->color, i->banner, i->channels, i->bots, i->whom);

+ 14 - 14
src/mod/ctcp.mod/ctcp.c

@@ -405,7 +405,7 @@ static int ctcp_FINGER(char *nick, char *uhost, struct userrec *u, char *object,
   else if (cloak_heretime)
     idletime = now - cloak_heretime;
   bd::String msg;
-  msg.printf("\001%s %s (%s) Idle %d second%s\001", keyword, "",
+  msg = bd::String::printf("\001%s %s (%s) Idle %d second%s\001", keyword, "",
                    botuserhost, (int) idletime, idletime == 1 ? "" : "s");
   notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
@@ -417,7 +417,7 @@ static int ctcp_ECHO(char *nick, char *uhost, struct userrec *u, char *object, c
 
   strlcpy(reply, text, sizeof(reply));
   bd::String msg;
-  msg.printf("\001%s %s\001", keyword, reply);
+  msg = bd::String::printf("\001%s %s\001", keyword, reply);
   notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
@@ -425,7 +425,7 @@ static int ctcp_PING(char *nick, char *uhost, struct userrec *u, char *object, c
 {
   if (strlen(text) <= 80) {       /* bitchx ignores > 80 */
     bd::String msg;
-    msg.printf("\001%s %s\001", keyword, text);
+    msg = bd::String::printf("\001%s %s\001", keyword, text);
     notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
@@ -475,11 +475,11 @@ static int ctcp_VERSION(char *nick, char *uhost, struct userrec *u, char *object
   }
 
   bd::String msg;
-  msg.printf("\001%s %s%s\001", keyword, ctcpversion, s);
+  msg = bd::String::printf("\001%s %s%s\001", keyword, ctcpversion, s);
   notice(nick, msg.c_str(), queue);
 
   if (ctcpversion2[0]) {
-    msg.printf("\001%s %s\001", keyword, ctcpversion2);
+    msg = bd::String::printf("\001%s %s\001", keyword, ctcpversion2);
     notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
@@ -489,7 +489,7 @@ static int ctcp_WHOAMI(char *nick, char *uhost, struct userrec *u, char *object,
 {
   if (cloak_script > 0 && cloak_script < 9) {
     bd::String msg;
-    msg.printf("\002BitchX\002: Access Denied");
+    msg = bd::String::printf("\002BitchX\002: Access Denied");
     notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
@@ -505,7 +505,7 @@ static int ctcp_OP(char *nick, char *uhost, struct userrec *u, char *object, cha
     if (p)
       *p = 0;
     bd::String msg;
-    msg.printf("\002BitchX\002: I'm not on %s or I'm not opped", chan);
+    msg = bd::String::printf("\002BitchX\002: I'm not on %s or I'm not opped", chan);
     notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
@@ -525,14 +525,14 @@ static int ctcp_INVITE_UNBAN(char *nick, char *uhost, struct userrec *u, char *o
     while (chan) {
       if (chan->ircnet_status & CHAN_ACTIVE) {
         if (!strcasecmp(chan->name, chname)) {
-          msg.printf("\002BitchX\002: Access Denied");
+          msg = bd::String::printf("\002BitchX\002: Access Denied");
           notice(nick, msg.c_str(), DP_HELP);
           return BIND_RET_LOG;
         }
       }
       chan = chan->next;
     }
-    msg.printf("\002BitchX\002: I'm not on that channel");
+    msg = bd::String::printf("\002BitchX\002: I'm not on that channel");
     notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
@@ -547,7 +547,7 @@ static int ctcp_USERINFO(char *nick, char *uhost, struct userrec *u, char *objec
     strlcat(ctcpuserinfo, " ?", sizeof(ctcpuserinfo));
   }
   bd::String msg;
-  msg.printf("\001%s %s\001", keyword, ctcpuserinfo);
+  msg = bd::String::printf("\001%s %s\001", keyword, ctcpuserinfo);
   notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
@@ -609,11 +609,11 @@ static int ctcp_CLIENTINFO(char *nick, char *uhost, struct userrec *u, char *obj
   else if (!strcasecmp(text, "UPTIME"))
     strlcpy(buf, "UPTIME my uptime", sizeof(buf));
   else {
-    msg.printf("\001ERRMSG %s is not a valid function\001", text);
+    msg = bd::String::printf("\001ERRMSG %s is not a valid function\001", text);
     notice(nick, msg.c_str(), DP_HELP);
     return BIND_RET_LOG;
   }
-  msg.printf("\001%s %s\001", keyword, buf);
+  msg = bd::String::printf("\001%s %s\001", keyword, buf);
   notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
@@ -624,7 +624,7 @@ static int ctcp_TIME(char *nick, char *uhost, struct userrec *u, char *object, c
 
   strlcpy(tms, ctime(&now), sizeof(tms));
   bd::String msg;
-  msg.printf("\001%s %s\001", keyword, tms);
+  msg = bd::String::printf("\001%s %s\001", keyword, tms);
   notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
@@ -658,7 +658,7 @@ static int ctcp_CHAT(char *nick, char *uhost, struct userrec *u, char *object, c
        * CTCP replies are NOTICE's this has to be a PRIVMSG
        * -poptix 5/1/1997 */
       bd::String msg;
-      msg.printf("\001DCC CHAT chat %lu %u\001", iptolong(getmyip()), dcc[ix].port);
+      msg = bd::String::printf("\001DCC CHAT chat %lu %u\001", iptolong(getmyip()), dcc[ix].port);
       privmsg(nick, msg.c_str(), DP_SERVER);
     }
     return BIND_RET_BREAK;

+ 1 - 1
src/mod/irc.mod/chan.c

@@ -1667,7 +1667,7 @@ static int got341(char *from, char *msg)
   }
   putlog(LOG_MISC, "*", "HIJACKED invite detected: %s to %s", nick, chan->dname);
   bd::String msg;
-  msg.printf("ALERT! \002%s was invited via a hijacked connection/process.\002", nick);
+  msg = bd::String::printf("ALERT! \002%s was invited via a hijacked connection/process.\002", nick);
   privmsg(chan->name, msg.c_str(), DP_MODE_NEXT);
   return 0;
 }

+ 2 - 2
src/mod/irc.mod/cmdsirc.c

@@ -120,7 +120,7 @@ static void cmd_act(int idx, char *par)
   putlog(LOG_CMDS, "*", "#%s# (%s) act %s", dcc[idx].nick,
 	 chan->dname, par);
   bd::String msg;
-  msg.printf("\001ACTION %s\001", par);
+  msg = bd::String::printf("\001ACTION %s\001", par);
   privmsg(chan->name, msg.c_str(), DP_HELP);
   dprintf(idx, "Action to %s: %s\n", chan->dname, par);
 }
@@ -1761,7 +1761,7 @@ static void cmd_adduser(int idx, char *par)
     dprintf(idx, "%s's initial secpass set to \002%s\002\n", hand, s3);
 
     bd::String msg;
-    msg.printf("*** You've been add to this botnet as '%s' with the host '%s'. Ask a botnet admin for the msg cmds. Your initial password is: %s", hand, p1, s2);
+    msg = bd::String::printf("*** You've been add to this botnet as '%s' with the host '%s'. Ask a botnet admin for the msg cmds. Your initial password is: %s", hand, p1, s2);
     privmsg(nick, msg.c_str(), DP_HELP);
   } else {
     dprintf(idx, "Added hostmask %s to %s.\n", p1, u->handle);

+ 1 - 1
src/mod/irc.mod/irc.c

@@ -199,7 +199,7 @@ void notice_invite(struct chanset_t *chan, char *handle, char *nick, char *uhost
     simple_snprintf(fhandle, sizeof(fhandle), "\002%s\002 ", handle);
   putlog(LOG_MISC, "*", "Invited %s%s(%s%s%s) to %s.", handle ? handle : "", handle ? " " : "", nick, uhost ? "!" : "", uhost ? uhost : "", chan->dname);
   bd::String msg;
-  msg.printf("\001ACTION has invited %s(%s%s%s) to %s.%s\001",
+  msg = bd::String::printf("\001ACTION has invited %s(%s%s%s) to %s.%s\001",
     fhandle, nick, uhost ? "!" : "", uhost ? uhost : "", chan->dname, op ? ops : "");
   privmsg(chan->name, msg.c_str(), DP_MODE);
 }

+ 15 - 15
src/mod/irc.mod/msgcmds.c

@@ -43,7 +43,7 @@ static int msg_bewm(char *nick, char *host, struct userrec *u, char *par)
   bd::String msg;
 
   if (!u) {
-    msg.printf(STR("---- (%s!%s) attempted to gain secure invite, but is not a recognized user."), nick, host);
+    msg = bd::String::printf(STR("---- (%s!%s) attempted to gain secure invite, but is not a recognized user."), nick, host);
     privmsg(chan->name, msg.c_str(), DP_SERVER);
 
     putlog(LOG_CMDS, "*", STR("(%s!%s) !*! BEWM"), nick, host);
@@ -58,12 +58,12 @@ static int msg_bewm(char *nick, char *host, struct userrec *u, char *par)
 
   if (!chk_op(fr, chan))  {
     putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! !BEWM"), nick, host, u->handle);
-    msg.printf(STR("---- %s (%s!%s) attempted to gain secure invite, but is missing a flag."), u->handle, nick, host);
+    msg = bd::String::printf(STR("---- %s (%s!%s) attempted to gain secure invite, but is missing a flag."), u->handle, nick, host);
     privmsg(chan->name, msg.c_str(), DP_SERVER);
     return BIND_RET_BREAK;
   }
 
-  msg.printf("\001ACTION has invited \002%s\002 (%s!%s) to %s.\001", u->handle, nick, host, chan->dname);
+  msg = bd::String::printf("\001ACTION has invited \002%s\002 (%s!%s) to %s.\001", u->handle, nick, host, chan->dname);
   privmsg(chan->name, msg.c_str(), DP_SERVER);
 
   cache_invite(chan, nick, host, u->handle, 0, 0);
@@ -117,7 +117,7 @@ static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
 
   set_user(&USERENTRY_PASS, u, mynew);
   bd::String msg;
-  msg.printf("%s '%s'.", mynew == old ? "Password set to:" : "Password changed to:", mynew);
+  msg = bd::String::printf("%s '%s'.", mynew == old ? "Password set to:" : "Password changed to:", mynew);
   notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
@@ -142,9 +142,9 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
     if (hchan && channel_active(hchan) && !ismember(hchan, nick)) {
       putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP %s (not in %s)", nick, host, par, homechan);
       if (par[0]) 
-        msg.printf("---- (%s!%s) attempted to OP for %s but is not currently in %s.", nick, host, par, homechan);
+        msg = bd::String::printf("---- (%s!%s) attempted to OP for %s but is not currently in %s.", nick, host, par, homechan);
       else
-        msg.printf("---- (%s!%s) attempted to OP but is not currently in %s.", nick, host, homechan);
+        msg = bd::String::printf("---- (%s!%s) attempted to OP but is not currently in %s.", nick, host, homechan);
       privmsg(homechan, msg.c_str(), DP_SERVER);
       return BIND_RET_BREAK;
     }
@@ -161,7 +161,7 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
               stats_add(u, 0, 1);
               putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP %s", nick, host, u->handle, par);
               if (manop_warn && chan->manop) {
-                msg.printf("%s is currently set to punish for manual op.", chan->dname);
+                msg = bd::String::printf("%s is currently set to punish for manual op.", chan->dname);
                 notice(nick, msg.c_str(), DP_HELP);
               }
             }
@@ -176,7 +176,7 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
             if (do_op(nick, chan, 0, 1)) {
               stats++;
               if (manop_warn && chan->manop) {
-                msg.printf("%s is currently set to punish for manual op.", chan->dname);
+                msg = bd::String::printf("%s is currently set to punish for manual op.", chan->dname);
                 notice(nick, msg.c_str(), DP_HELP);
               }
             }
@@ -220,14 +220,14 @@ static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
       notice(nick, "I recognize you there.", DP_HELP);
       return BIND_RET_BREAK;
     } else if (u) {
-      msg.printf("You're not %s, you're %s.", who, u->handle);
+      msg = bd::String::printf("You're not %s, you're %s.", who, u->handle);
       notice(nick, msg.c_str(), DP_HELP);
       return BIND_RET_BREAK;
     } else {
       putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
       simple_snprintf(s, sizeof s, "%s!%s", nick, host);
       maskaddr(s, s1, 0); /* *!user@host */
-      msg.printf("Added hostmask: %s", s1);
+      msg = bd::String::printf("Added hostmask: %s", s1);
       notice(nick, msg.c_str(), DP_HELP);
       addhost_by_handle(who, s1);
       check_this_user(who, 0, NULL);
@@ -261,12 +261,12 @@ static int msg_invite(char *nick, char *host, struct userrec *u, char *par)
     }
     bd::String msg;
     if (!(chan = findchan_by_dname(par))) {
-      msg.printf("Usage: /MSG %s %s <pass> <channel>", botname, msginvite);
+      msg = bd::String::printf("Usage: /MSG %s %s <pass> <channel>", botname, msginvite);
       notice(nick, msg.c_str(), DP_HELP);
       return BIND_RET_BREAK;
     }
     if (!channel_active(chan)) {
-      msg.printf("%s: Not on that channel right now.", par);
+      msg = bd::String::printf("%s: Not on that channel right now.", par);
       notice(nick, msg.c_str(), DP_HELP);
       return BIND_RET_BREAK;
     }
@@ -320,7 +320,7 @@ static int msg_authstart(char *nick, char *host, struct userrec *u, char *par)
   /* Send "auth." if they are recognized, otherwise "auth!" */
   auth->Status(AUTH_PASS);
   bd::String msg;
-  msg.printf(STR("auth%s %s"), u ? "." : "!", conf.bot->nick);
+  msg = bd::String::printf(STR("auth%s %s"), u ? "." : "!", conf.bot->nick);
   privmsg(nick, msg.c_str(), DP_HELP);
 
   return BIND_RET_BREAK;
@@ -332,7 +332,7 @@ AuthFinish(Auth *auth)
   putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! +AUTH"), auth->nick, auth->host, auth->handle);
   auth->Done();
   bd::String msg;
-  msg.printf(STR("You are now authorized for cmds, see %chelp"), auth_prefix[0]);
+  msg = bd::String::printf(STR("You are now authorized for cmds, see %chelp"), auth_prefix[0]);
   notice(auth->nick, msg.c_str(), DP_HELP);
 }
 
@@ -359,7 +359,7 @@ static int msg_auth(char *nick, char *host, struct userrec *u, char *par)
       auth->Status(AUTH_HASH);
       auth->MakeHash();
       bd::String msg;
-      msg.printf(STR("-Auth %s %s"), auth->rand, conf.bot->nick);
+      msg = bd::String::printf(STR("-Auth %s %s"), auth->rand, conf.bot->nick);
       privmsg(nick, msg.c_str(), DP_HELP);
     } else {
       /* no auth_key and/or no SECPASS for the user, don't require a hash auth */

+ 1 - 2
src/mod/server.mod/server.c

@@ -510,8 +510,7 @@ void replay_cache(int idx, bd::Stream* stream) {
 
   for (r = cacheq.head; r; r = r->next) {
     if (stream) {
-      bd::String buf;
-      *stream << buf.printf(STR("+serv_cache %s\n"), r->msg);
+      *stream << bd::String::printf(STR("+serv_cache %s\n"), r->msg);
     } else {
       //Create temporary buffer since server_activity may squash the buffer
       p_ptr = p = strdup(r->msg);

+ 1 - 1
src/mod/transfer.mod/transfer.c

@@ -751,7 +751,7 @@ static void dcc_get_pending(int idx, char *buf, int len)
   dcc[idx].port = (int) port;
   if (dcc[idx].sock == -1) {
     bd::String msg;
-    msg.printf("Bad connection (%s)", strerror(errno));
+    msg = bd::String::printf("Bad connection (%s)", strerror(errno));
     notice(dcc[idx].nick, msg.c_str(), DP_HELP);
     putlog(LOG_FILES, "*", "DCC bad connection: GET %s (%s!%s)",
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);

+ 6 - 6
src/net.c

@@ -312,16 +312,16 @@ sock_write(bd::Stream &stream, int fd)
   if (socklist[fd].sock > 0) {
     bd::String buf;
 
-    stream << buf.printf(STR("-sock\n"));
-    stream << buf.printf(STR("sock %d %d\n"), socklist[fd].sock, socklist[fd].flags);
+    stream << bd::String::printf(STR("-sock\n"));
+    stream << bd::String::printf(STR("sock %d %d\n"), socklist[fd].sock, socklist[fd].flags);
 #ifdef USE_IPV6
-    stream << buf.printf(STR("af %u\n"), socklist[fd].af);
+    stream << bd::String::printf(STR("af %u\n"), socklist[fd].af);
 #endif
     if (socklist[fd].host)
-      stream << buf.printf(STR("host %s\n"), socklist[fd].host);
+      stream << bd::String::printf(STR("host %s\n"), socklist[fd].host);
     if (socklist[fd].port)
-      stream << buf.printf(STR("port %d\n"), socklist[fd].port);
-    stream << buf.printf(STR("+sock\n"));
+      stream << bd::String::printf(STR("port %d\n"), socklist[fd].port);
+    stream << bd::String::printf(STR("+sock\n"));
   }    
 }
 

+ 3 - 5
src/set.c

@@ -871,10 +871,8 @@ static char *var_rem_list(const char *botnick, variable_t *var, const char *elem
 
 void write_vars_and_cmdpass(bd::Stream& stream, int idx)
 {
-  bd::String buf;
-
   putlog(LOG_DEBUG, "@", "Writing set entries...");
-  stream << buf.printf(SET_NAME " - -\n");
+  stream << bd::String::printf(SET_NAME " - -\n");
 
   int i = 0;
 
@@ -888,12 +886,12 @@ void write_vars_and_cmdpass(bd::Stream& stream, int idx)
           ((vars[i].flags & VAR_NOLDEF) && have_linked_to_hub))
          )) {
       /* send blanks if our variable isn't set, theirs MIGHT be set and needs to be UNSET */
-      stream << buf.printf("@ %s %s\n", vars[i].name, vars[i].gdata ? vars[i].gdata : "");
+      stream << bd::String::printf("@ %s %s\n", vars[i].name, vars[i].gdata ? vars[i].gdata : "");
     }
   }
 
   for (struct cmd_pass *cp = cmdpass; cp; cp = cp->next)
-    stream << buf.printf("- %s %s\n", cp->name, cp->pass);
+    stream << bd::String::printf("- %s %s\n", cp->name, cp->pass);
 }
 
 

+ 1 - 1
src/sorthelp.c

@@ -98,7 +98,7 @@ int parse_help(const bd::String& infile, const bd::String& outfile) {
     out << ":";
     if (cmdlist[i].leaf) out << "leaf";
     else if (cmdlist[i].hub) out << "hub";
-    out << buf.printf(":%s\n", cmdlist[i].name->c_str());
+    out << bd::String::printf(":%s\n", cmdlist[i].name->c_str());
     out << cmdlist[i].txt->sub("{NEWLINE}", "\n");
   }
 

+ 6 - 12
src/userent.c

@@ -99,15 +99,13 @@ void write_userfile_protected(bd::Stream& stream, const struct userrec *u, const
   int localhub = nextbot(u->handle);
   /* only write if saving local, or if sending to hub, or if sending to same user as entry, or the localhub in the chain */
   if (idx == -1 || dcc[idx].hub || dcc[idx].user == u || (localhub != -1 && idx == localhub)) {
-    bd::String buf;
-    stream << buf.printf("--%s %s\n", e->type->name, e->u.string);
+    stream << bd::String::printf("--%s %s\n", e->type->name, e->u.string);
   }
 }
 
 void def_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
-  bd::String buf;
-  stream << buf.printf("--%s %s\n", e->type->name, e->u.string);
+  stream << bd::String::printf("--%s %s\n", e->type->name, e->u.string);
 }
 
 void *def_get(struct userrec *u, struct user_entry *e)
@@ -370,10 +368,9 @@ static void set_write_userfile(bd::Stream& stream, const struct userrec *u, cons
   /* only write if saving local, or if sending to hub, or if sending to same user as entry, or the localhub in the chain */
   if (idx == -1 || dcc[idx].hub || dcc[idx].user == u || (localhub != -1 && idx == localhub)) {
     struct xtra_key *x = (struct xtra_key *) e->u.extra;
-    bd::String buf;
 
     for (; x; x = x->next)
-      stream << buf.printf("--%s %s %s\n", e->type->name, x->key, x->data ? x->data : "");
+      stream << bd::String::printf("--%s %s %s\n", e->type->name, x->key, x->data ? x->data : "");
   }
 }
 
@@ -706,9 +703,8 @@ static bool laston_unpack(struct userrec *u, struct user_entry *e)
 static void laston_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   struct laston_info *li = (struct laston_info *) e->u.extra;
-  bd::String buf;
 
-  stream << buf.printf("--LASTON %li %s\n", (long) li->laston, li->lastonplace ? li->lastonplace : "");
+  stream << bd::String::printf("--LASTON %li %s\n", (long) li->laston, li->lastonplace ? li->lastonplace : "");
 }
 
 static bool laston_kill(struct user_entry *e)
@@ -828,9 +824,8 @@ static bool botaddr_kill(struct user_entry *e)
 static void botaddr_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
-  bd::String buf;
 
-  stream << buf.printf("--%s %s:%u/%u:%u:%s\n", e->type->name, bi->address, bi->telnet_port, bi->relay_port, bi->hublevel, bi->uplink);
+  stream << bd::String::printf("--%s %s:%u/%u:%u:%s\n", e->type->name, bi->address, bi->telnet_port, bi->relay_port, bi->hublevel, bi->uplink);
 }
 
 static bool botaddr_set(struct userrec *u, struct user_entry *e, void *buf)
@@ -915,10 +910,9 @@ struct user_entry_type USERENTRY_BOTADDR =
 static void hosts_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   struct list_type *h = NULL;
-  bd::String buf;
 
   for (h = (struct list_type *) e->u.extra; h; h = h->next)
-    stream << buf.printf("--HOSTS %s\n", h->extra);
+    stream << bd::String::printf("--HOSTS %s\n", h->extra);
 }
 
 static bool hosts_null(struct userrec *u, struct user_entry *e)

+ 3 - 5
src/userrec.c

@@ -360,10 +360,9 @@ static void write_user(const struct userrec *u, bd::Stream& stream, int idx)
 {
   char s[181] = "";
   struct flag_record fr = {FR_GLOBAL, u->flags, 0, 0 };
-  bd::String buf;
 
   build_flags(s, &fr, NULL);
-  stream << buf.printf("%s%s - %s\n", u->bot ? "-" : "", u->handle, s);
+  stream << bd::String::printf("%s%s - %s\n", u->bot ? "-" : "", u->handle, s);
 
   struct chanset_t *cst = NULL;
 
@@ -377,7 +376,7 @@ static void write_user(const struct userrec *u, bd::Stream& stream, int idx)
       fr.match = FR_CHAN;
       fr.chan = ch->flags;
       build_flags(s, &fr, NULL);
-      stream << buf.printf("! %s %li %s %s\n", ch->channel, (long) ch->laston, s, ch->info ? ch->info : "");
+      stream << bd::String::printf("! %s %li %s %s\n", ch->channel, (long) ch->laston, s, ch->info ? ch->info : "");
     }
   }
   for (struct user_entry *ue = u->entries; ue; ue = ue->next) {
@@ -466,11 +465,10 @@ static void sort_userlist()
 void stream_writeuserfile(bd::Stream& stream, const struct userrec *bu, bool old) {
   time_t tt = now;
   char s1[81] = "";
-  bd::String buf;
 
   strcpy(s1, ctime(&tt));
 
-  stream << buf.printf("#4v: %s -- %s -- written %s", ver, conf.bot->nick, s1);
+  stream << bd::String::printf("#4v: %s -- %s -- written %s", ver, conf.bot->nick, s1);
   channels_writeuserfile(stream, old);
 
   for (const struct userrec *u = bu; u; u = u->next)