2 * Copyright (c) 1987-2018 by the citadel.org team
4 * This program is open source software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
14 #define DEFAULT_HOST "localhost"
15 #define DEFAULT_PORT "504"
16 #define CLIENT_VERSION 920
19 /* commands we can send to the stty_ctdl() routine */
20 #define SB_NO_INTR 0 // set to Citadel client mode, i/q disabled
21 #define SB_YES_INTR 1 // set to Citadel client mode, i/q enabled
22 #define SB_SAVE 2 // save settings
23 #define SB_RESTORE 3 // restore settings
24 #define SB_LAST 4 // redo the last command sent
26 #define UGLISTLEN 100 // you get a ungoto list of this size */
27 #define ROOMNAMELEN 128 // The size of a roomname string
28 #define USERNAME_SIZE 64 // The size of a username string
29 #define MAX_EDITORS 5 // number of external editors supported, must be at least 1
30 #define NONCE_SIZE 128 // Added by <bc> to allow for APOP auth
32 #define S_KEEPALIVE 30 // How often (in seconds) to send keepalives to the server
35 #define READ_MSGBODY 3
37 #define NUM_CONFIGS 72
42 /* citadel.rc stuff */
43 #define RC_NO 0 /* always no */
44 #define RC_YES 1 /* always yes */
45 #define RC_DEFAULT 2 /* setting depends on user config */
49 KA_NO, /* no keepalives */
50 KA_YES, /* full keepalives */
51 KA_HALF /* half keepalives */
54 /* for <;G>oto and <;S>kip commands */
55 #define GF_GOTO 0 /* <;G>oto floor mode */
56 #define GF_SKIP 1 /* <;S>kip floor mode */
57 #define GF_ZAP 2 /* <;Z>ap floor mode */
61 * Colors for color() command
71 #define BRIGHT_BLACK 8
73 #define BRIGHT_GREEN 10
74 #define BRIGHT_YELLOW 11
75 #define BRIGHT_BLUE 12
76 #define BRIGHT_MAGENTA 13
77 #define BRIGHT_CYAN 14
78 #define BRIGHT_WHITE 15
79 #define COLOR_PUSH 16 /* Save current color */
80 #define COLOR_POP 17 /* Restore saved color */
81 #define ORIGINAL_PAIR -1 /* Default terminal colors */
83 typedef void (*sighandler_t)(int);
95 #include <sys/types.h>
98 #include <sys/ioctl.h>
100 // #include <sgtty.h> not needed if we have termios.h
103 #include <sys/socket.h>
104 #include <arpa/inet.h>
105 #include <netinet/in.h>
116 #include <sys/select.h>
118 #include <libcitadel.h>
121 #ifdef HAVE_PTHREAD_H
125 #include <openssl/ssl.h>
126 #include <openssl/err.h>
127 #include <openssl/rand.h>
131 struct CtdlServInfo {
138 char site_location[64];
140 char moreprompt[256];
145 int newuser_disabled;
146 char default_cal_zone[256];
151 int fulltext_enabled;
152 char svn_revision[256];
158 * This class is responsible for the server connection
160 typedef struct _CtdlIPC {
161 struct CtdlServInfo ServInfo; /* The server info for this connection */
162 #if defined(HAVE_OPENSSL)
163 SSL *ssl; /* NULL if not encrypted, non-NULL otherwise */
165 int sock; /* Socket for connection to server, or -1 if not connected */
166 int isLocal; /* 1 if server is local, 0 otherwise or if not connected */
167 int downloading; /* 1 if a download is open on the server, 0 otherwise */
168 int uploading; /* 1 if an upload is open on the server, 0 otherwise */
169 time_t last_command_sent; /* Time the last command was sent to the server */
170 char *Buf; /* Our buffer for linebuffered read. */
174 void (*network_status_cb)(int state); /* Callback for update on whether the IPC is locked */
175 char ip_hostname[256]; /* host name of server to which we are connected (if network) */
176 char ip_address[64]; /* IP address of server to which we are connected (if network) */
179 extern char *axdefs[];
180 extern char *viewdefs[];
181 extern char fullname[USERNAME_SIZE];
182 extern unsigned room_flags;
183 extern char room_name[ROOMNAMELEN];
184 extern struct CtdlServInfo serv_info;
186 extern char is_room_aide;
187 extern unsigned userflags;
188 extern char sigcaught;
189 extern char editor_paths[MAX_EDITORS][SIZ];
190 extern char printcmd[SIZ];
191 extern char imagecmd[SIZ];
192 extern char have_xterm;
193 extern char rc_username[USERNAME_SIZE];
194 extern char rc_password[32];
195 extern char rc_floor_mode;
196 extern time_t rc_idle_threshold;
198 extern char rc_encrypt; /* from the citadel.rc file */
199 extern char arg_encrypt; /* from the command line */
201 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
202 extern char rc_screen;
203 extern char arg_screen;
205 extern char rc_alt_semantics;
206 extern char instant_msgs;
207 void ctdl_logoff(char *file, int line, CtdlIPC *ipc, int code);
208 #define logoff(ipc, code) ctdl_logoff(__FILE__, __LINE__, (ipc), (code))
209 void formout(CtdlIPC *ipc, char *name);
210 void sighandler(int which_sig);
212 void remove_march(char *roomname, int floornum);
213 void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg);
216 * This struct stores a list of rooms with new messages which the client
217 * fetches from the server. This allows the client to "march" through
218 * relevant rooms without having to ask the server each time where to go next.
220 typedef struct ExpirePolicy ExpirePolicy;
221 struct ExpirePolicy {
226 typedef struct march march;
229 char march_name[ROOMNAMELEN];
230 unsigned int march_flags;
233 unsigned int march_flags2;
238 * This is NOT the same 'struct ctdluser' from the server.
240 typedef struct ctdluser ctdluser;
241 struct ctdluser { // User record
242 int version; // Cit vers. which created this rec
243 uid_t uid; // Associate with a unix account?
244 char password[32]; // password
245 unsigned flags; // See US_ flags below
246 long timescalled; // Total number of logins
247 long posted; // Number of messages ever submitted
248 uint8_t axlevel; // Access level
249 long usernum; // User number (never recycled)
250 time_t lastcall; // Date/time of most recent login
251 int USuserpurge; // Purge time (in days) for user
252 char fullname[64]; // Display name (primary identifier)
253 char emailaddrs[512]; // Internet email addresses
256 typedef struct ctdlroom ctdlroom;
258 char QRname[ROOMNAMELEN]; /* Name of room */
259 char QRpasswd[10]; /* Only valid if it's a private rm */
260 long QRroomaide; /* User number of room aide */
261 long QRhighest; /* Highest message NUMBER in room */
262 time_t QRgen; /* Generation number of room */
263 unsigned QRflags; /* See flag values below */
264 char QRdirname[15]; /* Directory name, if applicable */
265 long QRinfo; /* Info file update relative to msgs*/
266 char QRfloor; /* Which floor this room is on */
267 time_t QRmtime; /* Date/time of last post */
268 struct ExpirePolicy QRep; /* Message expiration policy */
269 long QRnumber; /* Globally unique room number */
270 char QRorder; /* Sort key for room listing order */
271 unsigned QRflags2; /* Additional flags */
272 int QRdefaultview; /* How to display the contents */
277 CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf);
279 void CtdlIPC_delete(CtdlIPC* ipc);
280 /* Convenience destructor; also nulls out caller's pointer */
281 void CtdlIPC_delete_ptr(CtdlIPC** pipc);
282 /* Read a line from server, discarding newline, for chat, will go away */
283 void CtdlIPC_chat_recv(CtdlIPC* ipc, char *buf);
284 /* Write a line to server, adding newline, for chat, will go away */
285 void CtdlIPC_chat_send(CtdlIPC* ipc, const char *buf);
288 char RRname[ROOMNAMELEN]; /* Name of room */
289 long RRunread; /* Number of unread messages */
290 long RRtotal; /* Total number of messages in room */
291 char RRinfoupdated; /* Nonzero if info was updated */
292 unsigned RRflags; /* Various flags (see LKRN) */
293 unsigned RRflags2; /* Various flags (see LKRN) */
294 long RRhighest; /* Highest message number in room */
295 long RRlastread; /* Highest message user has read */
296 char RRismailbox; /* Is this room a mailbox room? */
297 char RRaide; /* User can do aide commands in room */
298 long RRnewmail; /* Number of new mail messages */
299 char RRfloor; /* Which floor this room is on */
300 char RRcurrentview; /* The user's current view for this room */
301 char RRdefaultview; /* The default view for this room */
307 char number[16]; /* part number */
308 char name[PATH_MAX]; /* Name */
309 char filename[PATH_MAX]; /* Suggested filename */
310 char mimetype[SIZ]; /* MIME type */
311 char disposition[SIZ]; /* Content disposition */
312 unsigned long length; /* Content length */
316 struct ctdlipcmessage {
317 char msgid[SIZ]; /* Original message ID */
318 char path[SIZ]; /* Return path to sender */
319 char zaps[SIZ]; /* Message ID that this supersedes */
320 char subject[SIZ]; /* Message subject */
321 char email[SIZ]; /* Email address of sender */
322 char author[SIZ]; /* Sender of message */
323 char recipient[SIZ]; /* Recipient of message */
324 char room[SIZ]; /* Originating room */
325 struct parts *attachments; /* Available attachments */
326 char *text; /* Message text */
327 int type; /* Message type */
328 time_t time; /* Time message was posted */
329 char nhdr; /* Suppress message header? */
330 char anonymous; /* An anonymous message */
331 char mime_chosen[SIZ]; /* Chosen MIME part to output */
332 char content_type[SIZ]; /* How would you like that? */
333 char references[SIZ]; /* Thread references */
338 char remote_name[PATH_MAX]; /* Filename on server */
339 char local_name[PATH_MAX]; /* Filename on client */
340 char description[80]; /* Description on server */
341 FILE *local_fd; /* Open file on client */
342 size_t size; /* Size of file in octets */
343 unsigned int upload:1; /* uploading? 0 if downloading */
344 unsigned int complete:1; /* Transfer has finished? */
349 long newmail; /* Number of new Mail messages */
350 char needregis; /* Nonzero if user needs to register */
351 char needvalid; /* Nonzero if users need validation */
356 SubscribedRoomsWithNewMessages,
357 SubscribedRoomsWithNoNewMessages,
372 enum MessageDirection {
376 extern char file_citadel_rc[PATH_MAX];
377 extern char file_citadel_config[PATH_MAX];
379 /* Shared Diffie-Hellman parameters */
380 #define DH_P "F6E33BD70D475906ABCFB368DA2D1E5611D57DFDAC6A10CD78F406D6952519C74E21FFDCC5A780B9359722AACC8036E4CD24D5F5165EAC9EF226DBD9BBCF678F8DDEE86386F1BC20E291A9854A513A2CA326B411DC92E38F2ED2FEB6A3B792F13DB6550371FDBAC5ECA373BE5050CA4905431CA86088737D52B36C8D13CE9CB4EEF4C910285035E8329DD07551A80B87775676DD1067395CCEE9040C9B8BF998C528B3772B4C590A2CF18C5E58929BFCB538A62638B7437A9C68572D15287E97692B0B1EC5444D9DAB6EB062D20B79CA005EC5035065567AFD1FEF9B251D74747C6065D8C8B6B0862D1EE03F3A244C429EADE0CCC5C3A4196F5CBF5AA01A9026EFB20AA90E462BD64620278F271905EB604F38E6CFAE412EAA6C468E3B58170909BC18662FE2053224F30BE4FDB93BF9FBF969D91A5427A0665AC7BD1C43701B991094C92F7A935063055617142164F02973EB4ED86DD74D2BBAB3CD3B28F7BBD8D9F925B0FE92F7F7D0568D783F9ECE7AF96FB5AF274B586924B64639733A73ACA8F2BD1E970DF51ADDD983F7F6361A2B0DC4F086DE26D8656EC8813DE4B74D6D57BC1E690AC2FF1682B7E16938565A41D1DC64C75ADB81DA4582613FC68C0FDD327D35E2CDF20D009465303773EF3870FBDB0985EE7002A95D7912BBCC78187C29DB046763B7FABFF44EABE820F8ED0D7230AA0AF24F428F82448345BC099B"
383 #define CIT_CIPHERS "ALL:RC4+RSA:+SSLv2:+TLSv1:!MD5:@STRENGTH" /* see ciphers(1) */
385 int CtdlIPCNoop(CtdlIPC *ipc);
386 int CtdlIPCEcho(CtdlIPC *ipc, const char *arg, char *cret);
387 int CtdlIPCQuit(CtdlIPC *ipc);
388 int CtdlIPCLogout(CtdlIPC *ipc);
389 int CtdlIPCTryLogin(CtdlIPC *ipc, const char *username, char *cret);
390 int CtdlIPCTryPassword(CtdlIPC *ipc, const char *passwd, char *cret);
391 int CtdlIPCTryApopPassword(CtdlIPC *ipc, const char *response, char *cret);
392 int CtdlIPCCreateUser(CtdlIPC *ipc, const char *username, int selfservice,
394 int CtdlIPCChangePassword(CtdlIPC *ipc, const char *passwd, char *cret);
395 int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor,
396 struct march **listing, char *cret);
397 int CtdlIPCGetConfig(CtdlIPC *ipc, struct ctdluser **uret, char *cret);
398 int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret);
399 int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd,
400 struct ctdlipcroom **rret, char *cret);
401 int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
402 const char *mtemplate, unsigned long **mret, char *cret);
403 int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
404 struct ctdlipcmessage **mret, char *cret);
405 int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret);
406 int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret);
407 /* int CtdlIPCReadDirectory(CtdlIPC *ipc, struct ctdlipcfile **files, char *cret); */
408 int CtdlIPCReadDirectory(CtdlIPC *ipc, char **listing, char *cret);
409 int CtdlIPCSetLastRead(CtdlIPC *ipc, long msgnum, char *cret);
410 int CtdlIPCInviteUserToRoom(CtdlIPC *ipc, const char *username, char *cret);
411 int CtdlIPCKickoutUserFromRoom(CtdlIPC *ipc, const char *username, char *cret);
412 int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret);
413 int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct ctdlroom *qret,
415 int CtdlIPCGetRoomAide(CtdlIPC *ipc, char *cret);
416 int CtdlIPCSetRoomAide(CtdlIPC *ipc, const char *username, char *cret);
417 int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, int *subject_required,
418 struct ctdlipcmessage *mr,
420 int CtdlIPCRoomInfo(CtdlIPC *ipc, char **iret, char *cret);
421 int CtdlIPCDeleteMessage(CtdlIPC *ipc, long msgnum, char *cret);
422 int CtdlIPCMoveMessage(CtdlIPC *ipc, int copy, long msgnum,
423 const char *destroom, char *cret);
424 int CtdlIPCDeleteRoom(CtdlIPC *ipc, int for_real, char *cret);
425 int CtdlIPCCreateRoom(CtdlIPC *ipc, int for_real, const char *roomname,
426 int type, const char *password, int floor, char *cret);
427 int CtdlIPCForgetRoom(CtdlIPC *ipc, char *cret);
428 int CtdlIPCSystemMessage(CtdlIPC *ipc, const char *message, char **mret,
430 int CtdlIPCNextUnvalidatedUser(CtdlIPC *ipc, char *cret);
431 int CtdlIPCGetUserRegistration(CtdlIPC *ipc, const char *username, char **rret,
433 int CtdlIPCValidateUser(CtdlIPC *ipc, const char *username, int axlevel,
435 int CtdlIPCSetRoomInfo(CtdlIPC *ipc, int for_real, const char *info,
437 int CtdlIPCUserListing(CtdlIPC *ipc, char *searchstring, char **list, char *cret);
438 int CtdlIPCSetRegistration(CtdlIPC *ipc, const char *info, char *cret);
439 int CtdlIPCMiscCheck(CtdlIPC *ipc, struct ctdlipcmisc *chek, char *cret);
440 int CtdlIPCDeleteFile(CtdlIPC *ipc, const char *filename, char *cret);
441 int CtdlIPCMoveFile(CtdlIPC *ipc, const char *filename, const char *destroom, char *cret);
442 int CtdlIPCNetSendFile(CtdlIPC *ipc, const char *filename, const char *destnode, char *cret);
443 int CtdlIPCOnlineUsers(CtdlIPC *ipc, char **listing, time_t *stamp, char *cret);
444 int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
446 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
448 int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
450 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
452 int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf,
453 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
455 int CtdlIPCFileUpload(CtdlIPC *ipc, const char *save_as, const char *comment,
457 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
459 int CtdlIPCImageUpload(CtdlIPC *ipc, int for_real, const char *path,
461 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
463 int CtdlIPCQueryUsername(CtdlIPC *ipc, const char *username, char *cret);
464 int CtdlIPCFloorListing(CtdlIPC *ipc, char **listing, char *cret);
465 int CtdlIPCCreateFloor(CtdlIPC *ipc, int for_real, const char *name, char *cret);
466 int CtdlIPCDeleteFloor(CtdlIPC *ipc, int for_real, int floornum, char *cret);
467 int CtdlIPCEditFloor(CtdlIPC *ipc, int floornum, const char *floorname, char *cret);
468 int CtdlIPCIdentifySoftware(CtdlIPC *ipc, int developerid, int clientid,
469 int revision, const char *software_name, const char *hostname,
471 int CtdlIPCSendInstantMessage(CtdlIPC *ipc, const char *username, const char *text, char *cret);
472 int CtdlIPCGetInstantMessage(CtdlIPC *ipc, char **listing, char *cret);
473 int CtdlIPCEnableInstantMessageReceipt(CtdlIPC *ipc, int mode, char *cret);
474 int CtdlIPCSetBio(CtdlIPC *ipc, char *bio, char *cret);
475 int CtdlIPCGetBio(CtdlIPC *ipc, const char *username, char **listing, char *cret);
476 int CtdlIPCListUsersWithBios(CtdlIPC *ipc, char **listing, char *cret);
477 int CtdlIPCStealthMode(CtdlIPC *ipc, int mode, char *cret);
478 int CtdlIPCTerminateSession(CtdlIPC *ipc, int sid, char *cret);
479 int CtdlIPCTerminateServerNow(CtdlIPC *ipc, char *cret);
480 int CtdlIPCTerminateServerScheduled(CtdlIPC *ipc, int mode, char *cret);
481 int CtdlIPCEnterSystemMessage(CtdlIPC *ipc, const char *filename, const char *text, char *cret);
482 int CtdlIPCChangeHostname(CtdlIPC *ipc, const char *hostname, char *cret);
483 int CtdlIPCChangeRoomname(CtdlIPC *ipc, const char *roomname, char *cret);
484 int CtdlIPCChangeUsername(CtdlIPC *ipc, const char *username, char *cret);
485 time_t CtdlIPCServerTime(CtdlIPC *ipc, char *crert);
486 int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who, struct ctdluser **uret, char *cret);
487 int CtdlIPCAideGetEmailAddresses(CtdlIPC *ipc, const char *who, char *, char *cret);
488 int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char *cret);
489 int CtdlIPCAideSetEmailAddresses(CtdlIPC *ipc, const char *who, char *emailaddrs, char *cret);
490 int CtdlIPCRenameUser(CtdlIPC *ipc, char *oldname, char *newname, char *cret);
491 int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret);
492 int CtdlIPCSetMessageExpirationPolicy(CtdlIPC *ipc, int which, struct ExpirePolicy *policy, char *cret);
493 int CtdlIPCGetSystemConfig(CtdlIPC *ipc, char **listing, char *cret);
494 int CtdlIPCSetSystemConfig(CtdlIPC *ipc, const char *listing, char *cret);
495 int CtdlIPCGetSystemConfigByType(CtdlIPC *ipc, const char *mimetype, char **listing, char *cret);
496 int CtdlIPCSetSystemConfigByType(CtdlIPC *ipc, const char *mimetype, const char *listing, char *cret);
497 int CtdlIPCGetRoomNetworkConfig(CtdlIPC *ipc, char **listing, char *cret);
498 int CtdlIPCSetRoomNetworkConfig(CtdlIPC *ipc, const char *listing, char *cret);
499 int CtdlIPCRequestClientLogout(CtdlIPC *ipc, int session, char *cret);
500 int CtdlIPCSetMessageSeen(CtdlIPC *ipc, long msgnum, int seen, char *cret);
501 int CtdlIPCStartEncryption(CtdlIPC *ipc, char *cret);
502 int CtdlIPCDirectoryLookup(CtdlIPC *ipc, const char *address, char *cret);
503 int CtdlIPCSpecifyPreferredFormats(CtdlIPC *ipc, char *cret, char *formats);
504 int CtdlIPCInternalProgram(CtdlIPC *ipc, int secret, char *cret);
506 /* ************************************************************************** */
507 /* Stuff below this line is not for public consumption */
508 /* ************************************************************************** */
510 char *CtdlIPCReadListing(CtdlIPC *ipc, char *dest);
511 int CtdlIPCSendListing(CtdlIPC *ipc, const char *listing);
512 size_t CtdlIPCPartialRead(CtdlIPC *ipc, void **buf, size_t offset, size_t bytes, char *cret);
513 int CtdlIPCEndUpload(CtdlIPC *ipc, int discard, char *cret);
514 int CtdlIPCWriteUpload(CtdlIPC *ipc, FILE *uploadFP,
515 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
517 int CtdlIPCEndDownload(CtdlIPC *ipc, char *cret);
518 int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
519 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
521 int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes,
523 void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
525 int CtdlIPCGenericCommand(CtdlIPC *ipc, const char *command,
526 const char *to_send, size_t bytes_to_send, char **to_receive,
527 size_t *bytes_to_receive, char *proto_response);
530 int starttls(CtdlIPC *ipc);
531 void setCryptoStatusHook(void (*hook)(char *s));
532 void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state));
533 /* This is all Ford's doing. FIXME: figure out what it's doing */
534 extern int (*error_printf)(char *s, ...);
535 void setIPCDeathHook(void (*hook)(void));
536 void setIPCErrorPrintf(int (*func)(char *s, ...));
537 void connection_died(CtdlIPC* ipc, int using_ssl);
538 int CtdlIPC_getsockfd(CtdlIPC* ipc);
539 char CtdlIPC_get(CtdlIPC* ipc);
540 void CtdlIPC_lock(CtdlIPC *ipc);
541 void CtdlIPC_unlock(CtdlIPC *ipc);
542 char *libcitadelclient_version_string(void);
543 void chatmode(CtdlIPC *ipc);
544 void page_user(CtdlIPC *ipc);
545 void quiet_mode(CtdlIPC *ipc);
546 void stealth_mode(CtdlIPC *ipc);
547 extern char last_paged[];
549 void determine_pwfilename(char *pwfile, size_t n);
550 void get_stored_password(
555 void set_stored_password(
560 void offer_to_remember_password(CtdlIPC *ipc,
566 void load_command_set(void);
567 void stty_ctdl(int cmd);
568 void newprompt(char *prompt, char *str, int len);
569 void strprompt(char *prompt, char *str, int len);
570 int boolprompt(char *prompt, int prev_val);
571 int intprompt(char *prompt, int ival, int imin, int imax);
572 int fmout(int width, FILE *fpin, char *text, FILE *fpout, int subst);
573 int getcmd(CtdlIPC *ipc, char *argbuf);
574 void display_help(CtdlIPC *ipc, char *name);
575 void color(int colornum);
576 void cls(int colornum);
577 void send_ansi_detect(void);
578 void look_for_ansi(void);
580 void set_keepalives(int s);
581 extern int enable_color;
585 char keymenu(char *menuprompt, char *menustring);
586 void async_ka_start(void);
587 void async_ka_end(void);
588 int checkpagin(int lp, unsigned int pagin, unsigned int height);
589 char was_a_key_pressed(void);
592 void pprintf(const char *format, ...) __attribute__((__format__(__printf__,1,2)));
594 void pprintf(const char *format, ...);
598 extern char rc_url_cmd[SIZ];
599 extern char rc_open_cmd[SIZ];
600 extern char rc_gotmail_cmd[SIZ];
601 extern int lines_printed;
602 extern int rc_remember_passwords;
613 void MD5Init(struct MD5Context *context);
614 void MD5Update(struct MD5Context *context, unsigned char const *buf,
616 void MD5Final(unsigned char digest[16], struct MD5Context *context);
617 void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
618 char *make_apop_string(char *realpass, char *nonce, char *buffer, size_t n);
621 * This is needed to make RSAREF happy on some MS-DOS compilers.
624 typedef struct MD5Context MD5_CTX;
627 #define MD5_DIGEST_LEN 16
628 #define MD5_HEXSTRING_SIZE 33
633 #define MAXURLS 50 /* Max embedded URL's per message */
635 extern char urls[MAXURLS][SIZ];
637 int ka_system(char *shc);
638 int entmsg(CtdlIPC *ipc, int is_reply, int c, int masquerade);
639 void readmsgs(CtdlIPC *ipc, enum MessageList c, enum MessageDirection rdir, int q);
640 void edit_system_message(CtdlIPC *ipc, char *which_message);
641 pid_t ka_wait(int *kstatus);
642 void list_urls(CtdlIPC *ipc);
643 int client_make_message(CtdlIPC *ipc,
644 char *filename, /* temporary file name */
645 char *recipient, /* NULL if it's not mail */
646 int anon_type, /* see MES_ types in header file */
652 void citedit(FILE *);
653 char *load_message_from_file(FILE *src);
654 int file_checksum(char *filename);
655 void listzrooms(CtdlIPC *ipc);
656 void readinfo(CtdlIPC *ipc);
657 void forget(CtdlIPC *ipc);
658 void entroom(CtdlIPC *ipc);
659 void killroom(CtdlIPC *ipc);
660 void invite(CtdlIPC *ipc);
661 void kickout(CtdlIPC *ipc);
662 void editthisroom(CtdlIPC *ipc);
663 void roomdir(CtdlIPC *ipc);
664 void download(CtdlIPC *ipc, int proto);
665 void ungoto(CtdlIPC *ipc);
666 void dotungoto(CtdlIPC *ipc, char *towhere);
667 void whoknows(CtdlIPC *ipc);
668 void enterinfo(CtdlIPC *ipc);
669 void knrooms(CtdlIPC *ipc, int kn_floor_mode);
670 void dotknown(CtdlIPC *ipc, int what, char *match);
671 void load_floorlist(CtdlIPC *ipc);
672 void create_floor(CtdlIPC *ipc);
673 void edit_floor(CtdlIPC *ipc);
674 void kill_floor(CtdlIPC *ipc);
675 void enter_bio(CtdlIPC *ipc);
676 int save_buffer(void *file, size_t filelen, const char *pathname);
677 void destination_directory(char *dest, const char *supplied_filename);
678 void do_edit(CtdlIPC *ipc, char *desc, char *read_cmd, char *check_cmd, char *write_cmd);
682 * This struct holds a list of rooms for client display.
685 struct ctdlroomlisting {
686 struct ctdlroomlisting *lnext;
687 struct ctdlroomlisting *rnext;
688 char rlname[ROOMNAMELEN];
702 void updatels(CtdlIPC *ipc);
703 void updatelsa(CtdlIPC *ipc);
704 void movefile(CtdlIPC *ipc);
705 void deletefile(CtdlIPC *ipc);
706 void netsendfile(CtdlIPC *ipc);
707 void entregis(CtdlIPC *ipc);
709 void upload(CtdlIPC *ipc, int c);
710 void cli_upload(CtdlIPC *ipc);
711 void validate(CtdlIPC *ipc);
712 void read_bio(CtdlIPC *ipc);
713 void cli_image_upload(CtdlIPC *ipc, char *keyname);
714 int room_prompt(unsigned int qrflags);
715 int val_user(CtdlIPC *ipc, char *user, int do_validate);
717 void edituser(CtdlIPC *ipc, int cmd);
718 void interr(int errnum);
719 int struncmp(char *lstr, char *rstr, int len);
720 int pattern(char *search, char *patn);
721 void enter_config(CtdlIPC* ipc, int mode);
722 void locate_host(CtdlIPC* ipc, char *hbuf);
723 void misc_server_cmd(CtdlIPC *ipc, char *cmd);
724 int nukedir(char *dirname);
725 void strproc(char *string);
726 void back(int spaces);
727 void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
728 int set_attr(CtdlIPC *ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards);
730 void screen_new(void);
731 int scr_printf(char *fmt, ...);
732 #define SCR_NOBLOCK 0
734 int scr_getc(int delay);
736 void scr_flush(void);
737 int scr_blockread(void);
738 sighandler_t scr_winch(int signum);
739 void wait_indicator(int state);
740 void ctdl_beep(void);
741 void scr_wait_indicator(int);
742 extern char status_line[];
743 extern void check_screen_dims(void);
744 extern int screenwidth;
745 extern int screenheight;
746 void do_internet_configuration(CtdlIPC *ipc);
747 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment);
748 void do_pop3client_configuration(CtdlIPC *ipc);
749 void do_rssclient_configuration(CtdlIPC *ipc);
750 void do_system_configuration(CtdlIPC *ipc);
751 extern char editor_path[PATH_MAX];
752 extern int enable_status_line;