Ver Fonte

* Use bd::Stream

Bryan Drewery há 17 anos atrás
pai
commit
e44719ee4f

+ 10 - 6
src/mod/channels.mod/channels.h

@@ -24,6 +24,10 @@ static int count_mask(maskrec *);
 
 #endif				/* MAKING_CHANNELS */
 
+namespace bd {
+  class Stream;
+}
+
 void remove_channel(struct chanset_t *);
 void add_chanrec_by_handle(struct userrec *, char *, char *);
 void get_handle_chaninfo(char *, char *, char *);
@@ -31,11 +35,11 @@ void set_handle_chaninfo(struct userrec *, char *, char *, char *);
 struct chanuserrec *get_chanrec(struct userrec *u, char *);
 struct chanuserrec *add_chanrec(struct userrec *u, char *);
 void del_chanrec(struct userrec *, char *);
-void write_bans(Stream&, int);
-void write_exempts(Stream&, int);
-void write_chans(Stream&, int);
-void write_chans_compat(Stream&, int);
-void write_invites(Stream&, int);
+void write_bans(bd::Stream&, int);
+void write_exempts(bd::Stream&, int);
+void write_chans(bd::Stream&, int);
+void write_chans_compat(bd::Stream&, int);
+void write_invites(bd::Stream&, int);
 bool expired_mask(struct chanset_t *, char *);
 void set_handle_laston(char *, struct userrec *, time_t);
 int u_delmask(char type, struct chanset_t *c, char *who, int doit);
@@ -51,7 +55,7 @@ bool u_match_mask(struct maskrec *, char *);
 bool ismasked(masklist *, const char *);
 bool ismodeline(masklist *, const char *);
 void channels_report(int, int);
-void channels_writeuserfile(Stream&, bool = 0);
+void channels_writeuserfile(bd::Stream&, bool = 0);
 void rcmd_chans(char *, char *, char *);
 
 extern char		glob_chanset[512];

+ 8 - 8
src/mod/channels.mod/userchan.c

@@ -24,7 +24,7 @@
  */
 
 
-#include "src/Stream.h"
+#include <bdlib/src/Stream.h>
 extern struct cmd_pass *cmdpass;
 
 struct chanuserrec *get_chanrec(struct userrec *u, char *chname)
@@ -569,7 +569,7 @@ static void tell_masks(const char type, int idx, bool show_inact, char *match, b
 
 /* Write the ban lists and the ignore list to a file.
  */
-void write_bans(Stream& stream, int idx)
+void write_bans(bd::Stream& stream, int idx)
 {
   if (global_ign)
     stream.printf(IGNORE_NAME " - -\n");
@@ -620,7 +620,7 @@ void write_bans(Stream& stream, int idx)
 }
 /* Write the exemptlists to a file.
  */
-void write_exempts(Stream& stream, int idx)
+void write_exempts(bd::Stream& stream, int idx)
 {
   if (global_exempts)
     stream.printf(EXEMPT_NAME " - -\n");
@@ -657,7 +657,7 @@ void write_exempts(Stream& stream, int idx)
 
 /* Write the invitelists to a file.
  */
-void write_invites(Stream& stream, int idx)
+void write_invites(bd::Stream& stream, int idx)
 {
   if (global_invites)
     stream.printf(INVITE_NAME " - -\n");
@@ -695,7 +695,7 @@ void write_invites(Stream& stream, int idx)
 
 /* Write the channels to the userfile
  */
-void write_chans(Stream& stream, int idx)
+void write_chans(bd::Stream& stream, int idx)
 {
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
@@ -796,7 +796,7 @@ flood-exempt %d flood-lock-time %d \
 /* FIXME: remove after 1.2.14 */
 /* Write the channels to the userfile
  */
-void write_chans_compat(Stream& stream, int idx)
+void write_chans_compat(bd::Stream& stream, int idx)
 {
   putlog(LOG_DEBUG, "*", "Writing channels..");
 
@@ -889,13 +889,13 @@ exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
   }
 }
 
-void channels_writeuserfile(Stream& stream, bool old)
+void channels_writeuserfile(bd::Stream& stream, bool old)
 {
   putlog(LOG_DEBUG, "@", "Writing channel/ban/exempt/invite entries.");
   if (!old)
     write_chans(stream, -1);
   else
-    write_chans_compat(stream -1);
+    write_chans_compat(stream, -1);
   write_vars_and_cmdpass(stream, -1);
   write_bans(stream, -1);
   write_exempts(stream, -1);

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

@@ -39,7 +39,7 @@
 #include "src/users.h"
 #include "src/misc.h"
 #include "src/core_binds.h"
-#include "src/Stream.h"
+#include <bdlib/src/Stream.h>
 
 struct console_info {
   char *channel;
@@ -101,7 +101,7 @@ console_kill(struct user_entry *e)
 }
 
 static void
-console_write_userfile(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+console_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   if (u->bot)
     return;

+ 4 - 4
src/mod/share.mod/share.c

@@ -55,7 +55,7 @@
 
 static struct flag_record fr = { 0, 0, 0, 0 };
 
-static Stream stream_in;
+static bd::Stream stream_in;
 
 struct delay_mode {
   struct delay_mode *next;
@@ -71,7 +71,7 @@ static struct delay_mode *start_delay = NULL;
 /* Prototypes */
 static void start_sending_users(int);
 static void stream_send_users(int);
-static void share_read_stream(int, Stream&);
+static void share_read_stream(int, bd::Stream&);
 #ifdef __GNUC__
  static void shareout_but(int, const char *, ...)  __attribute__ ((format(printf, 2, 3)));
 #else
@@ -1312,7 +1312,7 @@ finish_share(int idx)
   }
 */
 }
-static void share_read_stream(int idx, Stream& stream) {
+static void share_read_stream(int idx, bd::Stream& stream) {
   struct userrec *u = NULL, *ou = NULL;
   struct chanset_t *chan = NULL;
   int i;
@@ -1478,7 +1478,7 @@ ulsend(int idx, const char* data, size_t datalen)
 static void
 stream_send_users(int idx)
 {
-  Stream stream;
+  bd::Stream stream;
   stream_writeuserfile(stream, userlist, idx);
   stream.seek(0, SEEK_SET);
   dprintf(idx, "s ls\n");

+ 2 - 2
src/set.c

@@ -20,7 +20,7 @@
 #include "userrec.h"
 #include "userent.h"
 #include "rfc1459.h"
-#include "Stream.h"
+#include <bdlib/src/Stream.h>
 
 #include "set_default.h"
 
@@ -824,7 +824,7 @@ static char *var_rem_list(const char *botnick, variable_t *var, const char *elem
   return ret;
 }
 
-void write_vars_and_cmdpass(Stream& stream, int idx)
+void write_vars_and_cmdpass(bd::Stream& stream, int idx)
 {
   putlog(LOG_DEBUG, "@", "Writing set entries...");
   stream.printf(SET_NAME " - -\n");

+ 5 - 1
src/set.h

@@ -76,7 +76,11 @@ extern int		cloak_script, fight_threshold, fork_interval, in_bots, set_noshare,
                         ison_time;
 extern rate_t		op_requests, close_threshold;
 
-void write_vars_and_cmdpass (Stream&, int);
+namespace bd {
+  class Stream;
+}
+
+void write_vars_and_cmdpass (bd::Stream&, int);
 void var_userfile_share_line(char *, int, bool);
 void var_parse_my_botset();
 void init_vars();

+ 7 - 7
src/userent.c

@@ -37,7 +37,7 @@
 #include "dccutil.h"
 #include "crypt.h"
 #include "botmsg.h"
-#include "Stream.h"
+#include <bdlib/src/Stream.h>
 
 static struct user_entry_type *entry_type_list = NULL;
 
@@ -92,14 +92,14 @@ bool def_kill(struct user_entry *e)
   return 1;
 }
 
-void write_userfile_protected(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+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);
 }
 
-void def_write_userfile(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+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);
 }
@@ -358,7 +358,7 @@ static bool set_gotshare(struct userrec *u, struct user_entry *e, char *buf, int
   return 1;
 }
 
-static void set_write_userfile(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+static void set_write_userfile(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) {
@@ -694,7 +694,7 @@ static bool laston_unpack(struct userrec *u, struct user_entry *e)
   return 1;
 }
 
-static void laston_write_userfile(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+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;
 
@@ -816,7 +816,7 @@ static bool botaddr_kill(struct user_entry *e)
   return 1;
 }
 
-static void botaddr_write_userfile(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+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;
 
@@ -903,7 +903,7 @@ struct user_entry_type USERENTRY_BOTADDR =
   "BOTADDR"
 };
 
-static void hosts_write_userfile(Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
+static void hosts_write_userfile(bd::Stream& stream, const struct userrec *u, const struct user_entry *e, int idx)
 {
   struct list_type *h = NULL;
 

+ 2 - 2
src/userrec.c

@@ -355,7 +355,7 @@ int u_pass_match(struct userrec *u, char *in)
   return 0;
 }
 
-static void write_user(const struct userrec *u, Stream& stream, int idx)
+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 };
@@ -461,7 +461,7 @@ static void sort_userlist()
   }
 }
 
-void stream_writeuserfile(Stream& stream, const struct userrec *bu, int idx, old) {
+void stream_writeuserfile(bd::Stream& stream, const struct userrec *bu, int idx, old) {
   time_t tt = now;
   char s1[81] = "";
 

+ 5 - 1
src/userrec.h

@@ -1,6 +1,10 @@
 #ifndef _USERREC_H
 #define _USERREC_H
 
+namespace bd {
+  class Stream;
+}
+
 struct userrec *adduser(struct userrec *, char *, char *, char *, flag_t, int);
 void addhost_by_handle(char *, char *);
 void clear_masks(struct maskrec *);
@@ -11,7 +15,7 @@ int count_users(struct userrec *);
 int deluser(char *);
 int change_handle(struct userrec *, char *);
 void correct_handle(char *);
-void stream_writeuserfile(Stream&, const struct userrec *, int, bool = 0);
+void stream_writeuserfile(bd::Stream&, const struct userrec *, int, bool = 0);
 int write_userfile(int);
 void touch_laston(struct userrec *, char *, time_t);
 void user_del_chan(char *);

+ 1 - 1
src/users.c

@@ -595,7 +595,7 @@ int readuserfile(const char *file, struct userrec **ret)
   return res;
 }
 
-int stream_readuserfile(Stream& stream, struct userrec **ret)
+int stream_readuserfile(bd::Stream& stream, struct userrec **ret)
 {
   char *p = NULL, buf[1024] = "", lasthand[512] = "", *attr = NULL, *pass = NULL;
   char *code = NULL, s1[1024] = "", *s = buf, ignored[512] = "";

+ 5 - 3
src/users.h

@@ -25,7 +25,9 @@ bool list_append(struct list_type **, struct list_type *);
 bool list_delete(struct list_type **, struct list_type *);
 bool list_contains(struct list_type *, struct list_type *);
 
-class Stream;
+namespace bd {
+  class Stream;
+}
 
 /* New userfile format stuff
  */
@@ -35,7 +37,7 @@ struct user_entry_type {
   struct user_entry_type *next;
   bool (*got_share) (struct userrec *, struct user_entry *, char *, int);
   bool (*unpack) (struct userrec *, struct user_entry *);
-  void (*write_userfile) (Stream&, const struct userrec *, const struct user_entry *, int);
+  void (*write_userfile) (bd::Stream&, const struct userrec *, const struct user_entry *, int);
   bool (*kill) (struct user_entry *);
   void *(*get) (struct userrec *, struct user_entry *);
   bool (*set) (struct userrec *, struct user_entry *, void *);
@@ -172,7 +174,7 @@ void tell_file_stats(int, char *);
 void tell_user_ident(int, char *);
 void tell_users_match(int, char *, int, int, char *, int);
 int readuserfile(const char *, struct userrec **);
-int stream_readuserfile(Stream&, struct userrec **);
+int stream_readuserfile(bd::Stream&, struct userrec **);
 void check_pmode();
 void link_pref_val(struct userrec *u, char *lval);
 void check_stale_dcc_users();