diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-06-12 16:38:18 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-06-12 16:38:18 +0800 |
commit | e7ecc5b089fa18b0ae854c68888892dd3f16bae0 (patch) | |
tree | f05b8d16c985110a8fd75bb3dbc1eea61db44c0d | |
parent | 524762d356060ffea62fe04c8411a1555634b1a9 (diff) | |
download | pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.tar pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.tar.gz pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.tar.bz2 pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.tar.lz pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.tar.xz pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.tar.zst pttbbs-e7ecc5b089fa18b0ae854c68888892dd3f16bae0.zip |
* add hashed filename utility API (good idea from kcwu)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5064 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/common/bbs/path.c | 18 | ||||
-rw-r--r-- | pttbbs/include/cmbbs.h | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/pttbbs/common/bbs/path.c b/pttbbs/common/bbs/path.c index 560ac793..cfe88ad6 100644 --- a/pttbbs/common/bbs/path.c +++ b/pttbbs/common/bbs/path.c @@ -40,7 +40,6 @@ sethomeman(char *buf, const char *userid) snprintf(buf, PATHLEN, str_home_file, userid[0], userid, "man"); } - void sethomefile(char *buf, const char *userid, const char *fname) { @@ -49,6 +48,23 @@ sethomefile(char *buf, const char *userid, const char *fname) snprintf(buf, PATHLEN, str_home_file, userid[0], userid, fname); } +void +setuserhashedfile(char *buf, const char *filename) +{ +#ifdef USERHASHSTORE_ROOTPATH + // hash designed by kcwu + unsigned hash = StringHash(cuser.userid) & 0xffff; + assert(is_validuserid(cuser.userid)); + snprintf(buf, PATHLEN, + USERHASHSTORE_ROOTPATH "/%02x/%02x/%s.%s.%x", + (hash >> 8) & 0xff, hash & 0xff, + filename, cuser.userid, cuser.firstlogin); +#else + assert(!"you must define and initialize USERHASHSTORE_ROOTPATH"); +#endif +} + + void setapath(char *buf, const char *boardname) { diff --git a/pttbbs/include/cmbbs.h b/pttbbs/include/cmbbs.h index 7cd6309c..393d849c 100644 --- a/pttbbs/include/cmbbs.h +++ b/pttbbs/include/cmbbs.h @@ -18,6 +18,7 @@ extern void sethomepath(char *buf, const char *userid); extern void sethomedir (char *buf, const char *userid); extern void sethomeman (char *buf, const char *userid); extern void sethomefile(char *buf, const char *userid, const char *fname); +extern void setuserhashedfile(char *buf, const char *filename); // setbdir // setuserfile |