3 This is a rough start at the beginnings of what will eventually become
4 something that resembles a draft of the implementation of an API for writing
7 In other words, as functions are developed we'll stick writeups in here.
14 1. All user-callable functions start with "Ctdl".
16 2. The functions starting with "CtdlInternal" are only to be used by other
17 API functions. They are implemented mainly to consolidate the common code
18 used by similar API functions, and make their implementation simple and
23 WRITING A SERVER-SIDE APPLICATION
24 ---------------------------------
26 Server-side applications written to the CitadelAPI may be written in any
27 language, as long as the "citadelapi" library is linked in. Unlike normal
28 user-mode programs, you must not declare a main() function, and there will be
29 no stdin/stdout/stderr available. Instead, you must declare this:
32 /* your program's main loop goes here */
35 When a server-side application is started, the main() loop inside the
36 CitadelAPI is invoked. This will perform all of the necessary initialization
37 (attach to the server, authenticate, identify itself, etc.) and then call
38 your program's CtdlMain() loop.
40 By the time CtdlMain() receives control, there will be two public symbols
41 you can access, which point to data structures containing various information
42 that may be useful to the program:
44 extern struct CtdlServerHandle CtdlAppHandle;
45 extern struct CtdlServInfo CtdlAppServInfo;
47 CtdlAppHandle contains various information about how and why this program is
48 connected to the server. CtdlAppSrvInfo contains various static information
49 about the server the program is connected to. Both CtdlServerHandle and
50 CtdlServInfo are defined in the standard header files.
57 int CtdlGetLastError()
59 Returns the error code of a failed API call. The error codes used by the
60 API are the same as those used by the Citadel session layer protocol, in order
61 to facilitate a consistent development experience.
65 INTERPROCESS COMMUNICATION FUNCTIONS
66 ------------------------------------
68 int CtdlSendExpressMessage(char *ToUser, char *MsgText)
70 This function sends an express message (page) to the named user.
74 USER ACCOUNT FUNCTIONS
75 ----------------------
76 The user account functions require administrative or privileged access. They
77 return -1 in the event of an error.
81 int CtdlGetUserPassword(char *buf, char *WhichUser)
82 int CtdlSetUserPassword(char *buf, char *WhichUser)
84 Get or set the password for a user account.
87 unsigned int CtdlGetUserFlags(char *WhichUser)
88 int CtdlSetUserFlags(unsigned int NewFlags, char *WhichUser)
90 Get or set the various bits associated with a user account. Be careful with
91 these flags; it is possible to corrupt a user account by handling them the
92 wrong way. It is best to call CtdlGetUserFlags() to acquire the current set
93 of flags, then twiddle the bits you're interested in, then call
94 CtdlSetUserFlags() to write them back.
97 int CtdlGetUserTimesCalled(char *WhichUser)
98 int CtdlSetUserTimesCalled(unsigned int NewValue, char *WhichUser)
100 Get or set the "number of times called" value for a user.
103 int CtdlGetUserMessagesPosted(char *WhichUser)
104 int CtdlSetUserMessagesPosted(unsigned int NewValue, char *WhichUser)
106 Get or set the "number of messages posted" value for a user.
109 int CtdlGetUserAccessLevel(char *WhichUser)
110 int CtdlSetUserAccessLevel(unsigned int NewValue, char *WhichUser)
112 Get or set a user's access level.
115 long CtdlGetUserNumber(char *WhichUser)
116 int CtdlSetUserNumber(long NewValue, char *WhichUser)
118 Get or set the user number, In general there is never any reason to change
119 a user's number. If for some reason you need to do this, be sure not to use
120 a user number which already exists, or which has not yet been assigned.
123 time_t CtdlGetUserLastCall(char *WhichUser)
124 int CtdlSetUserLastCall(time_t NewValue, char *WhichUser)
126 Get or set the timestamp of a user's last call.
129 int CtdlForEachUser(int (*CallBack)(char *EachUser))
131 This allows a user-supplied function to be called once for each user account
132 on the system; the single argument passed to the function will be the name of
133 the user being processed.
141 extern struct CtdlRoomInfo CtdlCurrentRoom;
143 This structure contains information about the current room.
147 int CtdlGotoRoom(char *RoomName)
149 Goto any room to which the extension has access. An extension with
150 administrative or privileged access may enter any room on the system. An
151 extension running in the context of an ordinary user may enter any room to
152 which the user has access.
155 int CtdlForEachRoom(int (*CallBack)(char *EachRoom))
157 This allows a user-supplied function to be called once for each active room
158 on the system; the single argument passed to the function will be the name of
159 the room being processed.