Просмотр исходного кода

* Moved egg_strcatn() to irc.mod/mode.c

svn: 1364
Bryan Drewery 21 лет назад
Родитель
Сommit
3e5829b79b
3 измененных файлов с 49 добавлено и 50 удалено
  1. 0 49
      src/misc.c
  2. 0 1
      src/misc.h
  3. 49 0
      src/mod/irc.mod/mode.c

+ 0 - 49
src/misc.c

@@ -47,55 +47,6 @@ bool		use_exempts = 1;            /* Jason/drummer */
 /* low-level stuff for other modules
  */
 
-/*	  This implementation wont overrun dst - 'max' is the max bytes that dst
- *	can be, including the null terminator. So if 'dst' is a 128 byte buffer,
- *	pass 128 as 'max'. The function will _always_ null-terminate 'dst'.
- *
- *	Returns: The number of characters appended to 'dst'.
- *
- *  Usage eg.
- *
- *		char 	buf[128];
- *		size_t	bufsize = sizeof(buf);
- *
- *		buf[0] = 0, bufsize--;
- *
- *		while (blah && bufsize) {
- *			bufsize -= egg_strcatn(buf, <some-long-string>, sizeof(buf));
- *		}
- *
- *	<Cybah>
- */
-size_t egg_strcatn(char *dst, const char *src, size_t max)
-{
-  size_t tmpmax = 0;
-
-  /* find end of 'dst' */
-  while (*dst && max > 0) {
-    dst++;
-    max--;
-  }
-
-  /*    Store 'max', so we can use it to workout how many characters were
-   *  written later on.
-   */
-  tmpmax = max;
-
-  /* copy upto, but not including the null terminator */
-  while (*src && max > 1) {
-    *dst++ = *src++;
-    max--;
-  }
-
-  /* null-terminate the buffer */
-  *dst = 0;
-
-  /*    Don't include the terminating null in our count, as it will cumulate
-   *  in loops - causing a headache for the caller.
-   */
-  return tmpmax - max;
-}
-
 size_t my_strcpy(register char *a, register char *b)
 {
   register char *c = b;

+ 0 - 1
src/misc.h

@@ -22,7 +22,6 @@ char *replace(const char *, const char *, const char *);
 int goodpass(char *, int, char *);
 int bot_aggressive_to(struct userrec *);
 int updatebin(int, char *, int);
-size_t egg_strcatn(char *dst, const char *src, size_t max);
 size_t my_strcpy(char *, char *);
 void maskhost(const char *, char *);
 char *stristr(char *, char *);

+ 49 - 0
src/mod/irc.mod/mode.c

@@ -21,6 +21,54 @@ static bool reversing = 0;
 static struct flag_record user = { FR_GLOBAL | FR_CHAN, 0, 0, 0 };
 static struct flag_record victim = { FR_GLOBAL | FR_CHAN, 0, 0, 0 };
 
+/*        This implementation wont overrun dst - 'max' is the max bytes that dst
+ *      can be, including the null terminator. So if 'dst' is a 128 byte buffer,
+ *      pass 128 as 'max'. The function will _always_ null-terminate 'dst'.
+ *
+ *      Returns: The number of characters appended to 'dst'.
+ *
+ *  Usage eg.
+ *
+ *              char    buf[128];
+ *              size_t  bufsize = sizeof(buf);
+ *
+ *              buf[0] = 0, bufsize--;
+ *
+ *              while (blah && bufsize) {
+ *                      bufsize -= egg_strcatn(buf, <some-long-string>, sizeof(buf));
+ *              }
+ *
+ *      <Cybah>
+ */
+static size_t egg_strcatn(char *dst, const char *src, size_t max)
+{
+  size_t tmpmax = 0;
+
+  /* find end of 'dst' */
+  while (*dst && max > 0) {
+    dst++;
+    max--;
+  }
+
+  /*    Store 'max', so we can use it to workout how many characters were
+   *  written later on.
+   */
+  tmpmax = max;
+
+  /* copy upto, but not including the null terminator */
+  while (*src && max > 1) {
+    *dst++ = *src++;
+    max--;
+  }
+
+  /* null-terminate the buffer */
+  /*    Don't include the terminating null in our count, as it will cumulate
+   *  in loops - causing a headache for the caller.
+   */
+  return tmpmax - max;
+}
+
+
 static bool
 do_op(char *nick, struct chanset_t *chan, time_t delay, bool force)
 {
@@ -897,6 +945,7 @@ gotmode(char *from, char *msg)
         } else {
           if (channel_pending(chan))
             return 0;
+          dprintf(DP_MODE, "KICK %s %s :Desync\n", chan->dname, nick);
           putlog(LOG_MISC, "*", CHAN_BADCHANMODE, chan->dname, nick);
           dprintf(DP_MODE, "WHO %s\n", nick);
           return 0;