X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=textclient%2Ftextclient.h;h=86e0046f64030736d0f7ae74d6de73b915b6420f;hb=e535ffa5422a3600b9a1d05a8ee71e632548d4e9;hp=922644642358d81d9a092aec432b536394ef9290;hpb=25220160fc09e185bbf9f13f7565bb568cc5a463;p=citadel.git diff --git a/textclient/textclient.h b/textclient/textclient.h index 922644642..86e0046f6 100644 --- a/textclient/textclient.h +++ b/textclient/textclient.h @@ -1,22 +1,20 @@ -/* - * Copyright (c) 1987-2019 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// Copyright (c) 1987-2022 by the citadel.org team +// +// This program is open source software. Use, duplication, and/or +// disclosure are subject to the GNU General Purpose License version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. #define UDS "_UDS_" #define DEFAULT_HOST "localhost" #define DEFAULT_PORT "504" -#define CLIENT_VERSION 924 +#define CLIENT_VERSION 978 #define CLIENT_TYPE 0 -/* commands we can send to the stty_ctdl() routine */ +// commands we can send to the stty_ctdl() routine #define SB_NO_INTR 0 // set to Citadel client mode, i/q disabled #define SB_YES_INTR 1 // set to Citadel client mode, i/q enabled #define SB_SAVE 2 // save settings @@ -27,7 +25,6 @@ #define ROOMNAMELEN 128 // The size of a roomname string #define USERNAME_SIZE 64 // The size of a username string #define MAX_EDITORS 5 // number of external editors supported, must be at least 1 -#define NONCE_SIZE 128 // Added by to allow for APOP auth #define S_KEEPALIVE 30 // How often (in seconds) to send keepalives to the server @@ -39,27 +36,29 @@ #define NEXT_KEY 15 #define STOP_KEY 3 -/* citadel.rc stuff */ -#define RC_NO 0 /* always no */ -#define RC_YES 1 /* always yes */ -#define RC_DEFAULT 2 /* setting depends on user config */ +// citadel.rc stuff +#define RC_NO 0 // always no +#define RC_YES 1 // always yes +#define RC_DEFAULT 2 // setting depends on user config -/* keepalives */ +// keepalives enum { - KA_NO, /* no keepalives */ - KA_YES, /* full keepalives */ - KA_HALF /* half keepalives */ + KA_NO, // no keepalives + KA_YES, // full keepalives + KA_HALF // half keepalives }; -/* for <;G>oto and <;S>kip commands */ -#define GF_GOTO 0 /* <;G>oto floor mode */ -#define GF_SKIP 1 /* <;S>kip floor mode */ -#define GF_ZAP 2 /* <;Z>ap floor mode */ +// for <;G>oto and <;S>kip commands +#define GF_GOTO 0 // <;G>oto floor mode +#define GF_SKIP 1 // <;S>kip floor mode +#define GF_ZAP 2 // <;Z>ap floor mode +// Can messages be entered in this room? +#define ENTMSG_OK_NO 0 // You may not enter messages here +#define ENTMSG_OK_YES 1 // Go ahead! +#define ENTMSG_OK_BLOG 2 // Yes, but warn the user about how blog rooms work -/* - * Colors for color() command - */ +// Colors for color() command #define DIM_BLACK 0 #define DIM_RED 1 #define DIM_GREEN 2 @@ -76,12 +75,9 @@ enum { #define BRIGHT_MAGENTA 13 #define BRIGHT_CYAN 14 #define BRIGHT_WHITE 15 -#define COLOR_PUSH 16 /* Save current color */ -#define COLOR_POP 17 /* Restore saved color */ -#define ORIGINAL_PAIR -1 /* Default terminal colors */ - -typedef void (*sighandler_t)(int); - +#define COLOR_PUSH 16 // Save current color +#define COLOR_POP 17 // Restore saved color +#define ORIGINAL_PAIR -1 // Default terminal colors #include @@ -97,7 +93,6 @@ typedef void (*sighandler_t)(int); #include #include #include -// #include not needed if we have termios.h #include #include #include @@ -139,8 +134,6 @@ struct CtdlServInfo { char sysadm[64]; char moreprompt[256]; int ok_floors; - int paging_level; - int supports_qnop; int supports_ldap; int newuser_disabled; char default_cal_zone[256]; @@ -154,9 +147,7 @@ struct CtdlServInfo { }; -/* - * This class is responsible for the server connection - */ +// This class is responsible for the server connection typedef struct _CtdlIPC { struct CtdlServInfo ServInfo; /* The server info for this connection */ #if defined(HAVE_OPENSSL) @@ -212,17 +203,15 @@ extern int secure; void remove_march(char *roomname, int floornum); void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg); -/* - * This struct stores a list of rooms with new messages which the client - * fetches from the server. This allows the client to "march" through - * relevant rooms without having to ask the server each time where to go next. - */ typedef struct ExpirePolicy ExpirePolicy; struct ExpirePolicy { int expire_mode; int expire_value; }; +// This struct stores a list of rooms with new messages which the client +// fetches from the server. This allows the client to "march" through +// relevant rooms without having to ask the server each time where to go next. typedef struct march march; struct march { struct march *next; @@ -295,7 +284,6 @@ struct ctdlipcroom { long RRlastread; /* Highest message user has read */ char RRismailbox; /* Is this room a mailbox room? */ char RRaide; /* User can do aide commands in room */ - long RRnewmail; /* Number of new mail messages */ char RRfloor; /* Which floor this room is on */ char RRcurrentview; /* The user's current view for this room */ char RRdefaultview; /* The default view for this room */ @@ -331,6 +319,7 @@ struct ctdlipcmessage { char mime_chosen[SIZ]; /* Chosen MIME part to output */ char content_type[SIZ]; /* How would you like that? */ char references[SIZ]; /* Thread references */ + int is_local; /* Nonzero if the message originated on the local system */ }; @@ -389,51 +378,36 @@ int CtdlIPCLogout(CtdlIPC *ipc); int CtdlIPCTryLogin(CtdlIPC *ipc, const char *username, char *cret); int CtdlIPCTryPassword(CtdlIPC *ipc, const char *passwd, char *cret); int CtdlIPCTryApopPassword(CtdlIPC *ipc, const char *response, char *cret); -int CtdlIPCCreateUser(CtdlIPC *ipc, const char *username, int selfservice, - char *cret); +int CtdlIPCCreateUser(CtdlIPC *ipc, const char *username, int selfservice, char *cret); int CtdlIPCChangePassword(CtdlIPC *ipc, const char *passwd, char *cret); -int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, - struct march **listing, char *cret); +int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, struct march **listing, char *cret); int CtdlIPCGetConfig(CtdlIPC *ipc, struct ctdluser **uret, char *cret); int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret); -int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd, - struct ctdlipcroom **rret, char *cret); -int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg, - const char *mtemplate, unsigned long **mret, char *cret); -int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime, - struct ctdlipcmessage **mret, char *cret); +int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret); +int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg, const char *mtemplate, unsigned long **mret, char *cret); +int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret); int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret); int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret); -/* int CtdlIPCReadDirectory(CtdlIPC *ipc, struct ctdlipcfile **files, char *cret); */ int CtdlIPCReadDirectory(CtdlIPC *ipc, char **listing, char *cret); int CtdlIPCSetLastRead(CtdlIPC *ipc, long msgnum, char *cret); int CtdlIPCInviteUserToRoom(CtdlIPC *ipc, const char *username, char *cret); int CtdlIPCKickoutUserFromRoom(CtdlIPC *ipc, const char *username, char *cret); int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret); -int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct ctdlroom *qret, - char *cret); +int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct ctdlroom *qret, char *cret); int CtdlIPCGetRoomAide(CtdlIPC *ipc, char *cret); int CtdlIPCSetRoomAide(CtdlIPC *ipc, const char *username, char *cret); -int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, int *subject_required, - struct ctdlipcmessage *mr, - char *cret); +int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, int *subject_required, struct ctdlipcmessage *mr, char *cret); int CtdlIPCRoomInfo(CtdlIPC *ipc, char **iret, char *cret); int CtdlIPCDeleteMessage(CtdlIPC *ipc, long msgnum, char *cret); -int CtdlIPCMoveMessage(CtdlIPC *ipc, int copy, long msgnum, - const char *destroom, char *cret); +int CtdlIPCMoveMessage(CtdlIPC *ipc, int copy, long msgnum, const char *destroom, char *cret); int CtdlIPCDeleteRoom(CtdlIPC *ipc, int for_real, char *cret); -int CtdlIPCCreateRoom(CtdlIPC *ipc, int for_real, const char *roomname, - int type, const char *password, int floor, char *cret); +int CtdlIPCCreateRoom(CtdlIPC *ipc, int for_real, const char *roomname, int type, const char *password, int floor, char *cret); int CtdlIPCForgetRoom(CtdlIPC *ipc, char *cret); -int CtdlIPCSystemMessage(CtdlIPC *ipc, const char *message, char **mret, - char *cret); +int CtdlIPCSystemMessage(CtdlIPC *ipc, const char *message, char **mret, char *cret); int CtdlIPCNextUnvalidatedUser(CtdlIPC *ipc, char *cret); -int CtdlIPCGetUserRegistration(CtdlIPC *ipc, const char *username, char **rret, - char *cret); -int CtdlIPCValidateUser(CtdlIPC *ipc, const char *username, int axlevel, - char *cret); -int CtdlIPCSetRoomInfo(CtdlIPC *ipc, int for_real, const char *info, - char *cret); +int CtdlIPCGetUserRegistration(CtdlIPC *ipc, const char *username, char **rret, char *cret); +int CtdlIPCValidateUser(CtdlIPC *ipc, const char *username, int axlevel, char *cret); +int CtdlIPCSetRoomInfo(CtdlIPC *ipc, int for_real, const char *info, char *cret); int CtdlIPCUserListing(CtdlIPC *ipc, char *searchstring, char **list, char *cret); int CtdlIPCSetRegistration(CtdlIPC *ipc, const char *info, char *cret); int CtdlIPCMiscCheck(CtdlIPC *ipc, struct ctdlipcmisc *chek, char *cret); @@ -441,33 +415,17 @@ int CtdlIPCDeleteFile(CtdlIPC *ipc, const char *filename, char *cret); int CtdlIPCMoveFile(CtdlIPC *ipc, const char *filename, const char *destroom, char *cret); int CtdlIPCNetSendFile(CtdlIPC *ipc, const char *filename, const char *destnode, char *cret); int CtdlIPCOnlineUsers(CtdlIPC *ipc, char **listing, time_t *stamp, char *cret); -int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf, - size_t resume, - void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), - char *cret); -int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part, - void **buf, - void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), - char *cret); -int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf, - void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), - char *cret); -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); -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); +int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf, size_t resume, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret); +int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part, void **buf, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret); +int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret); +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); +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); int CtdlIPCQueryUsername(CtdlIPC *ipc, const char *username, char *cret); int CtdlIPCFloorListing(CtdlIPC *ipc, char **listing, char *cret); int CtdlIPCCreateFloor(CtdlIPC *ipc, int for_real, const char *name, char *cret); int CtdlIPCDeleteFloor(CtdlIPC *ipc, int for_real, int floornum, char *cret); int CtdlIPCEditFloor(CtdlIPC *ipc, int floornum, const char *floorname, char *cret); -int CtdlIPCIdentifySoftware(CtdlIPC *ipc, int developerid, int clientid, - int revision, const char *software_name, const char *hostname, - char *cret); +int CtdlIPCIdentifySoftware(CtdlIPC *ipc, int developerid, int clientid, int revision, const char *software_name, const char *hostname, char *cret); int CtdlIPCSendInstantMessage(CtdlIPC *ipc, const char *username, const char *text, char *cret); int CtdlIPCGetInstantMessage(CtdlIPC *ipc, char **listing, char *cret); int CtdlIPCEnableInstantMessageReceipt(CtdlIPC *ipc, int mode, char *cret); @@ -508,32 +466,20 @@ char *CtdlIPCReadListing(CtdlIPC *ipc, char *dest); int CtdlIPCSendListing(CtdlIPC *ipc, const char *listing); size_t CtdlIPCPartialRead(CtdlIPC *ipc, void **buf, size_t offset, size_t bytes, char *cret); int CtdlIPCEndUpload(CtdlIPC *ipc, int discard, char *cret); -int CtdlIPCWriteUpload(CtdlIPC *ipc, FILE *uploadFP, - void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), - char *cret); +int CtdlIPCWriteUpload(CtdlIPC *ipc, FILE *uploadFP, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret); int CtdlIPCEndDownload(CtdlIPC *ipc, char *cret); -int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, - void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), - char *cret); -int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, - size_t resume, - void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), - char *cret); -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); +int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret); +int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long), char *cret); +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); /* Internals */ int starttls(CtdlIPC *ipc); void setCryptoStatusHook(void (*hook)(char *s)); void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state)); -/* This is all Ford's doing. FIXME: figure out what it's doing */ extern int (*error_printf)(char *s, ...); void setIPCDeathHook(void (*hook)(void)); void setIPCErrorPrintf(int (*func)(char *s, ...)); void connection_died(CtdlIPC* ipc, int using_ssl); -int CtdlIPC_getsockfd(CtdlIPC* ipc); -char CtdlIPC_get(CtdlIPC* ipc); void CtdlIPC_lock(CtdlIPC *ipc); void CtdlIPC_unlock(CtdlIPC *ipc); char *libcitadelclient_version_string(void); @@ -544,21 +490,9 @@ void stealth_mode(CtdlIPC *ipc); extern char last_paged[]; void determine_pwfilename(char *pwfile, size_t n); -void get_stored_password( - char *host, - char *port, - char *username, - char *password); -void set_stored_password( - char *host, - char *port, - char *username, - char *password); -void offer_to_remember_password(CtdlIPC *ipc, - char *host, - char *port, - char *username, - char *password); +void get_stored_password( char *host, char *port, char *username, char *password); +void set_stored_password( char *host, char *port, char *username, char *password); +void offer_to_remember_password(CtdlIPC *ipc, char *host, char *port, char *username, char *password); void load_command_set(void); void stty_ctdl(int cmd); @@ -598,36 +532,7 @@ extern char rc_gotmail_cmd[SIZ]; extern int lines_printed; extern int rc_remember_passwords; -#ifndef MD5_H -#define MD5_H - -struct MD5Context { - uint32_t buf[4]; - uint32_t bits[2]; - uint32_t in[16]; -}; - -void MD5Init(struct MD5Context *context); -void MD5Update(struct MD5Context *context, unsigned char const *buf, - unsigned len); -void MD5Final(unsigned char digest[16], struct MD5Context *context); -void MD5Transform(uint32_t buf[4], uint32_t const in[16]); -char *make_apop_string(char *realpass, char *nonce, char *buffer, size_t n); - -/* - * This is needed to make RSAREF happy on some MS-DOS compilers. - */ -#ifndef HAVE_OPENSSL -typedef struct MD5Context MD5_CTX; -#endif - -#define MD5_DIGEST_LEN 16 -#define MD5_HEXSTRING_SIZE 33 - -#endif /* !MD5_H */ - - -#define MAXURLS 50 /* Max embedded URL's per message */ +#define MAXURLS 50 // Max embedded URL's per message (oooh, can we use our elastic array class here?) extern int num_urls; extern char urls[MAXURLS][SIZ]; @@ -732,7 +637,7 @@ int scr_getc(int delay); int scr_putc(int c); void scr_flush(void); int scr_blockread(void); -sighandler_t scr_winch(int signum); +void scr_winch(int signum); void wait_indicator(int state); void ctdl_beep(void); void scr_wait_indicator(int);