root/1.8.3/tags/p6/hdrs/access.h

Revision 1117, 3.0 KB (checked in by shawnw, 15 months ago)

Merge with devel

Line 
1#ifndef __ACCESS_H
2#define __ACCESS_H
3
4/** Access information for a host-pattern.
5 * This structure holds access information for a given host-pattern.
6 * It's organized into a linked list of access rules.
7 */
8struct access {
9  char host[BUFFER_LEN];        /**< The host pattern */
10  char comment[BUFFER_LEN];     /**< A comment about the rule */
11  dbref who;                    /**< Who created this rule if sitelock used */
12  uint32_t can;                      /**< Bitflags of what the host can do */
13  uint32_t cant;                     /**< Bitflags of what the host can't do */
14  pcre *re;                     /**< Compiled regexp */
15  struct access *next;          /**< Pointer to next rule in the list */
16};
17
18
19/* These flags are can/can't - a site may or may not be allowed to do them */
20#define ACS_CONNECT     0x1U    /* Connect to non-guests */
21#define ACS_CREATE      0x2U    /* Create new players */
22#define ACS_GUEST       0x4U    /* Connect to guests */
23#define ACS_REGISTER    0x8U    /* Site can use the 'register' command */
24/* These flags are set in the 'can' bit, but they mark special processing */
25#define ACS_SITELOCK    0x10U   /* Marker for where to insert @sitelock */
26#define ACS_SUSPECT     0x20U   /* All players from this site get SUSPECT */
27#define ACS_DENY_SILENT 0x40U   /* Don't log failed attempts */
28#define ACS_REGEXP      0x80U   /* Treat the host pattern as a regexp */
29
30#define ACS_GOD         0x100U  /* God can connect from this site */
31#define ACS_WIZARD      0x200U  /* Wizards can connect from this site */
32#define ACS_ADMIN       0x400U  /* Admins can connect from this site */
33
34/* This is the usual default access */
35#define ACS_DEFAULT             (ACS_CONNECT|ACS_CREATE|ACS_GUEST)
36
37/* Usefile macros */
38
39#define Site_Can_Connect(hname, who)  site_can_access(hname,ACS_CONNECT, who)
40#define Site_Can_Create(hname)  site_can_access(hname,ACS_CREATE, AMBIGUOUS)
41#define Site_Can_Guest(hname,who)  site_can_access(hname,ACS_GUEST, who)
42#define Site_Can_Register(hname)  site_can_access(hname,ACS_REGISTER, AMBIGUOUS)
43#define Deny_Silent_Site(hname, who) site_can_access(hname,ACS_DENY_SILENT, who)
44#define Suspect_Site(hname, who)  site_can_access(hname,ACS_SUSPECT, who)
45#define Forbidden_Site(hname)  (!site_can_access(hname,ACS_DEFAULT, AMBIGUOUS))
46
47/* Public functions */
48bool read_access_file(void);
49void write_access_file(void);
50bool site_can_access(const char *hname, uint32_t flag, dbref who);
51struct access *site_check_access(const char *hname, dbref who, int *rulenum);
52void format_access(struct access *ap, int rulenum,
53                   dbref who
54                   __attribute__ ((__unused__)), char *buff, char **bp);
55bool add_access_sitelock(dbref player, const char *host, dbref who,
56                         uint32_t can, uint32_t cant);
57int remove_access_sitelock(const char *pattern);
58void do_list_access(dbref player);
59int parse_access_options
60  (const char *opts, dbref *who, uint32_t * can, uint32_t * cant, dbref player);
61
62#endif                          /* __ACCESS_H */
Note: See TracBrowser for help on using the browser.