diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-30 06:00:39 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-30 06:00:39 +0800 |
commit | 36d5b89b27a3d9a1c814a8aa79e971f151d40dba (patch) | |
tree | 6c602475d0b6594b113530338735cac7e960626f /util/uhash_loader.c | |
parent | 76746edd9196c752cf198765e1921f55978276e3 (diff) | |
download | pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.tar pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.tar.gz pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.tar.bz2 pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.tar.lz pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.tar.xz pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.tar.zst pttbbs-36d5b89b27a3d9a1c814a8aa79e971f151d40dba.zip |
before reboot
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1631 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/uhash_loader.c')
-rw-r--r-- | util/uhash_loader.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/util/uhash_loader.c b/util/uhash_loader.c index d5171d56..931a0b64 100644 --- a/util/uhash_loader.c +++ b/util/uhash_loader.c @@ -117,11 +117,28 @@ unsigned string_hash(unsigned char *s) return (v * 2654435769UL) >> (32 - HASH_BITS); } +int loadmoney(char * userid) +{ + static userec_t u; + int fd, money=0; + char path[256]; + sprintf(path,"home/%c/%s", userid[0], userid); + if((fd=open(path, O_RDONLY))<0) + return 0; + if(lseek(fd, (off_t)((int)&u.money - (int)&u), SEEK_SET) >= 0) + read(fd, &money, sizeof(int)); + close(fd); + return money; +} + void add_to_uhash(int n, userec_t *user) { int *p, h = string_hash(user->userid); strcpy(SHM->userid[n], user->userid); - SHM->money[n] = user->money; + SHM->money[n] = loadmoney(user->userid); + //SHM->money[n] = user->money; + // Ptt: money is not accurate must load from user home + p = &(SHM->hash_head[h]); while (*p != -1) |