PennMUSH Community

root/1.8.3/trunk/hdrs/lock.h

Revision 1032, 5.4 kB (checked in by shawnw, 1 year ago)

Merged 1.8.3p4 into trunk

Line 
1 /* lock.h */
2
3 #include "copyrite.h"
4
5 #ifndef __LOCK_H
6 #define __LOCK_H
7
8 #include "mushtype.h"
9 #include "conf.h"
10 #include "boolexp.h"
11
12 /* I'm using a string for a lock type instead of a magic-cookie int for
13  * several reasons:
14  * 1) I don't think it will hurt efficiency that much. I'll profile it
15  * to check.
16  * 2) It will make debugging much easier to see lock types that can easily
17  * be interpreted by a human.
18  * 3) It allows the possibility of having arbitrary user-defined locks.
19  */
20
21 /** A list of locks set on an object.
22  * An object's locks are represented as a linked list of these structures.
23  */
24 struct lock_list {
25   lock_type type;               /**< Type of lock */
26   boolexp key;          /**< Lock value ("key") */
27   dbref creator;                /**< Dbref of lock creator */
28   privbits flags;                       /**< Lock flags */
29   struct lock_list *next;       /**< Pointer to next lock in object's list */
30 };
31
32 /* Our table of lock types, attributes, and default flags */
33 typedef struct lock_msg_info LOCKMSGINFO;
34 /** A lock.
35  * This structure represents a lock in the table of lock types
36  */
37 struct lock_msg_info {
38   lock_type type;               /**< Type of lock */
39   const char *succbase;         /**< Base name of success attribute */
40   const char *failbase;         /**< Base name of failure attribute */
41 };
42
43 #define LF_VISUAL  0x1U         /**< Anyone can see this lock with lock()/elock() */
44 #define LF_PRIVATE 0x2U         /**< This lock doesn't get inherited */
45 #define LF_WIZARD  0x4U         /**< Only wizards can set/unset this lock */
46 #define LF_LOCKED  0x8U         /**< Only the lock's owner can set/unset it */
47 #define LF_NOCLONE 0x10U /**< This lock isn't copied in @clone */
48 #define LF_OX      0x20U        /**< This lock's success messages includes OX*. */
49 #define LF_NOSUCCACTION 0x40U   /**< This lock doesn't have an @a-action for success. */
50 #define LF_NOFAILACTION 0x80U   /**< This lock doesn't have an @a-action for failure */
51 #define LF_OWNER        0x100U  /**< Lock can only be set/unset by object's owner */
52 #define LF_DEFAULT        0x200U  /**< Use default flags when setting lock */
53
54 /* lock.c */
55 boolexp getlock(dbref thing, lock_type type);
56 boolexp getlock_noparent(dbref thing, lock_type type);
57 lock_type match_lock(lock_type type);
58 const lock_list *get_lockproto(lock_type type);
59 int add_lock(dbref player, dbref thing, lock_type type, boolexp key,
60              privbits flags);
61 int add_lock_raw(dbref player, dbref thing, lock_type type,
62                  boolexp key, privbits flags);
63 void free_locks(lock_list *ll);
64 int eval_lock(dbref player, dbref thing, lock_type ltype);
65 int eval_lock_with(dbref player, dbref thing, lock_type ltype, dbref env0,
66                    dbref env1);
67 int fail_lock(dbref player, dbref thing, lock_type ltype, const char *def,
68               dbref loc);
69 void do_unlock(dbref player, const char *name, lock_type type);
70 void do_lock(dbref player, const char *name, const char *keyname,
71              lock_type type);
72 void init_locks(void);
73 void clone_locks(dbref player, dbref orig, dbref clone);
74 void do_lset(dbref player, char *what, char *flags);
75 void do_list_locks(dbref player, const char *arg, int lc, const char *label);
76 void list_locks(char *buff, char **bp, const char *name);
77 const char *lock_flags(lock_list *ll);
78 const char *lock_flags_long(lock_list *ll);
79 void list_lock_flags(char *buff, char **bp);
80 void list_lock_flags_long(char *buff, char **bp);
81 lock_list *getlockstruct(dbref thing, lock_type type);
82 void check_zone_lock(dbref player, dbref zone, int noisy);
83 void define_lock(lock_type name, privbits flags);
84 #define L_FLAGS(lock) ((lock)->flags)
85 #define L_CREATOR(lock) ((lock)->creator)
86 #define L_TYPE(lock) ((lock)->type)
87 #define L_KEY(lock) ((lock)->key)
88 #define L_NEXT(lock) ((lock)->next)
89 /* can p read/evaluate lock l on object x? */
90 bool lock_visual(dbref, lock_type);
91 #define Can_Read_Lock(p,x,l)   \
92     (See_All(p) || controls(p,x) || ((Visual(x) || lock_visual(x, l)) && \
93      eval_lock(p,x,Examine_Lock)))
94 /* The actual magic cookies. */
95 extern lock_type Basic_Lock;
96 extern lock_type Enter_Lock;
97 extern lock_type Use_Lock;
98 extern lock_type Zone_Lock;
99 extern lock_type Page_Lock;
100 extern lock_type Tport_Lock;
101 extern lock_type Speech_Lock;   /* Who can speak aloud in me */
102 extern lock_type Listen_Lock;   /* Who can trigger ^s/ahears on me */
103 extern lock_type Command_Lock;  /* Who can use $commands on me */
104 extern lock_type Parent_Lock;   /* Who can @parent to me */
105 extern lock_type Link_Lock;     /* Who can @link to me */
106 extern lock_type Leave_Lock;    /* Who can leave me */
107 extern lock_type Drop_Lock;     /* Who can drop me */
108 extern lock_type Give_Lock;     /* Who can give me */
109 extern lock_type Mail_Lock;     /* Who can @mail me */
110 extern lock_type Follow_Lock;   /* Who can follow me */
111 extern lock_type Examine_Lock;  /* Who can examine visual me */
112 extern lock_type Chzone_Lock;   /* Who can @chzone to this object? */
113 extern lock_type Forward_Lock;  /* Who can @forwardlist to object? */
114 extern lock_type Control_Lock;  /* Who can control this object? */
115 extern lock_type Dropto_Lock;   /* Who follows the dropto of this room? */
116 extern lock_type Destroy_Lock;  /* Who can @dest me if I'm dest_ok? */
117 extern lock_type Interact_Lock;
118 extern lock_type MailForward_Lock;      /* Who can forward mail to me */
119 extern lock_type Take_Lock;     /* Who can take from the contents of this object? */
120
121 #endif                          /* __LOCK_H */
Note: See TracBrowser for help on using the browser.