Sfoglia il codice sorgente

* Converted over user_entry_type to one binary mix

svn: 1831
Bryan Drewery 21 anni fa
parent
commit
dc70f3ae47
7 ha cambiato i file con 61 aggiunte e 128 eliminazioni
  1. 2 2
      src/chan.h
  2. 2 7
      src/mod/console.mod/console.c
  3. 0 2
      src/mod/notes.mod/notes.c
  4. 44 103
      src/userent.c
  5. 1 3
      src/userrec.c
  6. 12 9
      src/users.c
  7. 0 2
      src/users.h

+ 2 - 2
src/chan.h

@@ -212,10 +212,10 @@ struct chanset_t {
 #define CHAN_BITCH          BIT4	/* be a tightwad with ops             */
 #define CHAN_TAKE 	    BIT5	/* When a bot gets opped, take the chan */
 #define CHAN_PROTECTOPS     BIT6	/* re-op any +o people who get deop'd */
-#undef  CHAN_7              BIT7        /* unused */
+#undef  CHAN_7              /* BIT7         unused */
 #define CHAN_REVENGE        BIT8	/* get revenge on bad people          */
 #define CHAN_SECRET         BIT9	/* don't advertise channel on botnet  */
-#undef  CHAN_10		    BIT10       /* not used */
+#undef  CHAN_10		    /* BIT10        not used */
 #define CHAN_CYCLE          BIT11	/* cycle the channel if possible      */
 #define CHAN_INACTIVE       BIT12	/* no irc support for this channel */
 #define CHAN_VOICE          BIT13	/* a bot +y|y will voice *, except +q */

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

@@ -81,7 +81,6 @@ console_kill(struct user_entry *e)
   return 1;
 }
 
-#ifdef HUB
 static bool
 console_write_userfile(FILE * f, struct userrec *u, struct user_entry *e)
 {
@@ -97,7 +96,6 @@ console_write_userfile(FILE * f, struct userrec *u, struct user_entry *e)
     return 0;
   return 1;
 }
-#endif /* HUB */
 
 static bool
 console_set(struct userrec *u, struct user_entry *e, void *buf)
@@ -229,9 +227,7 @@ static struct user_entry_type USERENTRY_CONSOLE = {
   0,                            /* always 0 ;) */
   console_gotshare,
   console_unpack,
-#ifdef HUB
   console_write_userfile,
-#endif /* HUB */
   console_kill,
   def_get,
   console_set,
@@ -357,9 +353,8 @@ console_store(int idx, char *par)
   }
   set_user(&USERENTRY_CONSOLE, dcc[idx].user, i);
   dprintf(idx, "Console setting stored.\n");
-#ifdef HUB
-  write_userfile(idx);
-#endif /* HUB */
+  if (conf.bot->hub)
+    write_userfile(idx);
   return 0;
 }
 

+ 0 - 2
src/mod/notes.mod/notes.c

@@ -38,9 +38,7 @@ static struct user_entry_type USERENTRY_FWD =
   NULL,				/* always 0 ;) */
   NULL,
   NULL,
-#ifdef HUB
   NULL,
-#endif /* HUB */
   NULL,
   NULL,
   NULL,

+ 44 - 103
src/userent.c

@@ -68,14 +68,12 @@ bool def_kill(struct user_entry *e)
   return 1;
 }
 
-#ifdef HUB
 bool def_write_userfile(FILE * f, struct userrec *u, struct user_entry *e)
 {
   if (lfprintf(f, "--%s %s\n", e->type->name, e->u.string) == EOF)
     return 0;
   return 1;
 }
-#endif /* HUB */
 
 void *def_get(struct userrec *u, struct user_entry *e)
 {
@@ -120,9 +118,8 @@ bool def_set(struct userrec *u, struct user_entry *e, void *buf)
 
 bool def_gotshare(struct userrec *u, struct user_entry *e, char *data, int idx)
 {
-#ifdef HUB
-  putlog(LOG_DEBUG, "@", "%s: change %s %s", dcc[idx].nick, e->type->name, u->handle);
-#endif
+  if (conf.bot->hub)
+    putlog(LOG_DEBUG, "@", "%s: change %s %s", dcc[idx].nick, e->type->name, u->handle);
   return e->type->set(u, e, data);
 }
 
@@ -143,9 +140,7 @@ struct user_entry_type USERENTRY_COMMENT =
   0,				/* always 0 ;) */
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   def_set,
@@ -158,9 +153,7 @@ struct user_entry_type USERENTRY_INFO =
   0,				/* always 0 ;) */
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   def_set,
@@ -193,9 +186,7 @@ struct user_entry_type USERENTRY_ADDED = {
   0,				/* always 0 ;) */
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   def_set,
@@ -272,18 +263,18 @@ static bool config_unpack(struct userrec *u, struct user_entry *e)
 
 static void config_display(int idx, struct user_entry *e, struct userrec *u)
 {
-#ifdef HUB
-  struct xtra_key *xk = NULL;
-  struct flag_record fr = {FR_GLOBAL, 0, 0, 0 };
-
-  get_user_flagrec(dcc[idx].user, &fr, NULL);
-  /* scan thru xtra field, searching for matches */
-  for (xk = (struct xtra_key *) e->u.extra; xk; xk = xk->next) {
-    /* ok, it's a valid xtra field entry */
-    if (glob_owner(fr))
-      dprintf(idx, "  %s: %s\n", xk->key, xk->data);
+  if (conf.bot->hub) {
+    struct xtra_key *xk = NULL;
+    struct flag_record fr = {FR_GLOBAL, 0, 0, 0 };
+
+    get_user_flagrec(dcc[idx].user, &fr, NULL);
+    /* scan thru xtra field, searching for matches */
+    for (xk = (struct xtra_key *) e->u.extra; xk; xk = xk->next) {
+      /* ok, it's a valid xtra field entry */
+      if (glob_owner(fr))
+        dprintf(idx, "  %s: %s\n", xk->key, xk->data);
+    }
   }
-#endif /* HUB */
 }
 
 static bool config_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
@@ -328,7 +319,6 @@ static bool config_gotshare(struct userrec *u, struct user_entry *e, char *buf,
   return 1;
 }
 
-#ifdef HUB
 static bool config_write_userfile(FILE *f, struct userrec *u, struct user_entry *e)
 {
   struct xtra_key *x = NULL;
@@ -337,7 +327,6 @@ static bool config_write_userfile(FILE *f, struct userrec *u, struct user_entry
     lfprintf(f, "--CONFIG %s %s\n", x->key, x->data);
   return 1;
 }
-#endif /* HUB */
 
 static bool config_kill(struct user_entry *e)
 {
@@ -357,9 +346,7 @@ struct user_entry_type USERENTRY_CONFIG = {
   0,
   config_gotshare,
   config_unpack,
-#ifdef HUB
   config_write_userfile,
-#endif /* HUB */
   config_kill,
   def_get,
   config_set,
@@ -367,32 +354,26 @@ struct user_entry_type USERENTRY_CONFIG = {
   "CONFIG"
 };
 
-#ifdef HUB
 static void botmisc_display(int idx, struct user_entry *e, struct userrec *u)
 {
-  struct flag_record fr = {FR_GLOBAL, 0, 0, 0 };
+  if (conf.bot->hub) {
+    struct flag_record fr = {FR_GLOBAL, 0, 0, 0 };
 
-  get_user_flagrec(dcc[idx].user, &fr, NULL);
-  if (glob_admin(fr))
-    dprintf(idx, "  %s: %s\n", e->type->name, e->u.string ? e->u.string : "");
+    get_user_flagrec(dcc[idx].user, &fr, NULL);
+    if (glob_admin(fr))
+      dprintf(idx, "  %s: %s\n", e->type->name, e->u.string ? e->u.string : "");
+  }
 }
-#endif /* HUB */
 
 struct user_entry_type USERENTRY_USERNAME = {
  0,
  def_gotshare,
  def_unpack,
-#ifdef HUB
  def_write_userfile,
-#endif /* HUB */
  def_kill,
  def_get,
  def_set,
-#ifdef HUB
  botmisc_display,
-#else
- NULL,
-#endif /* HUB */
  "USERNAME"
 };
 
@@ -400,17 +381,11 @@ struct user_entry_type USERENTRY_NODENAME = {
  0,
  def_gotshare,
  def_unpack,
-#ifdef HUB
  def_write_userfile,
-#endif /* HUB */
  def_kill,
  def_get,
  def_set,
-#ifdef HUB
  botmisc_display,
-#else
- NULL,
-#endif /* HUB */
  "NODENAME"
 };
 
@@ -418,17 +393,11 @@ struct user_entry_type USERENTRY_OS = {
  0,
  def_gotshare,
  def_unpack,
-#ifdef HUB
  def_write_userfile,
-#endif /* HUB */
  def_kill,
  def_get,
  def_set,
-#ifdef HUB
  botmisc_display,
-#else
- NULL,
-#endif /* HUB */
  "OS"
 };
 
@@ -474,9 +443,7 @@ struct user_entry_type USERENTRY_STATS = {
   0,				/* always 0 ;) */
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   def_set,
@@ -516,9 +483,7 @@ struct user_entry_type USERENTRY_MODIFIED =
   0,
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   def_set,
@@ -564,9 +529,7 @@ struct user_entry_type USERENTRY_PASS =
   0,
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   pass_set,
@@ -606,9 +569,7 @@ struct user_entry_type USERENTRY_TMPPASS =
   0,
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   tmppass_set,
@@ -624,14 +585,14 @@ static void secpass_display(int idx, struct user_entry *e, struct userrec *u)
   get_user_flagrec(dcc[idx].user, &fr, NULL);
 
   if (!strcmp(u->handle, dcc[idx].nick) || (glob_admin(fr) && isowner(dcc[idx].nick))) {
-#ifdef HUB
-    dprintf(idx, "  %s: %s\n", e->type->name, e->u.string);
-#else
-    dprintf(idx, "  %s: Hidden on leaf bots.", e->type->name);
-    if (dcc[idx].u.chat->su_nick)
-      dprintf(idx, " Nice try, %s.", dcc[idx].u.chat->su_nick);
-    dprintf(idx, "\n");
-#endif /* HUB */
+    if (conf.bot->hub)
+      dprintf(idx, "  %s: %s\n", e->type->name, e->u.string);
+    else {
+      dprintf(idx, "  %s: Hidden on leaf bots.", e->type->name);
+      if (dcc[idx].u.chat->su_nick)
+        dprintf(idx, " Nice try, %s.", dcc[idx].u.chat->su_nick);
+      dprintf(idx, "\n");
+    }
   }
 }
 
@@ -640,9 +601,7 @@ struct user_entry_type USERENTRY_SECPASS =
   0,
   def_gotshare,
   def_unpack,
-#ifdef HUB
   def_write_userfile,
-#endif /* HUB */
   def_kill,
   def_get,
   def_set,
@@ -664,7 +623,6 @@ static bool laston_unpack(struct userrec *u, struct user_entry *e)
   return 1;
 }
 
-#ifdef HUB
 static bool laston_write_userfile(FILE * f, struct userrec *u, struct user_entry *e)
 {
   struct laston_info *li = (struct laston_info *) e->u.extra;
@@ -674,7 +632,6 @@ static bool laston_write_userfile(FILE * f, struct userrec *u, struct user_entry
     return 0;
   return 1;
 }
-#endif /* HUB */
 
 static bool laston_kill(struct user_entry *e)
 {
@@ -729,9 +686,7 @@ struct user_entry_type USERENTRY_LASTON =
   0,				/* always 0 ;) */
   laston_gotshare,
   laston_unpack,
-#ifdef HUB
   laston_write_userfile,
-#endif /* HUB */
   laston_kill,
   def_get,
   laston_set,
@@ -795,7 +750,6 @@ static bool botaddr_kill(struct user_entry *e)
   return 1;
 }
 
-#ifdef HUB
 static bool botaddr_write_userfile(FILE *f, struct userrec *u, struct user_entry *e)
 {
   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
@@ -805,7 +759,6 @@ static bool botaddr_write_userfile(FILE *f, struct userrec *u, struct user_entry
     return 0;
   return 1;
 }
-#endif /* HUB */
 
 static bool botaddr_set(struct userrec *u, struct user_entry *e, void *buf)
 {
@@ -835,25 +788,26 @@ static bool botaddr_set(struct userrec *u, struct user_entry *e, void *buf)
   return 1;
 }
 
-#ifdef HUB
 static void botaddr_display(int idx, struct user_entry *e, struct userrec *u)
 {
-  struct flag_record fr = {FR_GLOBAL, 0, 0, 0 };
+  if (conf.bot->hub) {
+    struct flag_record fr = {FR_GLOBAL, 0, 0, 0 };
 
-  get_user_flagrec(dcc[idx].user, &fr, NULL);
-  if (glob_admin(fr)) {
-    register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
-    if (bi->address && bi->hublevel && bi->hublevel != 0) {
-      dprintf(idx, "  ADDRESS: %.70s\n", bi->address);
-      dprintf(idx, "     port: %d\n", bi->telnet_port);
+    get_user_flagrec(dcc[idx].user, &fr, NULL);
+    if (glob_admin(fr)) {
+      register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
+
+      if (bi->address && bi->hublevel && bi->hublevel != 0) {
+        dprintf(idx, "  ADDRESS: %.70s\n", bi->address);
+        dprintf(idx, "     port: %d\n", bi->telnet_port);
+      }
+      if (bi->hublevel && bi->hublevel != 0)
+        dprintf(idx, "  HUBLEVEL: %d\n", bi->hublevel);
+      if (bi->uplink && bi->uplink[0])
+        dprintf(idx, "  UPLINK: %s\n", bi->uplink);
     }
-    if (bi->hublevel && bi->hublevel != 0)
-      dprintf(idx, "  HUBLEVEL: %d\n", bi->hublevel);
-    if (bi->uplink && bi->uplink[0])
-      dprintf(idx, "  UPLINK: %s\n", bi->uplink);
   }
 }
-#endif /* HUB */
 
 static bool botaddr_gotshare(struct userrec *u, struct user_entry *e, char *buf, int idx)
 {
@@ -880,21 +834,14 @@ struct user_entry_type USERENTRY_BOTADDR =
   0,				/* always 0 ;) */
   botaddr_gotshare,
   botaddr_unpack,
-#ifdef HUB
   botaddr_write_userfile,
-#endif /* HUB */
   botaddr_kill,
   def_get,
   botaddr_set,
-#ifdef HUB
   botaddr_display,
-#else
-  NULL,
-#endif /* HUB */
   "BOTADDR"
 };
 
-#ifdef HUB
 static bool hosts_write_userfile(FILE *f, struct userrec *u, struct user_entry *e)
 {
   struct list_type *h = NULL;
@@ -904,7 +851,6 @@ static bool hosts_write_userfile(FILE *f, struct userrec *u, struct user_entry *
       return 0;
   return 1;
 }
-#endif /* HUB */
 
 static bool hosts_null(struct userrec *u, struct user_entry *e)
 {
@@ -920,11 +866,10 @@ static bool hosts_kill(struct user_entry *e)
 
 static void hosts_display(int idx, struct user_entry *e, struct userrec *u)
 {
-#ifdef LEAF
   /* if this is a su, dont show hosts
    * otherwise, let users see their own hosts */
-  if (dcc[idx].simul || (!strcmp(u->handle,dcc[idx].nick) && !dcc[idx].u.chat->su_nick)) { 
-#endif /* LEAF */
+  if (conf.bot->hub || 
+     (!conf.bot->hub && (dcc[idx].simul || (!strcmp(u->handle,dcc[idx].nick) && !dcc[idx].u.chat->su_nick)))) { 
     char s[1024] = "";
     struct list_type *q = NULL;
 
@@ -946,14 +891,12 @@ static void hosts_display(int idx, struct user_entry *e, struct userrec *u)
     }
     if (s[0])
       dprintf(idx, "%s\n", s);
-#ifdef LEAF
-  } else {
+  } else if (!conf.bot->hub) {
     dprintf(idx, "  HOSTS:          Hidden on leaf bots.");
     if (dcc[idx].u.chat->su_nick)
       dprintf(idx, " Nice try, %s.", dcc[idx].u.chat->su_nick);
     dprintf(idx, "\n");
   }
-#endif /* LEAF */
 }
 
 static bool hosts_set(struct userrec *u, struct user_entry *e, void *buf)
@@ -1006,9 +949,7 @@ struct user_entry_type USERENTRY_HOSTS =
   0,
   hosts_gotshare,
   hosts_null,
-#ifdef HUB
   hosts_write_userfile,
-#endif /* HUB */
   hosts_kill,
   def_get,
   hosts_set,

+ 1 - 3
src/userrec.c

@@ -280,10 +280,8 @@ bool write_user(struct userrec *u, FILE * f, int idx)
 	if (lfprintf(f, "--%s %s\n", ue->name, lt->extra) == EOF)
 	  return 0;
     } else {
-#ifdef HUB
-      if (!ue->type->write_userfile(f, u, ue))
+      if (conf.bot->hub && !ue->type->write_userfile(f, u, ue))
 	return 0;
-#endif /* HUB */
     }
   }
   return 1;

+ 12 - 9
src/users.c

@@ -990,9 +990,8 @@ int readuserfile(const char *file, struct userrec **ret)
       }
   }
   /* process the user data *now* */
-#ifdef LEAF
-  unlink(userfile);
-#endif /* LEAF */
+  if (!conf.bot->hub)
+    unlink(userfile);
   noshare = 0;
   return 1;
 }
@@ -1061,8 +1060,7 @@ struct userrec *next_hub(struct userrec *current, char *lowval, char *highval)
   return NULL;
 }
 
-#ifdef HUB
-void autolink_cycle(char *start)
+void autolink_cycle_hub(char *start)
 {
   char bestval[HANDLEN + 4] = "", curval[HANDLEN + 4] = "", myval[HANDLEN + 4] = "";
   tand_t *bot = NULL;
@@ -1135,9 +1133,7 @@ void autolink_cycle(char *start)
   if ((u) && (!in_chain(u->handle)))
     botlink("", -3, u->handle);
 }
-#endif /* HUB */
 
-#ifdef LEAF
 typedef struct hublist_entry {
   struct hublist_entry *next;
   struct userrec *u;
@@ -1145,7 +1141,7 @@ typedef struct hublist_entry {
 
 int botlinkcount = 0;
 
-void autolink_cycle(char *start)
+void autolink_cycle_leaf(char *start)
 {
   struct bot_addr *my_ba = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, conf.bot->u);
   char uplink[HANDLEN + 1] = "", avoidbot[HANDLEN + 1] = "", curhub[HANDLEN + 1] = "";
@@ -1252,5 +1248,12 @@ void autolink_cycle(char *start)
     hl = hl2;
   }
 }
-#endif /* LEAF */
 
+
+void autolink_cycle(char *start)
+{
+  if (conf.bot->hub)
+    autolink_cycle_hub(start);
+  else
+    autolink_cycle_leaf(start);
+}

+ 0 - 2
src/users.h

@@ -34,9 +34,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 *);
-#ifdef HUB
   bool (*write_userfile) (FILE *, struct userrec *, struct user_entry *);
-#endif /* HUB */
   bool (*kill) (struct user_entry *);
   void *(*get) (struct userrec *, struct user_entry *);
   bool (*set) (struct userrec *, struct user_entry *, void *);