summaryrefslogtreecommitdiffstats
path: root/mbbsd/assess.c
blob: af361a1325824a27391b62ed38fcd792e5be14c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* $Id$ */
#include "bbs.h"

#ifdef ASSESS

/* do (*num) + n, n is integer. */
inline static void inc(unsigned char *num, int n)
{
    if (n >= 0 && SALE_MAXVALUE - *num <= n)
    (*num) = SALE_MAXVALUE;
    else if (n < 0 && *num < -n)
    (*num) = 0;
    else
    (*num) += n;
}

#define modify_column(_attr) \
int inc_##_attr(char *userid, int num) \
{ \
    int uid = getuser(userid);\
    if( uid > 0 ){ \
    userinfo_t *uinfo = search_ulist(uid); \
    if (uinfo != NULL) \
        inc(&uinfo->_attr, num); \
    inc(&xuser._attr, num); \
    passwd_update(uid, &xuser); \
    return xuser._attr; }\
    return 0;\
}

modify_column(goodpost); /* inc_goodpost */
modify_column(badpost);  /* inc_badpost */
modify_column(goodsale); /* inc_goodsale */
modify_column(badsale);  /* inc_badsale */

#if 0 //unused function
void set_assess(char *userid, unsigned char num, int type)
{
    int uid = getuser(userid);
    if(uid<=0) return;
    switch (type){
    case GOODPOST:
        xuser.goodpost = num;
        break;
    case BADPOST:
        xuser.badpost = num;
        break;
    case GOODSALE:
        xuser.goodsale = num;
        break;
    case BADSALE:
        xuser.badsale = num;
        break;
    }
    passwd_update(uid, &xuser);
}
#endif

#endif