fdc1882e2959365f40d6f8717984f48c66c989a1
[citadel.git] / citadel / techdoc / protocol.txt
1               APPLICATION LAYER PROTOCOL FOR THE CITADEL SYSTEM
2          (c) 1995-2005 by Art Cancro et. al.    All Rights Reserved
3
4
5  INTRODUCTION
6  ------------
7
8  This is an attempt to document the application layer protocol used by the
9 Citadel system, beginning with version 4.00, which is the first version
10 to implement a client/server paradigm.  It is intended as a resource for
11 programmers who intend to develop their own Citadel clients, but it may have
12 other uses as well.
13
14
15  IMPORTANT NOTE TO DEVELOPERS!
16  -----------------------------
17
18  Anyone who wants to add commands or other functionality to this protocol,
19 *please* get in touch so that these efforts can be coordinated.  New
20 commands added by other developers can be added to this document, so we
21 don't end up with new server commands from multiple developers which have
22 the same name but perform different functions.  If you don't coordinate new
23 developments ahead of time, please at least send in an e-mail documenting
24 what you did, so that your new commands can be added to this document.
25
26  The coordinator of the Citadel project is Art Cancro
27 <ajc@uncensored.citadel.org>.
28
29
30  CONNECTING TO A SERVER
31  ----------------------
32
33  The protocols used below the application layer are beyond the scope of this
34 document, but we will briefly cover the methodology employed by Citadel.
35
36  Citadel offers its client protocol using TCP/IP.  It does so via a
37 multithreaded server listening on a TCP port.  Local connections may also
38 be made using the same protocol using Unix domain sockets.
39
40  The port number officially assigned to Citadel by the IANA is 504/tcp.  Since
41 our application layer assumes a clean, reliable, sequenced connection, the use
42 of UDP would render the server unstable and unusable, so we stick with TCP.
43
44
45  CHARACTER SETS
46  --------------
47  
48  The native character set for the Citadel system is UTF-8.  Unless otherwise
49 specified, all data elements are expected to be in the UTF-8 character set.
50 Specifically, all non-MIME messages should be assumed to be in UTF-8.  MIME
51 messages may be in whatever character set is specified by the MIME header, of
52 course; however, some clients (such as WebCit) will automatically convert
53 messages from other character sets before displaying them.
54  
55  
56  GENERAL INFORMATION ABOUT THE SERVER
57  ------------------------------------
58
59  The server is connection-oriented and stateful: each client requires its own
60 connection to a server process, and when a command is sent, the client must
61 read the response, and then transfer data or change modes if necessary.
62
63  The application layer is very much like other Internet protocols such as SMTP
64 or NNTP.  A client program sends one-line commands to the server, and the
65 server responds with a three-digit numeric result code followed by a message
66 describing what happened.  This cycle continues until the end of the
67 session.
68
69  Unlike protocols such as FTP, all data transfers occur in-band.  This means
70 that the same connection that is used for exchange of client/server
71 messages, will also be used to transfer data back and forth.  (FTP opens a
72 separate connection for data transfers.)  This keeps protocol administration
73 straightforward, as it can traverse firewalls without any special protocol
74 support on the firewall except for opening the port number.
75
76
77  RESULT CODES
78  ------------
79
80  The server will respond to all commands with a 3-digit result code, which
81 will be the first three characters on the line.  The rest of the line may
82 contain a human-readable string explaining what happened.  (Some client
83 software will display some of these strings to the user.)
84
85  The first digit is the most important.  The following codes are defined for
86 this position: ERROR, OK, MORE_DATA, LISTING_FOLLOWS, and SEND_LISTING.
87
88  The second and third digits may provide a reason as to why a command
89 succeeded or failed.  See ipcdef.h for the available codes.
90
91  ERROR means the command did not complete.
92  OK means the command executed successfully.
93  MORE_DATA means the command executed partially.  Usually this means that
94 another command needs to be executed to complete the operation.  For example,
95 sending the USER command to log in a user usually results in a MORE_DATA
96 result code, because the client needs to execute a PASS command to send the
97 password and complete the login.
98  LISTING_FOLLOWS means that after the server response, the server will
99 output a listing of some sort.  The client *must* read the listing, whether
100 it wants to or not.  The end of the listing is signified by the string
101 "000" on a line by itself.
102  SEND_LISTING is the opposite of LISTING_FOLLOWS.  It means that the client
103 should begin sending a listing of some sort.  The client *must* send something,
104 even if it is an empty listing.  Again, the listing ends with "000" on a line
105 by itself.
106  BINARY_FOLLOWS and SEND_BINARY mean that the client must immediately send
107 or receive a block of binary data.  The first parameter will always be the
108 number of bytes.
109  ASYNC_MESSAGE_FOLLOWS means that an asynchronous, or unsolicited, message
110 follows.  The next line will be one of the above codes, and if a data transfer
111 is involved it must be handled immediately.  Note that the client will not
112 receive this type of response unless it indicates to the server that it is
113 capable of handling them; see the writeup of the ASYN command later in this
114 document.
115
116  PARAMETERIZATION
117  ----------------
118
119  Zero or more parameters may be passed to a command.  When more than one
120 parameter is passed to a command, they should be separated by the "|"
121 symbol like this:
122   SETU 80|24|260
123  In this example, we're using the "SETU" command and passing three
124 parameters: 80, 24, and 260.
125
126  When the server spits out data that has parameters, if more than one
127 parameter is returned, they will be separated by the "|" symbol like
128 this:
129   200 80|24|260
130  In this example, we just executed the "GETU" command, and it returned us
131 an OK result code (the '2' in the 200) and three parameters: 80, 24, and
132 260.
133
134
135  COMMANDS
136  --------
137
138  This is a listing of all the commands that a Citadel server can execute.
139
140
141  NOOP   (NO OPeration)
142
143  This command does nothing.  It takes no arguments and always returns
144 OK.  It is intended primarily for testing and development, but it might also
145 be used as a "keep alive" command to prevent the server from timing out, if
146 it's running over a transport that needs this type of thing.
147
148
149  ECHO   (ECHO something)
150
151  This command also does nothing.  It simply returns OK followed by whatever
152 its arguments are.
153
154
155  QUIT   (QUIT)
156
157  Terminate the server connection.  This command takes no arguments.  It
158 returns OK and closes the connection immediately.
159
160
161  LOUT   (LogOUT)
162
163  Log out the user without closing the server connection.  It always returns
164 OK even if no user is logged in.
165
166
167  USER   (send USER name)
168
169  The first step in logging in a user.  This command takes one argument: the
170 name of the user to be logged in.  If the user exists, a MORE_DATA return
171 code will be sent, which means the client should execute PASS as the next
172 command.  If the user does not exist, ERROR + NO_SUCH_USER is returned.
173
174
175  PASS   (send PASSword)
176
177  The second step in logging in a user.  This command takes one argument: the
178 password for the user we are attempting to log in.  If the password doesn't
179 match the correct password for the user we specified for the USER command,
180 ERROR + PASSWORD_REQUIRED is returned.  If a USER command has not been
181 executed yet, ERROR + USERNAME_REQUIRED is returned.  If a user is already
182 logged in, ERROR + ALREADY_LOGGED_IN is returned.  If the password is
183 correct, OK is returned and the user is now logged in... and most of the
184 other server commands can now be executed.  Along with OK, the following
185 parameters are returned:
186
187  0 - The user's name (in case the client wants the right upper/lower casing)
188  1 - The user's current access level
189  2 - Times called
190  3 - Messages posted
191  4 - Various flags (see citadel.h)
192  5 - User number
193  6 - Time of last call (UNIX timestamp)
194
195
196  NEWU   (create NEW User account)
197
198  This command creates a new user account AND LOGS IT IN.  The argument to
199 this command will be the name of the account.  No case conversion is done
200 on the name.  Note that the new account is installed with a default
201 configuration, and no password, so the client should immediately prompt the
202 user for a password and install it with the SETP command as soon as this
203 command completes.  This command returns OK if the account was created and
204 logged in, ERROR + ALREADY_EXISTS if another user already exists with this
205 name, ERROR + NOT_HERE if self-service account creation is disabled,
206 ERROR + MAX_SESSIONS_EXCEEDED if too many users are logged in, ERROR +
207 USERNAME_REQUIRED if a username was not provided, or ERROR + ILELGAL_VALUE
208 if the username provided is invalid.  If OK, it will also return the same
209 parameters that PASS returns.
210
211  Please note that the NEWU command should only be used for self-service
212 user account creation.  For administratively creating user accounts, please
213 use the CREU command.
214
215
216  SETP   (SET new Password)
217
218  This command sets a new password for the currently logged in user.  The
219 argument to this command will be the new password.  The command always
220 returns OK, unless the client is not logged in, in which case it will return
221 ERROR + NOT_LOGGED_IN, or if the user is an auto-login user, in which case
222 it will return ERROR + NOT_HERE.
223
224
225  CREU   (CREate new User account)
226
227  This command creates a new user account AND DOES NOT LOG IT IN.  The first
228 argument to this command will be the name of the account.  No case conversion
229 is done on the name.  Note that the new account is installed with a default
230 configuration, and no password.  The second argument is optional, and will be
231 an initial password for the user.  This command returns OK if the account was
232 created, ERROR + HIGHER_ACCESS_REQUIRED if the user is not an Aide, ERROR +
233 USERNAME_REQUIRED if no username was specified, or ERROR + ALREADY_EXISTS if
234 another user already exists with this name.
235
236  Please note that CREU is intended to be used for activities in which a
237 system administrator is creating user accounts.  For self-service user
238 account creation, use the NEWU command.
239
240
241  LKRN   (List Known Rooms with New messages)
242
243  List known rooms with new messages.  If the client is not logged in, ERROR +
244 NOT_LOGGED_IN is returned.  Otherwise, LISTING_FOLLOWS is returned, followed
245 by the room listing.  Each line in the listing contains the full name of a
246 room, followed by the '|' symbol, and then a number that may contain the
247 following bits:
248
249 #define QR_PERMANENT    1               /* Room does not purge              */
250 #define QR_PRIVATE      4               /* Set for any type of private room */
251 #define QR_PASSWORDED   8               /* Set if there's a password too    */
252 #define QR_GUESSNAME    16              /* Set if it's a guessname room     */
253 #define QR_DIRECTORY    32              /* Directory room                   */
254 #define QR_UPLOAD       64              /* Allowed to upload                */
255 #define QR_DOWNLOAD     128             /* Allowed to download              */
256 #define QR_VISDIR       256             /* Visible directory                */
257 #define QR_ANONONLY     512             /* Anonymous-Only room              */
258 #define QR_ANON2        1024            /* Anonymous-Option room            */
259 #define QR_NETWORK      2048            /* Shared network room              */
260 #define QR_PREFONLY     4096            /* Preferred status needed to enter */
261 #define QR_READONLY     8192            /* Aide status required to post     */
262
263  Then it returns another '|' symbol, followed by a second set of bits comprised
264 of the following:
265
266 #define QR2_SYSTEM      1               /* System room; hide by default     */
267 #define QR2_SELFLIST    2               /* Self-service mailing list mgmt   */
268
269  Other bits may be defined in the future.  The listing terminates, as with
270 all listings, with "000" on a line by itself.
271
272  Starting with version 4.01 and above, floors are supported.  The first
273 argument to LKRN should be the number of the floor to list rooms from.  Only
274 rooms from this floor will be listed.  If no arguments are passed to LKRN, or
275 if the floor number requested is (-1), rooms on all floors will be listed.
276
277  The third field displayed on each line is the number of the floor the room
278 is on.  The LFLR command should be used to associate floor numbers with
279 floor names.
280
281  The fourth field displayed on each line is a "room listing order."  Unless
282 there is a compelling reason not to, clients should sort any received room
283 listings by this value.
284  
285  The fifth field is a special bit bucket containing fields which pertain to
286 room access controls:
287
288 #define UA_KNOWN                2       /* Known room */
289 #define UA_GOTOALLOWED          4       /* Access will be granted to this room
290                                          * if the user calls it up by name */
291 #define UA_HASNEWMSGS           8       /* Unread messages exist in room */
292 #define UA_ZAPPED              16       /* Zapped from known rooms list */
293   
294  The sixth field is the user's current view for the room. (See VIEW command)
295  
296  
297  LKRO   (List Known Rooms with Old [no new] messages)
298
299  This follows the same usage and format as LKRN.
300
301
302  LZRM   (List Zapped RooMs)
303
304  This follows the same usage and format as LKRN and LKRO.
305
306
307  LKRA   (List All Known Rooms)
308
309  Same format.  Lists all known rooms, with or without new messages.
310
311
312  LRMS   (List all accessible RooMS)
313
314  Again, same format.  This command lists all accessible rooms, known and
315 forgotten, with and without new messages.  It does not, however, list
316 inaccessible private rooms.
317
318
319  LPRM   (List all Public RooMs)
320
321  Again, same format.  This command lists all public rooms, and nothing else.
322 Unlike the other list rooms commands, this one can be executed without logging
323 in.
324
325
326  GETU   (GET User configuration)
327
328  This command retrieves the screen dimensions and user options for the
329 currently logged in account.  ERROR + NOT_LOGGED_IN will be returned if no
330 user is logged in, of course.  Otherwise, OK will be returned, followed by
331 four parameters.  The first parameter is the user's screen width, the second
332 parameter is the user's screen height, and the third parameter is a bag of
333 bits with the following meanings:
334
335  #define US_LASTOLD     16              /* Print last old message with new  */
336  #define US_EXPERT      32              /* Experienced user                 */
337  #define US_UNLISTED    64              /* Unlisted userlog entry           */
338  #define US_NOPROMPT    128             /* Don't prompt after each message  */
339  #define US_DISAPPEAR   512             /* Use "disappearing msg prompts"   */
340  #define US_PAGINATOR   2048            /* Pause after each screen of text  */
341
342  There are other bits, too, but they can't be changed by the user (see below).
343
344
345  SETU   (SET User configuration)
346
347  This command does the opposite of SETU: it takes the screen dimensions and
348 user options (which were probably obtained with a GETU command, and perhaps
349 modified by the user) and writes them to the user account.  This command
350 should be passed three parameters: the screen width, the screen height, and
351 the option bits (see above).  It returns ERROR + NOT_LOGGED_IN if no user is
352 logged in, and ERROR + ILLEGAL_VALUE if the parameters are incorrect.
353
354  Note that there exist bits here which are not listed in this document.  Some
355 are flags that can only be set by Aides or the system administrator.  SETU
356 will ignore attempts to toggle these bits.  There also may be more user
357 settable bits added at a later date.  To maintain later downward compatibility,
358 the following procedure is suggested:
359
360  1. Execute GETU to read the current flags
361  2. Toggle the bits that we know we can toggle
362  3. Execute SETU to write the flags
363
364  If we are passed a bit whose meaning we don't know, it's best to leave it
365 alone, and pass it right back to the server.  That way we can use an old
366 client on a server that uses an unknown bit without accidentally clearing
367 it every time we set the user's configuration.
368
369
370  GOTO   (GOTO a room)
371
372  This command is used to goto a new room.  When the user first logs in (login
373 is completed after execution of the PASS command) this command is
374 automatically and silently executed to take the user to the first room in the
375 system (usually called the Lobby).
376
377  This command can be passed one or two parameters.  The first parameter is,
378 of course, the name of the room.  Although it is not case sensitive, the
379 full name of the room must be used.  Wildcard matching or unique string
380 matching of room names should be the responsibility of the client.
381
382  Note that the reserved room name "_BASEROOM_" can be passed to the server
383 to cause the goto command to take the user to the first room in the system,
384 traditionally known as the Lobby>.   As long as a user is logged in, a
385 GOTO command to _BASEROOM_ is guaranteed to succeed.  This is useful to
386 allow client software to return to the base room when it doesn't know
387 where else to go.
388
389  There are also several additional reserved room names:
390  "_MAIL_" goes to the user's inbox (i.e. the Mail> room).
391  "_TRASH_" goes to the user's personal trashcan room (trash folder).
392  "_BITBUCKET_" goes to a room that has been chosen for messages without a home.
393  "_CALENDAR_" goes to the user's primary personal calendar.
394  "_CONTACTS_" goes to the user's primary personal address book.
395  "_NOTES_" goes to the user's primary personal notes room.
396  "_TASKS_" goes to the user's primary personal task list.
397  
398
399  The second (and optional) parameter is a password, if one is required for
400 access to the room.  This allows for all types of rooms to be accessed via
401 this command: for public rooms, invitation-only rooms to which the user
402 has access, and preferred users only rooms to which the user has access, the
403 room will appear in a room listing.  For guess-name rooms, this command
404 will work transparently, adding the room to the user's known room list when
405 it completes.  For passworded rooms, access will be denied if the password
406 is not supplied or is incorrect, or the command will complete successfully
407 if the password is correct.
408
409  The third (and also) optional parameter is a "transient" flag.  Normally,
410 when a user enters a private and/or zapped room, the room is added to the
411 user's known rooms list.  If the transient flag is set to non-zero, this is
412 called a "transient goto" which causes the user to enter the room without
413 adding the room to the known rooms list.
414
415  The possible result codes are:
416
417  OK    - The command completed successfully.  User is now in the room.
418          (See the list of returned parameters below)
419
420  ERROR - The command did not complete successfully.  Check the second and
421 third positions of the result code to find out what happened:
422
423    NOT_LOGGED_IN     -  Of course you can't go there.  You didn't log in.
424    PASSWORD_REQUIRED -  Either a password was not supplied, or the supplied
425 password was incorrect.
426    ROOM_NOT_FOUND    -  The requested room does not exist.
427
428  The typical procedure for entering a passworded room would be:
429
430  1. Execute a GOTO command without supplying any password.
431  2. ERROR + PASSWORD_REQUIRED will be returned.  The client now knows that
432 the room is passworded, and prompts the user for a password.
433  3. Execute a GOTO command, supplying both the room name and the password.
434  4. If OK is returned, the command is complete.  If, however,
435 ERROR + PASSWORD_REQUIRED is still returned, tell the user that the supplied
436 password was incorrect.  The user remains in the room he/she was previously
437 in.
438
439  When the command succeeds, these parameters are returned:
440    0. The name of the room
441    1. Number of unread messages in this room
442    2. Total number of messages in this room
443    3. Info flag: set to nonzero if the user needs to read this room's info
444       file (see RINF command below)
445    4. Various flags associated with this room.  (See LKRN cmd above)
446    5. The highest message number present in this room
447    6. The highest message number the user has read in this room
448    7. Boolean flag: 1 if this is a Mail> room, 0 otherwise.
449    8. Aide flag: 1 if the user is either the Room Aide for this room, *or* is
450 a regular Aide (this makes access checks easy).
451    9. The number of new Mail messages the user has (useful for alerting the
452 user to the arrival of new mail during a session)
453   10. The floor number this room resides on
454   11. The *current* "view" for this room (see views.txt for more info)
455   12. The *default* "view" for this room
456   13. Boolian flag: 1 if this is the user's Trash folder, 0 otherwise.
457  
458  The default view gives the client a hint as to what views the user should
459 be allowed to select.  For example, it would be confusing to allow messages
460 in a room intended for calendar items.  The server does not enforce these
461 restrictions, though.
462
463
464  MSGS   (get pointers to MeSsaGeS in this room)
465
466  This command obtains a listing of all the messages in the current room
467 which the client may request.  This command may be passed a single parameter:
468 either "all", "old", or "new" to request all messages, only old messages, or
469 new messages.  Or it may be passed two parameters: "last" plus a number, in
470 which case that many message pointers will be returned; "first" plus a
471 number, for the corresponding effect; or "gt" plus a number, to list all
472 messages in the current room with a message number greater than the one
473 specified.  If no parameters are specified, "all" is assumed.
474
475  The third argument, may be either 0 or 1.  If it is 1, this command behaves
476 differently: before a listing is returned, the client must transmit a list
477 of fields to search for.  The field headers are listed below in the writeup
478 for the "MSG0" command.
479  
480  The optional fourth argument may also be either 0 or 1.  If it is 1, the
481 output of this command will include not only a list of message numbers, but
482 a simple header summary of each message as well.  This is somewhat resource
483 intensive so you shouldn't do this unless you absolutely need all the headers
484 immediately.  The fields which are output (in the usual delimited fashion, of
485 course) are: message number, timestamp, display name, node name, Internet
486 email address (if present), subject (if present).
487
488  This command can return three possible results.  ERROR + NOT_LOGGED_IN will
489 be returned if no user is currently logged in.  Otherwise, LISTING_FOLLOWS
490 will be returned, and the listing will consist of zero or more message
491 numbers, one per line.  The listing ends, as always, with the string "000"
492 alone on a line by itself.  The listed message numbers can be used to request
493 messages from the system.  If "search mode" is being used, the server will
494 return START_CHAT_MODE, and the client is expected to transmit the search
495 criteria, and then read the message list.
496
497  Since this is somewhat complex, here are some examples:
498
499  Example 1: Read all new messages
500
501  Client:   MSGS NEW
502  Server:   100 Message list...
503            523218
504            523293
505            523295
506            000
507
508  Example 2: Read the last five messages
509
510  Client:   MSGS LAST|5
511  Server:   100 Message list...
512            523190
513            523211
514            523218
515            523293
516            523295
517            000
518
519  Example 3: Read all messages written by "IGnatius T Foobar"
520
521  Client:   MSGS ALL|0|1
522  Server:   800 Send template then receive message list
523  Client:   from|IGnatius T Foobar
524            000
525  Server:   518604
526            519366
527            519801
528            520201
529            520268
530            520805
531            520852
532            521579
533            521720
534            522571
535            000
536
537  Note that in "search mode" the client may specify any number of search
538 criteria.  These criteria are applied with an AND logic.
539
540
541  MSG0   (read MeSsaGe, mode 0)
542
543  This is a command used to read the text of a message.  "Mode 0" implies that
544 other MSG commands (MSG1, MSG2, etc.) will probably be added later on to read
545 messages in more robust formats.  This command should be passed two arguments.
546 The first is the message number of the message being requested.  The second
547 argument specifies whether the client wants headers and/or message body:
548  0 = Headers and body
549  1 = Headers only
550  2 = Body only
551  3 = Headers only, with MIME information suppressed (this runs faster)
552
553  If the request is denied, ERROR + NOT_LOGGED_IN or ERROR + MESSAGE_NOT_FOUND
554 will be returned.  Otherwise, LISTING_FOLLOWS will be returned, followed by
555 the contents of the message.  The following fields may be sent:
556
557  type=   Formatting type.  The currently defined types are:
558   0 = "traditional" Citadel formatting.  This means that newlines should be
559 treated as spaces UNLESS the first character on the next line is a space.  In
560 other words, only indented lines should generate a newline on the user's screen
561 when the message is being displayed.  This allows a message to be formatted to
562 the reader's screen width.  It also allows the use of proportional fonts.
563   1 = a simple fixed-format message.  The message should be displayed to
564 the user's screen as is, preferably in a fixed-width font that will fit 80
565 columns on a screen.
566   4 = MIME format message.  The message text is expected to contain a header
567 with the "Content-type:" directive (and possibly others).
568
569  msgn=   The message ID of this message on the system it originated on.
570  path=   An e-mailable path back to the user who wrote the message.
571
572  time=   The date and time of the message, in Unix format (the number of
573 seconds since midnight on January 1, 1970, GMT).
574
575  from=   The name of the author of the message.
576  rcpt=   If the message is a private e-mail, this is the recipient.
577  room=   The name of the room the message originated in.
578  node=   The short node name of the system this message originated on.
579  hnod=   The long node name of the system this message originated on.
580  zaps=   The id/node of a message which this one zaps (supersedes).
581
582  part=   Information about a MIME part embedded in this message.
583  pref=   Information about a multipart MIME prefix such as "multipart/mixed"
584          or "multipart/alternative".  This will be output immediately prior
585          to the various "part=" lines which make up the multipart section.
586  suff=   Information about a multipart MIME suffix.  This will be output
587          immediately following the various "part=" lines which make up the
588          multipart section.
589
590  text    Note that there is no "=" after the word "text".  This string
591 signifies that the message text begins on the next line.
592
593
594  WHOK   (WHO Knows room)
595
596  This command is available only to Aides.  ERROR + HIGHER_ACCESS_REQUIRED 
597 will be returned if the user is not an Aide.  Otherwise, it returns
598 LISTING_FOLLOWS and then lists, one user per line, every user who has
599 access to the current room.
600
601
602  INFO   (get server INFO)
603
604  This command will *always* return LISTING_FOLLOWS and then print out a
605 listing of zero or more strings.  Client software should be written to expect
606 anywhere from a null listing to an infinite number of lines, to allow later
607 backward compatibility.  The current implementation defines the following
608 parts of the listing:
609
610  Line 1  - Your unique session ID on the server
611  Line 2  - The node name of the Citadel server
612  Line 3  - Human-readable node name of the Citadel server
613  Line 4  - The fully-qualified domain name (FQDN) of the server
614  Line 5  - The name of the server software, i.e. "Citadel 4.00"
615  Line 6  - (The revision level of the server code) * 100
616  Line 7  - The geographical location of the site (city and state if in the US)
617  Line 8  - The name of the system administrator
618  Line 9  - A number identifying the server type (see below)
619  Line 10 - The text of the system's paginator prompt
620  Line 11 - Floor Flag.  1 if the system supports floors, 0 otherwise.
621  Line 12 - Paging level.  0 if the system only supports inline paging,
622            1 if the system supports "extended" paging (check-only and
623            multiline modes).  See the SEXP command for further information.
624  Line 13 - The "nonce" for this session, for support of APOP-style
625            authentication.  If this field is present, clients may authenticate
626            in this manner.
627  Line 14 - Set to nonzero if this server supports the QNOP command.
628  Line 15 - Set to nonzero if this server is capable of connecting to a
629            directory service using LDAP.
630
631  *** NOTE! ***   The "server type" code is intended to promote global
632 compatibility in a scenario in which developers have added proprietary
633 features to their servers or clients.  We are attempting to avoid a future
634 situation in which users need to keep different client software around for
635 each Citadel they use.  *Please*, if you are a developer and plan to add
636 proprietary features:
637
638  -> Your client programs should still be able to utilize servers other than
639 your own.
640  -> Clients other than your own should still be able to utilize your server,
641 even if your proprietary extensions aren't supported.
642  -> Please contact Art Cancro <ajc@uncensored.citadel.org> and obtain a unique
643 server type code, which can be assigned to your server program.
644  -> If you document what you did in detail, perhaps it can be added to a
645 future release of the Citadel program, so everyone can enjoy it.  Better
646 yet, just work with the Citadel development team on the main source tree.
647
648  If everyone follows this scheme, we can avoid a chaotic situation with lots
649 of confusion about which client program works with which server, etc.  Client
650 software can simply check the server type (and perhaps the revision level)
651 to determine ahead of time what commands may be utilized.
652
653  Please refer to "developers.txt" for information on what codes belong to whom.
654
655
656
657  RDIR   (Read room DIRectory)
658
659  Use this command to read the directory of a directory room.  ERROR + NOT_HERE
660 will be returned if the room has no directory, ERROR + HIGHER_ACCESS_REQUIRED
661 will be returned if the room's directory is not visible and the user does not
662 have Aide or Room Aide privileges, ERROR + NOT_LOGGED_IN will be returned if
663 the user is not logged in; otherwise LISTING_FOLLOWS will be returned,
664 followed by the room's directory.  Each line of the directory listing will
665 contain three fields: a filename, the length of the file, and a description.
666
667  The server message contained on the same line with LISTING_FOLLOWS will
668 contain the name of the system and the name of the directory, such as:
669
670   uncensored.citadel.org|/usr/local/citadel/files/my_room_directory
671
672
673  SLRP   (Set Last-message-Read Pointer)
674
675  This command marks all messages in the current room as read (seen) up to and
676 including the specified number.  Its sole parameter is the number of the last
677 message that has been read.  This allows the pointer to be set at any
678 arbitrary point in the room.  Optionally, the parameter "highest" may be used
679 instead of a message number, to set the pointer to the number of the highest
680 message in the room, effectively marking all messages in the room as having
681 been read (ala the Citadel <G>oto command).
682
683  The command will return OK if the pointer was set, or ERROR + NOT_LOGGED_IN
684 if the user is not logged in.  If OK is returned, it will be followed by a
685 single argument containing the message number the last-read-pointer was set to.
686
687
688  INVT   (INViTe a user to a room)
689
690  This command may only be executed by Aides, or by the room aide for the
691 current room.  It is used primarily to add users to invitation-only rooms,
692 but it may also be used in other types of private rooms as well.  Its sole
693 parameter is the name of the user to invite.
694
695  The command will return OK if the operation succeeded.  ERROR + NO_SUCH_USER
696 will be returned if the user does not exist, ERROR + HIGHER_ACCESS_REQUIRED
697 will be returned if the operation would have been possible if the user had
698 higher access, and ERROR + NOT_HERE may be returned if the room is not a
699 private room.
700
701
702  KICK   (KICK a user out of a room)
703
704  This is the opposite of INVT: it is used to kick a user out of a private
705 room.  It can also be used to kick a user out of a public room, but the
706 effect will only be the same as if the user <Z>apped the room - a non-stupid
707 user can simply un-zap the room to get back in.
708
709
710  GETR   (GET Room attributes)
711
712  This command is used for editing the various attributes associated with a
713 room.  A typical "edit room" command would work like this:
714  1. Use the GETR command to get the current attributes
715  2. Change some of them around
716  3. Use SETR (see below) to save the changes
717  4. Possibly also change the room aide using the GETA and SETA commands
718
719  GETR takes no arguments.  It will only return OK if the SETR command will
720 also return OK.  This allows client software to tell the user that he/she
721 can't edit the room *before* going through the trouble of actually doing the
722 editing.  Possible return codes are:
723
724  ERROR+NOT_LOGGED_IN          - No user is logged in.
725  ERROR+HIGHER_ACCESS_REQUIRED - Not enough access.  Typically, only aides
726 and the room aide associated with the current room, can access this command.
727  OK                           - Command succeeded.  Parameters are returned.
728
729  If OK is returned, the following parameters will be returned as well:
730
731  0. The name of the room
732  1. The room's password (if it's a passworded room)
733  2. The name of the room's directory (if it's a directory room)
734  3. Various flags (bits) associated with the room (see LKRN cmd above)
735  4. The floor number on which the room resides
736  5. The room listing order
737  6. The default view for the room (see views.txt)
738  7. A second set of flags (bits) associated with the room
739
740
741  SETR   (SET Room attributes)
742
743  This command sets various attributes associated with the current room.  It
744 should be passed the following arguments:
745
746  0. The name of the room
747  1. The room's password (if it's a passworded room)
748  2. The name of the room's directory (if it's a directory room)
749  3. Various flags (bits) associated with the room (see LKRN cmd above)
750  4. "Bump" flag (see below)
751  5. The floor number on which the room should reside
752  6. The room listing order
753  7. The default view for the room (see views.txt)
754  8. A second set of flags (bits) associated with the room
755
756  *Important: You should always use GETR to retrieve the current attributes of
757 the room, then change what you want to change, and then use SETR to write it
758 all back.  This is particularly important with respect to the flags: if a
759 particular bit is set, and you don't know what it means, LEAVE IT ALONE and
760 only toggle the bits you want to toggle.  This will allow for upward
761 compatibility.
762
763  The _BASEROOM_, user's Mail> and Aide> rooms can only be partially edited.
764 Any changes which cannot be made will be silently ignored.
765
766  If the room is a private room, you have the option of causing all users who
767 currently have access, to forget the room.  If you want to do this, set the
768 "bump" flag to 1, otherwise set it to 0.
769
770
771  GETA
772
773  This command is used to get the name of the Room Aide for the current room.
774 It will return ERROR + NOT_LOGGED_IN if no user is logged in, or OK if the
775 command succeeded.  Along with OK there will be returned one parameter: the
776 name of the Room Aide.  A conforming server must guarantee that the user is
777 always in some room.
778
779
780  SETA
781
782  The opposite of GETA, used to set the Room Aide for the current room.  One
783 parameter should be passed, which is the name of the user who is to be the
784 new Room Aide.  Under Citadel, this command may only be executed by Aides
785 and by the *current* Room Aide for the room.  Return codes possible are:
786  ERROR + NOT_LOGGED_IN          (Not logged in.)
787  ERROR + HIGHER_ACCESS_REQUIRED (Higher access required.)
788  ERROR + NOT_HERE               (Room cannot be edited.)
789  OK                             (Command succeeded.)
790
791
792  ENT0   (ENTer message, mode 0)
793
794  This command is used to enter messages into the system.  It accepts four
795 arguments:
796
797   0  -  Post flag.  This should be set to 1 to post a message.  If it is
798 set to 0, the server only returns OK or ERROR (plus any flags describing
799 the error) without reading in a message.  Client software should, in fact,
800 perform this operation at the beginning of an "enter message" command
801 *before* starting up its editor, so the user does not end up typing a message
802 in vain that will not be permitted to be saved.  If it is set to 2, the
803 server will accept an "apparent" post name if the user is privileged enough.
804 This post name is arg 5.
805   1  -  Recipient (To: field).  This argument is utilized only for private
806 mail.  It is ignored for public messages.  It contains, of course, the name
807 of the recipient(s) of the message.
808   2  -  Anonymous flag.  This argument is ignored unless the room allows
809 anonymous messages.  In such rooms, this flag may be set to 1 to flag a
810 message as anonymous, otherwise 0 for a normal message.
811   3  -  Format type.  Any valid Citadel format type may be used (this will
812 typically be 0; see the MSG0 command above).
813   4  -  Subject.  If present, this argument will be used as the subject of
814 the message.
815   5  -  Post name.  When postflag is 2, this is the name you are posting as.
816 This is an Aide only command.
817   6  -  Do Confirmation.  NOTE: this changes the protocol semantics!  When
818 you set this to nonzero, ENT0 will reply with a confirmation message after
819 you submit the message text.  The reply code for the ENT0 command will be
820 START_CHAT_MODE instead of SEND_LISTING.
821   7  -  Recipient (Cc: field).  This argument is utilized only for private
822 mail.  It is ignored for public messages.  It contains, of course, the name
823 of the recipient(s) of the message.
824   8  -  Recipient (Bcc: field).  This argument is utilized only for private
825 mail.  It is ignored for public messages.  It contains, of course, the name
826 of the recipient(s) of the message.
827
828  Possible result codes:
829   OK  -  The request is valid.  (Client did not set the "post" flag, so the
830 server will not read in message text.)   If the message is an e-mail with
831 a recipient, the text that follows the OK code will contain the exact name
832 to which mail is being sent.  The client can display this to the user.  The
833 implication here is that the name that the server returns will contain the
834 correct upper and lower case characters.  In addition, if the recipient is
835 having his/her mail forwarded, the forwarding address will be returned.
836   SEND_LISTING  -  The request is valid.  The client should now transmit
837 the text of the message (ending with a 000 on a line by itself, as usual).
838   START_CHAT_MODE  -  The request is valid.  The client should now transmit
839 the text of the message, ending with a 000 on a line by itself.  After
840 transmitting the 000 terminator, the client MUST read in the confirmation
841 from the server, which will also end with 000 on a line by itself.  The format
842 of the confirmation appears below.
843   ERROR + NOT_LOGGED_IN  -  Not logged in.
844   ERROR + HIGHER_ACCESS_REQUIRED  -  Higher access is required.  An
845 explanation follows, worded in a form that can be displayed to the user.
846   ERROR + NO_SUCH_USER  -  The specified recipient does not exist.
847
848 The format of the confirmation message, if requested, is as follows:
849 Line 1: The new message number on the server for the message.  It will be
850         positive for a real message number, or negative to denote
851         that an error occurred.  If an error occurred, the message was
852         not saved.
853 Line 2: A human-readable confirmation or error message.
854 Line 3: The resulting Exclusive UID of the message, if present.
855 (More may be added to this in the future, so do not assume that there will
856 only be these lines output.  Keep reading until 000 is received.)
857
858
859  RINF   (read Room INFormation file)
860
861  Each room has associated with it a text file containing a description of
862 the room, perhaps containing its intended purpose or other important
863 information.  The info file for the Lobby> (the system's base room) is
864 often used as a repository for system bulletins and the like.
865
866  This command, which accepts no arguments, is simply used to read the info
867 file for the current room.  It will return LISTING_FOLLOWS followed by
868 the text of the message (always in format type 0) if the request can be
869 honored, or ERROR if no info file exists for the current room (which is
870 often the case).  Other error description codes may accompany this result.
871
872  When should this command be used?  This is, of course, up to the discretion
873 of client software authors, but in Citadel it is executed in two situations:
874 the first time the user ever enters a room; and whenever the contents of the
875 file change.  The latter can be determined from the result of a GOTO command,
876 which will tell the client whether the file needs to be read (see GOTO above).
877
878
879  DELE   (DELEte a message)
880
881  Delete a message from the current room.  The one argument that should be
882 passed to this command is the message number of the message to be deleted.
883 The return value will be OK if the message was deleted, or an ERROR code.
884 If the delete is successful, the message's reference count is decremented, and
885 if the reference count reaches zero, the message is removed from the message
886 base.
887
888
889  MOVE   (MOVE or copy a message to a different room)
890
891  Move or copy a message to a different room.  This command expects to be
892 passed three arguments:
893  0: the message number of the message to be moved or copied.
894  1: the name of the target room.
895  2: flag: 0 to move the message, 1 to copy it without deleting from the
896     source room.
897  
898  This command never creates or deletes copies of a message; it merely moves
899 around links.  When a message is moved, its reference count remains the same.
900 When a message is copied, its reference count is incremented.
901
902
903  KILL   (KILL current room)
904
905  This command deletes the current room.  It accepts a single argument, which
906 should be nonzero to actually delete the room, or zero to merely check
907 whether the room can be deleted.
908
909  Once the room is deleted, the current room is undefined.  It is suggested
910 that client software immediately GOTO another room (usually _BASEROOM_)
911 after this command completes.
912
913  Possible return codes:
914
915  OK  -  room has been deleted (or, if checking only, request is valid).
916  ERROR+NOT_LOGGED_IN  -  no user is logged in.
917  ERROR+HIGHER_ACCESS_REQUIRED  -  not enough access to delete rooms.
918  ERROR+NOT_HERE  -  this room can not be deleted.
919
920
921  CRE8   (CRE[ate] a new room)
922
923  This command is used to create a new room.  Like some of the other
924 commands, it provides a mechanism to first check to see if a room can be
925 created before actually executing the command.  CRE8 accepts the following
926 arguments:
927
928  0  -  Create flag.  Set this to 1 to actually create the room.  If it is
929 set to 0, the server merely checks that there is a free slot in which to
930 create a new room, and that the user has enough access to create a room.  It
931 returns OK if the client should go ahead and prompt the user for more info,
932 or ERROR or ERROR+HIGHER_ACCESS_REQUIRED if the command will not succeed.
933  1  -  Name for new room.
934  2  -  Access type for new room:
935        0  -  Public
936        1  -  Private; can be entered by guessing the room's name
937        2  -  Private; can be entered by knowing the name *and* password
938        3  -  Private; invitation only (sometimes called "exclusive")
939        4  -  Personal (mailbox for this user only)
940  3  -  Password for new room (if it is a type 2 room)
941  4  -  Floor number on which the room should reside (optional)
942  5  -  Set to 1 to avoid automatically gaining access to the created room.
943  6  -  The default "view" for the room.
944
945  If the create flag is set to 1, the room is created (unless something
946 went wrong and an ERROR return is sent), and the server returns OK, but
947 the session is **not** automatically sent to that room.  The client still
948 must perform a GOTO command to go to the new room.
949
950
951  FORG   (FORGet the current room)
952
953  This command is used to forget (zap) the current room.  For those not
954 familiar with Citadel, this terminology refers to removing the room from
955 a user's own known rooms list, *not* removing the room itself.  After a
956 room is forgotten, it no longer shows up in the user's known room list,
957 but it will exist in the user's forgotten room list, and will return to the
958 known room list if the user goes to the room (in Citadel, this is
959 accomplished by explicitly typing the room's name in a <.G>oto command).
960
961  The command takes no arguments.  If the command cannot execute for any
962 reason, ERROR will be returned.  ERROR+NOT_LOGGED_IN or ERROR+NOT_HERE may
963 be returned as they apply.
964
965  If the command succeeds, OK will be returned.  At this point, the current
966 room is **undefined**, and the client software is responsible for taking
967 the user to another room before executing any other room commands (usually
968 this will be _BASEROOM_ since it is always there).
969
970
971  MESG    (read system MESsaGe)
972
973  This command is used to display system messages and/or help files.  The
974 single argument it accepts is the name of the file to display.  IT IS CASE
975 SENSITIVE.  Citadel looks for these files first in the "messages"
976 subdirectory and then in the "help" subdirectory.
977
978  If the file is found, LISTING_FOLLOWS is returned, followed by a pathname
979 to the file being displayed.  Then the message is printed, in format type 0
980 (see MSG0 command for more information on this).  If the file is not found,
981 ERROR is returned.
982
983  There are some "well known" names of system messages which client software
984 may expect most servers to carry:
985
986  hello        -  Welcome message, to be displayed before the user logs in.
987  changepw     -  To be displayed whenever the user is prompted for a new
988                  password.  Warns about picking guessable passwords and such.
989  register     -  Should be displayed prior to the user entering registration.
990                  Warnings about not getting access if not registered, etc.
991  help         -  Main system help file.
992  goodbye      -  System logoff banner; display when user logs off.
993  roomaccess   -  Information about how public rooms and different types of
994                  private rooms function with regards to access.
995  unlisted     -  Tells users not to choose to be unlisted unless they're
996                  really paranoid, and warns that aides can still see
997                  unlisted userlog entries.
998
999  Citadel provides these for the Citadel Unix text client.  They are
1000 probably not very useful for other clients:
1001
1002  mainmenu     -  Main menu (when in idiot mode).
1003  aideopt      -  .A?
1004  readopt      -  .R?
1005  entopt       -  .E?
1006  dotopt       -  .?
1007  saveopt      -  Options to save a message, abort, etc.
1008  entermsg     -  Displayed just before a message is entered, when in
1009                  idiot mode.
1010
1011
1012  GNUR   (Get Next Unvalidated User)
1013
1014  This command shows the name of a user that needs to be validated.  If there
1015 are no unvalidated users, OK is returned.  Otherwise, MORE_DATA is returned
1016 along with the name of the first unvalidated user the server finds.  All of
1017 the usual ERROR codes may be returned as well (for example, if the user is
1018 not an Aide and cannot validate users).
1019
1020  A typical "Validate New Users" command would keep executing this command,
1021 and then validating each user it returns, until it returns OK when all new
1022 users have been validated.
1023
1024
1025  GREG   (Get REGistration for user)
1026
1027  This command retrieves the registration info for a user, whose name is the
1028 command's sole argument.  All the usual error messages can be returned.  If
1029 the command succeeds, LISTING_FOLLOWS is returned, followed by the user's name
1030 (retrieved from the userlog, with the right upper and lower case etc.)  The
1031 contents of the listing contains one field per line, followed by the usual
1032 000 on the last line.
1033
1034  The following lines are defined.  Others WILL be added in the futre, so all
1035 software should be written to read the lines it knows about and then ignore
1036 all remaining lines:
1037
1038  Line 1:  User number
1039  Line 2:  Password
1040  Line 3:  Real name
1041  Line 4:  Street address or PO Box
1042  Line 5:  City/town/village/etc.
1043  Line 6:  State/province/etc.
1044  Line 7:  ZIP Code
1045  Line 8:  Telephone number
1046  Line 9:  Access level
1047  Line 10: Internet e-mail address
1048  Line 11: Country
1049
1050  Users without Aide privileges may retrieve their own registration using
1051 this command.  This can be accomplished either by passing the user's own
1052 name as the argument, or the string "_SELF_".  The command will always
1053 succeed when used in this manner, unless no user is logged in.
1054
1055
1056  VALI   (VALIdate user)
1057
1058  This command is used to validate users.  Obviously, it can only be executed
1059 by users with Aide level access.  It should be passed two parameters: the
1060 name of the user to validate, and the desired access level
1061
1062  If the command succeeds, OK is returned.  The user's access level is changed
1063 and the "need validation" bit is cleared.  If the command fails for any
1064 reason, ERROR, ERROR+NO_SUCH_USER, or ERROR+HIGHER_ACCESS_REQUIRED will be
1065 returned.
1066
1067
1068  EINF   (Enter INFo file for room)
1069
1070  Transmit the info file for the current room with this command.  EINF uses
1071 a boolean flag (1 or 0 as the first and only argument to the command) to
1072 determine whether the client actually wishes to transmit a new info file, or
1073 is merely checking to see if it has permission to do so.
1074
1075  If the command cannot succeed, it returns ERROR.
1076  If the client is only checking for permission, and permission will be
1077 granted, OK is returned.
1078  If the client wishes to transmit the new info file, SEND_LISTING is
1079 returned, and the client should transmit the text of the info file, ended
1080 by the usual 000 on a line by itself.
1081
1082
1083  LIST   (user LISTing)
1084
1085  This is a simple user listing.  It always succeeds, returning
1086 LISTING_FOLLOWS followed by zero or more user records, 000 terminated.  The
1087 fields on each line are as follows:
1088
1089  1. User name
1090  2. Access level
1091  3. User number
1092  4. Date/time of last login (Unix format)
1093  5. Times called
1094  6. Messages posted
1095  7. Password (listed only if the user requesting the list is an Aide)
1096
1097  Unlisted entries will also be listed to Aides logged into the server, but
1098 not to ordinary users.
1099  
1100  The LIST command accepts an optional single argument, which is a simple,
1101 case-insensitive search string.  If this argument is present, only usernames
1102 in which the search string is present will be returned.  It is a simple
1103 substring search, not a regular expression search.  If this string is empty
1104 or not present, all users will be returned.
1105
1106
1107  REGI   (send REGIstration)
1108
1109  Clients will use this command to transmit a user's registration info.  If
1110 no user is logged in, ERROR+NOT_LOGGED_IN is returned.  Otherwise,
1111 SEND_LISTING is returned, and the server will expect the following information
1112 (terminated by 000 on a line by itself):
1113
1114  Line 1:  Real name
1115  Line 2:  Street address or PO Box
1116  Line 3:  City/town/village/etc.
1117  Line 4:  State/province/etc.
1118  Line 5:  ZIP Code
1119  Line 6:  Telephone number
1120  Line 7:  e-mail address
1121  Line 8:  Country
1122
1123
1124  CHEK   (CHEcK various things)
1125
1126  When logging in, there are various things that need to be checked.   This
1127 command will return ERROR+NOT_LOGGED_IN if no user is logged in.  Otherwise
1128 it returns OK and the following parameters:
1129
1130  0: Number of new private messages in Mail>
1131  1: Nonzero if the user needs to register
1132  2: (Relevant to Aides only) Nonzero if new users require validation
1133  3: The user's preferred Internet e-mail address
1134
1135
1136  DELF   (DELete a File)
1137
1138  This command deletes a file from the room's directory, if there is one.  The
1139 name of the file to delete is the only parameter to be supplied.  Wildcards
1140 are not acceptable, and any slashes in the filename will be converted to
1141 underscores, to prevent unauthorized access to neighboring directories.  The
1142 possible return codes are:
1143
1144  OK                            -  Command succeeded.  The file was deleted.
1145  ERROR+NOT_LOGGED_IN           -  Not logged in.
1146  ERROR+HIGHER_ACCESS_REQUIRED  -  Not an Aide or Room Aide.
1147  ERROR+NOT_HERE                -  There is no directory in this room.
1148  ERROR+FILE_NOT_FOUND          -  Requested file was not found.
1149
1150
1151  MOVF   (MOVe a File)
1152
1153  This command is similar to DELF, except that it moves a file (and its
1154 associated file description) to another room.  It should be passed two
1155 parameters: the name of the file to move, and the name of the room to move
1156 the file to.  All of the same return codes as DELF may be returned, and also
1157 one additional one: ERROR+NO_SUCH_ROOM, which means that the target room
1158 does not exist.  ERROR+NOT_HERE could also mean that the target room does
1159 not have a directory.
1160
1161
1162  NETF   (NETwork send a File)
1163
1164  This command is similar to MOVF, except that it attempts to send a file over
1165 the network to another system.  It should be passed two parameters: the name
1166 of the file to send, and the node name of the system to send it to.  All of
1167 the same return codes as MOVF may be returned, except for ERROR+NO_SUCH_ROOM.
1168 Instead, ERROR+NO_SUCH_SYSTEM may be returned if the name of the target
1169 system is invalid.
1170
1171  The name of the originating room will be sent along with the file.  Most
1172 implementations will look for a room with the same name at the receiving end
1173 and attempt to place the file there, otherwise it goes into a bit bucket room
1174 for miscellaneous files.  This is, however, beyond the scope of this document;
1175 see elsewhere for more details.
1176
1177
1178  RWHO   (Read WHO's online)
1179
1180  Displays a list of all users connected to the server.  No error codes are
1181 ever returned.  LISTING_FOLLOWS will be returned, followed by zero or more
1182 lines containing the following three fields:
1183
1184  0 - Session ID.  Citadel fills this with the pid of a server program.
1185  1 - User name.
1186  2 - The name of the room the user is currently in.  This field might not
1187 be displayed (for example, if the user is in a private room) or it might
1188 contain other information (such as the name of a file the user is
1189 downloading).
1190  3 - (server v4.03 and above) The name of the host the client is connecting
1191 from, or "localhost" if the client is local.
1192  4 - (server v4.04 and above) Description of the client software being used
1193  5 - The last time, locally to the server, that a command was received from
1194      this client (Note: NOOP's don't count)
1195  6 - The last command received from a client. (NOOP's don't count)
1196  7 - Session flags.  These are: + (spoofed address), - (STEALTH mode), *
1197      (posting) and . (idle).
1198  8 - Actual user name, if user name is masqueraded and viewer is an Aide.
1199  9 - Actual room name, if room name is masqueraded and viewer is an Aide.
1200  10 - Actual host name, if host name is masqueraded and viewer is an Aide.
1201  11 - Nonzero if the session is a logged-in user, zero otherwise.
1202
1203  The listing is terminated, as always, with the string "000" on a line by
1204 itself.
1205
1206
1207  OPEN   (OPEN a file for download)
1208
1209  This command is used to open a file for downloading.  Only one download
1210 file may be open at a time.  The only argument to this command is the name
1211 of the file to be opened.  The user should already be in the room where the
1212 file resides.  Possible return codes are:
1213
1214  ERROR+NOT_LOGGED_IN
1215  ERROR+NOT_HERE                (no directory in this room)
1216  ERROR+FILE_NOT_FOUND          (could not open the file)
1217  ERROR                         (misc errors)
1218  OK                            (file is open)
1219
1220  If the file is successfully opened, OK will be returned, along with the
1221 size (in bytes) of the file, the time of last modification (if applicable),
1222 the filename (if known), and the MIME type of the file (if known).
1223
1224
1225  CLOS   (CLOSe the download file)
1226
1227  This command is used to close the download file.  It returns OK if the
1228 file was successfully closed, or ERROR if there wasn't any file open in the
1229 first place.
1230
1231
1232  READ   (READ from the download file)
1233
1234  Two arguments are passed to this command.  The first is the starting position
1235 in the download file, and the second is the total number of bytes to be
1236 read.  If the operation can be performed, BINARY_FOLLOWS will be returned,
1237 along with the number of bytes to follow.  Then, immediately following the
1238 newline, will be that many bytes of binary data.  The client *must* read
1239 exactly that number of bytes, otherwise the client and server will get out
1240 of sync.
1241
1242  If the operation cannot be performed, any of the usual error codes will be
1243 returned.
1244
1245
1246  UOPN   (OPeN a file for Uploading)
1247
1248  This command is similar to OPEN, except that this one is used when the
1249 client wishes to upload a file to the server.  The first argument is the name
1250 of the file to create, and the second argument is a one-line comment
1251 describing the contents of the file.  Only one upload file may be open at a
1252 time.  Possible return codes are:
1253
1254  ERROR+NOT_LOGGED_IN
1255  ERROR+NOT_HERE               (no directory in this room)
1256  ERROR+FILE_NOT_FOUND         (a name must be specified)
1257  ERROR                        (miscellaneous errors)
1258  ERROR+ALREADY_EXISTS         (a file with the same name already exists)
1259  OK
1260
1261  If OK is returned, the command has succeeded and writes may be performed.
1262
1263
1264  UCLS   (CLoSe the Upload file)
1265
1266  Close the file opened with UOPN.  An argument of "1" should be passed to
1267 this command to close and save the file; otherwise, the transfer will be
1268 considered aborted and the file will be deleted.  This command returns OK
1269 if the operation succeeded or ERROR if it did not.
1270
1271
1272  WRIT   (WRITe to the upload file)
1273
1274  If an upload file is open, this command may be used to write to it.  The
1275 argument passed to this command is the number of bytes the client wishes to
1276 transmit.  An ERROR code will be returned if the operation cannot be
1277 performed.
1278
1279  If the operation can be performed, SEND_BINARY will be returned, followed
1280 by the number of bytes the server is expecting.  The client must then transmit
1281 exactly that number of bytes.  Note that in the current implementation, the
1282 number of bytes the server is expecting will always be the number of bytes
1283 the client requested to transmit, but the client software should never assume
1284 that this will always happen, in case changes are made later.
1285
1286
1287  QUSR   (Query for a USeR)
1288
1289  This command is used to check to see if a particular user exists.  The only
1290 argument to this command is the name of the user being searched for.  If
1291 the user exists, OK is returned, along with the name of the user in the userlog
1292 (so the client software can learn the correct upper/lower casing of the name
1293 if necessary).  If the user does not exist, ERROR+NO_SUCH_USER is returned.
1294 No login or current room is required to utilize this command.
1295
1296
1297  OIMG   (Open an IMaGe file)
1298
1299  Open an image (graphics) file for downloading.  Once opened, the file can be
1300 read as if it were a download file.  This implies that an image and a download
1301 cannot be opened at the same time.  OIMG returns the same result codes as OPEN.
1302
1303  All images will be in GIF (Graphics Interchange Format).  In the case of
1304 Citadel, the server will convert the supplied filename to all lower case,
1305 append the characters ".gif" to the filename, and look for it in the "images"
1306 subdirectory.  As with the MESG command, there are several "well known"
1307 images which are likely to exist on most servers:
1308
1309  hello        - "Welcome" graphics to be displayed alongside MESG "hello"
1310  goodbye      - Logoff banner graphics to be displayed alongside MESG "goodbye"
1311  background   - Background image (usually tiled) for graphical clients
1312
1313  The following "special" image names are defined in Citadel server version
1314 5.00 and above:
1315
1316  _userpic_    - Picture of a user (send the username as the second argument)
1317  _floorpic_   - A graphical floor label (send the floor number as the second
1318                 argument).  Clients which request a floor picture will display
1319                 the picture *instead* of the floor name.
1320  _roompic_    - A graphic associated with the *current* room.  Clients which
1321                 request a room picture will display the picture in *addition*
1322                 to the room name (i.e. it's used for a room banner, as
1323                 opposed to the floor picture's use in a floor listing).
1324
1325
1326  NETP   (authenticate as network session with connection NET Password)
1327
1328  This command is used by client software to identify itself as a transport
1329 session for Citadel site-to-site networking.  It should be called with
1330 two arguments: the node name of the calling system, and the "shared secret"
1331 password for that connection.  If the authentication succeeds, NETP will
1332 return OK, otherwise, it returns ERROR.
1333
1334  
1335  NSYN   (Network SYNchronize room)
1336  
1337  This command can be used to synchronize the contents of a room on the
1338 network.  It is only usable by Aides.  It accepts one argument: the name of
1339 a network node (which must be a valid one).
1340  
1341  When NSYN is run, the *entire* contents of the current room will be spooled
1342 to the specified node, without regard to whether any of the messages have
1343 already undergone network processing.  It is up to the receiving node to
1344 check for duplicates (the Citadel networker does handle this) and avoid
1345 posting them twice.
1346  
1347  The command returns OK upon success or ERROR if the user is not an Aide.
1348   
1349  
1350  NUOP   (Network Upload OPen file)
1351
1352  Open a network spool file for uploading.  The client must have already
1353 identified itself as a network session using the NETP command.  If the command
1354 returns OK, the client may begin transmitting IGnet/Open spool data using
1355 a series of WRIT commands.  When a UCLS command is issued, the spooled data
1356 is entered into the server if the argument to UCLS is 1 or discarded if the
1357 argument to UCLS is 0.  If the client has not authenticated itself with a
1358 NETP command, ERROR+HIGHER_ACCESS_REQUIRED will be returned.
1359
1360
1361  NDOP   (Network Download OPen file)
1362
1363  Open a network spool file for downloading.  The client must have already
1364 identified itself as a network session using the NETP command.  If the command
1365 returns OK, the client may begin receiving IGnet/Open spool data using
1366 a series of READ commands.  When a CLOS command is issued, the spooled data
1367 is deleted from the server and may not be read again.  If the client has not
1368 authenticated itself with a NETP command, ERROR+HIGHER_ACCESS_REQUIRED will
1369 be returned.
1370
1371
1372  LFLR   (List all known FLooRs)
1373
1374  On systems supporting floors, this command lists all known floors.  The
1375 command accepts no parameters.  It will return ERROR+NOT_LOGGED_IN if no
1376 user is logged in.  Otherwise it returns LISTING_FOLLOWS and a list of
1377 the available floors, each line consisting of three fields:
1378
1379  1. The floor number associated with the floor
1380  2. The name of the floor
1381  3. Reference count (number of rooms on this floor)
1382
1383
1384  CFLR   (Create a new FLooR)
1385
1386  This command is used to create a new floor.  It should be passed two
1387 arguments: the name of the new floor to be created, and a 1 or 0 depending
1388 on whether the client is actually creating a floor or merely checking to
1389 see if it has permission to create the floor.   The user must be logged in
1390 and have Aide privileges to create a floor.
1391
1392  If the command succeeds, it will return OK followed by the floor number
1393 associated with the new floor.  Otherwise, it will return ERROR (plus perhaps
1394 HIGHER_ACCESS_REQUIRED, ALREADY_EXISTS, or INVALID_FLOOR_OPERATION)
1395 followed by a description of why the command failed.
1396
1397
1398  KFLR   (Kill a FLooR)
1399
1400  This command is used to delete a floor.  It should be passed two
1401 argument: the *number* of the floor to be deleted, and a 1 or 0 depending
1402 on whether the client is actually deleting the floor or merely checking to
1403 see if it has permission to delete the floor.  The user must be logged in
1404 and have Aide privileges to delete a floor.
1405
1406  Floors that contain rooms may not be deleted.  If there are rooms on a floor,
1407 they must be either deleted or moved to different floors first.  This implies
1408 that the Main Floor (floor 0) can never be deleted, since Lobby>, Mail>, and
1409 Aide> all reside on the Main Floor and cannot be deleted.
1410
1411  If the command succeeds, it will return OK.  Otherwise it will return
1412 ERROR (plus perhaps HIGHER_ACCESS_REQUIRED or INVALID_FLOOR_OPERATION)
1413 followed by a description of why the command failed.
1414
1415
1416  EFLR   (Edit a FLooR)
1417
1418  Edit the parameters of a floor.  The client may pass one or more parameters
1419 to this command:
1420
1421  1. The number of the floor to be edited
1422  2. The desired new name
1423
1424  More parameters may be added in the future.  Any parameters not passed to
1425 the server will remain unchanged.  A minimal command would be EFLR and a
1426 floor number -- which would do nothing.  EFLR plus the floor number plus a
1427 floor name would change the floor's name.
1428
1429  If the command succeeds, it will return OK.  Otherwise it will return
1430 ERROR (plus perhaps HIGHER_ACCESS_REQUIRED or INVALID_FLOOR_OPERATION)
1431
1432
1433 IDEN (IDENtify the client software)
1434
1435  The client software has the option to identify itself to the server.
1436 Currently, the server does nothing with this information except to write
1437 it to the syslog to satisfy the system administrator's curiosity.  Other
1438 uses might become apparent in the future.
1439
1440  The IDEN command should contain five fields: a developer ID number (same as
1441 the server developer ID numbers in the INFO command -- please obtain one if
1442 you are a new developer), a client ID number (which does not have to be
1443 globally unique - only unique within the domain of the developer number),
1444 a version number, a free-form text string describing the client, and the name
1445 of the host the user is located at.
1446
1447  It is up to the server to determine whether to accept the host name or to
1448 use the host name it has detected itself.  Generally, if the client is
1449 running on a trusted host (either localhost or a well-known publically
1450 accessible client) it should use the host name transmitted by IDEN,
1451 otherwise it should use the host name it has detected itself.
1452
1453  IDEN always returns OK, but since that's the only way it ever returns
1454 there's no point in checking the result code.
1455
1456
1457 IPGM (identify as an Internal ProGraM)
1458
1459  IPGM is a low-level command that should not be used by normal user clients.
1460 It is used for various utilities to communicate with the server on the same
1461 host.  For example, the "sendcommand" utility logs onto the server as an
1462 internal program in order to run arbitrary server commands.  Since user clients
1463 do not utilize this command (or any of its companion commands), developers
1464 writing Citadel-compatible servers need not implement it.
1465
1466  The sole argument to IPGM is the system's internal program password.  This
1467 password is generated by the setup program and stored in the config file.
1468 Since internal programs have access to the config file, they know the correct
1469 password to use.
1470
1471  IPGM returns OK for a correct authentication or ERROR otherwise.
1472
1473
1474 CHAT (enter CHAT mode)
1475
1476  This command functions differently from every other command in the system.  It
1477 is used to implement multi-user chat.  For this to function, a new transfer
1478 mode, called START_CHAT_MODE, is implemented.  If a client does not support
1479 chat mode, it should never send a CHAT command!
1480
1481  In chat mode, messages may arrive asynchronously from the server at any
1482 time.  The client may send messages at any time.  This allows the arrival of
1483 messages without the client having to poll for them.  Arriving messages will
1484 be of the form  "user|message", where the "user" portion is, of course, the
1485 name of the user sending the message, and "message" is the message text.
1486
1487  Chat mode ends when the server says it ends.  The server will signal the end
1488 of chat mode by transmitting "000" on a line by itself.  When the client reads
1489 this line, it must immediately exit from chat mode without sending any
1490 further traffic to the server.  The next transmission sent to the server
1491 will be a regular server command.
1492
1493  The Citadel server understands the following commands:
1494  /quit   -   Exit from chat mode (causes the server to do an 000 end)
1495  /who    -   List users currently in chat
1496  /whobbs -   List users currently in chat and elsewhere
1497  /me     -   Do an irc-style action.
1498  /join   -   Join a new "room" in which all messages are only heard by
1499              people in that room.
1500  /msg    -   /msg <user> <msg> will send the msg to <user> only.
1501  /help   -   Print help information
1502  NOOP    -   Do nothing (silently)
1503
1504  Any other non-empty string is treated as message text and will be broadcast
1505 to other users currently in chat.
1506
1507
1508  SEXP   (Send instant message)
1509
1510  This is one of two commands which implement instant messages (also known
1511 as "paging").  Commands ending in "...EXP" are so-named because we called
1512 them "express messages" before the industry standardized on the term
1513 "instant messages."  When an instant message is sent, it will be
1514 logged in user to another.  When an instant message is sent, it will be
1515 displayed the next time the target user executes a PEXP or GEXP command.
1516
1517  The SEXP command accepts two arguments: the name of the user to send the
1518 message to, and the text of the message.  If the message is successfully
1519 transmitted, OK is returned.  If the target user is not logged in or if
1520 anything else goes wrong, ERROR is returned.
1521
1522  If the server supports extended paging, sending a zero-length message
1523 merely checks for the presence of the requested user without actually sending
1524 a message.  Sending a message consisting solely of a "-" (hyphen) will cause
1525 the server to return SEND_LISTING if the requested user is logged in, and the
1526 client can then transmit a multi-line page.
1527
1528  The reserved name "broadcast" may be used instead of a user name, to
1529 broadcast an instant message to all users currently connected to the server.
1530
1531  Do be aware that if an instant message is transmitted to a user who is logged
1532 in using a client that does not check for instant messages, the message will
1533 never be received.  Also, instant messages are NOT sent via the following
1534 transports:  SMTP, POP3.
1535
1536
1537  PEXP   (Print instant messages)   ***DEPRECATED***
1538
1539  This command is deprecated; it will eventually disappear from the protocol and
1540 its use is not recommended.  Please use the GEXP command instead.
1541
1542  Called without any arguments, PEXP simply dumps out the contents
1543 of any waiting instant messages.  It returns ERROR if there is a problem,
1544 otherwise it returns LISTING_FOLLOWS followed by all messages.
1545
1546  So how does the client know there are instant messages waiting?  It could
1547 execute a random PEXP every now and then.  Or, it can check the byte in
1548 server return code messages, between the return code and the parameters.  In
1549 much the same way as FTP uses "-" to signify a continuation, Citadel uses
1550 an "*" in this position to signify the presence of waiting instant messages.
1551
1552
1553  EBIO   (Enter BIOgraphy)
1554
1555  Transmit to the server a free-form text file containing a little bit of
1556 information about the user for other users to browse.  This is typically
1557 referred to as a 'bio' online.  EBIO returns SEND_LISTING if it succeeds,
1558 after which the client is expected to transmit the file, or any of the usual
1559 ERROR codes if it fails.
1560
1561
1562  RBIO   (Read BIOgraphy)
1563
1564  Receive from the server a named user's bio.  This command should be passed
1565 a single argument - the name of the user whose bio is requested.  RBIO returns
1566 LISTING_FOLLOWS plus the bio file if the user exists and has a bio on file.
1567 The return has the following parameters:  the user name, user number, access
1568 level, date of last call, times called, and messages posted.  This command
1569 returns ERROR+NO_SUCH_USER if the named user does not exist.
1570
1571  RBIO no longer considers a user with no bio on file to be an error condition.
1572 It now returns a message saying the user has no bio on file as the text of the
1573 bio.  This allows newer servers to operate with older clients.
1574
1575
1576  STEL   (enter STEaLth mode)
1577
1578  When in "stealth mode," a user will not show up in the "Who is online"
1579 listing (the RWHO server command).  Only Aides may use stealth mode.  The
1580 STEL command accepts one argument: a 1 indicating that the user wishes to
1581 enter stealth mode, or a 0 indicating that the user wishes to exit stealth
1582 mode.  STEL returns OK if the command succeeded, ERROR+NOT_LOGGED_IN if no
1583 user is logged in, or ERROR+HIGHER_ACCESS_REQUIRED if the user is not an Aide;
1584 followed by a 1 or 0 indicating the new state.
1585
1586  If any value other than 1 or 0 is sent by the client, the server simply
1587 replies with 1 or 0 to indicate the current state without changing it.
1588
1589 The STEL command also makes it so a user does not show up in the chat room
1590 /who.
1591
1592
1593  LBIO   (List users who have BIOs on file)
1594
1595  This command is self-explanatory.  Any user who has used EBIO to place a bio
1596 on file is listed.  LBIO almost always returns LISTING_FOLLOWS followed by
1597 this listing, unless it experiences an internal error in which case ERROR
1598 is returned.
1599
1600
1601  MSG2   (read MeSsaGe, mode 2)
1602
1603  MSG2 follows the same calling convention as MSG0.  The difference between
1604 the two commands is that MSG2 outputs messages in standard RFC822 format
1605 rather than in Citadel proprietary format.
1606
1607  This command was implemented in order to make various gateway programs
1608 easier to implement, and to provide some sort of multimedia support in the
1609 future.  Keep in mind that when this command is used, all messages will be
1610 output in fixed 80-column format.
1611
1612
1613  MSG3   (read MeSsaGe, mode 3 -- internal command)
1614
1615  MSG3 is for use by internal programs only and should not be utilized by
1616 user-mode clients.  It does require IPGM authentication.  MSG3 follows the
1617 same calling convention as the other MSG commands, but upon success returns
1618 BINARY_FOLLOWS followed by a data block containing the _raw_ message format
1619 on disk.
1620
1621
1622  TERM   (TERMinate another session)
1623
1624  In a multithreaded environment, it sometimes becomes necessary to terminate
1625 a session that is unusable for whatever reason.  The TERM command performs
1626 this task.  Naturally, only Aides can execute TERM.  The command should be
1627 called with a single argument: the session ID (obtained from an RWHO command)
1628 of the session to be terminated.
1629
1630  TERM returns OK if the session was terminated, or ERROR otherwise.  Note that
1631 a client program is prohibited from terminating the session it is currently
1632 running on.
1633
1634  See also: REQT
1635
1636
1637  DOWN   (shut DOWN the server)
1638
1639  This command, which may only be executed by an Aide, immediately shuts down
1640 the server.  It is only implemented on servers on which such an operation is
1641 possible, such as a multithreaded Citadel engine.  The server does not restart.
1642 DOWN returns OK if the user is allowed to shut down the server, in which case
1643 the client program should expect the connection to be immediately broken.
1644
1645
1646  SCDN   (Schedule or Cancel a shutDowN)
1647
1648  SCDN sets or clears the "scheduled shutdown" flag.  Pass this command a 1 or
1649 0 to respectively set or clear the flag.  When the "scheduled shutdown" flag is
1650 set, the server will be shut down when there are no longer any users logged in.
1651 Any value other than 0 or 1 will not change the flag, only report its state.
1652 No users will be kicked off the system, and in fact the server is still
1653 available for new connections.  The command returns ERROR if it fails;
1654 otherwise, it returns OK followed by a number representing the current state
1655 of the flag.
1656
1657
1658  EMSG   (Enter a system MeSsaGe)
1659
1660  This is the opposite of the MESG command - it allows the creation and editing
1661 of system messages.  The only argument passed to EMSG is the name of the
1662 file being transmitted.  If the file exists in any system message directory
1663 on the server it will be overwritten, otherwise a new file is created.  EMSG
1664 returns SEND_LISTING on success or ERROR+HIGHER_ACCESS_REQUIRED if the user
1665 is not an Aide.
1666
1667  Typical client software would use MESG to retrieve any existing message into
1668 an edit buffer, then present an editor to the user and run EMSG if the changes
1669 are to be saved.
1670
1671
1672  UIMG   (Upload an IMaGe file)
1673
1674  UIMG is complemenary to OIMG; it is used to upload an image to the server.
1675 The first parameter supplied to UIMG should be 0 if the client is only checking
1676 for permission to upload, or 1 if the client is actually attempting to begin
1677 the upload operation.  The second argument is the name of the file to be
1678 transmitted.  In Citadel, the filename is converted to all lower case,
1679 appended with the characters ".gif", and stored in the "images" directory.
1680
1681  UIMG returns OK if the client has permission to perform the requested upload,
1682 or ERROR+HIGHER_ACCESS_REQUIRED otherwise.  If the client requested to begin
1683 the operation (first parameter set to 1), an upload file is opened, and the
1684 client should begin writing to it with WRIT commands, then close it with a
1685 UCLS command.
1686
1687  The supplied filename should be one of:
1688
1689  ->  _userpic_   (Server will attempt to write to the user's online photo)
1690  ->  Any of the "well known" filenames described in the writeup for the
1691      OIMG command.
1692
1693
1694  HCHG   (Hostname CHanGe)
1695
1696  HCHG is a command, usable by any user, that allows a user to change their RWHO
1697 host value.  This will mask a client's originating hostname from normal
1698 users; access level 6 and higher can see, in an extended wholist, the actual
1699 hostname the user originates from.
1700
1701  The format of an HCHG command is:
1702
1703  HCHG <name>
1704
1705  If a HCHG command is successful, the value OK (200) is returned.
1706
1707
1708  RCHG   (Roomname CHanGe)
1709
1710  RCHG is a command, usable by any user, that allows a user to change their RWHO
1711 room value.  This will mask a client's roomname from normal users; access
1712 level 6 and higher can see, in an extended wholist, the actual room the user
1713 is in.
1714
1715  The format of an RCHG command is:
1716
1717  RCHG <name>
1718
1719  If a RCHG command is successful, the value OK (200) is returned.
1720
1721
1722  UCHG   (Username CHanGe)
1723
1724  UCHG is an aide-level command which allows an aide to effectively change their
1725 username.  If this value is blank, the user goes into stealth mode (see
1726 STEL).  Posts
1727 will show up as being from the real username in this mode, however.  In
1728 addition, the RWHO listing will include both the spoofed and real usernames.
1729
1730  The format of an UCHG command is:
1731
1732  UCHG <name>
1733
1734  If a UCHG command is successful, the value OK (200) is returned.
1735
1736
1737  TIME   (get server local TIME)
1738
1739  TIME returns OK followed by the current time measured in seconds since
1740 00:00:00 GMT, Jan 1, 1970 (standard Unix format).
1741
1742  This is used in allowing a client to calculate idle times.
1743
1744
1745  AGUP   (Administrative Get User Parameters)
1746  ASUP   (Administrative Set User Parameters)
1747
1748  These commands are only executable by Aides and by server extensions running
1749 at system-level.  They are used to get/set any and all parameters relating to
1750 a user account.  AGUP requires only one argument: the name of the user in
1751 question.  SGUP requires all of the parameters to be set.  The parameters are
1752 as follows, and are common to both commands:
1753
1754  0 - User name
1755  1 - Password
1756  2 - Flags (see citadel.h)
1757  3 - Times called
1758  4 - Messages posted
1759  5 - Access level
1760  6 - User number
1761  7 - Timestamp of last call
1762  8 - Purge time (in days) for this user (or 0 to use system default)
1763
1764  Upon success, AGUP returns OK followed by all these parameters, and ASUP
1765 simply returns OK.  If the client has insufficient access to perform the
1766 requested operation, ERROR+HIGHER_ACCESS_REQUIRED is returned.  If the
1767 requested user does not exist, ERROR+NO_SUCH_USER is returned.
1768
1769
1770
1771  GPEX   (Get Policy for message EXpiration)
1772
1773  Returns the policy of the current room, floor, or site regarding the automatic
1774 purging (expiration) of messages.  The following policies are available:
1775    0  -  Fall back to the policy of the next higher level.  If this is a room,
1776          use the floor's default policy.  If this is a floor, use the system
1777          default policy.  This is an invalid value for the system policy.
1778    1  -  Do not purge messages automatically.
1779    2  -  Purge by message count.  (Requires a value: number of messages)
1780    3  -  Purge by message age.  (Requires a value: number of days)
1781
1782  The format of this command is:  GPEX <which>
1783  The value of <which> must be one of: "room" "floor" "site" "mailboxes"
1784
1785  If successful, GPEX returns OK followed by <policy>|<value>.
1786
1787
1788
1789  SPEX   (Set Policy for message EXpiration)
1790
1791  Sets the policy of the current room, floor, or site regarding the automatic
1792 purging (expiration) of messages.  See the writeup for the GPEX command for
1793 the list of available policies.
1794
1795  The format of this command is:  SPEX <which>|<policy>|<value>
1796  The value of <which> must be one of: "room" "floor" "site" "mailboxes"
1797
1798  If successful, GPEX returns OK; otherwise, an ERROR code is returned.
1799
1800
1801
1802  CONF   (get or set global CONFiguration options)
1803
1804  Retrieves or sets various system-wide configuration and policy options.  This
1805 command is only available to Aides.  The sole parameter accepted is a command,
1806 which should be either GET or SET.  If the GET command succeeds, CONF will
1807 return LISTING_FOLLOWS followed by the fields described below, one line at a
1808 time.  If the SET command succeeds, CONF will return SEND_LISTING and expect
1809 the fields described below, one line at a time (don't worry about other fields
1810 being added in the future; if a 'short' configuration list is sent, the missing
1811 values at the end will be left unchanged on the system).  If either command
1812 fails for any reason, ERROR is returned.
1813
1814  The configuration lines are as follows:
1815
1816  1. Node name
1817  2. Fully qualified domain name
1818  3. Human-readable node name
1819  4. Landline telephone number of this system
1820  5. Flag (0 or 1) - creator of private room automatically becomes room aide
1821  6. Server connection idle timeout (in seconds)
1822  7. Initial access level for new users
1823  8. Flag (0 or 1) - require registration for new users
1824  9. Flag (0 or 1) - automatically move Problem User messages to twit room
1825  10. Name of twit room
1826  11. Text of <more> prompt
1827  12. Flag (0 or 1) - restrict access to Internet mail
1828  13. Geographic location of this system
1829  14. Name of the system administrator
1830  15. Number of maximum concurrent sessions allowed on the server
1831  16. (placeholder -- this field is no longer in use)
1832  17. Default purge time (in days) for users
1833  18. Default purge time (in days) for rooms
1834  19. Name of room to log instant messages to (or a zero-length name for none)
1835  20. Access level required to create rooms
1836  21. Maximum message length which may be entered into the system
1837  22. Minimum number of worker threads
1838  23. Maximum number of worker threads
1839  24. Port number for POP3 service
1840  25. Port number for SMTP service
1841  26. Flag (0 or 1) - strict RFC822 adherence - don't correct From: forgeries
1842  27. Flag (0 or 1) - allow Aides to zap (forget) rooms
1843  28. Port number for IMAP service
1844  29. How often (in seconds) to run the networker
1845  30. Flag (0 or 1) - disable self-service new user registration
1846  31. (placeholder -- this field is no longer in use)
1847  32. Hour (0 through 23) during which database auto-purge jobs are run
1848  33. Name of host where an LDAP service may be found
1849  34. Port number of LDAP service on above host
1850  35. LDAP Base DN
1851  36. LDAP Bind DN
1852  37. Password for LDAP Bind DN
1853  38. Server IP address to listen on (or "0.0.0.0" for all addresses)
1854  39. Port number for SMTP MSA service
1855  40. Port number for IMAPS (SSL-encrypted IMAP)
1856  41. Port number for POP3S (SSL-encrypted POP3)
1857  42. Port number for SMTPS (SSL-encrypted SMTP)
1858  43. Flag (0 or 1) - enable full text search index
1859  44. Flag (0 or 1) - automatically cull database log files
1860  45. Flag (0 or 1) - enable IMAP "instant expunge" of deleted messages
1861  46. Flag (0 or 1) - allow unauthenticated SMTP clients to spoof my domains
1862
1863  CONF also accepts two additional commands: GETSYS and PUTSYS followed by an
1864 arbitrary MIME type (such as application/x-citadel-internet-config) which
1865 provides a means of storing generic configuration data in the Global System
1866 Configuration room without the need to add extra get/set commands to the
1867 server.
1868  
1869  Please note that the LDAP-specific configs have no effect on Citadel servers
1870 in which LDAP support is not enabled.
1871
1872
1873
1874  MSG4   (read MeSsaGe, mode 4 -- output in preferred MIME format)
1875
1876  This is the equivalent of MSG0, except it's a bit smarter about messages in
1877 rich text formats.  Immediately following the "text" directive, the server
1878 will output RFC822-like MIME part headers such as "Content-type:" and
1879 "Content-length:".  MIME formats are chosen and/or converted based on the
1880 client's preferred format settings, which are set using the MSGP command,
1881 described below.
1882  
1883  The MSG4 command also accepts an optional second argument, which may be the
1884 MIME part specifier of an encapsulated message/rfc822 message.  This is useful
1885 for fetching the encapsulated message instead of the top-level message, for
1886 example, when someone has forwarded a message as an attachment.  Note that the
1887 only way for the client to know the part specifier is to fetch the top-level
1888 message and then look for attachments of type message/rfc822, and then call
1889 MSG4 again with that part specifier.
1890
1891
1892
1893
1894  MSGP   (set MeSsaGe Preferred MIME format)
1895
1896  Client tells the server what MIME content types it knows how to handle, and
1897 the order in which it prefers them.  This is similar to an HTTP "Accept:"
1898 header.
1899
1900  The parameters to a MSGP command are the client's acceptable MIME content
1901 types, in the order it prefers them (from most preferred to least preferred).
1902 For example:  MSGP text/html|text/plain
1903
1904  The MSGP command always returns OK.
1905
1906
1907
1908  OPNA   (OPeN Attachment)
1909
1910  Opens, as a download file, a component of a MIME-encoded message.  The two
1911 parameters which must be passed to this command are the message number and the
1912 name of the desired section.  If the message or section does not exist, an
1913 appropriate ERROR code will be returned; otherwise, if the open is successful,
1914 this command will succeed returning the same information as an OPEN command.
1915
1916
1917  GEXP   (Get instant messages)
1918
1919  This is a more sophisticated way of retrieving instant messages than the old
1920 PEXP method.  If there are no instant messages waiting, PEXP returns ERROR;
1921 otherwise, it returns LISTING_FOLLOWS and the following arguments:
1922
1923  0 - a boolean value telling the client whether there are any additional
1924      instant messages waiting following this one
1925  1 - a Unix-style timestamp
1926  2 - flags (see server.h for more info)
1927  3 - the name of the sender
1928  4 - the node this message originated on (for future support of PIP, ICQ, etc.)
1929
1930  The text sent to the client will be the body of the instant message.
1931
1932  So how does the client know there are instant messages waiting?  It could
1933 execute a random GEXP every now and then.  Or, it can check the byte in
1934 server return code messages, between the return code and the parameters.  In
1935 much the same way as FTP uses "-" to signify a continuation, Citadel uses
1936 an "*" in this position to signify the presence of waiting instant messages.
1937
1938
1939  FSCK   (check message base reference counts)
1940
1941  Verify, via the long way, that all message referenmce counts are correct.  If
1942 the user has permission to do this then LISTING_FOLLOWS is returned, followed
1943 by a transcript of the run.  Otherwise ERROR is returned.
1944
1945
1946  DEXP   (Disable receiving instant messages)
1947
1948  DEXP sets or clears the "disable instant messages" flag.  Pass this command a
1949 1 or 0 to respectively set or clear the flag.  When the "disable instant
1950 messages" flag is set, no one except Aides may send the user instant messages.
1951 Any value other than 0 or 1 will not change the flag, only report its state.
1952 The command returns ERROR if it fails; otherwise, it returns OK followed by a
1953 number representing the current state of the flag.
1954
1955
1956  REQT   (REQuest client Termination)
1957
1958  Request that the specified client (or all clients) log off.  Aide level
1959 access is required to run this command, otherwise ERROR+HIGHER_ACCESS_REQUIRED
1960 is returned.
1961
1962  The REQT command accepts one parameter: the session ID of the client which
1963 should be terminated, or 0 for all clients.  When successful, the REQT command
1964 returns OK.
1965
1966  It should be noted that REQT simply transmits an instant message to the
1967 specified client(s) with the EM_GO_AWAY flag set.  Older clients do not honor
1968 this flag, and it is certainly possible for users to re-program their client
1969 software to ignore it.  Therefore the effects of the REQT command should be
1970 considered advisory only.  The recommended implementation practice is to first
1971 issue a REQT command, then wait a little while (from 30 seconds up to a few
1972 minutes) for well-behaved clients to voluntarily terminate, and then issue a
1973 TERM command to forcibly disconnect the client (or perhaps a DOWN command, if
1974 you are logging off users for the purpose of shutting down the server).
1975
1976
1977  SEEN   (set or clear the SEEN flag for a message)
1978
1979  Beginning with version 5.80, Citadel supports the concept of setting or
1980 clearing the "seen" flag for each individual message, instead of only allowing
1981 a "last seen" pointer.  In fact, the old semantics are implemented in terms
1982 of the new semantics.  This command requires two arguments: the number of the
1983 message to be set, and a 1 or 0 to set or clear the "seen" bit.
1984
1985  This command returns OK, unless the user is not logged in or a usage error
1986 occurred, in which case it returns ERROR.  Please note that no checking is
1987 done on the supplied data; if the requested message does not exist, the SEEN
1988 command simply returns OK without doing anything.
1989
1990
1991  GTSN   (GeT the list of SeeN messages)
1992
1993  This command retrieves the list of "seen" (as opposed to unread) messages for
1994 the current room.  It returns OK followed by an IMAP-format message list.
1995
1996
1997  SMTP   (utility commands for the SMTP gateway)
1998
1999  This command, accessible only by Aides, supports several utility operations
2000 which examine or manipulate Citadel's SMTP support.  The first command argument
2001 is a subcommand telling the server what to do.  The following subcommands are
2002 supported:
2003
2004       SMTP mx|hostname             (display all MX hosts for 'hostname')
2005       SMTP runqueue                (attempt immediate delivery of all messages
2006                                     in the outbound SMTP queue, ignoring any
2007                                     retry times stored there)
2008
2009
2010  STLS   (Start Transport Layer Security)
2011
2012  This command starts TLS on the current connection.  The current
2013 implementation uses OpenSSL on both the client and server end.  For future
2014 compatibility all clients must support at least TLSv1, and servers are
2015 guaranteed to support TLSv1.  During TLS negotiation (see below) the server
2016 and client may agree to use a different protocol.
2017
2018  The server returns ERROR if it does not support SSL or SSL initialization
2019 failed on the server; otherwise it returns OK.  Once the server returns OK and
2020 the client has read the response, the server and client immediately negotiate
2021 TLS (in OpenSSL, using SSL_connect() on the client and SSL_accept() on the
2022 server).  If negotiation fails, the server and client should attempt to resume
2023 the session unencrypted.  If either end is unable to resume the session, the
2024 connection should be closed.
2025
2026  This command may be run at any time.
2027
2028
2029  GTLS   (Get Transport Layer Security Status)
2030
2031  This command returns information about the current connection.  The server
2032 returns OK plus several parameters if the connection is encrypted, and ERROR
2033 if the connection is not encrypted.  It is primarily used for debugging.  The
2034 command may be run at any time.
2035
2036  0 - Protocol name, e.g. "SSLv3"
2037  1 - Cipher suite name, e.g. "ADH-RC4-MD5"
2038  2 - Cipher strength bits, e.g. 128
2039  3 - Cipher strength bits actually in use, e.g. 128
2040
2041
2042  IGAB   (Initialize Global Address Book)
2043
2044  This command creates, or re-creates, a database of Internet e-mail addresses
2045 using the vCard information in the Global Address Book room.  This procedure
2046 is normally run internally when the server determines it necessary, but is
2047 also provided as a server command to be used as a troubleshooting/maintenenance
2048 tool.  Only a system Aide can run the command.  It returns OK on success or
2049 ERROR on failure.
2050
2051
2052  QDIR   (Query global DIRectory)
2053
2054  Look up an internet address in the global directory.  Any logged-in user may
2055 call QDIR with one parameter, the Internet e-mail address to look up.  QDIR
2056 returns OK followed by a Citadel address if there is a match, otherwise it
2057 returns ERROR+NOT_LOGGED_IN.
2058
2059
2060  ISME   (find out if an e-mail address IS ME)
2061
2062  This is a quickie shortcut command to find out if a given e-mail address
2063 belongs to the user currently logged in.  Its sole argument is an address to
2064 parse.  The supplied address may be in any format (local, IGnet, or Internet).
2065 The command returns OK if the address belongs to the user, ERROR otherwise.
2066
2067
2068  VIEW   (set the VIEW for a room)
2069
2070  Set the preferred view for the current user in the current room.  Please see
2071 views.txt for more information on views.  The sole parameter for this command
2072 is the type of view requested.  VIEW returns OK on success or ERROR on failure.
2073
2074
2075  QNOP   (Quiet No OPeration)
2076
2077  This command does nothing, similar to the NOOP command.  However, unlike the
2078 NOOP command, it returns *absolutely no response* at all.  The client has no
2079 way of knowing that the command executed.  It is intended for sending
2080 "keepalives" in situations where a full NOOP would cause the client protocol
2081 to get out of sync.
2082
2083  Naturally, sending this command to a server that doesn't support it is an
2084 easy way to mess things up.  Therefore, client software should first check
2085 the output of an INFO command to ensure that the server supports quiet noops.
2086
2087
2088
2089  ICAL   (Internet CALendaring commands)
2090
2091  This command supports a number of subcommands which are used to process the
2092 calendaring/scheduling support in Citadel.  Here are the subcommands which
2093 may be issued:
2094
2095  ICAL test
2096   Test server for calendaring support.  Always returns OK unless the server
2097   does not have the calendar module enabled.
2098
2099  ICAL respond|msgnum|partnum|action
2100   Respond to a meeting request.  'msgnum' and 'partnum' refer to a MIME-encoded
2101   meeting invitation in the current room.  'action' must be set to either
2102   "accept" or "decline" to determine the action to take.  This subcommand will
2103   return either OK or ERROR.
2104
2105  ICAL conflicts|msgnum|partnum
2106   Determine whether an incoming VEVENT will fit in the user's calendar by
2107   checking it against the existing VEVENTs.  'msgnum' and 'partnum' refer to
2108   a MIME-encoded meeting invitation in the current room (usually the inbox).
2109   This command may return ERROR if something went wrong, but usually it will
2110   return LISTING_FOLLOWS followed by a list of zero or more conflicting
2111   events.  A zero-length list means that there were no conflicts.
2112  
2113  ICAL handle_rsvp|msgnum|partnum
2114   Handle an incoming "reply" (or RSVP) to a meeting request you sent out.
2115   'msgnum' and 'partnum' refer to a MIME-encoded reply in the current room.
2116   'action' must be set to either "update" or "ignore" to determine the action
2117   to take.  If the action is "update" then the server will hunt for the meeting
2118   in the user's Calendar> room, and update the status for this attendee.  Either
2119   way, the reply message is deleted from the current room.  This subcommand will
2120   return either OK or ERROR.
2121  
2122  ICAL freebusy|username
2123   Output the free/busy times for the requested user.  If the user specified
2124   has a calendar available, this command will return LISTING_FOLLOWS and a
2125   compound VCALENDAR object.  That object, in turn, will contain VEVENT
2126   objects that have been stripped of all properties except for the bare
2127   minimum needed to learn free/busy times (such as DTSTART, DTEND, and
2128   TRANSP).  If there is no such user, or no calendar available, the usual
2129   ERROR codes will be returned.
2130  
2131  ICAL sgi|<bool>
2132  
2133  Readers who are paying attention will notice that there is no subcommand to
2134 send out meeting invitations.  This is because that task can be handled
2135 automatically by the Citadel server.  Issue this command with <bool> set to 1
2136 to enable Server Generated Invitations.  In this mode, when an event is saved
2137 to the user's Calendar> room and it contains attendees, Citadel will
2138 automatically turn the event into vCalendar REQUEST messages and mail them
2139 out to all listed attendees.  If for some reason the client needs to disable
2140 Server Generated Invitations, the command may be sent again with <bool> = 0.
2141
2142
2143
2144  MRTG   (Multi Router Traffic Grapher)
2145
2146  Multi Router Traffic Grapher (please see http://www.mrtg.org for more info) is
2147 a tool which creates pretty graphs of network activity, usually collected from
2148 routers using SNMP.  However, its ability to call external scripts has spawned
2149 a small community of people using it to graph anything which can be graphed.
2150 The MRTG command can output Citadel server activity in the format MRTG expects.
2151
2152  This format is as follows:
2153
2154  LISTING_FOLLOWS
2155  Line 1: variable #1
2156  Line 2: variable #2
2157  Line 3: uptime of system
2158  Line 4: name of system
2159  000
2160
2161  MRTG accepts two different keywords.  "MRTG users" will return two variables,
2162 the number of connected users and the number of active users.  "MRTG messages"
2163 will return one variable (and a zero in the second field), showing the current
2164 highest message number on the system.  Any other keyword, or a missing keyword,
2165 will cause the MRTG command to return an ERROR code.
2166
2167  Please get in touch with the Citadel developers if you wish to experiment with
2168 this.
2169
2170
2171
2172  GNET   (Get NETwork configuration for this room)
2173  SNET   (Set NETwork configuration for this room)
2174  
2175  These commands get/set the network configuration for the current room.  Aide
2176 or Room Aide privileges are required, otherwise an ERROR code is returned.
2177 If the command succeeds, LISTING_FOLLOWS or SEND_LISTING is returned.  The
2178 network configuration for a specific room includes neighbor nodes with whom
2179 the room is shared, and mailing list recipients.  The format of the network
2180 configuration is described in the file "netconfigs.txt".
2181
2182
2183
2184  ASYN   (ASYNchronous message support)
2185
2186  Negotiate the use of asynchronous, or unsolicited, protocol messages.  The
2187 only parameter specified should be 1 or 0 to indicate that the client can or
2188 cannot handle this type of messages.  The server will reply OK followed by a
2189 1 or 0 to tell the client which mode it is now operating in.
2190
2191  If the command is not available on the server (i.e. it returns ERROR), or
2192 if the command has not been executed by the client, it should be assumed that
2193 this mode of operation is NOT in effect.
2194
2195  The client may also send any value other than 0 or 1 to simply cause the
2196 server to output its current state without changing it.
2197
2198  When asynchronous protocol mode is in effect, the client MUST handle any
2199 asynchronous messages as they arrive, before doing anything else.
2200
2201
2202
2203  AUTO   (AUTOcompletion of email addresses)
2204  
2205  The AUTO command is used by clients which want to request a list of email
2206 recipients whose names or email addresses match a partial string supplied by
2207 the client.  This string is the only parameter passed to this command.  The
2208 command will return ERROR if no user is logged in or if no address book could
2209 be found; otherwise, it returns LISTING_FOLLOWS followed by zero or more
2210 candidate recipients.
2211
2212
2213
2214  SRCH   (SeaRCH the message base)
2215  
2216  This command's implementation is incomplete and will be documented when it
2217 is finished.  The current implementation accepts a search string as its sole
2218 argument, and will respond with LISTING_FOLLOWS followed by a list of
2219 messages (globally, not just in the current room) which contain ALL of the
2220 words in the search string.  If the client desires an "exact phrase" match,
2221 it must then slow-search the text of each returned message for the exact
2222 string.  The client should also compare the returned message numbers against
2223 those which actually exist in the room or rooms being searched.  In
2224 particular, clients should avoid telling the user about messages which exist
2225 only in rooms to which the user does not have access.
2226  
2227  Again, keep in mind that this is a temporary implementation and is not
2228 guaranteed to continue to exist in this form.
2229
2230
2231 EUID   (get message number using an EUID)}
2232
2233  Returns the message number, if present, of the message in the current room
2234 which is indexed using the supplied EUID (exclusive message ID).  There can be
2235 only one message in a room with any given EUID; if another message arrives
2236 with the same EUID, the existing one is replaced.  This makes it possible to
2237 reference things like calendar items using an immutable URL that does not
2238 change even when the message number changes due to an update.
2239
2240  The format of this command is:  EUID <euid>
2241
2242  If successful, EUID returns OK followed by a message number.
2243  If no message exists in the current room with the supplied EUID, the command
2244 returns ERROR+MESSAGE_NOT_FOUND.
2245
2246  
2247  
2248  
2249  
2250  ASYNCHRONOUS MESSAGES
2251  ---------------------
2252
2253  When the client protocol is operating in asynchronous mode (please refer to
2254 the writeup of the ASYN command above), the following messages may arrive at
2255 any time:
2256
2257
2258  902  (instant message arriving)
2259
2260  One or more instant messages have arrived for this client.