Browse Source

* Fixed some bugs in sharing

svn: 944
Bryan Drewery 22 years ago
parent
commit
518081aed6
3 changed files with 49 additions and 44 deletions
  1. 1 1
      src/dcc.c
  2. 7 6
      src/dcc.h
  3. 41 37
      src/mod/share.mod/share.c

+ 1 - 1
src/dcc.c

@@ -495,7 +495,7 @@ static void dcc_bot(int idx, char *code, int i)
   if (debug_output) {
 /*    if (code[0] != 'z' && code[1] != 'b' && code[2] != ' ') { */
       if (code[0] == 's')
-        putlog(LOG_BOTSHARE, "@", "{%s} %s", dcc[idx].nick, code + 2);
+        putlog(LOG_BOTSHARE, "@", "{%s} %s", dcc[idx].nick, code);
       else
         putlog(LOG_BOTNET, "@", "<-[%s] %s", dcc[idx].nick, code);
 /*     } */

+ 7 - 6
src/dcc.h

@@ -151,12 +151,13 @@ struct dupwait_info {
 #define STAT_CHAT    BIT2    /* in file-system but may return        */
 #define STAT_TELNET  BIT3    /* connected via telnet                 */
 #define STAT_PARTY   BIT4    /* only on party line via 'p' flag      */
-#define STAT_PAGE    BIT5    /* page output to the user              */
-#define STAT_COLOR   BIT6    /* Color enabled for user */
-#define STAT_BANNER  BIT7    /* show banner on login? */
-#define STAT_CHANNELS BIT8  /* show channels on login? */
-#define STAT_BOTS    BIT9   /* Show bots linked on login? */
-#define STAT_WHOM    BIT10   /* show .whom on login? */
+/* skip 2 */
+#define STAT_PAGE    BIT7    /* page output to the user              */
+#define STAT_COLOR   BIT8    /* Color enabled for user */
+#define STAT_BANNER  BIT9    /* show banner on login? */
+#define STAT_CHANNELS BIT10  /* show channels on login? */
+#define STAT_BOTS    BIT11   /* Show bots linked on login? */
+#define STAT_WHOM    BIT12   /* show .whom on login? */
 
 /* For stripping out mIRC codes
  */

+ 41 - 37
src/mod/share.mod/share.c

@@ -103,9 +103,10 @@ check_delay()
   for (d = start_delay; d; d = dnext) {
     dnext = d->next;
     if (d->seconds <= now) {
-#ifdef LEAF
+#  ifdef LEAF
       add_mode(d->chan, d->plsmns, d->mode, d->mask);
-#endif /* LEAF */
+#  endif
+       /* LEAF */
       del_delay(d);
     }
   }
@@ -497,37 +498,40 @@ share_change(int idx, char *par)
   if (dcc[idx].status & STAT_SHARE) {
     key = newsplit(&par);
     hand = newsplit(&par);
-    if (!(uet = find_entry_type(key)))
-      /* If it's not a supported type, forget it */
-      debug2("Ignore ch %s from %s (unknown type)", key, dcc[idx].nick);
-    else {
-      if (!(dcc[idx].status & STAT_GETTING))
-        shareout_but(NULL, idx, "c %s %s %s\n", key, hand, par);
-      noshare = 1;
-      if (!u && (uet == &USERENTRY_BOTADDR)) {
-        char pass[30] = "";
-
-        makepass(pass);
-        userlist = adduser(userlist, hand, "none", pass, USER_BOT);
-        u = get_user_by_handle(userlist, hand);
-      } else if (!u)
-        return;
-      if (uet->got_share) {
-        if (!(e = find_user_entry(uet, u))) {
-          e = calloc(1, sizeof(struct user_entry));
-
-          e->type = uet;
-          e->name = NULL;
-          e->u.list = NULL;
-          list_insert((&(u->entries)), e);
-        }
-        uet->got_share(u, e, par, idx);
-        if (!e->u.list) {
-          list_delete((struct list_type **) &(u->entries), (struct list_type *) e);
-          free(e);
+    if ((u = get_user_by_handle(userlist, hand))) {
+      if (!(uet = find_entry_type(key)))
+        /* If it's not a supported type, forget it */
+        putlog(LOG_ERROR, "*", "Ignore ch %s from %s (unknown type)", key, dcc[idx].nick);
+      else {
+        if (!(dcc[idx].status & STAT_GETTING))
+          shareout_but(NULL, idx, "c %s %s %s\n", key, hand, par);
+        noshare = 1;
+        if (!u && (uet == &USERENTRY_BOTADDR)) {
+          char pass[30] = "";
+
+          makepass(pass);
+          userlist = adduser(userlist, hand, "none", pass, USER_BOT);
+          u = get_user_by_handle(userlist, hand);
+        } else if (!u)
+          return;
+
+        if (uet->got_share) {
+          if (!(e = find_user_entry(uet, u))) {
+            e = calloc(1, sizeof(struct user_entry));
+
+            e->type = uet;
+            e->name = NULL;
+            e->u.list = NULL;
+            list_insert((&(u->entries)), e);
+          }
+          uet->got_share(u, e, par, idx);
+          if (!e->u.list) {
+            list_delete((struct list_type **) &(u->entries), (struct list_type *) e);
+            free(e);
+          }
         }
+        noshare = 0;
       }
-      noshare = 0;
     }
   }
 }
@@ -958,7 +962,7 @@ share_ufyes(int idx, char *par)
     dcc[idx].status |= STAT_SHARE;
     dcc[idx].status |= STAT_SENDING;
 
-    dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
+    dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT);
     dprintf(idx, "s feats overbots invites exempts\n");
 
     lower_bot_linked(idx);
@@ -989,7 +993,7 @@ share_userfileq(int idx, char *par)
     if (!ok)
       dprintf(idx, "s un Already sharing.\n");
     else {
-      dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
+      dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT);
       dprintf(idx, "s uy overbots invites exempts\n");
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
@@ -1060,7 +1064,7 @@ share_version(int idx, char *par)
 {
   /* Cleanup any share flags */
   dcc[idx].status &= ~(STAT_SHARE | STAT_GETTING | STAT_SENDING | STAT_OFFERED | STAT_AGGRESSIVE);
-  dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
+  dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT);
   if (bot_aggressive_to(dcc[idx].user)) {
     dprintf(idx, "s u?\n");
     dcc[idx].status |= STAT_OFFERED;
@@ -1367,7 +1371,7 @@ finish_share(int idx)
   loading = 1;
   checkchans(0);                /* flag all the channels.. */
   Context;
-  if (!readuserfile(dcc[idx].u.xfer->filename, &u)) {		/* read the userfile into 'u' */
+  if (!readuserfile(dcc[idx].u.xfer->filename, &u)) {   /* read the userfile into 'u' */
     /* FAILURE */
     char xx[1024] = "";
 
@@ -1402,7 +1406,7 @@ finish_share(int idx)
 
   /* SUCCESS! */
 
-  unlink(dcc[idx].u.xfer->filename);    
+  unlink(dcc[idx].u.xfer->filename);
 
   loading = 0;
 
@@ -1417,7 +1421,7 @@ finish_share(int idx)
    *   - unshared (got_share == 0) user entries
    */
   clear_userlist(ou);
-  
+
   unlink(dcc[idx].u.xfer->filename);    /* Done with you!               */
 
   checkchans(1);                /* remove marked channels */