Skip to content

Commit

Permalink
chore(lib/acct.c): merge duplicated functions; unify deviated logic […
Browse files Browse the repository at this point in the history
…ref: #50]

* Add lib/acct.c to the source file lists
    * lib/CMakeLists.txt & lib/Makefile

* Move functions free of bbsd globals in maple/acct.c to lib/acct.c:
    * keeplog()
        * maple/acct.c
        * util/account.c
        * util/brdstat.c
        * util/stopperm.c
    * acct_load()
        * maple/acct.c
        * maple/xchatd.c
        * util/bbsmail.c
        * util/stopperm.c
    * acct_save()
        * maple/acct.c
        * util/addsong.c
        * util/resetvmail.c
        * util/stopperm.c
        * util/template.c
        * util/tranufo.c
    * seek_log_email()
        * maple/acct.c (static)
        * util/stopperm.c
    * deny_log_email()
        * maple/acct.c
        * util/stopperm.c
    * static deny_add_email()
        * maple/acct.c
        * util/stopperm.c
    * add_deny_exer() (duplicated with maple/acct.c add_deny())
        * util/stopperm.c

    * Other non-duplicated functions from maple/acct.c:
        * acct_userno()
        * maple/acct.c
        * addmoney()
        * addpoint1()
        * addpoint2()
        * ban_addr()
            * Add ban_addr_tlogger & ban_addr_tlogger_init() for log message output
        * allow_addr()
            * Drop the `#ifdef HAVE_WRITE` compilation condition
            * Make the function non-static
        * check_nckuemail()
        * find_same_email()

* Refine the whitespace usage of function parameter lists

* lib/acct.c keeplog():
    * Redefine the formerly case where arg `mode` == 3 in util/account.c,
      which behaviored as rename+mark rather than load+mark,
      as the new case where arg `mode` == 4
    * Refine the description for param `mode` for the easiness of comprehension

* maple/acct.c add_deny():
    * Move and merge the main logic to add_deny_exer()

* util/stopperm.c add_deny_exer() -> lib/acct.c add_deny_exer():
    * Make the behaviors consistent with the former add_deny()
        * Make suspension duration accumulate
        * Keep the content of user's FN_STOPPERM_LOG when appending messages,
          since suspension duration now accumulates
        * Unify the message text

* maple/acct.c ban_addr() -> lib/acct.c ban_addr():
    * Rewrite message logging with logger_tag() & TLogger
        * Add static TLogger object ban_addr_tlogger
        * Add ban_addr_tlogger_init()
            * Invoke it before the first call to ban_addr()
                * maple/bbsd.c main()
  • Loading branch information
IepIweidieng committed May 19, 2021
1 parent 0eac429 commit 46603f1
Show file tree
Hide file tree
Showing 16 changed files with 548 additions and 974 deletions.
16 changes: 16 additions & 0 deletions include/dao.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ extern "C" {
/* Thor.981206: lkchu patch */
extern const char radix32[32];

/* acct.c */
void addmoney(int addend, const char *userid);
void addpoint1(int addend, const char *userid);
void addpoint2(int addend, const char *userid);
void keeplog(const char *fnlog, const char *board, const char *title, int mode);
int acct_load(ACCT *acct, const char *userid);
void acct_save(const ACCT *acct);
int acct_userno(const char *userid);
void deny_log_email(const char *mail, time_t deny);
int seek_log_email(const char *mail, int mode);
int add_deny_exer(ACCT *u, int adm, int cross, const char *exer);
void ban_addr_tlogger_init(const TLogger *tlogger);
int ban_addr(const char *addr);
int allow_addr(const char *addr);
void check_nckuemail(char *email);
int find_same_email(const char *mail, int mode);
/* acl.c */
int acl_addr(const char *acl, const char *addr);
int acl_has(const char *acl, const char *user, const char *host);
Expand Down
11 changes: 0 additions & 11 deletions include/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,18 @@ char *genpasswd(char *pw, int mode);

/* acct.c */
void logitfile(const char *file, const char *key, const char *msg);
void addmoney(int addend, const char *userid);
void addpoint1(int addend, const char *userid);
void addpoint2(int addend, const char *userid);
void keeplog(const char *fnlog, const char *board, const char *title, int mode);
int acct_load(ACCT *acct, const char *userid);
void acct_save(const ACCT *acct);
int acct_userno(const char *userid);
int acct_get(const char *msg, ACCT *acct);
void x_file(int mode, const char *const xlist[], const char *const flist[]);
int check_admin(const char *name);
void bitmsg(const char *msg, const char *str, int level);
unsigned int bitset(unsigned int pbits, int count, int maxon, const char *msg, const char *const perms[]);
void acct_show(const ACCT *u, int adm);
void bm_setup(ACCT *u, int adm);
void deny_log_email(const char *mail, time_t deny);
int add_deny(ACCT *u, int adm, int cross);
void acct_setup(ACCT *u, int adm);
int u_info(void);
int m_user(void);
int m_bmset(void);
int ban_addr(const char *addr);
void check_nckuemail(char *email);
int find_same_email(const char *mail, int mode);
int u_addr(void);
void su_setup(ACCT *u);
int u_setup(void);
Expand Down
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ add_library(dao STATIC
acl.c file.c isnot.c radix32.c shm.c
dl_lib.c record.c splay.c date.c xsort.c
attr_lib.c dns.c header.c string.c xwrite.c
proc.c passwd.c mime.c logger.c
proc.c passwd.c mime.c logger.c acct.c
)
4 changes: 2 additions & 2 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ HDR = dao.h dao.p
SRC = acl.c file.c isnot.c radix32.c shm.c \
dl_lib.c record.c splay.c date.c xsort.c \
attr_lib.c dns.c header.c string.c xwrite.c \
proc.c passwd.c mime.c logger.c
proc.c passwd.c mime.c logger.c acct.c

OBJ = acl.o file.o isnot.o radix32.o shm.o \
dl_lib.o record.o splay.o date.o xsort.o \
attr_lib.o dns.o header.o string.o xwrite.o \
proc.o passwd.o mime.o logger.o
proc.o passwd.o mime.o logger.o acct.c

.c.o: ;$(CC) $(CFLAGS) -c $*.c

Expand Down
Loading

0 comments on commit 46603f1

Please sign in to comment.