1 Citadel/UX Server Extension API Documentation
2 ---------------------------------------------
4 This is a (very) incomplete documentation of the API for extending the
5 Citadel server using dynamically loaded modules. It really isn't an API at
6 all, but rather a list of some of the functions available in the server which
7 are likely to be of use to module writers.
9 Expect this document to become more complete over time, as both the API and
10 the person documenting it have a chance to mature a bit. :)
14 USER RELATED FUNCTIONS
15 ----------------------
17 The fundamental user data is stored in "struct usersupp" which is defined
18 in citadel.h. The following functions are available:
21 int getuser(struct usersupp *usbuf, char name[])
23 Given the name of a requested user and a buffer to store the usersupp
24 record in, getuser() will search the userlog for the named user and load its
25 data into the buffer. getuser() returns 0 upon success or a nonzero error
26 code if the requested operation could not be performed.
29 void putuser(struct usersupp *usbuf, char *name)
31 After reading in a user record with getuser() and perhaps modifying the data
32 in some way, a program may use putuser() to write it back to disk.
35 int lgetuser(struct usersupp *usbuf, char *name)
36 void lputuser(struct usersupp *usbuf, char *name)
38 If critical-section operation is required, this pair of calls may be used.
39 They function the same as getuser() and putuser(), except that lgetuser()
40 locks the user file immediately after retrieving the record and lputuser()
41 unlocks it. This will guarantee that no other threads manipulate the same
42 user record at the same time.
44 NOTE: do NOT attempt to combine the locking lgetuser/lputuser calls with any
45 other locking calls in this API. Attempting to obtain concurrent locks on
46 multiple files may result in a deadlock condition which would freeze the
50 void ForEachUser(void (*CallBack)(struct usersupp *EachUser))
52 This allows a user-supplied function to be called once for each user on
53 the system. The user-supplied function will be called with a pointer to a
54 usersupp structure as its only argument.
57 int getuserbynumber(struct usersupp *usbuf, long int number)
59 getuserbynumber() functions similarly to getuser(), except that it is
60 supplied with a user number rather than a name. Calling this function
61 results in a sequential search of the user file, so use it sparingly if at
65 int purge_user(char *pname)
67 This function deletes the named user off the system and erases all related
68 objects: bio, photo, etc. It returns 0 upon success or a nonzero error code
69 if the requested operation could not be performed.
73 HOW TO REGISTER FUNCTION HOOKS
74 ------------------------------
76 The truly powerful part of the Citadel API is the ability for extensions to
77 register "hooks" -- user-supplied functions will be called while the server
78 is performing various tasks. Here are the API calls to register hooks:
81 void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc)
83 Adds a new server command to the system. The handler function should accept
84 a single string parameter, which will be set to a string containing any
85 parameters the client software sent along with the server command. "cmd"
86 should be the four-character mnemonic the server command is known by, and
87 "desc" is a description of the new command.
90 void CtdlRegisterCleanupHook(void *fcn_ptr)
92 Registers a new function to be called whenever the server is shutting down.
93 Cleanup functions accept no parameters.
96 void CtdlRegisterSessionHook(void *fcn_ptr, int EventType)
98 Registers a session hook. Session hooks accept no parameters. There are
99 multiple types of session hooks; the server extension registers which one it
100 is interested in by setting the value of EventType. The available session
103 #define EVT_STOP 0 /* Session is terminating */
104 #define EVT_START 1 /* Session is starting */
105 #define EVT_LOGIN 2 /* A user is logging in */
106 #define EVT_NEWROOM 3 /* Changing rooms */
107 #define EVT_LOGOUT 4 /* A user is logging out */
108 #define EVT_SETPASS 5 /* Setting or changing password */
111 void CtdlRegisterUserHook(void *fcn_ptr, int EventType)
113 Registers a user hook. User hooks accept two parameters: a string pointer
114 containing the user name, and a long which *may* contain a user number (only
115 applicable for certain types of hooks). The available user hook types are:
117 #define EVT_PURGEUSER 100 /* Deleting a user */
118 #define EVT_OUTPUTMSG 101 /* Outputting a message */
122 FUNCTIONS WHICH MANIPULATE USER/ROOM RELATIONSHIPS
124 void CtdlGetRelationship(struct visit *vbuf,
125 struct usersupp *rel_user,
126 struct quickroom *rel_room);
127 void CtdlSetRelationship(struct visit *newvisit,
128 struct usersupp *rel_user,
129 struct quickroom *rel_room);
131 These functions get/set a "struct visit" structure which may contain
132 information about the relationship between a user and a room. Specifically:
138 unsigned int v_flags;
141 #define V_FORGET 1 /* User has zapped this room */
142 #define V_LOCKOUT 2 /* User is locked out of this room */
143 #define V_ACCESS 4 /* Access is granted to this room */
145 Don't change v_roomname or v_generation; they're used to identify the room
146 being referred to. A room is unique to the system by its combination of room
147 name and generation number. If a new room is created with the same name as
148 a recently deleted room, it will have a new generation number, and therefore
149 stale "visit" records will not be applied (and will eventually be purged).
151 v_lastseen contains the number of the newest message the user has read in
152 this room. Any existing messages higher than this number can be considered
155 v_flags contains information regarding access to the room.
159 int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf)
161 This is a convenience function which uses CtdlGetRelationship() to determine
162 whether a user has access to a room. It returns a bucket of bits which may
165 #define UA_INUSE 1 /* Room exists */
166 #define UA_KNOWN 2 /* Room is in user's Known list */
167 #define UA_GOTOALLOWED 4 /* User may <.G>oto this room */
168 #define UA_HASNEWMSGS 8 /* Room contains new messages */
169 #define UA_ZAPPED 16 /* User has forgotten this room */