summaryrefslogtreecommitdiffstats
path: root/util/indexuser.c
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-18 01:09:36 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-18 01:09:36 +0800
commitfd07e149a7791ef27928e2c8eb1365ee5afa4084 (patch)
tree3f2014943c64ad81d07e4f58301f723eb54383e3 /util/indexuser.c
parent6b33b2191f21f6cb0ea5d8490610704b29bbc98e (diff)
downloadpttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.tar
pttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.tar.gz
pttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.tar.bz2
pttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.tar.lz
pttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.tar.xz
pttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.tar.zst
pttbbs-fd07e149a7791ef27928e2c8eb1365ee5afa4084.zip
*** empty log message ***
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@417 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/indexuser.c')
-rw-r--r--util/indexuser.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/util/indexuser.c b/util/indexuser.c
new file mode 100644
index 00000000..c626303b
--- /dev/null
+++ b/util/indexuser.c
@@ -0,0 +1,41 @@
+#include "bbs.h"
+#define INDEXPATH BBSHOME"/index"
+
+unsigned string_hash(unsigned char *s)
+{
+ unsigned int v = 0;
+ while (*s)
+ {
+ v = (v << 8) | (v >> 24);
+ v ^= toupper(*s++); /* note this is case insensitive */
+ }
+ return (v * 2654435769UL) >> (32 - HASH_BITS);
+}
+
+
+int main()
+{
+ int j;
+ userec_t u;
+ char buf[256];
+
+ if(passwd_mmap())
+ {
+ printf("Sorry, the data is not ready.\n");
+ exit(0);
+ }
+ system("rm -f "INDEXPATH"/realname/* ");
+ system("rm -f "INDEXPATH"/email/* ");
+ system("rm -f "INDEXPATH"/ident/* ");
+ for(j = 1; j <= MAX_USERS; j++) {
+ passwd_query(j, &u);
+ if(!u.userid[0]) continue;
+ sprintf(buf,INDEXPATH"/realname/%X",string_hash(u.realname));
+ append_record(buf, &j, sizeof(j));
+ sprintf(buf,INDEXPATH"/email/%X",string_hash(u.email));
+ append_record(buf, &j, sizeof(j));
+ sprintf(buf,INDEXPATH"/ident/%X",string_hash(u.ident));
+ append_record(buf, &j, sizeof(j));
+ }
+ return 0;
+}