diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-03-07 23:13:44 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-03-07 23:13:44 +0800 |
commit | ae31e19f92e717919ac8e3db9039eb38d2b89aae (patch) | |
tree | c70164d6a1852344f44b04a653ae2815043512af /util/horoscope.c | |
download | pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2 pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip |
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/horoscope.c')
-rw-r--r-- | util/horoscope.c | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/util/horoscope.c b/util/horoscope.c new file mode 100644 index 00000000..c91db7cd --- /dev/null +++ b/util/horoscope.c @@ -0,0 +1,157 @@ +/* $Id: horoscope.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */ +#include <stdio.h> +#include <sys/types.h> +#include "config.h" +#include "pttstruct.h" +#include "util.h" +#include "common.h" + +struct userec_t cuser; + +int main() { + int i, j, k; + FILE *fp; + int max, item, maxhoroscope; + + int act[12]; + + char *name[13] = + {"牡羊", + "金牛", + "雙子", + "巨蟹", + "獅子", + "處女", + "天秤", + "天蠍", + "射手", + "摩羯", + "水瓶", + "雙魚", + "" + }; + char *blk[10] = + { + " ", "▏", "▎", "▍", "▌", + "▋", "▊", "▉", "█", "█", + }; + + memset(act, 0, sizeof(act)); + if(passwd_mmap()) + exit(1); + for(k = 1; k <= MAX_USERS; k++) { + passwd_query(k, &cuser); + if(!cuser.userid[0]) + continue; + switch (cuser.month) + { + case 1: + if (cuser.day <= 19) + act[9]++; + else + act[10]++; + break; + case 2: + if (cuser.day <= 18) + act[10]++; + else + act[11]++; + break; + case 3: + if (cuser.day <= 20) + act[11]++; + else + act[0]++; + break; + case 4: + if (cuser.day <= 19) + act[0]++; + else + act[1]++; + break; + case 5: + if (cuser.day <= 20) + act[1]++; + else + act[2]++; + break; + case 6: + if (cuser.day <= 21) + act[2]++; + else + act[3]++; + break; + case 7: + if (cuser.day <= 22) + act[3]++; + else + act[4]++; + break; + case 8: + if (cuser.day <= 22) + act[4]++; + else + act[5]++; + break; + case 9: + if (cuser.day <= 22) + act[5]++; + else + act[6]++; + break; + case 10: + if (cuser.day <= 23) + act[6]++; + else + act[7]++; + break; + case 11: + if (cuser.day <= 22) + act[7]++; + else + act[8]++; + break; + case 12: + if (cuser.day <= 21) + act[8]++; + else + act[9]++; + break; + } + } + + for (i = max = maxhoroscope = 0; i < 12; i++) + { + if (act[i] > max) + { + max = act[i]; + maxhoroscope = i; + } + } + + item = max / 30 + 1; + + if ((fp = fopen(BBSHOME"/etc/horoscope", "w")) == NULL) + { + printf("cann't open etc/horoscope\n"); + return 1; + } + + for (i = 0; i < 12; i++) + { + fprintf(fp, " [1;37m%s座 [0;36m", name[i]); + for (j = 0; j < act[i] / item; j++) + { + fprintf(fp, "%2s", blk[9]); + } + /* 為了剛好一頁 */ + if (i != 11) + fprintf(fp, "%2s [1;37m%d[m\n\n", blk[(act[i] % item) * 10 / item], + act[i]); + else + fprintf(fp, "%2s [1;37m%d[m\n", blk[(act[i] % item) * 10 / item], + act[i]); + } + fclose(fp); + return 0; +} |