}
-void userlist(CtdlIPC * ipc, char *patn)
-{
+void userlist(CtdlIPC * ipc, char *patn) {
char buf[SIZ];
char fl[SIZ];
struct tm tmbuf;
time_t lc;
- int r; /* IPC response code */
+ int r; // IPC response code
char *listing = NULL;
r = CtdlIPCUserListing(ipc, patn, &listing, buf);
/*
* grab assorted info about the user...
*/
-void load_user_info(char *params)
-{
+void load_user_info(char *params) {
extract_token(fullname, params, 0, '|', sizeof fullname);
axlevel = extract_int(params, 1);
timescalled = extract_int(params, 2);
* 'roomname' is set to _FLOOR_, in which case all rooms on the requested
* floor will be removed from the march list.
*/
-void remove_march(char *roomname, int floornum)
-{
+void remove_march(char *roomname, int floornum) {
struct march *mptr, *mptr2;
if (marchptr == NULL)
mptr2->next = mptr->next;
free(mptr);
mptr = mptr2;
- } else {
+ }
+ else {
mptr2 = mptr;
}
}
from_floor = curr_floor;
curr_floor = room->RRfloor;
- /* Determine, based on the room's default view, whether an <E>nter message
- * command will be valid here.
- */
+ // Determine, based on the room's default view, whether an <E>nter message command will be valid here.
switch (room->RRdefaultview) {
- case VIEW_BBS:
- case VIEW_MAILBOX:
- entmsg_ok = ENTMSG_OK_YES;
- break;
- case VIEW_BLOG:
- entmsg_ok = ENTMSG_OK_BLOG;
- break;
- default:
- entmsg_ok = ENTMSG_OK_NO;
- break;
+ case VIEW_BBS:
+ case VIEW_MAILBOX:
+ entmsg_ok = ENTMSG_OK_YES;
+ break;
+ case VIEW_BLOG:
+ entmsg_ok = ENTMSG_OK_BLOG;
+ break;
+ default:
+ entmsg_ok = ENTMSG_OK_NO;
+ break;
}
remove_march(room_name, 0);
color(BRIGHT_RED);
if (newmailcount == 1) {
scr_printf("*** A new mail message has arrived.\n");
- } else {
+ }
+ else {
scr_printf("*** %d new mail messages have arrived.\n", newmailcount);
}
color(DIM_WHITE);
ipc->ServInfo.humannode, ipc->ServInfo.site_location, room_name, newmailcount);
}
+
/* Goto next room having unread messages.
* We want to skip over rooms that the user has already been to, and take the
* user back to the lobby when done. The room we end up in is placed in
* newroom - which is set to 0 (the lobby) initially.
*/
-void gotonext(CtdlIPC * ipc)
-{
+void gotonext(CtdlIPC * ipc) {
char buf[SIZ];
struct march *mptr, *mptr2;
char next_room[ROOMNAMELEN];
if (marchptr == NULL) {
CtdlIPCKnownRooms(ipc, SubscribedRoomsWithNewMessages, AllFloors, &marchptr, buf);
-/* add _BASEROOM_ to the end of the march list, so the user will end up
- * in the system base room (usually the Lobby>) at the end of the loop
- */
+ // Add _BASEROOM_ to the end of the march list, so the user will end up
+ // in the system base room (usually the Lobby>) at the end of the loop.
mptr = (struct march *) malloc(sizeof(struct march));
mptr->next = NULL;
mptr->march_order = 0;
mptr2 = mptr2->next;
mptr2->next = mptr;
}
-/*
- * ...and remove the room we're currently in, so a <G>oto doesn't make us
- * walk around in circles
- */
+
+ // ...and remove the room we're currently in, so a <G>oto doesn't make us walk around in circles
remove_march(room_name, 0);
}
if (marchptr != NULL) {
strcpy(next_room, pop_march(curr_floor, marchptr));
- } else {
+ }
+ else {
strcpy(next_room, "_BASEROOM_");
}
remove_march(next_room, 0);
dotgoto(ipc, next_room, 1, 0);
}
+
/*
* forget all rooms on a given floor
*/
-void forget_all_rooms_on(CtdlIPC * ipc, int ffloor)
-{
+void forget_all_rooms_on(CtdlIPC *ipc, int ffloor) {
char buf[SIZ];
struct march *flist = NULL;
struct march *fptr = NULL;
}
}
+
/*
* Indexing mechanism for a room list, called by gotoroomstep()
*/
/* If we're at the first room, wrap to the last room */
if (rmslot == 0) {
rmslot = rmtotal - 1;
- } else {
+ }
+ else {
rmslot--;
}
- } else { /* Next room */
+ }
+ else { /* Next room */
/* If we're at the last room, wrap to the first room */
if (rmslot == rmtotal - 1) {
rmslot = 0;
- } else {
+ }
+ else {
rmslot++;
}
}
/*
* step through floors on system
*/
-void gotofloorstep(CtdlIPC * ipc, int direction, int mode)
-{
+void gotofloorstep(CtdlIPC * ipc, int direction, int mode) {
int tofloor;
if (floorlist[0][0] == 0)
}
}
+
/*
* Display user 'preferences'.
*/
free(user);
}
+
/*
* Display system statistics.
*/
scr_printf("Your system administrator is %s.\n", ipc->ServInfo.sysadm);
}
+
/*
* forget all rooms on current floor
*/
}
-
/*
* get info about the server we've connected to
*/
}
-
/*
* Session username compare function for SortOnlineUsers()
*/
}
-
/*
* Display list of users currently logged on to the server
*/
}
scr_printf("\n");
- } else {
+ }
+ else {
if (isidle == 0) {
if (extract_int(buf, 0) == last_session) {
scr_printf(" ");
- } else {
+ }
+ else {
color(BRIGHT_MAGENTA);
scr_printf("%-3s", flags);
}
if (idlehours > 23999) {
scr_printf("fish");
/* over 10 days */
- } else if (idlehours > 239) {
+ }
+ else if (idlehours > 239) {
scr_printf("%3ldd", idlehours / 24);
/* over 10 hours */
- } else if (idlehours > 9) {
+ }
+ else if (idlehours > 9) {
scr_printf("%1ldd%02ld", idlehours / 24, idlehours % 24);
/* less than 10 hours */
- } else {
+ }
+ else {
scr_printf("%1ld:%02ld", idlehours, idlemins);
}
- } else {
+ }
+ else {
scr_printf(" ");
}
scr_printf(" ");
free(listing);
}
+
void enternew(CtdlIPC * ipc, char *desc, char *buf, int maxlen)
{
char bbb[128];
}
-
-int shift(int argc, char **argv, int start, int count)
-{
+int shift(int argc, char **argv, int start, int count) {
int i;
for (i = start; i < (argc - count); ++i) {
return argc;
}
-static void statusHook(char *s)
-{
+
+static void statusHook(char *s) {
scr_printf(s);
}
+
/*
* main
*/
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
int a, b, mcmd;
char aaa[100], bbb[100]; /* general purpose variables */
char argbuf[64]; /* command line buf */
arg_encrypt = RC_DEFAULT;
#endif
- /*
- * Handle command line options as if we were called like /bin/login
- * (i.e. from in.telnetd)
- */
+ // Handle command line options as if we were called like /bin/login (i.e. from in.telnetd)
for (a = 0; a < argc; ++a) {
if ((argc > a + 1) && (!strcmp(argv[a], "-h"))) {
telnet_client_host = argv[a + 1];
*/
check_screen_dims();
-
-#ifdef __CYGWIN__
- newprompt("Connect to (return for local server): ", hostbuf, 64);
-#endif
-
scr_printf("Attaching to server...\n");
ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
if (!ipc) {
#define CLIENT_VERSION 926
#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
#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 */
+// 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
#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 */
+#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);
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <termios.h>
-// #include <sgtty.h> not needed if we have termios.h
#include <stdlib.h>
#include <ctype.h>
#include <sys/socket.h>
};
-/*
- * 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)
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;
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);
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);
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, ...));
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);
};
void MD5Init(struct MD5Context *context);
-void MD5Update(struct MD5Context *context, unsigned char const *buf,
- unsigned len);
+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);
#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];