Removed discontinued fields from text client
[citadel.git] / textclient / textclient.h
1 // Copyright (c) 1987-2022 by the citadel.org team
2 //
3 // This program is open source software.  Use, duplication, and/or
4 // disclosure are subject to the GNU General Purpose License version 3.
5 //
6 // This program is distributed in the hope that it will be useful,
7 // but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 // GNU General Public License for more details.
10
11 #define UDS                     "_UDS_"
12 #define DEFAULT_HOST            "localhost"
13 #define DEFAULT_PORT            "504"
14 #define CLIENT_VERSION 980
15 #define CLIENT_TYPE             0
16
17 // commands we can send to the stty_ctdl() routine
18 #define SB_NO_INTR              0               // set to Citadel client mode, i/q disabled
19 #define SB_YES_INTR             1               // set to Citadel client mode, i/q enabled
20 #define SB_SAVE                 2               // save settings
21 #define SB_RESTORE              3               // restore settings
22 #define SB_LAST                 4               // redo the last command sent
23
24 #define UGLISTLEN               100             // you get a ungoto list of this size */
25 #define ROOMNAMELEN             128             // The size of a roomname string
26 #define USERNAME_SIZE           64              // The size of a username string
27 #define MAX_EDITORS             5               // number of external editors supported, must be at least 1
28
29 #define S_KEEPALIVE             30              // How often (in seconds) to send keepalives to the server
30
31 #define READ_HEADER             2
32 #define READ_MSGBODY            3
33
34 #define NUM_CONFIGS             72
35
36 #define NEXT_KEY                15
37 #define STOP_KEY                3
38
39 // citadel.rc stuff
40 #define RC_NO                   0               // always no
41 #define RC_YES                  1               // always yes
42 #define RC_DEFAULT              2               // setting depends on user config
43
44 // keepalives
45 enum {
46         KA_NO,                                  // no keepalives
47         KA_YES,                                 // full keepalives
48         KA_HALF                                 // half keepalives
49 };
50
51 // for <;G>oto and <;S>kip commands
52 #define GF_GOTO         0                       // <;G>oto floor mode
53 #define GF_SKIP         1                       // <;S>kip floor mode
54 #define GF_ZAP          2                       // <;Z>ap floor mode
55
56 // Can messages be entered in this room?
57 #define ENTMSG_OK_NO    0                       // You may not enter messages here
58 #define ENTMSG_OK_YES   1                       // Go ahead!
59 #define ENTMSG_OK_BLOG  2                       // Yes, but warn the user about how blog rooms work
60
61 // Colors for color() command
62 #define DIM_BLACK       0
63 #define DIM_RED         1
64 #define DIM_GREEN       2
65 #define DIM_YELLOW      3
66 #define DIM_BLUE        4
67 #define DIM_MAGENTA     5
68 #define DIM_CYAN        6
69 #define DIM_WHITE       7
70 #define BRIGHT_BLACK    8
71 #define BRIGHT_RED      9
72 #define BRIGHT_GREEN    10
73 #define BRIGHT_YELLOW   11
74 #define BRIGHT_BLUE     12
75 #define BRIGHT_MAGENTA  13
76 #define BRIGHT_CYAN     14
77 #define BRIGHT_WHITE    15
78 #define COLOR_PUSH      16                      // Save current color
79 #define COLOR_POP       17                      // Restore saved color
80 #define ORIGINAL_PAIR   -1                      // Default terminal colors
81
82
83 #include <stdlib.h>
84 #include <unistd.h>
85 #include <fcntl.h>
86 #include <stdio.h>
87 #include <ctype.h>
88 #include <string.h>
89 #include <time.h>
90 #include <limits.h>
91 #include <sys/types.h>
92 #include <sys/wait.h>
93 #include <sys/stat.h>
94 #include <sys/ioctl.h>
95 #include <termios.h>
96 #include <stdlib.h>
97 #include <ctype.h>
98 #include <sys/socket.h>
99 #include <arpa/inet.h>
100 #include <netinet/in.h>
101 #include <netdb.h>
102 #include <sys/un.h>
103 #include <errno.h>
104 #include <signal.h>
105 #include <pwd.h>
106 #include <stdarg.h>
107 #include <errno.h>
108 #include <signal.h>
109 #include <malloc.h>
110 #include <stdarg.h>
111 #include <sys/select.h>
112 #include <dirent.h>
113 #include <libcitadel.h>
114
115 #include <limits.h>
116 #ifdef HAVE_PTHREAD_H
117 #include <pthread.h>
118 #endif
119 #ifdef HAVE_OPENSSL
120 #include <openssl/ssl.h>
121 #include <openssl/err.h>
122 #include <openssl/rand.h>
123 #endif
124
125
126 struct CtdlServInfo {
127         int pid;
128         char nodename[32];
129         char humannode[64];
130         char fqdn[64];
131         char software[64];
132         int rev_level;
133         char site_location[64];
134         char sysadm[64];
135         char moreprompt[256];
136         int ok_floors;
137         int supports_ldap;
138         int newuser_disabled;
139         char default_cal_zone[256];
140         double load_avg;
141         double worker_avg;
142         int thread_count;
143         int has_sieve;
144         int fulltext_enabled;
145         char svn_revision[256];
146         int guest_logins;
147 };
148
149
150 // This class is responsible for the server connection
151 typedef struct _CtdlIPC {
152         struct CtdlServInfo ServInfo;   /* The server info for this connection */
153 #if defined(HAVE_OPENSSL)
154         SSL *ssl;                       /* NULL if not encrypted, non-NULL otherwise */
155 #endif
156         int sock;                       /* Socket for connection to server, or -1 if not connected */
157         int isLocal;                    /* 1 if server is local, 0 otherwise or if not connected */
158         int downloading;                /* 1 if a download is open on the server, 0 otherwise */
159         int uploading;                  /* 1 if an upload is open on the server, 0 otherwise */
160         time_t last_command_sent;       /* Time the last command was sent to the server */
161         char *Buf;                      /* Our buffer for linebuffered read. */
162         size_t BufSize;
163         size_t BufUsed;
164         char *BufPtr;
165         void (*network_status_cb)(int state);   /* Callback for update on whether the IPC is locked */
166         char ip_hostname[256];          /* host name of server to which we are connected (if network) */
167         char ip_address[64];            /* IP address of server to which we are connected (if network) */
168 } CtdlIPC;
169
170 extern char *axdefs[];
171 extern char *viewdefs[];
172 extern char fullname[USERNAME_SIZE];
173 extern unsigned room_flags;
174 extern char room_name[ROOMNAMELEN];
175 extern struct CtdlServInfo serv_info;
176 extern char axlevel;
177 extern char is_room_aide;
178 extern unsigned userflags;
179 extern char sigcaught;
180 extern char editor_paths[MAX_EDITORS][SIZ];
181 extern char printcmd[SIZ];
182 extern char imagecmd[SIZ];
183 extern char have_xterm;
184 extern char rc_username[USERNAME_SIZE];
185 extern char rc_password[32];
186 extern char rc_floor_mode;
187 extern time_t rc_idle_threshold;
188 #ifdef HAVE_OPENSSL
189 extern char rc_encrypt;                 /* from the citadel.rc file */
190 extern char arg_encrypt;                /* from the command line */
191 #endif
192 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
193 extern char rc_screen;
194 extern char arg_screen;
195 #endif
196 extern char rc_alt_semantics;
197 extern char instant_msgs;
198 void ctdl_logoff(char *file, int line, CtdlIPC *ipc, int code);
199 #define logoff(ipc, code)       ctdl_logoff(__FILE__, __LINE__, (ipc), (code))
200 void formout(CtdlIPC *ipc, char *name);
201 void sighandler(int which_sig);
202 extern int secure;
203 void remove_march(char *roomname, int floornum);
204 void calc_dirs_n_files(int relh, int home, const char *relhome, char  *ctdldir, int dbg);
205
206 typedef struct ExpirePolicy ExpirePolicy;
207 struct ExpirePolicy {
208         int expire_mode;
209         int expire_value;
210 };
211
212 // This struct stores a list of rooms with new messages which the client
213 // fetches from the server.  This allows the client to "march" through
214 // relevant rooms without having to ask the server each time where to go next.
215 typedef struct march march;
216 struct march {
217         struct march *next;
218         char march_name[ROOMNAMELEN];
219         unsigned int march_flags;
220         char march_floor;
221         char march_order;
222         unsigned int march_flags2;
223         int march_access;
224 };
225
226 /*
227  * This is NOT the same 'struct ctdluser' from the server.
228  */
229 typedef struct ctdluser ctdluser;
230 struct ctdluser {                       // User record
231         int version;                    // Cit vers. which created this rec
232         uid_t uid;                      // Associate with a unix account?
233         char password[32];              // password
234         unsigned flags;                 // See US_ flags below
235         uint8_t axlevel;                // Access level
236         long usernum;                   // User number (never recycled)
237         time_t lastcall;                // Date/time of most recent login
238         int USuserpurge;                // Purge time (in days) for user
239         char fullname[64];              // Display name (primary identifier)
240         char emailaddrs[512];           // Internet email addresses
241 };
242
243 typedef struct ctdlroom ctdlroom;
244 struct ctdlroom {
245         char QRname[ROOMNAMELEN];       /* Name of room                     */
246         char QRpasswd[10];              /* Only valid if it's a private rm  */
247         long QRroomaide;                /* User number of room aide         */
248         long QRhighest;                 /* Highest message NUMBER in room   */
249         time_t QRgen;                   /* Generation number of room        */
250         unsigned QRflags;               /* See flag values below            */
251         char QRdirname[15];             /* Directory name, if applicable    */
252         long QRinfo;                    /* Info file update relative to msgs*/
253         char QRfloor;                   /* Which floor this room is on      */
254         time_t QRmtime;                 /* Date/time of last post           */
255         struct ExpirePolicy QRep;       /* Message expiration policy        */
256         long QRnumber;                  /* Globally unique room number      */
257         char QRorder;                   /* Sort key for room listing order  */
258         unsigned QRflags2;              /* Additional flags                 */
259         int QRdefaultview;              /* How to display the contents      */
260 };
261
262
263 /* C constructor */
264 CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf);
265 /* C destructor */
266 void CtdlIPC_delete(CtdlIPC* ipc);
267 /* Convenience destructor; also nulls out caller's pointer */
268 void CtdlIPC_delete_ptr(CtdlIPC** pipc);
269 /* Read a line from server, discarding newline, for chat, will go away */
270 void CtdlIPC_chat_recv(CtdlIPC* ipc, char *buf);
271 /* Write a line to server, adding newline, for chat, will go away */
272 void CtdlIPC_chat_send(CtdlIPC* ipc, const char *buf);
273
274 struct ctdlipcroom {
275         char RRname[ROOMNAMELEN];       /* Name of room */
276         long RRunread;                  /* Number of unread messages */
277         long RRtotal;                   /* Total number of messages in room */
278         char RRinfoupdated;             /* Nonzero if info was updated */
279         unsigned RRflags;               /* Various flags (see LKRN) */
280         unsigned RRflags2;              /* Various flags (see LKRN) */
281         long RRhighest;                 /* Highest message number in room */
282         long RRlastread;                /* Highest message user has read */
283         char RRismailbox;               /* Is this room a mailbox room? */
284         char RRaide;                    /* User can do aide commands in room */
285         char RRfloor;                   /* Which floor this room is on */
286         char RRcurrentview;             /* The user's current view for this room */
287         char RRdefaultview;             /* The default view for this room */
288 };
289
290
291 struct parts {
292         struct parts *next;
293         char number[16];                /* part number */
294         char name[PATH_MAX];            /* Name */
295         char filename[PATH_MAX];        /* Suggested filename */
296         char mimetype[SIZ];             /* MIME type */
297         char disposition[SIZ];          /* Content disposition */
298         unsigned long length;           /* Content length */
299 };
300
301
302 struct ctdlipcmessage {
303         char msgid[SIZ];                /* Original message ID */
304         char path[SIZ];                 /* Return path to sender */
305         char zaps[SIZ];                 /* Message ID that this supersedes */
306         char subject[SIZ];              /* Message subject */
307         char email[SIZ];                /* Email address of sender */
308         char author[SIZ];               /* Sender of message */
309         char recipient[SIZ];            /* Recipient of message */
310         char room[SIZ];                 /* Originating room */
311         struct parts *attachments;      /* Available attachments */
312         char *text;                     /* Message text */
313         int type;                       /* Message type */
314         time_t time;                    /* Time message was posted */
315         char nhdr;                      /* Suppress message header? */
316         char anonymous;                 /* An anonymous message */
317         char mime_chosen[SIZ];          /* Chosen MIME part to output */
318         char content_type[SIZ];         /* How would you like that? */
319         char references[SIZ];           /* Thread references */
320         int is_local;                   /* Nonzero if the message originated on the local system */
321 };
322
323
324 struct ctdlipcfile {
325         char remote_name[PATH_MAX];     /* Filename on server */
326         char local_name[PATH_MAX];      /* Filename on client */
327         char description[80];           /* Description on server */
328         FILE *local_fd;                 /* Open file on client */
329         size_t size;                    /* Size of file in octets */
330         unsigned int upload:1;          /* uploading? 0 if downloading */
331         unsigned int complete:1;        /* Transfer has finished? */
332 };
333
334
335 struct ctdlipcmisc {
336         long newmail;                   /* Number of new Mail messages */
337         char needregis;                 /* Nonzero if user needs to register */
338         char needvalid;                 /* Nonzero if users need validation */
339 };
340
341 enum RoomList {
342         SubscribedRooms,
343         SubscribedRoomsWithNewMessages,
344         SubscribedRoomsWithNoNewMessages,
345         UnsubscribedRooms,
346         AllAccessibleRooms,
347         AllPublicRooms
348 };
349 #define AllFloors -1
350 enum MessageList {
351         AllMessages,
352         OldMessages,
353         NewMessages,
354         LastMessages,
355         FirstMessages,
356         MessagesGreaterThan,
357         MessagesLessThan
358 };
359 enum MessageDirection {
360         ReadReverse = -1,
361         ReadForward = 1
362 };
363 extern char file_citadel_rc[PATH_MAX];
364 extern char file_citadel_config[PATH_MAX];
365
366 /* Shared Diffie-Hellman parameters */
367 #define DH_P            "F6E33BD70D475906ABCFB368DA2D1E5611D57DFDAC6A10CD78F406D6952519C74E21FFDCC5A780B9359722AACC8036E4CD24D5F5165EAC9EF226DBD9BBCF678F8DDEE86386F1BC20E291A9854A513A2CA326B411DC92E38F2ED2FEB6A3B792F13DB6550371FDBAC5ECA373BE5050CA4905431CA86088737D52B36C8D13CE9CB4EEF4C910285035E8329DD07551A80B87775676DD1067395CCEE9040C9B8BF998C528B3772B4C590A2CF18C5E58929BFCB538A62638B7437A9C68572D15287E97692B0B1EC5444D9DAB6EB062D20B79CA005EC5035065567AFD1FEF9B251D74747C6065D8C8B6B0862D1EE03F3A244C429EADE0CCC5C3A4196F5CBF5AA01A9026EFB20AA90E462BD64620278F271905EB604F38E6CFAE412EAA6C468E3B58170909BC18662FE2053224F30BE4FDB93BF9FBF969D91A5427A0665AC7BD1C43701B991094C92F7A935063055617142164F02973EB4ED86DD74D2BBAB3CD3B28F7BBD8D9F925B0FE92F7F7D0568D783F9ECE7AF96FB5AF274B586924B64639733A73ACA8F2BD1E970DF51ADDD983F7F6361A2B0DC4F086DE26D8656EC8813DE4B74D6D57BC1E690AC2FF1682B7E16938565A41D1DC64C75ADB81DA4582613FC68C0FDD327D35E2CDF20D009465303773EF3870FBDB0985EE7002A95D7912BBCC78187C29DB046763B7FABFF44EABE820F8ED0D7230AA0AF24F428F82448345BC099B"
368 #define DH_G            "2"
369 #define DH_L            4096
370 #define CIT_CIPHERS     "ALL:RC4+RSA:+SSLv2:+TLSv1:!MD5:@STRENGTH"      /* see ciphers(1) */
371
372 int CtdlIPCNoop(CtdlIPC *ipc);
373 int CtdlIPCEcho(CtdlIPC *ipc, const char *arg, char *cret);
374 int CtdlIPCQuit(CtdlIPC *ipc);
375 int CtdlIPCLogout(CtdlIPC *ipc);
376 int CtdlIPCTryLogin(CtdlIPC *ipc, const char *username, char *cret);
377 int CtdlIPCTryPassword(CtdlIPC *ipc, const char *passwd, char *cret);
378 int CtdlIPCTryApopPassword(CtdlIPC *ipc, const char *response, char *cret);
379 int CtdlIPCCreateUser(CtdlIPC *ipc, const char *username, int selfservice, char *cret);
380 int CtdlIPCChangePassword(CtdlIPC *ipc, const char *passwd, char *cret);
381 int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, struct march **listing, char *cret);
382 int CtdlIPCGetConfig(CtdlIPC *ipc, struct ctdluser **uret, char *cret);
383 int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret);
384 int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret);
385 int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg, const char *mtemplate, unsigned long **mret, char *cret);
386 int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret);
387 int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret);
388 int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret);
389 int CtdlIPCReadDirectory(CtdlIPC *ipc, char **listing, char *cret);
390 int CtdlIPCSetLastRead(CtdlIPC *ipc, long msgnum, char *cret);
391 int CtdlIPCInviteUserToRoom(CtdlIPC *ipc, const char *username, char *cret);
392 int CtdlIPCKickoutUserFromRoom(CtdlIPC *ipc, const char *username, char *cret);
393 int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret);
394 int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct ctdlroom *qret, char *cret);
395 int CtdlIPCGetRoomAide(CtdlIPC *ipc, char *cret);
396 int CtdlIPCSetRoomAide(CtdlIPC *ipc, const char *username, char *cret);
397 int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, int *subject_required, struct ctdlipcmessage *mr, char *cret);
398 int CtdlIPCRoomInfo(CtdlIPC *ipc, char **iret, char *cret);
399 int CtdlIPCDeleteMessage(CtdlIPC *ipc, long msgnum, char *cret);
400 int CtdlIPCMoveMessage(CtdlIPC *ipc, int copy, long msgnum, const char *destroom, char *cret);
401 int CtdlIPCDeleteRoom(CtdlIPC *ipc, int for_real, char *cret);
402 int CtdlIPCCreateRoom(CtdlIPC *ipc, int for_real, const char *roomname, int type, const char *password, int floor, char *cret);
403 int CtdlIPCForgetRoom(CtdlIPC *ipc, char *cret);
404 int CtdlIPCSystemMessage(CtdlIPC *ipc, const char *message, char **mret, char *cret);
405 int CtdlIPCNextUnvalidatedUser(CtdlIPC *ipc, char *cret);
406 int CtdlIPCGetUserRegistration(CtdlIPC *ipc, const char *username, char **rret, char *cret);
407 int CtdlIPCValidateUser(CtdlIPC *ipc, const char *username, int axlevel, char *cret);
408 int CtdlIPCSetRoomInfo(CtdlIPC *ipc, int for_real, const char *info, char *cret);
409 int CtdlIPCUserListing(CtdlIPC *ipc, char *searchstring, char **list, char *cret);
410 int CtdlIPCSetRegistration(CtdlIPC *ipc, const char *info, char *cret);
411 int CtdlIPCMiscCheck(CtdlIPC *ipc, struct ctdlipcmisc *chek, char *cret);
412 int CtdlIPCDeleteFile(CtdlIPC *ipc, const char *filename, char *cret);
413 int CtdlIPCMoveFile(CtdlIPC *ipc, const char *filename, const char *destroom, char *cret);
414 int CtdlIPCNetSendFile(CtdlIPC *ipc, const char *filename, const char *destnode, char *cret);
415 int CtdlIPCOnlineUsers(CtdlIPC *ipc, char **listing, time_t *stamp, char *cret);
416 int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf, size_t resume, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
417 int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part, void **buf, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
418 int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
419 int CtdlIPCFileUpload(CtdlIPC *ipc, const char *save_as, const char *comment, const char *path, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
420 int CtdlIPCImageUpload(CtdlIPC *ipc, int for_real, const char *path, const char *save_as, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
421 int CtdlIPCQueryUsername(CtdlIPC *ipc, const char *username, char *cret);
422 int CtdlIPCFloorListing(CtdlIPC *ipc, char **listing, char *cret);
423 int CtdlIPCCreateFloor(CtdlIPC *ipc, int for_real, const char *name, char *cret);
424 int CtdlIPCDeleteFloor(CtdlIPC *ipc, int for_real, int floornum, char *cret);
425 int CtdlIPCEditFloor(CtdlIPC *ipc, int floornum, const char *floorname, char *cret);
426 int CtdlIPCIdentifySoftware(CtdlIPC *ipc, int developerid, int clientid, int revision, const char *software_name, const char *hostname, char *cret);
427 int CtdlIPCSendInstantMessage(CtdlIPC *ipc, const char *username, const char *text, char *cret);
428 int CtdlIPCGetInstantMessage(CtdlIPC *ipc, char **listing, char *cret);
429 int CtdlIPCEnableInstantMessageReceipt(CtdlIPC *ipc, int mode, char *cret);
430 int CtdlIPCSetBio(CtdlIPC *ipc, char *bio, char *cret);
431 int CtdlIPCGetBio(CtdlIPC *ipc, const char *username, char **listing, char *cret);
432 int CtdlIPCListUsersWithBios(CtdlIPC *ipc, char **listing, char *cret);
433 int CtdlIPCStealthMode(CtdlIPC *ipc, int mode, char *cret);
434 int CtdlIPCTerminateSession(CtdlIPC *ipc, int sid, char *cret);
435 int CtdlIPCTerminateServerNow(CtdlIPC *ipc, char *cret);
436 int CtdlIPCTerminateServerScheduled(CtdlIPC *ipc, int mode, char *cret);
437 int CtdlIPCEnterSystemMessage(CtdlIPC *ipc, const char *filename, const char *text, char *cret);
438 time_t CtdlIPCServerTime(CtdlIPC *ipc, char *crert);
439 int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who, struct ctdluser **uret, char *cret);
440 int CtdlIPCAideGetEmailAddresses(CtdlIPC *ipc, const char *who, char *, char *cret);
441 int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char *cret);
442 int CtdlIPCAideSetEmailAddresses(CtdlIPC *ipc, const char *who, char *emailaddrs, char *cret);
443 int CtdlIPCRenameUser(CtdlIPC *ipc, char *oldname, char *newname, char *cret);
444 int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret);
445 int CtdlIPCSetMessageExpirationPolicy(CtdlIPC *ipc, int which, struct ExpirePolicy *policy, char *cret);
446 int CtdlIPCGetSystemConfig(CtdlIPC *ipc, char **listing, char *cret);
447 int CtdlIPCSetSystemConfig(CtdlIPC *ipc, const char *listing, char *cret);
448 int CtdlIPCGetSystemConfigByType(CtdlIPC *ipc, const char *mimetype, char **listing, char *cret);
449 int CtdlIPCSetSystemConfigByType(CtdlIPC *ipc, const char *mimetype, const char *listing, char *cret);
450 int CtdlIPCGetRoomNetworkConfig(CtdlIPC *ipc, char **listing, char *cret);
451 int CtdlIPCSetRoomNetworkConfig(CtdlIPC *ipc, const char *listing, char *cret);
452 int CtdlIPCRequestClientLogout(CtdlIPC *ipc, int session, char *cret);
453 int CtdlIPCSetMessageSeen(CtdlIPC *ipc, long msgnum, int seen, char *cret);
454 int CtdlIPCStartEncryption(CtdlIPC *ipc, char *cret);
455 int CtdlIPCDirectoryLookup(CtdlIPC *ipc, const char *address, char *cret);
456 int CtdlIPCSpecifyPreferredFormats(CtdlIPC *ipc, char *cret, char *formats);
457 int CtdlIPCInternalProgram(CtdlIPC *ipc, int secret, char *cret);
458
459 /* ************************************************************************** */
460 /*             Stuff below this line is not for public consumption            */
461 /* ************************************************************************** */
462
463 char *CtdlIPCReadListing(CtdlIPC *ipc, char *dest);
464 int CtdlIPCSendListing(CtdlIPC *ipc, const char *listing);
465 size_t CtdlIPCPartialRead(CtdlIPC *ipc, void **buf, size_t offset, size_t bytes, char *cret);
466 int CtdlIPCEndUpload(CtdlIPC *ipc, int discard, char *cret);
467 int CtdlIPCWriteUpload(CtdlIPC *ipc, FILE *uploadFP, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
468 int CtdlIPCEndDownload(CtdlIPC *ipc, char *cret);
469 int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
470 int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret);
471 int CtdlIPCGenericCommand(CtdlIPC *ipc, const char *command, const char *to_send, size_t bytes_to_send, char **to_receive, size_t *bytes_to_receive, char *proto_response);
472
473 /* Internals */
474 int starttls(CtdlIPC *ipc);
475 void setCryptoStatusHook(void (*hook)(char *s));
476 void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state));
477 extern int (*error_printf)(char *s, ...);
478 void setIPCDeathHook(void (*hook)(void));
479 void setIPCErrorPrintf(int (*func)(char *s, ...));
480 void connection_died(CtdlIPC* ipc, int using_ssl);
481 void CtdlIPC_lock(CtdlIPC *ipc);
482 void CtdlIPC_unlock(CtdlIPC *ipc);
483 char *libcitadelclient_version_string(void);
484 void chatmode(CtdlIPC *ipc);
485 void page_user(CtdlIPC *ipc);
486 void quiet_mode(CtdlIPC *ipc);
487 void stealth_mode(CtdlIPC *ipc);
488 extern char last_paged[];
489
490 void determine_pwfilename(char *pwfile, size_t n);
491 void get_stored_password( char *host, char *port, char *username, char *password);
492 void set_stored_password( char *host, char *port, char *username, char *password);
493 void offer_to_remember_password(CtdlIPC *ipc, char *host, char *port, char *username, char *password);
494
495 void load_command_set(void);
496 void stty_ctdl(int cmd);
497 void newprompt(char *prompt, char *str, int len);
498 void strprompt(char *prompt, char *str, int len);
499 int boolprompt(char *prompt, int prev_val);
500 int intprompt(char *prompt, int ival, int imin, int imax);
501 int fmout(int width, FILE *fpin, char *text, FILE *fpout, int subst);
502 int getcmd(CtdlIPC *ipc, char *argbuf);
503 void display_help(CtdlIPC *ipc, char *name);
504 void color(int colornum);
505 void cls(int colornum);
506 void send_ansi_detect(void);
507 void look_for_ansi(void);
508 int inkey(void);
509 void set_keepalives(int s);
510 extern int enable_color;
511 int yesno(void);
512 int yesno_d(int d);
513 void keyopt(char *);
514 char keymenu(char *menuprompt, char *menustring);
515 void async_ka_start(void);
516 void async_ka_end(void);
517 int checkpagin(int lp, unsigned int pagin, unsigned int height);
518 char was_a_key_pressed(void);
519
520 #ifdef __GNUC__
521 void pprintf(const char *format, ...) __attribute__((__format__(__printf__,1,2)));
522 #else
523 void pprintf(const char *format, ...);
524 #endif
525
526
527 extern char rc_url_cmd[SIZ];
528 extern char rc_open_cmd[SIZ];
529 extern char rc_gotmail_cmd[SIZ];
530 extern int lines_printed;
531 extern int rc_remember_passwords;
532
533 #define MAXURLS         50                      // Max embedded URL's per message (oooh, can we use our elastic array class here?)
534 extern int num_urls;
535 extern char urls[MAXURLS][SIZ];
536
537 int ka_system(char *shc);
538 int entmsg(CtdlIPC *ipc, int is_reply, int c, int masquerade);
539 void readmsgs(CtdlIPC *ipc, enum MessageList c, enum MessageDirection rdir, int q);
540 void edit_system_message(CtdlIPC *ipc, char *which_message);
541 pid_t ka_wait(int *kstatus);
542 void list_urls(CtdlIPC *ipc);
543 int client_make_message(CtdlIPC *ipc,
544                         char *filename,         /* temporary file name */
545                         char *recipient,        /* NULL if it's not mail */
546                         int anon_type,          /* see MES_ types in header file */
547                         int format_type,
548                         int mode,
549                         char *subject,
550                         int subject_required
551 );
552 void citedit(FILE *);
553 char *load_message_from_file(FILE *src);
554 int file_checksum(char *filename);
555 void listzrooms(CtdlIPC *ipc);
556 void readinfo(CtdlIPC *ipc);
557 void forget(CtdlIPC *ipc);
558 void entroom(CtdlIPC *ipc);
559 void killroom(CtdlIPC *ipc);
560 void invite(CtdlIPC *ipc);
561 void kickout(CtdlIPC *ipc);
562 void editthisroom(CtdlIPC *ipc);
563 void roomdir(CtdlIPC *ipc);
564 void download(CtdlIPC *ipc, int proto);
565 void ungoto(CtdlIPC *ipc);
566 void dotungoto(CtdlIPC *ipc, char *towhere);
567 void whoknows(CtdlIPC *ipc);
568 void enterinfo(CtdlIPC *ipc);
569 void knrooms(CtdlIPC *ipc, int kn_floor_mode);
570 void dotknown(CtdlIPC *ipc, int what, char *match);
571 void load_floorlist(CtdlIPC *ipc);
572 void create_floor(CtdlIPC *ipc);
573 void edit_floor(CtdlIPC *ipc);
574 void kill_floor(CtdlIPC *ipc);
575 void enter_bio(CtdlIPC *ipc);
576 int save_buffer(void *file, size_t filelen, const char *pathname);
577 void destination_directory(char *dest, const char *supplied_filename);
578 void do_edit(CtdlIPC *ipc, char *desc, char *read_cmd, char *check_cmd, char *write_cmd);
579
580
581 /* 
582  * This struct holds a list of rooms for client display.
583  * (oooh, a tree!)
584  */
585 struct ctdlroomlisting {
586         struct ctdlroomlisting *lnext;
587         struct ctdlroomlisting *rnext;
588         char rlname[ROOMNAMELEN];
589         unsigned rlflags;
590         int rlfloor;
591         int rlorder;
592         };
593
594
595 enum {
596         LISTRMS_NEW_ONLY,
597         LISTRMS_OLD_ONLY,
598         LISTRMS_ALL
599 };
600
601
602 void updatels(CtdlIPC *ipc);
603 void updatelsa(CtdlIPC *ipc);
604 void movefile(CtdlIPC *ipc);
605 void deletefile(CtdlIPC *ipc);
606 void netsendfile(CtdlIPC *ipc);
607 void entregis(CtdlIPC *ipc);
608 void subshell(void);
609 void upload(CtdlIPC *ipc, int c);
610 void cli_upload(CtdlIPC *ipc);
611 void validate(CtdlIPC *ipc);
612 void read_bio(CtdlIPC *ipc);
613 void cli_image_upload(CtdlIPC *ipc, char *keyname);
614 int room_prompt(unsigned int qrflags);
615 int val_user(CtdlIPC *ipc, char *user, int do_validate);
616
617 void edituser(CtdlIPC *ipc, int cmd);
618 void interr(int errnum);
619 int struncmp(char *lstr, char *rstr, int len);
620 int pattern(char *search, char *patn);
621 void enter_config(CtdlIPC* ipc, int mode);
622 void locate_host(CtdlIPC* ipc, char *hbuf);
623 void misc_server_cmd(CtdlIPC *ipc, char *cmd);
624 int nukedir(char *dirname);
625 void strproc(char *string);
626 void back(int spaces);
627 void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
628 int set_attr(CtdlIPC *ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards);
629
630 void screen_new(void);
631 int scr_printf(char *fmt, ...);
632 #define SCR_NOBLOCK 0
633 #define SCR_BLOCK -1
634 int scr_getc(int delay);
635 int scr_putc(int c);
636 void scr_flush(void);
637 int scr_blockread(void);
638 void scr_winch(int signum);
639 void wait_indicator(int state);
640 void ctdl_beep(void);
641 void scr_wait_indicator(int);
642 extern char status_line[];
643 extern void check_screen_dims(void);
644 extern int screenwidth;
645 extern int screenheight;
646 void do_internet_configuration(CtdlIPC *ipc);
647 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment);
648 void do_pop3client_configuration(CtdlIPC *ipc);
649 void do_rssclient_configuration(CtdlIPC *ipc);
650 void do_system_configuration(CtdlIPC *ipc);
651 extern char editor_path[PATH_MAX];
652 extern int enable_status_line;