summaryrefslogtreecommitdiffstats
path: root/mbbsd/stuff.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-06-18 12:18:41 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-06-18 12:18:41 +0800
commit7ca0e08f3bb2419e7aea55740c672a88fe9c62bd (patch)
treea024b0a46c9ce8f16b975ba268746c6e499e01e4 /mbbsd/stuff.c
parentddffb6f6493be88677a43407aa175d3abc4b3d3c (diff)
downloadpttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.tar
pttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.tar.gz
pttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.tar.bz2
pttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.tar.lz
pttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.tar.xz
pttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.tar.zst
pttbbs-7ca0e08f3bb2419e7aea55740c672a88fe9c62bd.zip
reject bad ips, including tor and bbsnet
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3373 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/stuff.c')
-rw-r--r--mbbsd/stuff.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 6a37d816..ee645421 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -981,6 +981,27 @@ inline int *intbsearch(int key, const int *base0, int nmemb)
return (NULL);
}
+inline unsigned int *
+uintbsearch(const unsigned int key, const unsigned int *base0, const int nmemb)
+{
+ /* 改自 /usr/src/lib/libc/stdlib/bsearch.c ,
+ 專給搜 int array 用的, 不透過 compar function 故較快些 */
+ const char *base = (const char *)base0;
+ size_t lim;
+ unsigned int *p;
+
+ for (lim = nmemb; lim != 0; lim >>= 1) {
+ p = (unsigned int *)(base + (lim >> 1) * 4);
+ if( key == *p )
+ return p;
+ if( key > *p ){/* key > p: move right */
+ base = (char *)p + 4;
+ lim--;
+ } /* else move left */
+ }
+ return (NULL);
+}
+
int qsort_intcompar(const void *a, const void *b)
{
return *(int *)a - *(int *)b;