Browse Source

* Update bdlib and change stream.printf calls to use String.printf instead

Bryan Drewery 17 years ago
parent
commit
90da1207ef
6 changed files with 59 additions and 33 deletions
  1. 1 1
      lib/bdlib
  2. 28 18
      src/mod/channels.mod/userchan.c
  3. 3 1
      src/mod/console.mod/console.c
  4. 6 3
      src/set.c
  5. 15 7
      src/userent.c
  6. 6 3
      src/userrec.c

+ 1 - 1
lib/bdlib

@@ -1 +1 @@
-Subproject commit b58d380d4da26014f0fea94c523c9667ccd95a26
+Subproject commit 6dbaaa8d5d2dcb03a7e6ad24785ab1a04ab576f1

+ 28 - 18
src/mod/channels.mod/userchan.c

@@ -24,6 +24,7 @@
  */
 
 
+#include <bdlib/src/String.h>
 #include <bdlib/src/Stream.h>
 extern struct cmd_pass *cmdpass;
 
@@ -571,15 +572,16 @@ 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.printf(IGNORE_NAME " - -\n");
+    stream << buf.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.printf("- %s:%s%li:%s:%li:%s\n", mask,
+	stream << buf.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 : "");
@@ -587,14 +589,14 @@ void write_bans(bd::Stream& stream, int idx)
     }
   }
   if (global_bans)
-    stream.printf(BAN_NAME " - -\n");
+    stream << buf.printf(BAN_NAME " - -\n");
 
   maskrec *b = NULL;
 
   for (b = global_bans; b; b = b->next) {
     mask = str_escape(b->mask, ':', '\\');
     if (mask) {
-	stream.printf("- %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+	stream << buf.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,
@@ -603,12 +605,12 @@ void write_bans(bd::Stream& stream, int idx)
     }
   }
   for (struct chanset_t *chan = chanset; chan; chan = chan->next) {
-    stream.printf("::%s bans\n", chan->dname);
+    stream << buf.printf("::%s bans\n", chan->dname);
 
     for (b = chan->bans; b; b = b->next) {
       mask = str_escape(b->mask, ':', '\\');
       if (mask) {
-        stream.printf("- %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+        stream << buf.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,
@@ -622,8 +624,10 @@ void write_bans(bd::Stream& stream, int idx)
  */
 void write_exempts(bd::Stream& stream, int idx)
 {
+  bd::String buf;
+
   if (global_exempts)
-    stream.printf(EXEMPT_NAME " - -\n");
+    stream << buf.printf(EXEMPT_NAME " - -\n");
 
   maskrec *e = NULL;
   char *mask = NULL;
@@ -631,7 +635,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.printf("%s %s:%s%li%s:+%li:%li:%s:%s\n", "%", mask,
+        stream << buf.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,
@@ -640,11 +644,11 @@ void write_exempts(bd::Stream& stream, int idx)
     }
   }
   for (struct chanset_t *chan = chanset;chan ;chan = chan->next) {
-    stream.printf("&&%s exempts\n", chan->dname);
+    stream << buf.printf("&&%s exempts\n", chan->dname);
     for (e = chan->exempts; e; e = e->next) {
       mask = str_escape(e->mask, ':', '\\');
       if (mask) {
-	stream.printf("%s %s:%s%li%s:+%li:%li:%s:%s\n","%", mask,
+	stream << buf.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,
@@ -659,8 +663,10 @@ void write_exempts(bd::Stream& stream, int idx)
  */
 void write_invites(bd::Stream& stream, int idx)
 {
+  bd::String buf;
+
   if (global_invites)
-    stream.printf(INVITE_NAME " - -\n");
+    stream << buf.printf(INVITE_NAME " - -\n");
 
   maskrec *ir = NULL;
   char *mask = NULL;
@@ -668,7 +674,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.printf("@ %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+      stream << buf.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,
@@ -677,12 +683,12 @@ void write_invites(bd::Stream& stream, int idx)
     }
   }
   for (struct chanset_t *chan = chanset; chan; chan = chan->next) {
-    stream.printf("$$%s invites\n", chan->dname);
+    stream << buf.printf("$$%s invites\n", chan->dname);
 
     for (ir = chan->invites; ir; ir = ir->next) {
       mask = str_escape(ir->mask, ':', '\\');
       if (mask) {
-        stream.printf("@ %s:%s%li%s:+%li:%li:%s:%s\n", mask,
+        stream << buf.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,
@@ -697,9 +703,11 @@ void write_invites(bd::Stream& stream, int idx)
  */
 void write_chans(bd::Stream& stream, int idx)
 {
+  bd::String buf;
+
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
-  stream.printf(CHANS_NAME " - -\n");
+  stream << buf.printf(CHANS_NAME " - -\n");
 
   char w[1024] = "";
 
@@ -716,7 +724,7 @@ void write_chans(bd::Stream& stream, int idx)
     else
       inactive = PLSMNS(channel_inactive(chan));
 
-    stream.printf("\
+    stream << buf.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 \
@@ -798,9 +806,11 @@ flood-exempt %d flood-lock-time %d \
  */
 void write_chans_compat(bd::Stream& stream, int idx)
 {
+  bd::String buf;
+
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
-  stream.printf(CHANS_NAME " - -\n");
+  stream << buf.printf(CHANS_NAME " - -\n");
 
   char w[1024] = "";
 
@@ -817,7 +827,7 @@ void write_chans_compat(bd::Stream& stream, int idx)
     else
       inactive = PLSMNS(channel_inactive(chan));
 
-    stream.printf("\
+    stream << buf.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 \

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

@@ -40,6 +40,7 @@
 #include "src/misc.h"
 #include "src/core_binds.h"
 #include <bdlib/src/Stream.h>
+#include <bdlib/src/String.h>
 
 struct console_info {
   char *channel;
@@ -107,8 +108,9 @@ 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.printf("--CONSOLE %s %s %s %d %d %d %d %d %d %d %d\n",
+  stream << buf.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);

+ 6 - 3
src/set.c

@@ -21,6 +21,7 @@
 #include "userent.h"
 #include "rfc1459.h"
 #include <bdlib/src/Stream.h>
+#include <bdlib/src/String.h>
 
 #include "set_default.h"
 
@@ -826,18 +827,20 @@ 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.printf(SET_NAME " - -\n");
+  stream << buf.printf(SET_NAME " - -\n");
 
   int i = 0;
 
   for (i = 0; vars[i].name; i++) {
     /* send blanks if our variable isn't set, theirs MIGHT be set and needs to be UNSET */
-    stream.printf("@ %s %s\n", vars[i].name, vars[i].gdata ? vars[i].gdata : "");
+    stream << buf.printf("@ %s %s\n", vars[i].name, vars[i].gdata ? vars[i].gdata : "");
   }
 
   for (struct cmd_pass *cp = cmdpass; cp; cp = cp->next)
-    stream.printf("- %s %s\n", cp->name, cp->pass);
+    stream << buf.printf("- %s %s\n", cp->name, cp->pass);
 }
 
 

+ 15 - 7
src/userent.c

@@ -38,6 +38,7 @@
 #include "crypt.h"
 #include "botmsg.h"
 #include <bdlib/src/Stream.h>
+#include <bdlib/src/String.h>
 
 static struct user_entry_type *entry_type_list = NULL;
 
@@ -95,13 +96,16 @@ bool def_kill(struct user_entry *e)
 void write_userfile_protected(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   /* only write if saving local, or if sending to hub, or if sending to same user as entry */
-  if (idx == -1 || dcc[idx].hub || dcc[idx].user == u)
-    stream.printf("--%s %s\n", e->type->name, e->u.string);
+  if (idx == -1 || dcc[idx].hub || dcc[idx].user == u) {
+    bd::String buf;
+    stream << buf.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)
 {
-  stream.printf("--%s %s\n", e->type->name, e->u.string);
+  bd::String buf;
+  stream << buf.printf("--%s %s\n", e->type->name, e->u.string);
 }
 
 void *def_get(struct userrec *u, struct user_entry *e)
@@ -363,9 +367,10 @@ 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 */
   if (idx == -1 || dcc[idx].hub || dcc[idx].user == u) {
     struct xtra_key *x = (struct xtra_key *) e->u.extra;
+    bd::String buf;
 
     for (; x; x = x->next)
-      stream.printf("--%s %s %s\n", e->type->name, x->key, x->data ? x->data : "");
+      stream << buf.printf("--%s %s %s\n", e->type->name, x->key, x->data ? x->data : "");
   }
 }
 
@@ -697,8 +702,9 @@ 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.printf("--LASTON %li %s\n", (long) li->laston, li->lastonplace ? li->lastonplace : "");
+  stream << buf.printf("--LASTON %li %s\n", (long) li->laston, li->lastonplace ? li->lastonplace : "");
 }
 
 static bool laston_kill(struct user_entry *e)
@@ -819,8 +825,9 @@ 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.printf("--%s %s:%u/%u:%u:%s\n", e->type->name, bi->address, bi->telnet_port, bi->relay_port, bi->hublevel, bi->uplink);
+  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);
 }
 
 static bool botaddr_set(struct userrec *u, struct user_entry *e, void *buf)
@@ -906,9 +913,10 @@ 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.printf("--HOSTS %s\n", h->extra);
+    stream << buf.printf("--HOSTS %s\n", h->extra);
 }
 
 static bool hosts_null(struct userrec *u, struct user_entry *e)

+ 6 - 3
src/userrec.c

@@ -50,6 +50,7 @@
 #include "socket.h"
 #include "net.h"
 #include "EncryptedStream.h"
+#include <bdlib/src/String.h>
 
 bool             noshare = 1;		/* don't send out to sharebots	    */
 struct userrec	*userlist = NULL;	/* user records are stored here	    */
@@ -359,9 +360,10 @@ 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.printf("%s%-10s - %-24s\n", u->bot ? "-" : "", u->handle, s);
+  stream << buf.printf("%s%-10s - %-24s\n", u->bot ? "-" : "", u->handle, s);
 
   struct chanset_t *cst = NULL;
 
@@ -375,7 +377,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.printf("! %-20s %li %-10s %s\n", ch->channel, (long) ch->laston, s, ch->info ? ch->info : "");
+      stream << buf.printf("! %-20s %li %-10s %s\n", ch->channel, (long) ch->laston, s, ch->info ? ch->info : "");
     }
   }
   for (struct user_entry *ue = u->entries; ue; ue = ue->next) {
@@ -464,10 +466,11 @@ static void sort_userlist()
 void stream_writeuserfile(bd::Stream& stream, const struct userrec *bu, int idx, bool old) {
   time_t tt = now;
   char s1[81] = "";
+  bd::String buf;
 
   strcpy(s1, ctime(&tt));
 
-  stream.printf("#4v: %s -- %s -- written %s", ver, conf.bot->nick, s1);
+  stream << buf.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)