summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/sys/sort.c43
-rw-r--r--daemon/utmpd/Makefile15
-rw-r--r--daemon/utmpd/utmpserver.c4
-rw-r--r--include/cmsys.h2
-rw-r--r--include/proto.h4
-rw-r--r--mbbsd/Makefile17
-rw-r--r--mbbsd/stuff.c41
7 files changed, 66 insertions, 60 deletions
diff --git a/common/sys/sort.c b/common/sys/sort.c
index edecc0a8..d649b9e4 100644
--- a/common/sys/sort.c
+++ b/common/sys/sort.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
int cmp_int(const void *a, const void *b)
{
@@ -8,3 +9,45 @@ int cmp_int_desc(const void * a, const void * b)
{
return cmp_int(b, a);
}
+
+int *
+intbsearch(int key, const int *base0, int nmemb)
+{
+ /* 改自 /usr/src/lib/libc/stdlib/bsearch.c ,
+ 專給搜 int array 用的, 不透過 compar function 故較快些 */
+ const char *base = (const char *)base0;
+ size_t lim;
+ int *p;
+
+ for (lim = nmemb; lim != 0; lim >>= 1) {
+ p = (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);
+}
+
+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);
+}
diff --git a/daemon/utmpd/Makefile b/daemon/utmpd/Makefile
index 73d7bfc9..a6f99333 100644
--- a/daemon/utmpd/Makefile
+++ b/daemon/utmpd/Makefile
@@ -5,7 +5,10 @@ SRCROOT= ../..
PROGRAMS= utmpserver utmpsync utmpserver2 utmpserver3 authserver
UTILDIR= $(SRCROOT)/util
-UTILOBJ= $(UTILDIR)/util_stuff.o $(UTILDIR)/util_var.o $(UTILDIR)/util_cache.o $(UTILDIR)/util_passwd.o $(UTILDIR)/util_record.o
+UTILOBJ= $(UTILDIR)/util_var.o $(UTILDIR)/util_cache.o $(UTILDIR)/util_passwd.o $(UTILDIR)/util_record.o
+
+LDLIBS+= $(SRCROOT)/common/sys/libcmsys.a \
+ $(SRCROOT)/common/bbs/libcmbbs.a
all: ${PROGRAMS}
@@ -16,16 +19,16 @@ all: ${PROGRAMS}
$(CCACHE) $(CXX) $(CFLAGS) -c $*.cpp
utmpserver: utmpserver.o $(UTILOBJ)
- ${CC} ${CFLAGS} ${LDFLAGS} -o $* $*.o $(UTILOBJ)
+ ${CC} ${CFLAGS} ${LDFLAGS} -o $* $*.o $(UTILOBJ) $(LDLIBS)
utmpserver2: utmpserver2.o friend.o $(UTILOBJ)
- ${CXX} ${CFLAGS} ${LDFLAGS} -o $* $*.o $(UTILOBJ) friend.o
+ ${CXX} ${CFLAGS} ${LDFLAGS} -o $* $*.o $(UTILOBJ) friend.o $(LDLIBS)
utmpserver3: utmpserver3.o friend.o $(UTILOBJ)
- ${CXX} ${CFLAGS} ${LDFLAGS} -levent -o $* $*.o $(UTILOBJ) friend.o
+ ${CXX} ${CFLAGS} ${LDFLAGS} -levent -o $* $*.o $(UTILOBJ) friend.o $(LDLIBS)
utmpsync: utmpsync.o $(UTILOBJ)
- ${CC} ${CFLAGS} ${LDFLAGS} -o $* $*.o $(UTILOBJ)
+ ${CC} ${CFLAGS} ${LDFLAGS} -o $* $*.o $(UTILOBJ) $(LDLIBS)
authserver: authserver.o $(UTILOBJ)
- ${CC} ${CFLAGS} ${LDFLAGS} -lcrypt -levent -o $* $>
+ ${CC} ${CFLAGS} ${LDFLAGS} -lcrypt -levent -o $* $> $(LDLIBS)
clean:
rm -f *~ ${PROGRAMS} friend.o utmpserver.o utmpserver2.o utmpserver3.o utmpsync.o authserver.o
diff --git a/daemon/utmpd/utmpserver.c b/daemon/utmpd/utmpserver.c
index 85adf8c3..19005a80 100644
--- a/daemon/utmpd/utmpserver.c
+++ b/daemon/utmpd/utmpserver.c
@@ -79,10 +79,10 @@ void initdata(int index)
utmp[index].nRejects = countarray(utmp[index].reject, MAX_REJECT);
if( utmp[index].nFriends > 0 )
qsort(utmp[index].friend, utmp[index].nFriends,
- sizeof(int), qsort_intcompar);
+ sizeof(int), cmp_int);
if( utmp[index].nRejects > 0 )
qsort(utmp[index].reject, utmp[index].nRejects,
- sizeof(int), qsort_intcompar);
+ sizeof(int), cmp_int);
}
inline void syncutmp(int cfd)
diff --git a/include/cmsys.h b/include/cmsys.h
index 10c9a928..42b0d032 100644
--- a/include/cmsys.h
+++ b/include/cmsys.h
@@ -71,6 +71,8 @@ extern int towrite(int fd, const void *buf, int len);
/* sort.c */
extern int cmp_int(const void *a, const void *b);
extern int cmp_int_desc(const void * a, const void * b);
+extern int *intbsearch(int key, const int *base0, int nmemb);
+extern unsigned int *uintbsearch(const unsigned int key, const unsigned int *base0, const int nmemb);
/* string.h */
extern void str_lower(char *t, const char *s);
diff --git a/include/proto.h b/include/proto.h
index b46b8b0d..73734e50 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -605,9 +605,7 @@ void cursor_show(int row, int column);
void printdash(const char *mesg, int msglen);
int userid_is_BM(const char *userid, const char *list);
int is_uBM(const char *list, const char *id);
-inline int *intbsearch(int key, const int *base0, int nmemb);
-inline unsigned int *uintbsearch(const unsigned int, const unsigned int *, const int);
-int qsort_intcompar(const void *a, const void *b);
+// int qsort_intcompar(const void *a, const void *b);
#ifndef CRITICAL_MEMORY
#define MALLOC(p) malloc(p)
#define FREE(p) free(p)
diff --git a/mbbsd/Makefile b/mbbsd/Makefile
index 17156401..7aa1b55b 100644
--- a/mbbsd/Makefile
+++ b/mbbsd/Makefile
@@ -10,17 +10,18 @@ SRCROOT= ..
PROG= mbbsd
CHESSOBJS= chc.o chc_tab.o chess.o go.o gomo.o dark.o reversi.o
GAMEOBJS = card.o guess.o chicken.o othello.o
-COREOBJS = bbs.o announce.o read.o board.o cache.o brc.o mail.o record.o fav.o
+COREOBJS = bbs.o announce.o read.o board.o cache.o cal.o brc.o mail.o record.o fav.o
ACCOBJS = user.o register.o passwd.o
TALKOBJS = talk.o chat.o friend.o
-NETOBJS = mbbsd.o io.o term.o
-UTILOBJS = stuff.o kaede.o convert.o name.o
-PLUGOBJS = lovepaper.o calendar.o topsong.o vice.o
-OBJS= admin.o assess.o cal.o edit.o menu.o more.o gamble.o \
- xyz.o syspost.o vote.o var.o voteboard.o \
- pmore.o telnet.o \
+NETOBJS = mbbsd.o io.o term.o telnet.o
+UTILOBJS = stuff.o kaede.o convert.o name.o syspost.o
+PLUGOBJS = lovepaper.o calendar.o topsong.o gamble.o vice.o
+PAGEROBJS= more.o pmore.o
+OBJS= admin.o assess.o edit.o menu.o xyz.o var.o \
+ vote.o voteboard.o \
$(COREOBJS) $(ACCOBJS) $(NETOBJS) $(TALKOBJS) $(UTILOBJS) \
- $(SYSOBJS) $(PLUGOBJS) $(CHESSOBJS) $(GAMEOBJS)
+ $(PAGEROBJS) $(SYSOBJS) $(PLUGOBJS) \
+ $(CHESSOBJS) $(GAMEOBJS)
#######################################################################
# conditional configurations and optional modules
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 1b3aace1..3b79de9a 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -531,47 +531,6 @@ DBCS_StringHash(const char *s)
return fnv1a_32_dbcs_strcase(s, FNV1_32_INIT);
}
-inline int *intbsearch(int key, const int *base0, int nmemb)
-{
- /* /usr/src/lib/libc/stdlib/bsearch.c ,
- Mj int array Ϊ, zL compar function G֨ */
- const char *base = (const char *)base0;
- size_t lim;
- int *p;
-
- for (lim = nmemb; lim != 0; lim >>= 1) {
- p = (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);
-}
-
-inline unsigned int *
-uintbsearch(const unsigned int key, const unsigned int *base0, const int nmemb)
-{
- /* /usr/src/lib/libc/stdlib/bsearch.c ,
- Mj int array Ϊ, zL compar function G֨ */
- 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);
-}
-
/* AIDS */
aidu_t fn2aidu(char *fn)
{