unsigned room_flags2;
int entmsg_ok = 0;
char room_name[ROOMNAMELEN];
-char *uglist[UGLISTLEN]; /* size of the ungoto list */
-long uglistlsn[UGLISTLEN]; /* current read position for all the ungoto's. Not going to make any friends with this one. */
+char *uglist[UGLISTLEN]; /* size of the ungoto list */
+long uglistlsn[UGLISTLEN]; /* current read position for all the ungoto's. Not going to make any friends with this one. */
int uglistsize = 0;
char is_mail = 0; /* nonzero when we're in a mail room */
-char axlevel = AxDeleted; /* access level */
+char axlevel = AxDeleted; /* access level */
char is_room_aide = 0; /* boolean flag, 1 if room admin */
int timescalled;
int posted;
/*
* here is our 'clean up gracefully and exit' routine
*/
-void ctdl_logoff(char *file, int line, CtdlIPC *ipc, int code)
+void ctdl_logoff(char *file, int line, CtdlIPC * ipc, int code)
{
int lp;
stty_ctdl(SB_RESTORE); /* return the old terminal settings */
/*
* uncomment the following if you need to know why Citadel exited
- printf("*** Exit code %d at %s:%d\n", code, file, line);
- sleep(2);
+ printf("*** Exit code %d at %s:%d\n", code, file, line);
+ sleep(2);
*/
exit(code); /* exit with the proper exit code */
}
/* general purpose routines */
/* display a file */
-void formout(CtdlIPC *ipc, char *name)
+void formout(CtdlIPC * ipc, char *name)
{
int r; /* IPC return code */
char buf[SIZ];
}
-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);
scr_printf(" User Name Num L Last Visit Logins Messages\n");
scr_printf("------------------------- ----- - ---------- ------ --------\n");
- if (listing != NULL) while (!IsEmptyStr(listing)) {
- extract_token(buf, listing, 0, '\n', sizeof buf);
- remove_token(listing, 0, '\n');
-
- if (sigcaught == 0) {
- extract_token(fl, buf, 0, '|', sizeof fl);
- if (pattern(fl, patn) >= 0) {
- scr_printf("%-25s ", fl);
- scr_printf("%5ld %d ", extract_long(buf, 2),
- extract_int(buf, 1));
- lc = extract_long(buf, 3);
- localtime_r(&lc, &tmbuf);
- scr_printf("%02d/%02d/%04d ",
- (tmbuf.tm_mon + 1),
- tmbuf.tm_mday,
- (tmbuf.tm_year + 1900));
- scr_printf("%6ld %8ld\n", extract_long(buf, 4), extract_long(buf, 5));
- }
+ if (listing != NULL)
+ while (!IsEmptyStr(listing)) {
+ extract_token(buf, listing, 0, '\n', sizeof buf);
+ remove_token(listing, 0, '\n');
+
+ if (sigcaught == 0) {
+ extract_token(fl, buf, 0, '|', sizeof fl);
+ if (pattern(fl, patn) >= 0) {
+ scr_printf("%-25s ", fl);
+ scr_printf("%5ld %d ", extract_long(buf, 2), extract_int(buf, 1));
+ lc = extract_long(buf, 3);
+ localtime_r(&lc, &tmbuf);
+ scr_printf("%02d/%02d/%04d ", (tmbuf.tm_mon + 1), tmbuf.tm_mday, (tmbuf.tm_year + 1900));
+ scr_printf("%6ld %8ld\n", extract_long(buf, 4), extract_long(buf, 5));
+ }
+ }
}
- }
free(listing);
scr_printf("\n");
}
/*
* jump directly to a room
*/
-void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
+void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto)
{
char aaa[SIZ], bbb[SIZ];
static long ls = 0L;
int partial_match, best_match;
char from_floor;
int ugpos = uglistsize;
- int r; /* IPC result code */
+ int r; /* IPC result code */
struct ctdlipcroom *room = NULL;
int rv = 0;
/* store ungoto information */
if (fromungoto == 0) {
/* sloppy slide them all down, hey it's the client, who cares. :-) */
- if (uglistsize >= (UGLISTLEN-1)) {
+ if (uglistsize >= (UGLISTLEN - 1)) {
int lp;
- free (uglist[0]);
- for (lp = 0; lp < (UGLISTLEN-1); lp++) {
- uglist[lp] = uglist[lp+1];
- uglistlsn[lp] = uglistlsn[lp+1];
+ free(uglist[0]);
+ for (lp = 0; lp < (UGLISTLEN - 1); lp++) {
+ uglist[lp] = uglist[lp + 1];
+ uglistlsn[lp] = uglistlsn[lp + 1];
}
ugpos--;
} else {
uglistsize++;
}
-
- uglist[ugpos] = malloc(strlen(room_name)+1);
+
+ uglist[ugpos] = malloc(strlen(room_name) + 1);
strcpy(uglist[ugpos], room_name);
uglistlsn[ugpos] = ls;
}
-
+
/* first try an exact match */
r = CtdlIPCGotoRoom(ipc, towhere, "", &room, aaa);
if (r / 10 == 54) {
scr_printf("Wrong password.\n");
return;
}
- }
+ }
/*
* If a match is not found, try a partial match.
/* 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:
- case VIEW_BLOG:
- entmsg_ok = 1;
- break;
- default:
- entmsg_ok = 0;
- break;
+ switch (room->RRdefaultview) {
+ case VIEW_BBS:
+ case VIEW_MAILBOX:
+ case VIEW_BLOG:
+ entmsg_ok = 1;
+ break;
+ default:
+ entmsg_ok = 0;
+ break;
}
remove_march(room_name, 0);
color(BRIGHT_RED);
if (newmailcount == 1) {
scr_printf("*** A new mail message has arrived.\n");
- }
- else {
- scr_printf("*** %d new mail messages have arrived.\n",
- newmailcount);
+ } else {
+ scr_printf("*** %d new mail messages have arrived.\n", newmailcount);
}
color(DIM_WHITE);
if (!IsEmptyStr(rc_gotmail_cmd)) {
rv = system(rc_gotmail_cmd);
- if (rv)
- scr_printf("*** failed to check for mail calling %s Reason %d.\n",
- rc_gotmail_cmd, rv);
+ if (rv)
+ scr_printf("*** failed to check for mail calling %s Reason %d.\n", rc_gotmail_cmd, rv);
}
}
free(room);
- if (screenwidth>5) snprintf(&status_line[1], screenwidth-1, "%s | %s | %s | %s | %d new mail |",
- (secure ? "Encrypted" : "Unencrypted"),
- ipc->ServInfo.humannode,
- ipc->ServInfo.site_location,
- room_name,
- newmailcount
- );
+ if (screenwidth > 5)
+ snprintf(&status_line[1], screenwidth - 1, "%s | %s | %s | %s | %d new mail |",
+ (secure ? "Encrypted" : "Unencrypted"),
+ ipc->ServInfo.humannode, ipc->ServInfo.site_location, room_name, newmailcount);
}
/* Goto next room having unread messages.
* 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;
* If it is, pop the first room off the list and go there.
*/
if (marchptr == NULL) {
- CtdlIPCKnownRooms(ipc, SubscribedRoomsWithNewMessages,
- AllFloors, &marchptr, buf);
+ 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
mptr = (struct march *) malloc(sizeof(struct march));
mptr->next = NULL;
mptr->march_order = 0;
- mptr->march_floor = 0;
+ mptr->march_floor = 0;
strcpy(mptr->march_name, "_BASEROOM_");
if (marchptr == NULL) {
marchptr = mptr;
/*
* 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;
struct ctdlipcroom *room = NULL;
- int r; /* IPC response code */
+ int r; /* IPC response code */
scr_printf("Forgetting all rooms on %s...\n", &floorlist[ffloor][0]);
remove_march("_FLOOR_", ffloor);
flist = flist->next;
free(fptr);
}
- if (room) free(room);
+ if (room)
+ free(room);
}
/*
* routine called by gotofloor() to move to a new room on a new floor
*/
-void gf_toroom(CtdlIPC *ipc, char *towhere, int mode)
+void gf_toroom(CtdlIPC * ipc, char *towhere, int mode)
{
int floor_being_left;
floor_being_left = curr_floor;
- if (mode == GF_GOTO) { /* <;G>oto mode */
+ if (mode == GF_GOTO) { /* <;G>oto mode */
updatels(ipc);
dotgoto(ipc, towhere, 1, 0);
- }
- else if (mode == GF_SKIP) { /* <;S>kip mode */
+ } else if (mode == GF_SKIP) { /* <;S>kip mode */
dotgoto(ipc, towhere, 1, 0);
remove_march("_FLOOR_", floor_being_left);
- }
- else if (mode == GF_ZAP) { /* <;Z>ap mode */
+ } else if (mode == GF_ZAP) { /* <;Z>ap mode */
dotgoto(ipc, towhere, 1, 0);
remove_march("_FLOOR_", floor_being_left);
forget_all_rooms_on(ipc, floor_being_left);
/*
* go to a new floor
*/
-void gotofloor(CtdlIPC *ipc, char *towhere, int mode)
+void gotofloor(CtdlIPC * ipc, char *towhere, int mode)
{
int a, tofloor;
- int r; /* IPC response code */
+ int r; /* IPC response code */
struct march *mptr;
char buf[SIZ], targ[SIZ];
/*. . . according to room order */
if (mptr)
- strcpy(targ, pop_march(tofloor, mptr));
+ strcpy(targ, pop_march(tofloor, mptr));
while (mptr) {
tmp = mptr->next;
free(mptr);
r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, tofloor, &mptr, buf);
if (r / 100 == 1) {
struct march *tmp = mptr;
-
- /*. . . according to room order */
+
+ /*. . . according to room order */
if (mptr)
strcpy(targ, pop_march(tofloor, mptr));
while (mptr) {
/*
* step through rooms on current floor
*/
-void gotoroomstep(CtdlIPC *ipc, int direction, int mode)
+void gotoroomstep(CtdlIPC * ipc, int direction, int mode)
{
struct march *listing = NULL;
struct march *mptr;
- int r; /* IPC response code */
+ int r; /* IPC response code */
char buf[SIZ];
struct ctdlroomlisting *rl = NULL;
struct ctdlroomlisting *rp;
for (mptr = listing; mptr != NULL; mptr = mptr->next) {
list_it = 1;
- if ( floor_mode
- && (mptr->march_floor != curr_floor))
+ if (floor_mode && (mptr->march_floor != curr_floor))
list_it = 0;
if (list_it) {
/* Find position of current room */
room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
- room_tree_list_query(rl, room_name, 0, NULL, &rmslot, &rmtotal);
+ room_tree_list_query(rl, room_name, 0, NULL, &rmslot, &rmtotal);
- if (direction == 0) { /* Previous room */
+ if (direction == 0) { /* Previous room */
/* If we're at the first room, wrap to the last room */
if (rmslot == 0) {
rmslot = rmtotal - 1;
} 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;
+ rmslot = 0;
} else {
rmslot++;
}
/* Get name of next/previous room */
room_tree_list_query(NULL, NULL, 0, NULL, NULL, NULL);
- room_tree_list_query(rl, NULL, rmslot, rmname, NULL, NULL);
+ room_tree_list_query(rl, NULL, rmslot, rmname, NULL, NULL);
/* Free the tree */
room_tree_list_query(rl, NULL, 0, NULL, NULL, NULL);
- if (mode == 0) { /* not skipping */
- updatels(ipc);
+ if (mode == 0) { /* not skipping */
+ updatels(ipc);
}
/* Free the room list */
/*
* step through floors on system
*/
-void gotofloorstep(CtdlIPC *ipc, int direction, int mode)
+void gotofloorstep(CtdlIPC * ipc, int direction, int mode)
{
- int tofloor;
+ int tofloor;
if (floorlist[0][0] == 0)
load_floorlist(ipc);
- empty_keep_going:
+ empty_keep_going:
- if (direction == 0) { /* Previous floor */
- if (curr_floor) tofloor = curr_floor - 1;
- else tofloor = 127;
+ if (direction == 0) { /* Previous floor */
+ if (curr_floor)
+ tofloor = curr_floor - 1;
+ else
+ tofloor = 127;
- while (!floorlist[tofloor][0]) tofloor--;
- } else { /* Next floor */
- if (curr_floor < 127) tofloor = curr_floor + 1;
- else tofloor = 0;
+ while (!floorlist[tofloor][0])
+ tofloor--;
+ } else { /* Next floor */
+ if (curr_floor < 127)
+ tofloor = curr_floor + 1;
+ else
+ tofloor = 0;
- while (!floorlist[tofloor][0] && tofloor < 127) tofloor++;
- if (!floorlist[tofloor][0]) tofloor = 0;
+ while (!floorlist[tofloor][0] && tofloor < 127)
+ tofloor++;
+ if (!floorlist[tofloor][0])
+ tofloor = 0;
}
/* ;g works when not in floor mode so . . . */
if (!floor_mode) {
- scr_printf("(%s)\n", floorlist[tofloor] );
+ scr_printf("(%s)\n", floorlist[tofloor]);
}
gotofloor(ipc, floorlist[tofloor], mode);
- if (curr_floor != tofloor) { /* gotofloor failed */
- curr_floor = tofloor;
- goto empty_keep_going;
- }
+ if (curr_floor != tofloor) { /* gotofloor failed */
+ curr_floor = tofloor;
+ goto empty_keep_going;
+ }
}
/*
* Display user 'preferences'.
*/
extern int rc_prompt_control;
-void read_config(CtdlIPC *ipc)
+void read_config(CtdlIPC * ipc)
{
char buf[SIZ];
char *resp = NULL;
int r; /* IPC response code */
- char _fullname[USERNAME_SIZE];
+ char _fullname[USERNAME_SIZE];
long _usernum;
int _axlevel, _timescalled, _posted;
time_t _lastcall;
struct ctdluser *user = NULL;
- /* get misc user info */
+ /* get misc user info */
r = CtdlIPCGetBio(ipc, fullname, &resp, buf);
if (r / 100 != 1) {
scr_printf("%s\n", buf);
_usernum = extract_long(buf, 2);
_axlevel = extract_int(buf, 3);
_lastcall = extract_long(buf, 4);
- _timescalled = extract_int(buf, 5);
+ _timescalled = extract_int(buf, 5);
_posted = extract_int(buf, 6);
free(resp);
resp = NULL;
-
+
/* get preferences */
r = CtdlIPCGetConfig(ipc, &user, buf);
if (r / 100 != 2) {
/* show misc user info */
scr_printf("%s\nAccess level: %d (%s)\n"
- "User #%ld / %d Calls / %d Posts",
- _fullname, _axlevel, axdefs[(int) _axlevel],
- _usernum, _timescalled, _posted);
+ "User #%ld / %d Calls / %d Posts", _fullname, _axlevel, axdefs[(int) _axlevel], _usernum, _timescalled, _posted);
if (_lastcall > 0L) {
- scr_printf(" / Curr login: %s",
- asctime(localtime(&_lastcall)));
+ scr_printf(" / Curr login: %s", asctime(localtime(&_lastcall)));
}
scr_printf("\n");
/* show preferences */
- scr_printf("Are you an experienced Citadel user: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXPERT) ? "Yes" : "No"); color(DIM_WHITE);
- scr_printf("Print last old message on New message request: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_LASTOLD)? "Yes" : "No"); color(DIM_WHITE);
- scr_printf("Prompt after each message: "); color(BRIGHT_CYAN); scr_printf("%s\n", (!(user->flags & US_NOPROMPT))? "Yes" : "No"); color(DIM_WHITE);
+ scr_printf("Are you an experienced Citadel user: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_EXPERT) ? "Yes" : "No");
+ color(DIM_WHITE);
+ scr_printf("Print last old message on New message request: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_LASTOLD) ? "Yes" : "No");
+ color(DIM_WHITE);
+ scr_printf("Prompt after each message: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (!(user->flags & US_NOPROMPT)) ? "Yes" : "No");
+ color(DIM_WHITE);
if ((user->flags & US_NOPROMPT) == 0) {
- scr_printf("Use 'disappearing' prompts: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_DISAPPEAR)? "Yes" : "No"); color(DIM_WHITE);
+ scr_printf("Use 'disappearing' prompts: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_DISAPPEAR) ? "Yes" : "No");
+ color(DIM_WHITE);
}
- scr_printf("Pause after each screenful of text: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PAGINATOR)? "Yes" : "No"); color(DIM_WHITE);
- if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) {
- scr_printf("<N>ext and <S>top work at paginator prompt: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_PROMPTCTL)? "Yes" : "No"); color(DIM_WHITE);
+ scr_printf("Pause after each screenful of text: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_PAGINATOR) ? "Yes" : "No");
+ color(DIM_WHITE);
+ if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) {
+ scr_printf("<N>ext and <S>top work at paginator prompt: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_PROMPTCTL) ? "Yes" : "No");
+ color(DIM_WHITE);
}
- if (rc_floor_mode == RC_DEFAULT) {
- scr_printf("View rooms by floor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_FLOORS)? "Yes" : "No"); color(DIM_WHITE);
+ if (rc_floor_mode == RC_DEFAULT) {
+ scr_printf("View rooms by floor: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_FLOORS) ? "Yes" : "No");
+ color(DIM_WHITE);
}
- if (rc_ansi_color == 3) {
- scr_printf("Enable color support: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_COLOR)? "Yes" : "No"); color(DIM_WHITE);
+ if (rc_ansi_color == 3) {
+ scr_printf("Enable color support: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_COLOR) ? "Yes" : "No");
+ color(DIM_WHITE);
}
- scr_printf("Be unlisted in userlog: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_UNLISTED)? "Yes" : "No"); color(DIM_WHITE);
+ scr_printf("Be unlisted in userlog: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_UNLISTED) ? "Yes" : "No");
+ color(DIM_WHITE);
if (!IsEmptyStr(editor_path)) {
- scr_printf("Always enter messages with the full-screen editor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXTEDIT)? "Yes" : "No"); color(DIM_WHITE);
+ scr_printf("Always enter messages with the full-screen editor: ");
+ color(BRIGHT_CYAN);
+ scr_printf("%s\n", (user->flags & US_EXTEDIT) ? "Yes" : "No");
+ color(DIM_WHITE);
}
free(user);
}
/*
* Display system statistics.
*/
-void system_info(CtdlIPC *ipc)
+void system_info(CtdlIPC * ipc)
{
char buf[SIZ];
char *resp = NULL;
size_t bytes;
- int mrtg_users, mrtg_active_users;
+ int mrtg_users, mrtg_active_users;
char mrtg_server_uptime[40];
long mrtg_himessage;
CtdlIPCServerInfo(ipc, buf);
scr_printf("You are connected to %s (%s) @%s\n", ipc->ServInfo.nodename, ipc->ServInfo.humannode, ipc->ServInfo.fqdn);
- scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float)CLIENT_VERSION/100);
- scr_printf("server build %s,\n", ipc->ServInfo.svn_revision, (float)CLIENT_VERSION/100);
+ scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float) CLIENT_VERSION / 100);
+ scr_printf("server build %s,\n", ipc->ServInfo.svn_revision, (float) CLIENT_VERSION / 100);
scr_printf("and located in %s.\n", ipc->ServInfo.site_location);
scr_printf("Connected users %d / Active users %d / Highest message #%ld\n", mrtg_users, mrtg_active_users, mrtg_himessage);
scr_printf("Server uptime: %s\n", mrtg_server_uptime);
/*
* forget all rooms on current floor
*/
-void forget_this_floor(CtdlIPC *ipc)
+void forget_this_floor(CtdlIPC * ipc)
{
if (curr_floor == 0) {
scr_printf("Can't forget this floor.\n");
if (floorlist[0][0] == 0) {
load_floorlist(ipc);
}
- scr_printf("Are you sure you want to forget all rooms on %s? ",
- &floorlist[(int) curr_floor][0]);
+ scr_printf("Are you sure you want to forget all rooms on %s? ", &floorlist[(int) curr_floor][0]);
if (yesno() == 0) {
return;
}
/*
* set floor mode depending on client, server, and user settings
*/
-void set_floor_mode(CtdlIPC* ipc)
+void set_floor_mode(CtdlIPC * ipc)
{
if (ipc->ServInfo.ok_floors == 0) {
floor_mode = 0; /* Don't use floors if the server */
/*
* Set or change the user's password
*/
-int set_password(CtdlIPC *ipc)
+int set_password(CtdlIPC * ipc)
{
char pass1[20];
char pass2[20];
/*
* get info about the server we've connected to
*/
-void get_serv_info(CtdlIPC *ipc, char *supplied_hostname)
+void get_serv_info(CtdlIPC * ipc, char *supplied_hostname)
{
char buf[SIZ];
/* be nice and identify ourself to the server */
CtdlIPCIdentifySoftware(ipc, CLIENT_TYPE, 0, CLIENT_VERSION,
- (ipc->isLocal ? "local" : "Citadel text mode client"),
- (supplied_hostname) ? supplied_hostname :
- /* Look up the , in the bible if you're confused */
- (locate_host(ipc, buf), buf), buf);
+ (ipc->isLocal ? "local" : "Citadel text mode client"), (supplied_hostname) ? supplied_hostname :
+ /* Look up the , in the bible if you're confused */
+ (locate_host(ipc, buf), buf), buf);
/* Indicate to the server that we prefer to decode Base64 and
* quoted-printable on the client side.
*/
- if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "dont_decode") / 100 ) != 2) {
+ if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "dont_decode") / 100) != 2) {
scr_printf("ERROR: Extremely old server; MSG4 framework not supported.\n");
logoff(ipc, 0);
}
* isn't really all that great, it's probably better to just go with
* the plain text when we have it available.
*/
- if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "text/plain|text/html|text/x-markdown") / 100 ) != 2) {
+ if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "text/plain|text/html|text/x-markdown") / 100) != 2) {
scr_printf("ERROR: Extremely old server; MSG4 framework not supported.\n");
logoff(ipc, 0);
}
/*
* Session username compare function for SortOnlineUsers()
*/
-int rwho_username_cmp(const void *rec1, const void *rec2) {
+int rwho_username_cmp(const void *rec1, const void *rec2)
+{
char *u1, *u2;
u1 = strchr(rec1, '|');
u2 = strchr(rec2, '|');
- return strcasecmp( (u1?++u1:"") , (u2?++u2:"") );
+ return strcasecmp((u1 ? ++u1 : ""), (u2 ? ++u2 : ""));
}
/*
* Idle time compare function for SortOnlineUsers()
*/
-int idlecmp(const void *rec1, const void *rec2) {
+int idlecmp(const void *rec1, const void *rec2)
+{
time_t i1, i2;
i1 = extract_long(rec1, 5);
i2 = extract_long(rec2, 5);
- if (i1 < i2) return(1);
- if (i1 > i2) return(-1);
- return(0);
+ if (i1 < i2)
+ return (1);
+ if (i1 > i2)
+ return (-1);
+ return (0);
}
* If 'condense' is nonzero, multiple sessions for the same user will be
* combined into one for brevity.
*/
-char *SortOnlineUsers(char *listing, int condense) {
+char *SortOnlineUsers(char *listing, int condense)
+{
int rows;
char *sortbuf;
char *retbuf;
rows = num_tokens(listing, '\n');
sortbuf = malloc(rows * SIZ);
- if (sortbuf == NULL) return(listing);
+ if (sortbuf == NULL)
+ return (listing);
retbuf = malloc(rows * SIZ);
if (retbuf == NULL) {
free(sortbuf);
- return(listing);
+ return (listing);
}
/* Copy the list into a fixed-record-size array for sorting */
- for (i=0; i<rows; ++i) {
+ for (i = 0; i < rows; ++i) {
memset(buf, 0, SIZ);
extract_token(buf, listing, i, '\n', sizeof buf);
- memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
+ memcpy(&sortbuf[i * SIZ], buf, (size_t) SIZ);
}
/* Sort by idle time */
/* Combine multiple sessions for the same user */
if (condense) {
qsort(sortbuf, rows, SIZ, rwho_username_cmp);
- if (rows > 1) for (i=1; i<rows; ++i) if (i>0) {
- char u1[USERNAME_SIZE];
- char u2[USERNAME_SIZE];
- extract_token(u1, &sortbuf[(i-1)*SIZ], 1, '|', sizeof u1);
- extract_token(u2, &sortbuf[i*SIZ], 1, '|', sizeof u2);
- if (!strcasecmp(u1, u2)) {
- memcpy(&sortbuf[i*SIZ], &sortbuf[(i+1)*SIZ], (rows-i-1)*SIZ);
- --rows;
- --i;
- }
- }
+ if (rows > 1)
+ for (i = 1; i < rows; ++i)
+ if (i > 0) {
+ char u1[USERNAME_SIZE];
+ char u2[USERNAME_SIZE];
+ extract_token(u1, &sortbuf[(i - 1) * SIZ], 1, '|', sizeof u1);
+ extract_token(u2, &sortbuf[i * SIZ], 1, '|', sizeof u2);
+ if (!strcasecmp(u1, u2)) {
+ memcpy(&sortbuf[i * SIZ], &sortbuf[(i + 1) * SIZ], (rows - i - 1) * SIZ);
+ --rows;
+ --i;
+ }
+ }
qsort(sortbuf, rows, SIZ, idlecmp); /* idle sort again */
}
/* Copy back to a \n delimited list */
strcpy(retbuf, "");
- for (i=0; i<rows; ++i) {
- if (!IsEmptyStr(&sortbuf[i*SIZ])) {
- strcat(retbuf, &sortbuf[i*SIZ]);
- if (i<(rows-1)) strcat(retbuf, "\n");
+ for (i = 0; i < rows; ++i) {
+ if (!IsEmptyStr(&sortbuf[i * SIZ])) {
+ strcat(retbuf, &sortbuf[i * SIZ]);
+ if (i < (rows - 1))
+ strcat(retbuf, "\n");
}
}
free(listing);
free(sortbuf);
- return(retbuf);
+ return (retbuf);
}
/*
* Display list of users currently logged on to the server
*/
-void who_is_online(CtdlIPC *ipc, int longlist)
+void who_is_online(CtdlIPC * ipc, int longlist)
{
char buf[SIZ], username[SIZ], roomname[SIZ], fromhost[SIZ];
char flags[SIZ];
int last_session = (-1);
int skipidle = 0;
char *listing = NULL;
- int r; /* IPC response code */
-
+ int r; /* IPC response code */
+
if (longlist == 2) {
longlist = 0;
skipidle = 1;
if (!longlist) {
color(BRIGHT_WHITE);
scr_printf(" User Name Room ");
- if (screenwidth >= 80) scr_printf(" Idle From host");
+ if (screenwidth >= 80)
+ scr_printf(" Idle From host");
scr_printf("\n");
color(DIM_WHITE);
scr_printf(" ------------------------- --------------------");
- if (screenwidth >= 80) scr_printf(" ---- ------------------------");
+ if (screenwidth >= 80)
+ scr_printf(" ---- ------------------------");
scr_printf("\n");
}
r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf);
if (r / 100 == 1) {
while (!IsEmptyStr(listing)) {
int isidle = 0;
-
+
/* Get another line */
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
scr_printf("In room: %s\n", roomname);
scr_printf(" Host: %s\n", fromhost);
scr_printf(" Client: %s\n", clientsoft);
- scr_printf(" Idle: %ld:%02ld:%02ld\n",
- (long) idlehours,
- (long) idlemins,
- (long) idlesecs);
-
- if ( (!IsEmptyStr(actual_user)&&
- !IsEmptyStr(actual_room)&&
- !IsEmptyStr(actual_host))) {
+ scr_printf(" Idle: %ld:%02ld:%02ld\n", (long) idlehours, (long) idlemins, (long) idlesecs);
+
+ if ((!IsEmptyStr(actual_user) && !IsEmptyStr(actual_room) && !IsEmptyStr(actual_host))) {
scr_printf("(really ");
- if (!IsEmptyStr(actual_user)) scr_printf("<%s> ", actual_user);
- if (!IsEmptyStr(actual_room)) scr_printf("in <%s> ", actual_room);
- if (!IsEmptyStr(actual_host)) scr_printf("from <%s> ", actual_host);
+ if (!IsEmptyStr(actual_user))
+ scr_printf("<%s> ", actual_user);
+ if (!IsEmptyStr(actual_room))
+ scr_printf("in <%s> ", actual_room);
+ if (!IsEmptyStr(actual_host))
+ scr_printf("from <%s> ", actual_host);
scr_printf(")\n");
}
scr_printf("\n");
} else {
if (isidle == 0) {
- if (extract_int(buf, 0) == last_session) {
- scr_printf(" ");
- }
- else {
- color(BRIGHT_MAGENTA);
- scr_printf("%-3s", flags);
- }
- last_session = extract_int(buf, 0);
- color(BRIGHT_CYAN);
- scr_printf("%-25s ", username);
- color(BRIGHT_MAGENTA);
- roomname[20] = 0;
- scr_printf("%-20s", roomname);
+ if (extract_int(buf, 0) == last_session) {
+ scr_printf(" ");
+ } else {
+ color(BRIGHT_MAGENTA);
+ scr_printf("%-3s", flags);
+ }
+ last_session = extract_int(buf, 0);
+ color(BRIGHT_CYAN);
+ scr_printf("%-25s ", username);
+ color(BRIGHT_MAGENTA);
+ roomname[20] = 0;
+ scr_printf("%-20s", roomname);
if (screenwidth >= 80) {
scr_printf(" ");
/* over 1000d, must be gone fishing */
if (idlehours > 23999) {
scr_printf("fish");
- /* over 10 days */
+ /* over 10 days */
} else if (idlehours > 239) {
scr_printf("%3ldd", idlehours / 24);
- /* over 10 hours */
+ /* over 10 hours */
} else if (idlehours > 9) {
- scr_printf("%1ldd%02ld",
- idlehours / 24,
- idlehours % 24);
- /* less than 10 hours */
- }
- else {
+ scr_printf("%1ldd%02ld", idlehours / 24, idlehours % 24);
+ /* less than 10 hours */
+ } else {
scr_printf("%1ld:%02ld", idlehours, idlemins);
}
- }
- else {
+ } else {
scr_printf(" ");
}
scr_printf(" ");
- color(BRIGHT_CYAN);
- fromhost[24] = '\0';
- scr_printf("%-24s", fromhost);
+ color(BRIGHT_CYAN);
+ fromhost[24] = '\0';
+ scr_printf("%-24s", fromhost);
}
scr_printf("\n");
- color(DIM_WHITE);
- }
+ color(DIM_WHITE);
+ }
}
}
}
free(listing);
}
-void enternew(CtdlIPC *ipc, char *desc, char *buf, int maxlen)
+void enternew(CtdlIPC * ipc, char *desc, char *buf, int maxlen)
{
char bbb[128];
snprintf(bbb, sizeof bbb, "Enter in your new %s: ", desc);
-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) {
- argv[i] = argv[i+count];
+ for (i = start; i < (argc - count); ++i) {
+ argv[i] = argv[i + count];
}
argc = argc - count;
return argc;
}
-static void statusHook(char *s) {
+static void statusHook(char *s)
+{
scr_printf(s);
}
int main(int argc, char **argv)
{
int a, b, mcmd;
- char aaa[100], bbb[100];/* general purpose variables */
+ char aaa[100], bbb[100]; /* general purpose variables */
char argbuf[64]; /* command line buf */
char nonce[NONCE_SIZE];
char *telnet_client_host = NULL;
char password[SIZ];
struct ctdlipcmisc chek;
struct ctdluser *myself = NULL;
- CtdlIPC* ipc; /* Our server connection */
- int r; /* IPC result code */
- int rv = 0; /* fetch but ignore syscall return value to suppress warnings */
-
- int relh=0;
- int home=0;
- char relhome[PATH_MAX]="";
- char ctdldir[PATH_MAX]=CTDLDIR;
- int lp;
+ CtdlIPC *ipc; /* Our server connection */
+ int r; /* IPC result code */
+ int rv = 0; /* fetch but ignore syscall return value to suppress warnings */
+
+ int relh = 0;
+ int home = 0;
+ char relhome[PATH_MAX] = "";
+ char ctdldir[PATH_MAX] = CTDLDIR;
+ int lp;
calc_dirs_n_files(relh, home, relhome, ctdldir, 0);
#ifdef HAVE_BACKTRACE
params.debugLevel = ECRASH_DEBUG_VERBOSE;
params.dumpAllThreads = TRUE;
params.useBacktraceSymbols = 1;
- params.signals[0]=SIGSEGV;
- params.signals[1]=SIGILL;
- params.signals[2]=SIGBUS;
- params.signals[3]=SIGABRT;
-#endif
+ params.signals[0] = SIGSEGV;
+ params.signals[1] = SIGILL;
+ params.signals[2] = SIGBUS;
+ params.signals[3] = SIGABRT;
+#endif
setIPCErrorPrintf(scr_printf);
setCryptoStatusHook(statusHook);
-
- stty_ctdl(SB_SAVE); /* Store the old terminal parameters */
- load_command_set(); /* parse the citadel.rc file */
- stty_ctdl(SB_NO_INTR); /* Install the new ones */
+
+ stty_ctdl(SB_SAVE); /* Store the old terminal parameters */
+ load_command_set(); /* parse the citadel.rc file */
+ stty_ctdl(SB_NO_INTR); /* Install the new ones */
signal(SIGPIPE, dropcarr); /* Cleanup gracefully if local conn. dropped */
signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
* 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];
+ for (a = 0; a < argc; ++a) {
+ if ((argc > a + 1) && (!strcmp(argv[a], "-h"))) {
+ telnet_client_host = argv[a + 1];
argc = shift(argc, argv, a, 2);
}
if (!strcmp(argv[a], "-x")) {
argc = shift(argc, argv, a, 1);
}
}
-
+
screen_new();
/* Get screen dimensions. First we go to a default of 80x24.
* Then attempt to read the actual screen size from the terminal.
/* If there is a [nonce] at the end, put the nonce in <nonce>, else nonce
* is zeroized.
*/
-
- if ((sptr = strchr(aaa, '<')) == NULL)
- {
+
+ if ((sptr = strchr(aaa, '<')) == NULL) {
+ nonce[0] = '\0';
+ } else {
+ if ((sptr2 = strchr(sptr, '>')) == NULL) {
nonce[0] = '\0';
+ } else {
+ sptr2++;
+ *sptr2 = '\0';
+ strncpy(nonce, sptr, (size_t) NONCE_SIZE);
}
- else
- {
- if ((sptr2 = strchr(sptr, '>')) == NULL)
- {
- nonce[0] = '\0';
- }
- else
- {
- sptr2++;
- *sptr2 = '\0';
- strncpy(nonce, sptr, (size_t)NONCE_SIZE);
- }
- }
+ }
#ifdef HAVE_OPENSSL
/* Evaluate encryption preferences */
#endif
get_serv_info(ipc, telnet_client_host);
- scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode,
- ipc->ServInfo.site_location);
+ scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode, ipc->ServInfo.site_location);
scr_printf(" pause next stop\n");
scr_printf(" ctrl-s ctrl-o ctrl-c\n\n");
formout(ipc, "hello"); /* print the opening greeting */
scr_printf("\n");
- GSTA: /* See if we have a username and password on disk */
+ GSTA: /* See if we have a username and password on disk */
if (rc_remember_passwords) {
get_stored_password(hostbuf, portbuf, fullname, password);
if (!IsEmptyStr(fullname)) {
r = CtdlIPCTryLogin(ipc, fullname, aaa);
if (r / 100 == 3) {
if (*nonce) {
- r = CtdlIPCTryApopPassword(ipc, make_apop_string(password, nonce, hexstring, sizeof hexstring), aaa);
+ r = CtdlIPCTryApopPassword(ipc,
+ make_apop_string(password, nonce, hexstring, sizeof hexstring),
+ aaa);
} else {
r = CtdlIPCTryPassword(ipc, password, aaa);
}
if (!strcasecmp(fullname, "new")) { /* just in case */
scr_printf("Please enter the name you wish to log in with.\n");
}
- } while (
- (!strcasecmp(fullname, "bbs"))
+ } while ((!strcasecmp(fullname, "bbs"))
|| (!strcasecmp(fullname, "new"))
|| (IsEmptyStr(fullname)));
}
/* FIXME this is a stupid way to do guest mode but it's a reasonable test harness FIXME */
- if ( (ipc->ServInfo.guest_logins) && (!strcasecmp(fullname, "guest")) ) {
+ if ((ipc->ServInfo.guest_logins) && (!strcasecmp(fullname, "guest"))) {
goto PWOK;
}
if (!IsEmptyStr(rc_password)) {
strcpy(password, rc_password);
} else {
- newprompt("\rPlease enter your password: ", password, -(SIZ-1));
+ newprompt("\rPlease enter your password: ", password, -(SIZ - 1));
}
if (*nonce) {
r = CtdlIPCTryPassword(ipc, password, aaa);
}
}
-
+
if (r / 100 == 2) {
load_user_info(aaa);
- offer_to_remember_password(ipc, hostbuf, portbuf,
- fullname, password);
+ offer_to_remember_password(ipc, hostbuf, portbuf, fullname, password);
goto PWOK;
}
scr_printf("<< wrong password >>\n");
logoff(ipc, 2);
goto GSTA;
-NEWUSR: if (IsEmptyStr(rc_password)) {
+ NEWUSR:if (IsEmptyStr(rc_password)) {
scr_printf("'%s' not found.\n", fullname);
scr_printf("Type 'off' if you would like to exit.\n");
if (ipc->ServInfo.newuser_disabled == 1) {
goto GSTA;
}
- scr_printf("Do you want to create a new user account called '%s'? ",
- fullname);
+ scr_printf("Do you want to create a new user account called '%s'? ", fullname);
if (yesno() == 0) {
goto GSTA;
}
enter_config(ipc, 1);
- PWOK:
+ PWOK:
/* Switch color support on or off if we're in user mode */
if (rc_ansi_color == 3) {
if (userflags & US_COLOR)
color(BRIGHT_WHITE);
scr_printf("\n%s\nAccess level: %d (%s)\n"
- "User #%ld / Login #%d",
- fullname, axlevel, axdefs[(int) axlevel],
- usernum, timescalled);
+ "User #%ld / Login #%d", fullname, axlevel, axdefs[(int) axlevel], usernum, timescalled);
if (lastcall > 0L) {
- scr_printf(" / Last login: %s",
- asctime(localtime(&lastcall)));
+ scr_printf(" / Last login: %s", asctime(localtime(&lastcall)));
}
scr_printf("\n");
if (!IsEmptyStr(rc_gotmail_cmd)) {
rv = system(rc_gotmail_cmd);
if (rv)
- scr_printf("*** failed to check for mail calling %s Reason %d.\n",
- rc_gotmail_cmd, rv);
+ scr_printf("*** failed to check for mail calling %s Reason %d.\n", rc_gotmail_cmd, rv);
}
}
dotgoto(ipc, "_BASEROOM_", 1, 0);
/* Main loop for the system... user is logged in. */
- free(uglist[0]);
+ free(uglist[0]);
uglistsize = 0;
if (newnow == 1)
mcmd = getcmd(ipc, argbuf); /* Get keyboard command */
#ifdef TIOCGWINSZ
- check_screen_dims(); /* get screen size */
+ check_screen_dims(); /* get screen size */
#endif
if (termn8 == 0)
case 78:
entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0), 1);
break;
- case 5: /* <G>oto */
+ case 5: /* <G>oto */
updatels(ipc);
gotonext(ipc);
break;
- case 47: /* <A>bandon */
+ case 47: /* <A>bandon */
gotonext(ipc);
break;
- case 90: /* <.A>bandon */
+ case 90: /* <.A>bandon */
dotgoto(ipc, argbuf, 0, 0);
break;
- case 58: /* <M>ail */
+ case 58: /* <M>ail */
updatelsa(ipc);
dotgoto(ipc, "_MAIL_", 1, 0);
break;
dotgoto(ipc, argbuf, 0, 0);
}
break;
- case 95: /* what exactly is the numbering scheme supposed to be anyway? --Ford, there isn't one. -IO */
+ case 95: /* what exactly is the numbering scheme supposed to be anyway? --Ford, there isn't one. -IO */
dotungoto(ipc, argbuf);
break;
case 10:
readmsgs(ipc, OldMessages, ReadReverse, 0);
break;
case 71:
- readmsgs(ipc, LastMessages, ReadForward,
- atoi(argbuf));
+ readmsgs(ipc, LastMessages, ReadForward, atoi(argbuf));
break;
case 7:
forget(ipc);
break;
case 85:
- scr_printf("All users will be disconnected! "
- "Really terminate the server? ");
+ scr_printf("All users will be disconnected! " "Really terminate the server? ");
if (yesno() == 1) {
updatels(ipc);
r = CtdlIPCTerminateServerNow(ipc, aaa);
break;
case 86:
- scr_printf("Do you really want to schedule a "
- "server shutdown? ");
+ scr_printf("Do you really want to schedule a " "server shutdown? ");
if (yesno() == 1) {
r = CtdlIPCTerminateServerScheduled(ipc, 1, aaa);
if (r / 100 == 2) {
if (atoi(aaa)) {
- scr_printf(
- "The Citadel server will terminate when all users are logged off.\n"
- );
+ scr_printf
+ ("The Citadel server will terminate when all users are logged off.\n");
} else {
- scr_printf(
- "The Citadel server will not terminate.\n"
- );
+ scr_printf("The Citadel server will not terminate.\n");
}
}
}
case 91:
who_is_online(ipc, 2);
break;
-
+
case 80:
do_system_configuration(ipc);
break;
page_user(ipc);
break;
- case 110: /* <+> Next room */
- gotoroomstep(ipc, 1, 0);
- break;
+ case 110: /* <+> Next room */
+ gotoroomstep(ipc, 1, 0);
+ break;
- case 111: /* <-> Previous room */
- gotoroomstep(ipc, 0, 0);
- break;
+ case 111: /* <-> Previous room */
+ gotoroomstep(ipc, 0, 0);
+ break;
- case 112: /* <>> Next floor */
- gotofloorstep(ipc, 1, GF_GOTO);
- break;
+ case 112: /* <>> Next floor */
+ gotofloorstep(ipc, 1, GF_GOTO);
+ break;
- case 113: /* <<> Previous floor */
- gotofloorstep(ipc, 0, GF_GOTO);
- break;
+ case 113: /* <<> Previous floor */
+ gotofloorstep(ipc, 0, GF_GOTO);
+ break;
- case 116: /* <.> skip to <+> Next room */
- gotoroomstep(ipc, 1, 1);
- break;
+ case 116: /* <.> skip to <+> Next room */
+ gotoroomstep(ipc, 1, 1);
+ break;
- case 117: /* <.> skip to <-> Previous room */
- gotoroomstep(ipc, 0, 1);
- break;
+ case 117: /* <.> skip to <-> Previous room */
+ gotoroomstep(ipc, 0, 1);
+ break;
- case 118: /* <.> skip to <>> Next floor */
- gotofloorstep(ipc, 1, GF_SKIP);
- break;
+ case 118: /* <.> skip to <>> Next floor */
+ gotofloorstep(ipc, 1, GF_SKIP);
+ break;
- case 119: /* <.> skip to <<> Previous floor */
- gotofloorstep(ipc, 0, GF_SKIP);
- break;
+ case 119: /* <.> skip to <<> Previous floor */
+ gotofloorstep(ipc, 0, GF_SKIP);
+ break;
- case 114:
- read_config(ipc);
- break;
+ case 114:
+ read_config(ipc);
+ break;
- case 115:
- system_info(ipc);
- break;
+ case 115:
+ system_info(ipc);
+ break;
- case 120: /* .KAnonymous */
- dotknown(ipc, 0, NULL);
- break;
+ case 120: /* .KAnonymous */
+ dotknown(ipc, 0, NULL);
+ break;
- case 121: /* .KDirectory */
- dotknown(ipc, 1, NULL);
- break;
+ case 121: /* .KDirectory */
+ dotknown(ipc, 1, NULL);
+ break;
- case 122: /* .KMatch */
- dotknown(ipc, 2, argbuf);
- break;
+ case 122: /* .KMatch */
+ dotknown(ipc, 2, argbuf);
+ break;
- case 123: /* .KpreferredOnly */
- dotknown(ipc, 3, NULL);
- break;
+ case 123: /* .KpreferredOnly */
+ dotknown(ipc, 3, NULL);
+ break;
- case 124: /* .KPrivate */
- dotknown(ipc, 4, NULL);
- break;
+ case 124: /* .KPrivate */
+ dotknown(ipc, 4, NULL);
+ break;
- case 125: /* .KRead only */
- dotknown(ipc, 5, NULL);
- break;
+ case 125: /* .KRead only */
+ dotknown(ipc, 5, NULL);
+ break;
- case 126: /* .KShared */
- dotknown(ipc, 6, NULL);
- break;
+ case 126: /* .KShared */
+ dotknown(ipc, 6, NULL);
+ break;
- case 127: /* Configure POP3 aggregation */
+ case 127: /* Configure POP3 aggregation */
do_pop3client_configuration(ipc);
break;
- case 128: /* Configure XML/RSS feed retrieval */
+ case 128: /* Configure XML/RSS feed retrieval */
do_rssclient_configuration(ipc);
break;
} /* end switch */
} while (termn8 == 0);
-TERMN8: scr_printf("%s logged out.", fullname);
+ TERMN8:scr_printf("%s logged out.", fullname);
termn8 = 0;
color(ORIGINAL_PAIR);
scr_printf("\n");
for (lp = 0; lp < uglistsize; lp++) {
free(uglist[lp]);
}
- uglistsize = 0;
+ uglistsize = 0;
goto GSTA;
-} /* end main() */
-
+} /* end main() */
char arg_encrypt;
char rc_encrypt;
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_OPENSSL */
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
-static void (*status_hook)(char *s) = NULL;
-char ctdl_autoetc_dir[PATH_MAX]="";
-char file_citadel_rc[PATH_MAX]="";
-char ctdl_run_dir[PATH_MAX]="";
-char ctdl_etc_dir[PATH_MAX]="";
+static void (*status_hook) (char *s) = NULL;
+char ctdl_autoetc_dir[PATH_MAX] = "";
+char file_citadel_rc[PATH_MAX] = "";
+char ctdl_run_dir[PATH_MAX] = "";
+char ctdl_etc_dir[PATH_MAX] = "";
char ctdl_home_directory[PATH_MAX] = "";
-char file_citadel_socket[PATH_MAX]="";
-
-char *viewdefs[]={
- "Messages",
- "Summary",
- "Address book",
- "Calendar",
- "Tasks"
+char file_citadel_socket[PATH_MAX] = "";
+
+char *viewdefs[] = {
+ "Messages",
+ "Summary",
+ "Address book",
+ "Calendar",
+ "Tasks"
};
-char *axdefs[]={
- "Deleted",
- "New User",
- "Problem User",
- "Local User",
- "Network User",
- "Preferred User",
- "Admin",
- "Admin"
- };
+char *axdefs[] = {
+ "Deleted",
+ "New User",
+ "Problem User",
+ "Local User",
+ "Network User",
+ "Preferred User",
+ "Admin",
+ "Admin"
+};
-void CtdlIPC_lock(CtdlIPC *ipc)
+void CtdlIPC_lock(CtdlIPC * ipc)
{
- if (ipc->network_status_cb) ipc->network_status_cb(1);
+ if (ipc->network_status_cb)
+ ipc->network_status_cb(1);
}
-void CtdlIPC_unlock(CtdlIPC *ipc)
+void CtdlIPC_unlock(CtdlIPC * ipc)
{
- if (ipc->network_status_cb) ipc->network_status_cb(0);
+ if (ipc->network_status_cb)
+ ipc->network_status_cb(0);
}
-#ifdef __cplusplus
-}
-#endif
-
-char *libcitadelclient_version_string(void) {
- return "libcitadelclient(unnumbered)";
+char *libcitadelclient_version_string(void)
+{
+ return "libcitadelclient(unnumbered)";
}
#define DBG_PRINT(A) if (dbg==1) fprintf (stderr,"%s : %s \n", #A, A)
-void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg)
+void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg)
{
- const char* basedir = "";
+ const char *basedir = "";
char dirbuffer[PATH_MAX] = "";
StripSlashes(ctdldir, 1);
#ifndef HAVE_RUN_DIR
- basedir=ctdldir;
+ basedir = ctdldir;
#else
- basedir=RUN_DIR;
+ basedir = RUN_DIR;
#endif
COMPUTE_DIRECTORY(ctdl_run_dir);
StripSlashes(ctdl_run_dir, 1);
#ifndef HAVE_AUTO_ETC_DIR
- basedir=ctdldir;
+ basedir = ctdldir;
#else
- basedir=AUTO_ETC_DIR;
+ basedir = AUTO_ETC_DIR;
#endif
COMPUTE_DIRECTORY(ctdl_autoetc_dir);
StripSlashes(ctdl_autoetc_dir, 1);
#ifndef HAVE_ETC_DIR
- basedir=ctdldir;
+ basedir = ctdldir;
#else
- basedir=ETC_DIR;
+ basedir = ETC_DIR;
#endif
COMPUTE_DIRECTORY(ctdl_etc_dir);
StripSlashes(ctdl_etc_dir, 1);
- snprintf(file_citadel_rc,
- sizeof file_citadel_rc,
- "%scitadel.rc",
- ctdl_etc_dir);
+ snprintf(file_citadel_rc, sizeof file_citadel_rc, "%scitadel.rc", ctdl_etc_dir);
StripSlashes(file_citadel_rc, 0);
- snprintf(file_citadel_socket,
- sizeof file_citadel_socket,
- "%scitadel.socket",
- ctdl_run_dir);
+ snprintf(file_citadel_socket, sizeof file_citadel_socket, "%scitadel.socket", ctdl_run_dir);
StripSlashes(file_citadel_socket, 0);
DBG_PRINT(ctdl_run_dir);
DBG_PRINT(file_citadel_rc);
}
-void setCryptoStatusHook(void (*hook)(char *s)) {
+void setCryptoStatusHook(void (*hook) (char *s))
+{
status_hook = hook;
}
-void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state)) {
+void CtdlIPC_SetNetworkStatusCallback(CtdlIPC * ipc, void (*hook) (int state))
+{
ipc->network_status_cb = hook;
}
char instant_msgs = 0;
-static void serv_read(CtdlIPC *ipc, char *buf, unsigned int bytes);
-static void serv_write(CtdlIPC *ipc, const char *buf, unsigned int nbytes);
+static void serv_read(CtdlIPC * ipc, char *buf, unsigned int bytes);
+static void serv_write(CtdlIPC * ipc, const char *buf, unsigned int nbytes);
#ifdef HAVE_OPENSSL
-static void serv_read_ssl(CtdlIPC *ipc, char *buf, unsigned int bytes);
-static void serv_write_ssl(CtdlIPC *ipc, const char *buf, unsigned int nbytes);
-static void endtls(SSL *ssl);
-#endif /* HAVE_OPENSSL */
-static void CtdlIPC_getline(CtdlIPC* ipc, char *buf);
-static void CtdlIPC_putline(CtdlIPC *ipc, const char *buf);
+static void serv_read_ssl(CtdlIPC * ipc, char *buf, unsigned int bytes);
+static void serv_write_ssl(CtdlIPC * ipc, const char *buf, unsigned int nbytes);
+static void endtls(SSL * ssl);
+#endif /* HAVE_OPENSSL */
+static void CtdlIPC_getline(CtdlIPC * ipc, char *buf);
+static void CtdlIPC_putline(CtdlIPC * ipc, const char *buf);
/*
* Does nothing. The server should always return 200.
*/
-int CtdlIPCNoop(CtdlIPC *ipc)
+int CtdlIPCNoop(CtdlIPC * ipc)
{
char aaa[128];
* Does nothing interesting. The server should always return 200
* along with your string.
*/
-int CtdlIPCEcho(CtdlIPC *ipc, const char *arg, char *cret)
+int CtdlIPCEcho(CtdlIPC * ipc, const char *arg, char *cret)
{
int ret;
char *aaa;
-
- if (!arg) return -2;
- if (!cret) return -2;
- aaa = (char *)malloc((size_t)(strlen(arg) + 6));
- if (!aaa) return -1;
+ if (!arg)
+ return -2;
+ if (!cret)
+ return -2;
+
+ aaa = (char *) malloc((size_t) (strlen(arg) + 6));
+ if (!aaa)
+ return -1;
sprintf(aaa, "ECHO %s", arg);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
* Asks the server to close the connecction.
* Should always return 200.
*/
-int CtdlIPCQuit(CtdlIPC *ipc)
+int CtdlIPCQuit(CtdlIPC * ipc)
{
int ret = 221; /* Default to successful quit */
- char aaa[SIZ];
+ char aaa[SIZ];
CtdlIPC_lock(ipc);
if (ipc->sock > -1) {
* Asks the server to log out. Should always return 200, even if no user
* was logged in. The user will not be logged in after this!
*/
-int CtdlIPCLogout(CtdlIPC *ipc)
+int CtdlIPCLogout(CtdlIPC * ipc)
{
int ret;
char aaa[SIZ];
* username is able to log in, with the username correctly spelled in cret.
* Returns various 500 error codes if the user doesn't exist, etc.
*/
-int CtdlIPCTryLogin(CtdlIPC *ipc, const char *username, char *cret)
+int CtdlIPCTryLogin(CtdlIPC * ipc, const char *username, char *cret)
{
int ret;
char *aaa;
- if (!username) return -2;
- if (!cret) return -2;
+ if (!username)
+ return -2;
+ if (!cret)
+ return -2;
- aaa = (char *)malloc((size_t)(strlen(username) + 6));
- if (!aaa) return -1;
+ aaa = (char *) malloc((size_t) (strlen(username) + 6));
+ if (!aaa)
+ return -1;
sprintf(aaa, "USER %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
* Second stage of authentication - provide password. The server returns
* 200 and several arguments in cret relating to the user's account.
*/
-int CtdlIPCTryPassword(CtdlIPC *ipc, const char *passwd, char *cret)
+int CtdlIPCTryPassword(CtdlIPC * ipc, const char *passwd, char *cret)
{
int ret;
char *aaa;
- if (!passwd) return -2;
- if (!cret) return -2;
+ if (!passwd)
+ return -2;
+ if (!cret)
+ return -2;
- aaa = (char *)malloc((size_t)(strlen(passwd) + 6));
- if (!aaa) return -1;
+ aaa = (char *) malloc((size_t) (strlen(passwd) + 6));
+ if (!aaa)
+ return -1;
sprintf(aaa, "PASS %s", passwd);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
* Second stage of authentication - provide password. The server returns
* 200 and several arguments in cret relating to the user's account.
*/
-int CtdlIPCTryApopPassword(CtdlIPC *ipc, const char *response, char *cret)
+int CtdlIPCTryApopPassword(CtdlIPC * ipc, const char *response, char *cret)
{
int ret;
char *aaa;
- if (!response) return -2;
- if (!cret) return -2;
+ if (!response)
+ return -2;
+ if (!cret)
+ return -2;
- aaa = (char *)malloc((size_t)(strlen(response) + 6));
- if (!aaa) return -1;
+ aaa = (char *) malloc((size_t) (strlen(response) + 6));
+ if (!aaa)
+ return -1;
sprintf(aaa, "PAS2 %s", response);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
* user - intended for use by system administrators to create accounts on
* behalf of other users.
*/
-int CtdlIPCCreateUser(CtdlIPC *ipc, const char *username, int selfservice, char *cret)
+int CtdlIPCCreateUser(CtdlIPC * ipc, const char *username, int selfservice, char *cret)
{
int ret;
char *aaa;
- if (!username) return -2;
- if (!cret) return -2;
+ if (!username)
+ return -2;
+ if (!cret)
+ return -2;
- aaa = (char *)malloc((size_t)(strlen(username) + 6));
- if (!aaa) return -1;
+ aaa = (char *) malloc((size_t) (strlen(username) + 6));
+ if (!aaa)
+ return -1;
- sprintf(aaa, "%s %s", selfservice ? "NEWU" : "CREU", username);
+ sprintf(aaa, "%s %s", selfservice ? "NEWU" : "CREU", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
free(aaa);
return ret;
/*
* Changes the user's password. Returns 200 if changed, errors otherwise.
*/
-int CtdlIPCChangePassword(CtdlIPC *ipc, const char *passwd, char *cret)
+int CtdlIPCChangePassword(CtdlIPC * ipc, const char *passwd, char *cret)
{
int ret;
char *aaa;
- if (!passwd) return -2;
- if (!cret) return -2;
+ if (!passwd)
+ return -2;
+ if (!cret)
+ return -2;
- aaa = (char *)malloc((size_t)(strlen(passwd) + 6));
- if (!aaa) return -1;
+ aaa = (char *) malloc((size_t) (strlen(passwd) + 6));
+ if (!aaa)
+ return -1;
sprintf(aaa, "SETP %s", passwd);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* Caller must free the march list */
/* Room types are defined in enum RoomList; keep these in sync! */
/* floor is -1 for all, or floornum */
-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 ret;
struct march *march = NULL;
- static char *proto[] =
- {"LKRA", "LKRN", "LKRO", "LZRM", "LRMS", "LPRM" };
+ static char *proto[] = { "LKRA", "LKRN", "LKRO", "LZRM", "LRMS", "LPRM" };
char aaa[SIZ];
char *bbb = NULL;
size_t bbb_len;
- if (!listing) return -2;
- if (*listing) return -2; /* Free the listing first */
- if (!cret) return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2; /* Free the listing first */
+ if (!cret)
+ return -2;
/* if (which < 0 || which > 4) return -2; */
- if (floor < -1) return -2; /* Can't validate upper bound, sorry */
+ if (floor < -1)
+ return -2; /* Can't validate upper bound, sorry */
sprintf(aaa, "%s %d", proto[which], floor);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, &bbb, &bbb_len, cret);
extract_token(aaa, bbb, 0, '\n', sizeof aaa);
a = strlen(aaa);
memmove(bbb, bbb + a + 1, strlen(bbb) - a);
- mptr = (struct march *) malloc(sizeof (struct march));
+ mptr = (struct march *) malloc(sizeof(struct march));
if (mptr) {
mptr->next = NULL;
extract_token(mptr->march_name, aaa, 0, '|', sizeof mptr->march_name);
}
}
*listing = march;
- if (bbb) free(bbb);
+ if (bbb)
+ free(bbb);
return ret;
}
/* GETU */
/* Caller must free the struct ctdluser; caller may pass an existing one */
-int CtdlIPCGetConfig(CtdlIPC *ipc, struct ctdluser **uret, char *cret)
+int CtdlIPCGetConfig(CtdlIPC * ipc, struct ctdluser **uret, char *cret)
{
int ret;
- if (!cret) return -2;
- if (!uret) return -2;
- if (!*uret) *uret = (struct ctdluser *)calloc(1, sizeof (struct ctdluser));
- if (!*uret) return -1;
+ if (!cret)
+ return -2;
+ if (!uret)
+ return -2;
+ if (!*uret)
+ *uret = (struct ctdluser *) calloc(1, sizeof(struct ctdluser));
+ if (!*uret)
+ return -1;
ret = CtdlIPCGenericCommand(ipc, "GETU", NULL, 0, NULL, NULL, cret);
if (ret / 100 == 2) {
/* SETU */
-int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret)
+int CtdlIPCSetConfig(CtdlIPC * ipc, struct ctdluser *uret, char *cret)
{
char aaa[48];
- if (!uret) return -2;
- if (!cret) return -2;
+ if (!uret)
+ return -2;
+ if (!cret)
+ return -2;
- sprintf(aaa,
- "SETU 80|24|%d",
- uret->flags
- );
+ sprintf(aaa, "SETU 80|24|%d", uret->flags);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}
/* RENU */
-int CtdlIPCRenameUser(CtdlIPC *ipc, char *oldname, char *newname, char *cret)
+int CtdlIPCRenameUser(CtdlIPC * ipc, char *oldname, char *newname, char *cret)
{
int ret;
char cmd[256];
- if (!oldname) return -2;
- if (!newname) return -2;
- if (!cret) return -2;
+ if (!oldname)
+ return -2;
+ if (!newname)
+ return -2;
+ if (!cret)
+ return -2;
snprintf(cmd, sizeof cmd, "RENU %s|%s", oldname, newname);
ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
/* GOTO */
-int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd,
- struct ctdlipcroom **rret, char *cret)
+int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!rret) return -2;
- if (!*rret) *rret = (struct ctdlipcroom *)calloc(1, sizeof (struct ctdlipcroom));
- if (!*rret) return -1;
+ if (!cret)
+ return -2;
+ if (!rret)
+ return -2;
+ if (!*rret)
+ *rret = (struct ctdlipcroom *) calloc(1, sizeof(struct ctdlipcroom));
+ if (!*rret)
+ return -1;
if (passwd) {
- aaa = (char *)malloc(strlen(room) + strlen(passwd) + 7);
+ aaa = (char *) malloc(strlen(room) + strlen(passwd) + 7);
if (!aaa) {
free(*rret);
return -1;
}
sprintf(aaa, "GOTO %s|%s", room, passwd);
} else {
- aaa = (char *)malloc(strlen(room) + 6);
+ aaa = (char *) malloc(strlen(room) + 6);
if (!aaa) {
free(*rret);
return -1;
/* MSGS */
/* which is 0 = all, 1 = old, 2 = new, 3 = last, 4 = first, 5 = gt, 6 = lt */
/* whicharg is number of messages, applies to last, first, gt, lt */
-int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
- const char *mtemplate, unsigned long **mret, char *cret)
+int CtdlIPCGetMessages(CtdlIPC * ipc, enum MessageList which, int whicharg, const char *mtemplate, unsigned long **mret, char *cret)
{
int ret;
unsigned long count = 0;
- static char *proto[] =
- { "ALL", "OLD", "NEW", "LAST", "FIRST", "GT", "LT" };
+ static char *proto[] = { "ALL", "OLD", "NEW", "LAST", "FIRST", "GT", "LT" };
char aaa[33];
char *bbb = NULL;
size_t bbb_len;
- if (!cret) return -2;
- if (!mret) return -2;
- if (*mret) return -2;
- if (which < 0 || which > 6) return -2;
+ if (!cret)
+ return -2;
+ if (!mret)
+ return -2;
+ if (*mret)
+ return -2;
+ if (which < 0 || which > 6)
+ return -2;
if (which <= 2)
- sprintf(aaa, "MSGS %s||%d", proto[which],
- (mtemplate) ? 1 : 0);
+ sprintf(aaa, "MSGS %s||%d", proto[which], (mtemplate) ? 1 : 0);
else
- sprintf(aaa, "MSGS %s|%d|%d", proto[which], whicharg,
- (mtemplate) ? 1 : 0);
- if (mtemplate) count = strlen(mtemplate);
+ sprintf(aaa, "MSGS %s|%d|%d", proto[which], whicharg, (mtemplate) ? 1 : 0);
+ if (mtemplate)
+ count = strlen(mtemplate);
ret = CtdlIPCGenericCommand(ipc, aaa, mtemplate, count, &bbb, &bbb_len, cret);
if (ret / 100 != 1)
return ret;
count = 0;
- *mret = (unsigned long *)calloc(1, sizeof(unsigned long));
+ *mret = (unsigned long *) calloc(1, sizeof(unsigned long));
if (!*mret)
return -1;
while (bbb && strlen(bbb)) {
extract_token(aaa, bbb, 0, '\n', sizeof aaa);
remove_token(bbb, 0, '\n');
- *mret = (unsigned long *)realloc(*mret, (size_t)((count + 2) *
- sizeof (unsigned long)));
+ *mret = (unsigned long *) realloc(*mret, (size_t) ((count + 2) * sizeof(unsigned long)));
if (*mret) {
(*mret)[count++] = atol(aaa);
(*mret)[count] = 0L;
break;
}
}
- if (bbb) free(bbb);
+ if (bbb)
+ free(bbb);
return ret;
}
/* MSG0, MSG2 */
-int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
- struct ctdlipcmessage **mret, char *cret)
+int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret)
{
int ret;
char aaa[SIZ];
char multipart_prefix[128];
char encoding[256];
- if (!cret) return -1;
- if (!mret) return -1;
- if (!*mret) *mret = (struct ctdlipcmessage *)calloc(1, sizeof (struct ctdlipcmessage));
- if (!*mret) return -1;
- if (!msgnum) return -1;
+ if (!cret)
+ return -1;
+ if (!mret)
+ return -1;
+ if (!*mret)
+ *mret = (struct ctdlipcmessage *) calloc(1, sizeof(struct ctdlipcmessage));
+ if (!*mret)
+ return -1;
+ if (!msgnum)
+ return -1;
strcpy(encoding, "");
strcpy(mret[0]->content_type, "");
*/
else if (!strncasecmp(aaa, "pref=", 5)) {
extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
- if (!strcasecmp(multipart_prefix,
- "multipart/alternative")) {
+ if (!strcasecmp(multipart_prefix, "multipart/alternative")) {
++multipart_hunting;
}
- }
- else if (!strncasecmp(aaa, "suff=", 5)) {
+ } else if (!strncasecmp(aaa, "suff=", 5)) {
extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
- if (!strcasecmp(multipart_prefix,
- "multipart/alternative")) {
+ if (!strcasecmp(multipart_prefix, "multipart/alternative")) {
++multipart_hunting;
}
}
else if (!strncasecmp(aaa, "part=", 5)) {
struct parts *ptr, *chain;
-
- ptr = (struct parts *)calloc(1, sizeof (struct parts));
+
+ ptr = (struct parts *) calloc(1, sizeof(struct parts));
if (ptr) {
/* Fill the buffers for the caller */
/* Now handle multipart/alternative */
if (multipart_hunting > 0) {
- if ( (!strcasecmp(ptr->mimetype,
- "text/plain"))
- || (!strcasecmp(ptr->mimetype,
- "text/html")) ) {
- strcpy(mret[0]->mime_chosen,
- ptr->number);
+ if ((!strcasecmp(ptr->mimetype, "text/plain"))
+ || (!strcasecmp(ptr->mimetype, "text/html"))) {
+ strcpy(mret[0]->mime_chosen, ptr->number);
}
}
}
if (strlen(bbb)) {
- if ( (!strcasecmp(encoding, "base64")) || (!strcasecmp(encoding, "quoted-printable")) ) {
+ if ((!strcasecmp(encoding, "base64")) || (!strcasecmp(encoding, "quoted-printable"))) {
char *ccc = NULL;
int bytes_decoded = 0;
ccc = malloc(strlen(bbb) + 32768);
if (!strcasecmp(encoding, "base64")) {
bytes_decoded = CtdlDecodeBase64(ccc, bbb, strlen(bbb));
- }
- else if (!strcasecmp(encoding, "quoted-printable")) {
+ } else if (!strcasecmp(encoding, "quoted-printable")) {
bytes_decoded = CtdlDecodeQuotedPrintable(ccc, bbb, strlen(bbb));
}
ccc[bytes_decoded] = 0;
}
/* FIXME: Strip trailing whitespace */
- bbb = (char *)realloc(bbb, (size_t)(strlen(bbb) + 1));
+ bbb = (char *) realloc(bbb, (size_t) (strlen(bbb) + 1));
} else {
- bbb = (char *)realloc(bbb, 1);
+ bbb = (char *) realloc(bbb, 1);
*bbb = '\0';
}
mret[0]->text = bbb;
/* WHOK */
-int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCWhoKnowsRoom(CtdlIPC * ipc, char **listing, char *cret)
{
int ret;
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
ret = CtdlIPCGenericCommand(ipc, "WHOK", NULL, 0, listing, &bytes, cret);
return ret;
/* INFO */
-int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret)
+int CtdlIPCServerInfo(CtdlIPC * ipc, char *cret)
{
int ret;
size_t bytes;
char *listing = NULL;
char buf[SIZ];
- if (!cret) return -2;
+ if (!cret)
+ return -2;
ret = CtdlIPCGenericCommand(ipc, "INFO", NULL, 0, &listing, &bytes, cret);
if (ret / 100 == 1) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
switch (line++) {
- case 0: ipc->ServInfo.pid = atoi(buf);
- break;
- case 1: strcpy(ipc->ServInfo.nodename,buf);
- break;
- case 2: strcpy(ipc->ServInfo.humannode,buf);
- break;
- case 3: strcpy(ipc->ServInfo.fqdn,buf);
- break;
- case 4: strcpy(ipc->ServInfo.software,buf);
- break;
- case 5: ipc->ServInfo.rev_level = atoi(buf);
- break;
- case 6: strcpy(ipc->ServInfo.site_location,buf);
- break;
- case 7: strcpy(ipc->ServInfo.sysadm,buf);
- break;
- case 9: strcpy(ipc->ServInfo.moreprompt,buf);
- break;
- case 10: ipc->ServInfo.ok_floors = atoi(buf);
- break;
- case 11: ipc->ServInfo.paging_level = atoi(buf);
- break;
- case 13: ipc->ServInfo.supports_qnop = atoi(buf);
- break;
- case 14: ipc->ServInfo.supports_ldap = atoi(buf);
- break;
- case 15: ipc->ServInfo.newuser_disabled = atoi(buf);
- break;
- case 16: strcpy(ipc->ServInfo.default_cal_zone, buf);
- break;
- case 17: ipc->ServInfo.load_avg = atof(buf);
- break;
- case 18: ipc->ServInfo.worker_avg = atof(buf);
- break;
- case 19: ipc->ServInfo.thread_count = atoi(buf);
- break;
- case 20: ipc->ServInfo.has_sieve = atoi(buf);
- break;
- case 21: ipc->ServInfo.fulltext_enabled = atoi(buf);
- break;
- case 22: strcpy(ipc->ServInfo.svn_revision, buf);
- break;
- case 24: ipc->ServInfo.guest_logins = atoi(buf);
- break;
+ case 0:
+ ipc->ServInfo.pid = atoi(buf);
+ break;
+ case 1:
+ strcpy(ipc->ServInfo.nodename, buf);
+ break;
+ case 2:
+ strcpy(ipc->ServInfo.humannode, buf);
+ break;
+ case 3:
+ strcpy(ipc->ServInfo.fqdn, buf);
+ break;
+ case 4:
+ strcpy(ipc->ServInfo.software, buf);
+ break;
+ case 5:
+ ipc->ServInfo.rev_level = atoi(buf);
+ break;
+ case 6:
+ strcpy(ipc->ServInfo.site_location, buf);
+ break;
+ case 7:
+ strcpy(ipc->ServInfo.sysadm, buf);
+ break;
+ case 9:
+ strcpy(ipc->ServInfo.moreprompt, buf);
+ break;
+ case 10:
+ ipc->ServInfo.ok_floors = atoi(buf);
+ break;
+ case 11:
+ ipc->ServInfo.paging_level = atoi(buf);
+ break;
+ case 13:
+ ipc->ServInfo.supports_qnop = atoi(buf);
+ break;
+ case 14:
+ ipc->ServInfo.supports_ldap = atoi(buf);
+ break;
+ case 15:
+ ipc->ServInfo.newuser_disabled = atoi(buf);
+ break;
+ case 16:
+ strcpy(ipc->ServInfo.default_cal_zone, buf);
+ break;
+ case 17:
+ ipc->ServInfo.load_avg = atof(buf);
+ break;
+ case 18:
+ ipc->ServInfo.worker_avg = atof(buf);
+ break;
+ case 19:
+ ipc->ServInfo.thread_count = atoi(buf);
+ break;
+ case 20:
+ ipc->ServInfo.has_sieve = atoi(buf);
+ break;
+ case 21:
+ ipc->ServInfo.fulltext_enabled = atoi(buf);
+ break;
+ case 22:
+ strcpy(ipc->ServInfo.svn_revision, buf);
+ break;
+ case 24:
+ ipc->ServInfo.guest_logins = atoi(buf);
+ break;
}
}
}
- if (listing) free(listing);
+ if (listing)
+ free(listing);
return ret;
}
/* RDIR */
-int CtdlIPCReadDirectory(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCReadDirectory(CtdlIPC * ipc, char **listing, char *cret)
{
int ret;
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
ret = CtdlIPCGenericCommand(ipc, "RDIR", NULL, 0, listing, &bytes, cret);
return ret;
/*
* Set last-read pointer in this room to msgnum, or 0 for HIGHEST.
*/
-int CtdlIPCSetLastRead(CtdlIPC *ipc, long msgnum, char *cret)
+int CtdlIPCSetLastRead(CtdlIPC * ipc, long msgnum, char *cret)
{
int ret;
char aaa[64];
- if (!cret) return -2;
+ if (!cret)
+ return -2;
if (msgnum) {
sprintf(aaa, "SLRP %ld", msgnum);
- }
- else {
+ } else {
sprintf(aaa, "SLRP HIGHEST");
}
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* INVT */
-int CtdlIPCInviteUserToRoom(CtdlIPC *ipc, const char *username, char *cret)
+int CtdlIPCInviteUserToRoom(CtdlIPC * ipc, const char *username, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "INVT %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* KICK */
-int CtdlIPCKickoutUserFromRoom(CtdlIPC *ipc, const char *username, char *cret)
+int CtdlIPCKickoutUserFromRoom(CtdlIPC * ipc, const char *username, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -1;
- if (!username) return -1;
+ if (!cret)
+ return -1;
+ if (!username)
+ return -1;
- aaa = (char *)malloc(strlen(username) + 6);
+ aaa = (char *) malloc(strlen(username) + 6);
sprintf(aaa, "KICK %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* GETR */
-int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret)
+int CtdlIPCGetRoomAttributes(CtdlIPC * ipc, struct ctdlroom **qret, char *cret)
{
int ret;
- if (!cret) return -2;
- if (!qret) return -2;
- if (!*qret) *qret = (struct ctdlroom *)calloc(1, sizeof (struct ctdlroom));
- if (!*qret) return -1;
+ if (!cret)
+ return -2;
+ if (!qret)
+ return -2;
+ if (!*qret)
+ *qret = (struct ctdlroom *) calloc(1, sizeof(struct ctdlroom));
+ if (!*qret)
+ return -1;
ret = CtdlIPCGenericCommand(ipc, "GETR", NULL, 0, NULL, NULL, cret);
if (ret / 100 == 2) {
/* SETR */
/* set forget to kick all users out of room */
-int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct ctdlroom *qret, char *cret)
+int CtdlIPCSetRoomAttributes(CtdlIPC * ipc, int forget, struct ctdlroom *qret, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!qret) return -2;
+ if (!cret)
+ return -2;
+ if (!qret)
+ return -2;
- aaa = (char *)malloc(strlen(qret->QRname) + strlen(qret->QRpasswd) +
- strlen(qret->QRdirname) + 64);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(qret->QRname) + strlen(qret->QRpasswd) + strlen(qret->QRdirname) + 64);
+ if (!aaa)
+ return -1;
sprintf(aaa, "SETR %s|%s|%s|%d|%d|%d|%d|%d|%d",
- qret->QRname, qret->QRpasswd, qret->QRdirname,
- qret->QRflags, forget, qret->QRfloor, qret->QRorder,
- qret->QRdefaultview, qret->QRflags2);
+ qret->QRname, qret->QRpasswd, qret->QRdirname,
+ qret->QRflags, forget, qret->QRfloor, qret->QRorder, qret->QRdefaultview, qret->QRflags2);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
free(aaa);
return ret;
/* GETA */
-int CtdlIPCGetRoomAide(CtdlIPC *ipc, char *cret)
+int CtdlIPCGetRoomAide(CtdlIPC * ipc, char *cret)
{
- if (!cret) return -1;
+ if (!cret)
+ return -1;
return CtdlIPCGenericCommand(ipc, "GETA", NULL, 0, NULL, NULL, cret);
}
/* SETA */
-int CtdlIPCSetRoomAide(CtdlIPC *ipc, const char *username, char *cret)
+int CtdlIPCSetRoomAide(CtdlIPC * ipc, const char *username, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "SETA %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* ENT0 */
-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 ret;
char cmd[SIZ];
char *ptr;
- if (!cret) return -2;
- if (!mr) return -2;
+ if (!cret)
+ return -2;
+ if (!mr)
+ return -2;
if (mr->references) {
- for (ptr=mr->references; *ptr != 0; ++ptr) {
- if (*ptr == '|') *ptr = '!';
+ for (ptr = mr->references; *ptr != 0; ++ptr) {
+ if (*ptr == '|')
+ *ptr = '!';
}
}
snprintf(cmd, sizeof cmd,
- "ENT0 %d|%s|%d|%d|%s|%s||||||%s|", flag, mr->recipient,
- mr->anonymous, mr->type, mr->subject, mr->author, mr->references);
- ret = CtdlIPCGenericCommand(ipc, cmd, mr->text, strlen(mr->text), NULL,
- NULL, cret);
+ "ENT0 %d|%s|%d|%d|%s|%s||||||%s|", flag, mr->recipient,
+ mr->anonymous, mr->type, mr->subject, mr->author, mr->references);
+ ret = CtdlIPCGenericCommand(ipc, cmd, mr->text, strlen(mr->text), NULL, NULL, cret);
if ((flag == 0) && (subject_required != NULL)) {
/* Is the server strongly recommending that the user enter a message subject? */
if ((cret[3] != '\0') && (cret[4] != '\0')) {
*subject_required = extract_int(&cret[4], 1);
}
-
+
}
return ret;
}
/* RINF */
-int CtdlIPCRoomInfo(CtdlIPC *ipc, char **iret, char *cret)
+int CtdlIPCRoomInfo(CtdlIPC * ipc, char **iret, char *cret)
{
size_t bytes;
- if (!cret) return -2;
- if (!iret) return -2;
- if (*iret) return -2;
+ if (!cret)
+ return -2;
+ if (!iret)
+ return -2;
+ if (*iret)
+ return -2;
return CtdlIPCGenericCommand(ipc, "RINF", NULL, 0, iret, &bytes, cret);
}
/* DELE */
-int CtdlIPCDeleteMessage(CtdlIPC *ipc, long msgnum, char *cret)
+int CtdlIPCDeleteMessage(CtdlIPC * ipc, long msgnum, char *cret)
{
char aaa[64];
- if (!cret) return -2;
- if (!msgnum) return -2;
+ if (!cret)
+ return -2;
+ if (!msgnum)
+ return -2;
sprintf(aaa, "DELE %ld", msgnum);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* MOVE */
-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 ret;
char *aaa;
- if (!cret) return -2;
- if (!destroom) return -2;
- if (!msgnum) return -2;
+ if (!cret)
+ return -2;
+ if (!destroom)
+ return -2;
+ if (!msgnum)
+ return -2;
- aaa = (char *)malloc(strlen(destroom) + 28);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(destroom) + 28);
+ if (!aaa)
+ return -1;
sprintf(aaa, "MOVE %ld|%s|%d", msgnum, destroom, copy);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* KILL */
-int CtdlIPCDeleteRoom(CtdlIPC *ipc, int for_real, char *cret)
+int CtdlIPCDeleteRoom(CtdlIPC * ipc, int for_real, char *cret)
{
char aaa[64];
- if (!cret) return -2;
+ if (!cret)
+ return -2;
sprintf(aaa, "KILL %d", for_real);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* CRE8 */
-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 ret;
char *aaa;
- if (!cret) return -2;
- if (!roomname) return -2;
+ if (!cret)
+ return -2;
+ if (!roomname)
+ return -2;
if (password) {
- aaa = (char *)malloc(strlen(roomname) + strlen(password) + 40);
- if (!aaa) return -1;
- sprintf(aaa, "CRE8 %d|%s|%d|%s|%d", for_real, roomname, type,
- password, floor);
+ aaa = (char *) malloc(strlen(roomname) + strlen(password) + 40);
+ if (!aaa)
+ return -1;
+ sprintf(aaa, "CRE8 %d|%s|%d|%s|%d", for_real, roomname, type, password, floor);
} else {
- aaa = (char *)malloc(strlen(roomname) + 40);
- if (!aaa) return -1;
- sprintf(aaa, "CRE8 %d|%s|%d||%d", for_real, roomname, type,
- floor);
+ aaa = (char *) malloc(strlen(roomname) + 40);
+ if (!aaa)
+ return -1;
+ sprintf(aaa, "CRE8 %d|%s|%d||%d", for_real, roomname, type, floor);
}
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
free(aaa);
/* FORG */
-int CtdlIPCForgetRoom(CtdlIPC *ipc, char *cret)
+int CtdlIPCForgetRoom(CtdlIPC * ipc, char *cret)
{
- if (!cret) return -2;
+ if (!cret)
+ return -2;
return CtdlIPCGenericCommand(ipc, "FORG", NULL, 0, NULL, NULL, cret);
}
/* MESG */
-int CtdlIPCSystemMessage(CtdlIPC *ipc, const char *message, char **mret, char *cret)
+int CtdlIPCSystemMessage(CtdlIPC * ipc, const char *message, char **mret, char *cret)
{
int ret;
char *aaa;
size_t bytes;
- if (!cret) return -2;
- if (!mret) return -2;
- if (*mret) return -2;
- if (!message) return -2;
+ if (!cret)
+ return -2;
+ if (!mret)
+ return -2;
+ if (*mret)
+ return -2;
+ if (!message)
+ return -2;
- aaa = (char *)malloc(strlen(message) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(message) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "MESG %s", message);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, mret, &bytes, cret);
/* GNUR */
-int CtdlIPCNextUnvalidatedUser(CtdlIPC *ipc, char *cret)
+int CtdlIPCNextUnvalidatedUser(CtdlIPC * ipc, char *cret)
{
- if (!cret) return -2;
+ if (!cret)
+ return -2;
return CtdlIPCGenericCommand(ipc, "GNUR", NULL, 0, NULL, NULL, cret);
}
/* GREG */
-int CtdlIPCGetUserRegistration(CtdlIPC *ipc, const char *username, char **rret, char *cret)
+int CtdlIPCGetUserRegistration(CtdlIPC * ipc, const char *username, char **rret, char *cret)
{
int ret;
char *aaa;
size_t bytes;
- if (!cret) return -2;
- if (!rret) return -2;
- if (*rret) return -2;
+ if (!cret)
+ return -2;
+ if (!rret)
+ return -2;
+ if (*rret)
+ return -2;
if (username)
- aaa = (char *)malloc(strlen(username) + 6);
+ aaa = (char *) malloc(strlen(username) + 6);
else
- aaa = (char *)malloc(12);
- if (!aaa) return -1;
+ aaa = (char *) malloc(12);
+ if (!aaa)
+ return -1;
if (username)
sprintf(aaa, "GREG %s", username);
/* VALI */
-int CtdlIPCValidateUser(CtdlIPC *ipc, const char *username, int axlevel, char *cret)
+int CtdlIPCValidateUser(CtdlIPC * ipc, const char *username, int axlevel, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
- if (axlevel < AxDeleted || axlevel > AxAideU) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
+ if (axlevel < AxDeleted || axlevel > AxAideU)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 17);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 17);
+ if (!aaa)
+ return -1;
sprintf(aaa, "VALI %s|%d", username, axlevel);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* EINF */
-int CtdlIPCSetRoomInfo(CtdlIPC *ipc, int for_real, const char *info, char *cret)
+int CtdlIPCSetRoomInfo(CtdlIPC * ipc, int for_real, const char *info, char *cret)
{
char aaa[64];
- if (!cret) return -1;
- if (!info) return -1;
+ if (!cret)
+ return -1;
+ if (!info)
+ return -1;
sprintf(aaa, "EINF %d", for_real);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* LIST */
-int CtdlIPCUserListing(CtdlIPC *ipc, char *searchstring, char **listing, char *cret)
+int CtdlIPCUserListing(CtdlIPC * ipc, char *searchstring, char **listing, char *cret)
{
size_t bytes;
char *cmd;
int ret;
- if (!cret) return -1;
- if (!listing) return -1;
- if (*listing) return -1;
- if (!searchstring) return -1;
+ if (!cret)
+ return -1;
+ if (!listing)
+ return -1;
+ if (*listing)
+ return -1;
+ if (!searchstring)
+ return -1;
cmd = malloc(strlen(searchstring) + 10);
sprintf(cmd, "LIST %s", searchstring);
ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, listing, &bytes, cret);
free(cmd);
- return(ret);
+ return (ret);
}
/* REGI */
-int CtdlIPCSetRegistration(CtdlIPC *ipc, const char *info, char *cret)
+int CtdlIPCSetRegistration(CtdlIPC * ipc, const char *info, char *cret)
{
- if (!cret) return -1;
- if (!info) return -1;
+ if (!cret)
+ return -1;
+ if (!info)
+ return -1;
- return CtdlIPCGenericCommand(ipc, "REGI", info, strlen(info),
- NULL, NULL, cret);
+ return CtdlIPCGenericCommand(ipc, "REGI", info, strlen(info), NULL, NULL, cret);
}
/* CHEK */
-int CtdlIPCMiscCheck(CtdlIPC *ipc, struct ctdlipcmisc *chek, char *cret)
+int CtdlIPCMiscCheck(CtdlIPC * ipc, struct ctdlipcmisc *chek, char *cret)
{
int ret;
- if (!cret) return -1;
- if (!chek) return -1;
+ if (!cret)
+ return -1;
+ if (!chek)
+ return -1;
ret = CtdlIPCGenericCommand(ipc, "CHEK", NULL, 0, NULL, NULL, cret);
if (ret / 100 == 2) {
/* DELF */
-int CtdlIPCDeleteFile(CtdlIPC *ipc, const char *filename, char *cret)
+int CtdlIPCDeleteFile(CtdlIPC * ipc, const char *filename, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!filename) return -2;
-
- aaa = (char *)malloc(strlen(filename) + 6);
- if (!aaa) return -1;
+ if (!cret)
+ return -2;
+ if (!filename)
+ return -2;
+
+ aaa = (char *) malloc(strlen(filename) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "DELF %s", filename);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* MOVF */
-int CtdlIPCMoveFile(CtdlIPC *ipc, const char *filename, const char *destroom, char *cret)
+int CtdlIPCMoveFile(CtdlIPC * ipc, const char *filename, const char *destroom, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!filename) return -2;
- if (!destroom) return -2;
+ if (!cret)
+ return -2;
+ if (!filename)
+ return -2;
+ if (!destroom)
+ return -2;
- aaa = (char *)malloc(strlen(filename) + strlen(destroom) + 7);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(filename) + strlen(destroom) + 7);
+ if (!aaa)
+ return -1;
sprintf(aaa, "MOVF %s|%s", filename, destroom);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* RWHO */
-int CtdlIPCOnlineUsers(CtdlIPC *ipc, char **listing, time_t *stamp, char *cret)
+int CtdlIPCOnlineUsers(CtdlIPC * ipc, char **listing, time_t * stamp, char *cret)
{
int ret;
size_t bytes;
- if (!cret) return -1;
- if (!listing) return -1;
- if (*listing) return -1;
+ if (!cret)
+ return -1;
+ if (!listing)
+ return -1;
+ if (*listing)
+ return -1;
*stamp = CtdlIPCServerTime(ipc, cret);
if (!*stamp)
/* OPEN */
-int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
- size_t resume,
- 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 ret;
size_t bytes;
char mimetype[SIZ];
char *aaa;
- if (!cret) return -2;
- if (!filename) return -2;
- if (!buf) return -2;
- if (*buf) return -2;
- if (ipc->downloading) return -2;
+ if (!cret)
+ return -2;
+ if (!filename)
+ return -2;
+ if (!buf)
+ return -2;
+ if (*buf)
+ return -2;
+ if (ipc->downloading)
+ return -2;
- aaa = (char *)malloc(strlen(filename) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(filename) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "OPEN %s", filename);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
last_mod = extract_int(cret, 1);
extract_token(mimetype, cret, 2, '|', sizeof mimetype);
- ret = CtdlIPCReadDownload(ipc, buf, bytes, resume,
- progress_gauge_callback, cret);
+ ret = CtdlIPCReadDownload(ipc, buf, bytes, resume, progress_gauge_callback, cret);
/*
- ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, resume,
- progress_gauge_callback, cret);
- */
+ ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, resume,
+ progress_gauge_callback, cret);
+ */
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
- sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
- filename, mimetype);
+ sprintf(cret, "%d|%ld|%s|%s", (int) bytes, last_mod, filename, mimetype);
}
return ret;
}
/* OPNA */
-int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
- void **buf,
- 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 ret;
size_t bytes;
char mimetype[SIZ];
char aaa[SIZ];
- if (!cret) return -2;
- if (!buf) return -2;
- if (*buf) return -2;
- if (!part) return -2;
- if (!msgnum) return -2;
- if (ipc->downloading) return -2;
+ if (!cret)
+ return -2;
+ if (!buf)
+ return -2;
+ if (*buf)
+ return -2;
+ if (!part)
+ return -2;
+ if (!msgnum)
+ return -2;
+ if (ipc->downloading)
+ return -2;
sprintf(aaa, "OPNA %ld|%s", msgnum, part);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
- sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
- filename, mimetype);
+ sprintf(cret, "%d|%ld|%s|%s", (int) bytes, last_mod, filename, mimetype);
}
return ret;
}
/* OIMG */
-int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, 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 ret;
size_t bytes;
char mimetype[SIZ];
char *aaa;
- if (!cret) return -1;
- if (!buf) return -1;
- if (*buf) return -1;
- if (!filename) return -1;
- if (ipc->downloading) return -1;
+ if (!cret)
+ return -1;
+ if (!buf)
+ return -1;
+ if (*buf)
+ return -1;
+ if (!filename)
+ return -1;
+ if (ipc->downloading)
+ return -1;
- aaa = (char *)malloc(strlen(filename) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(filename) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "OIMG %s", filename);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
- sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
- filename, mimetype);
+ sprintf(cret, "%d|%ld|%s|%s", (int) bytes, last_mod, filename, mimetype);
}
return ret;
}
/* UOPN */
-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 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 ret;
char *aaa;
const char *MimeType;
long len;
- if (!cret) return -1;
- if (!save_as) return -1;
- if (!comment) return -1;
- if (!path) return -1;
- if (!*path) return -1;
- if (ipc->uploading) return -1;
+ if (!cret)
+ return -1;
+ if (!save_as)
+ return -1;
+ if (!comment)
+ return -1;
+ if (!path)
+ return -1;
+ if (!*path)
+ return -1;
+ if (ipc->uploading)
+ return -1;
uploadFP = fopen(path, "r");
- if (!uploadFP) return -2;
+ if (!uploadFP)
+ return -2;
len = fread(&MimeTestBuf[0], 1, 64, uploadFP);
- rewind (uploadFP);
- if (len < 0)
+ rewind(uploadFP);
+ if (len < 0)
return -3;
MimeType = GuessMimeType(&MimeTestBuf[0], len);
- aaa = (char *)malloc(strlen(save_as) + strlen(MimeType) + strlen(comment) + 7);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(save_as) + strlen(MimeType) + strlen(comment) + 7);
+ if (!aaa)
+ return -1;
- sprintf(aaa, "UOPN %s|%s|%s", save_as, MimeType, comment);
+ sprintf(aaa, "UOPN %s|%s|%s", save_as, MimeType, comment);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
free(aaa);
if (ret / 100 == 2) {
/* UIMG */
-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 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 ret;
FILE *uploadFP;
const char *MimeType;
long len;
- if (!cret) return -1;
- if (!save_as) return -1;
- if (!path && for_real) return -1;
- if (!*path && for_real) return -1;
- if (ipc->uploading) return -1;
+ if (!cret)
+ return -1;
+ if (!save_as)
+ return -1;
+ if (!path && for_real)
+ return -1;
+ if (!*path && for_real)
+ return -1;
+ if (ipc->uploading)
+ return -1;
- aaa = (char *)malloc(strlen(save_as) + 17);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(save_as) + 17);
+ if (!aaa)
+ return -1;
uploadFP = fopen(path, "r");
- if (!uploadFP) return -2;
+ if (!uploadFP)
+ return -2;
len = fread(&MimeTestBuf[0], 1, 64, uploadFP);
- rewind (uploadFP);
- if (len < 0)
+ rewind(uploadFP);
+ if (len < 0)
return -3;
MimeType = GuessMimeType(&MimeTestBuf[0], 64);
/* QUSR */
-int CtdlIPCQueryUsername(CtdlIPC *ipc, const char *username, char *cret)
+int CtdlIPCQueryUsername(CtdlIPC * ipc, const char *username, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "QUSR %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* LFLR */
-int CtdlIPCFloorListing(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCFloorListing(CtdlIPC * ipc, char **listing, char *cret)
{
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
return CtdlIPCGenericCommand(ipc, "LFLR", NULL, 0, listing, &bytes, cret);
}
/* CFLR */
-int CtdlIPCCreateFloor(CtdlIPC *ipc, int for_real, const char *name, char *cret)
+int CtdlIPCCreateFloor(CtdlIPC * ipc, int for_real, const char *name, char *cret)
{
int ret;
char aaa[SIZ];
- if (!cret) return -2;
- if (!name) return -2;
+ if (!cret)
+ return -2;
+ if (!name)
+ return -2;
sprintf(aaa, "CFLR %s|%d", name, for_real);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* KFLR */
-int CtdlIPCDeleteFloor(CtdlIPC *ipc, int for_real, int floornum, char *cret)
+int CtdlIPCDeleteFloor(CtdlIPC * ipc, int for_real, int floornum, char *cret)
{
char aaa[SIZ];
- if (!cret) return -1;
- if (floornum < 0) return -1;
+ if (!cret)
+ return -1;
+ if (floornum < 0)
+ return -1;
sprintf(aaa, "KFLR %d|%d", floornum, for_real);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* EFLR */
-int CtdlIPCEditFloor(CtdlIPC *ipc, int floornum, const char *floorname, char *cret)
+int CtdlIPCEditFloor(CtdlIPC * ipc, int floornum, const char *floorname, char *cret)
{
int ret;
char aaa[SIZ];
- if (!cret) return -2;
- if (!floorname) return -2;
- if (floornum < 0) return -2;
+ if (!cret)
+ return -2;
+ if (!floorname)
+ return -2;
+ if (floornum < 0)
+ return -2;
sprintf(aaa, "EFLR %d|%s", floornum, floorname);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
* You only need to fill out hostname, the defaults will be used if any of the
* other fields are not set properly.
*/
-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 ret;
char *aaa;
- if (developerid < 0 || clientid < 0 || revision < 0 ||
- !software_name) {
+ if (developerid < 0 || clientid < 0 || revision < 0 || !software_name) {
developerid = 8;
clientid = 0;
revision = CLIENT_VERSION - 600;
software_name = "Citadel (libcitadel)";
}
- if (!hostname) return -2;
+ if (!hostname)
+ return -2;
- aaa = (char *)malloc(strlen(software_name) + strlen(hostname) + 29);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(software_name) + strlen(hostname) + 29);
+ if (!aaa)
+ return -1;
- sprintf(aaa, "IDEN %d|%d|%d|%s|%s", developerid, clientid,
- revision, software_name, hostname);
+ sprintf(aaa, "IDEN %d|%d|%d|%s|%s", developerid, clientid, revision, software_name, hostname);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
free(aaa);
return ret;
/* SEXP */
-int CtdlIPCSendInstantMessage(CtdlIPC *ipc, const char *username, const char *text,
- char *cret)
+int CtdlIPCSendInstantMessage(CtdlIPC * ipc, const char *username, const char *text, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 8);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 8);
+ if (!aaa)
+ return -1;
if (text) {
sprintf(aaa, "SEXP %s|-", username);
- ret = CtdlIPCGenericCommand(ipc, aaa, text, strlen(text),
- NULL, NULL, cret);
+ ret = CtdlIPCGenericCommand(ipc, aaa, text, strlen(text), NULL, NULL, cret);
} else {
sprintf(aaa, "SEXP %s||", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* GEXP */
-int CtdlIPCGetInstantMessage(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCGetInstantMessage(CtdlIPC * ipc, char **listing, char *cret)
{
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
return CtdlIPCGenericCommand(ipc, "GEXP", NULL, 0, listing, &bytes, cret);
}
/* DEXP */
/* mode is 0 = enable, 1 = disable, 2 = status */
-int CtdlIPCEnableInstantMessageReceipt(CtdlIPC *ipc, int mode, char *cret)
+int CtdlIPCEnableInstantMessageReceipt(CtdlIPC * ipc, int mode, char *cret)
{
char aaa[64];
- if (!cret) return -2;
+ if (!cret)
+ return -2;
sprintf(aaa, "DEXP %d", mode);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* EBIO */
-int CtdlIPCSetBio(CtdlIPC *ipc, char *bio, char *cret)
+int CtdlIPCSetBio(CtdlIPC * ipc, char *bio, char *cret)
{
- if (!cret) return -2;
- if (!bio) return -2;
+ if (!cret)
+ return -2;
+ if (!bio)
+ return -2;
- return CtdlIPCGenericCommand(ipc, "EBIO", bio, strlen(bio),
- NULL, NULL, cret);
+ return CtdlIPCGenericCommand(ipc, "EBIO", bio, strlen(bio), NULL, NULL, cret);
}
/* RBIO */
-int CtdlIPCGetBio(CtdlIPC *ipc, const char *username, char **listing, char *cret)
+int CtdlIPCGetBio(CtdlIPC * ipc, const char *username, char **listing, char *cret)
{
int ret;
size_t bytes;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "RBIO %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, listing, &bytes, cret);
/* LBIO */
-int CtdlIPCListUsersWithBios(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCListUsersWithBios(CtdlIPC * ipc, char **listing, char *cret)
{
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
return CtdlIPCGenericCommand(ipc, "LBIO", NULL, 0, listing, &bytes, cret);
}
/* STEL */
-int CtdlIPCStealthMode(CtdlIPC *ipc, int mode, char *cret)
+int CtdlIPCStealthMode(CtdlIPC * ipc, int mode, char *cret)
{
char aaa[64];
- if (!cret) return -1;
+ if (!cret)
+ return -1;
sprintf(aaa, "STEL %d", mode ? 1 : 0);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* TERM */
-int CtdlIPCTerminateSession(CtdlIPC *ipc, int sid, char *cret)
+int CtdlIPCTerminateSession(CtdlIPC * ipc, int sid, char *cret)
{
char aaa[64];
- if (!cret) return -1;
+ if (!cret)
+ return -1;
sprintf(aaa, "TERM %d", sid);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* DOWN */
-int CtdlIPCTerminateServerNow(CtdlIPC *ipc, char *cret)
+int CtdlIPCTerminateServerNow(CtdlIPC * ipc, char *cret)
{
- if (!cret) return -1;
+ if (!cret)
+ return -1;
return CtdlIPCGenericCommand(ipc, "DOWN", NULL, 0, NULL, NULL, cret);
}
/* SCDN */
-int CtdlIPCTerminateServerScheduled(CtdlIPC *ipc, int mode, char *cret)
+int CtdlIPCTerminateServerScheduled(CtdlIPC * ipc, int mode, char *cret)
{
char aaa[16];
- if (!cret) return -1;
+ if (!cret)
+ return -1;
sprintf(aaa, "SCDN %d", mode ? 1 : 0);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* EMSG */
-int CtdlIPCEnterSystemMessage(CtdlIPC *ipc, const char *filename, const char *text,
- char *cret)
+int CtdlIPCEnterSystemMessage(CtdlIPC * ipc, const char *filename, const char *text, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!text) return -2;
- if (!filename) return -2;
+ if (!cret)
+ return -2;
+ if (!text)
+ return -2;
+ if (!filename)
+ return -2;
- aaa = (char *)malloc(strlen(filename) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(filename) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "EMSG %s", filename);
ret = CtdlIPCGenericCommand(ipc, aaa, text, strlen(text), NULL, NULL, cret);
/* HCHG */
-int CtdlIPCChangeHostname(CtdlIPC *ipc, const char *hostname, char *cret)
+int CtdlIPCChangeHostname(CtdlIPC * ipc, const char *hostname, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!hostname) return -2;
+ if (!cret)
+ return -2;
+ if (!hostname)
+ return -2;
- aaa = (char *)malloc(strlen(hostname) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(hostname) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "HCHG %s", hostname);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* RCHG */
-int CtdlIPCChangeRoomname(CtdlIPC *ipc, const char *roomname, char *cret)
+int CtdlIPCChangeRoomname(CtdlIPC * ipc, const char *roomname, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!roomname) return -2;
+ if (!cret)
+ return -2;
+ if (!roomname)
+ return -2;
- aaa = (char *)malloc(strlen(roomname) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(roomname) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "RCHG %s", roomname);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* UCHG */
-int CtdlIPCChangeUsername(CtdlIPC *ipc, const char *username, char *cret)
+int CtdlIPCChangeUsername(CtdlIPC * ipc, const char *username, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!username) return -2;
+ if (!cret)
+ return -2;
+ if (!username)
+ return -2;
- aaa = (char *)malloc(strlen(username) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(username) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "UCHG %s", username);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* TIME */
/* This function returns the actual server time reported, or 0 if error */
-time_t CtdlIPCServerTime(CtdlIPC *ipc, char *cret)
+time_t CtdlIPCServerTime(CtdlIPC * ipc, char *cret)
{
time_t tret;
int ret;
/* AGUP */
-int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who, struct ctdluser **uret, char *cret)
+int CtdlIPCAideGetUserParameters(CtdlIPC * ipc, const char *who, struct ctdluser **uret, char *cret)
{
int ret;
char aaa[SIZ];
- if (!cret) return -2;
- if (!uret) return -2;
- if (!*uret) *uret = (struct ctdluser *)calloc(1, sizeof(struct ctdluser));
- if (!*uret) return -1;
+ if (!cret)
+ return -2;
+ if (!uret)
+ return -2;
+ if (!*uret)
+ *uret = (struct ctdluser *) calloc(1, sizeof(struct ctdluser));
+ if (!*uret)
+ return -1;
sprintf(aaa, "AGUP %s", who);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* ASUP */
-int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char *cret)
+int CtdlIPCAideSetUserParameters(CtdlIPC * ipc, const struct ctdluser *uret, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!uret) return -2;
+ if (!cret)
+ return -2;
+ if (!uret)
+ return -2;
- aaa = (char *)malloc(strlen(uret->fullname) + strlen(uret->password) + 84);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(uret->fullname) + strlen(uret->password) + 84);
+ if (!aaa)
+ return -1;
sprintf(aaa, "ASUP %s|%s|%d|%ld|%ld|%d|%ld|%ld|%d",
uret->fullname, uret->password, uret->flags, uret->timescalled,
- uret->posted, uret->axlevel, uret->usernum, uret->lastcall, uret->USuserpurge
- );
+ uret->posted, uret->axlevel, uret->usernum, uret->lastcall, uret->USuserpurge);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
free(aaa);
return ret;
/* AGEA */
-int CtdlIPCAideGetEmailAddresses(CtdlIPC *ipc, const char *who, char *target_buf, char *cret)
+int CtdlIPCAideGetEmailAddresses(CtdlIPC * ipc, const char *who, char *target_buf, char *cret)
{
int ret;
char aaa[SIZ];
/* ASEA */
-int CtdlIPCAideSetEmailAddresses(CtdlIPC *ipc, const char *who, char *emailaddrs, char *cret)
+int CtdlIPCAideSetEmailAddresses(CtdlIPC * ipc, const char *who, char *emailaddrs, char *cret)
{
char aaa[SIZ];
int ret;
- if (!who) return -2;
- if (!emailaddrs) return -2;
- if (!cret) return -2;
+ if (!who)
+ return -2;
+ if (!emailaddrs)
+ return -2;
+ if (!cret)
+ return -2;
sprintf(aaa, "ASEA %s", who);
ret = CtdlIPCGenericCommand(ipc, aaa, emailaddrs, 0, NULL, NULL, cret);
/* GPEX */
/* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */
/* caller must free the struct ExpirePolicy */
-int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, GPEXWhichPolicy which,
- struct ExpirePolicy **policy, char *cret)
+int CtdlIPCGetMessageExpirationPolicy(CtdlIPC * ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret)
{
static char *proto[] = {
strof(roompolicy),
char cmd[256];
int ret;
- if (!cret) return -2;
- if (!policy) return -2;
- if (!*policy) *policy = (struct ExpirePolicy *)calloc(1, sizeof(struct ExpirePolicy));
- if (!*policy) return -1;
- if (which < 0 || which > 3) return -2;
-
+ if (!cret)
+ return -2;
+ if (!policy)
+ return -2;
+ if (!*policy)
+ *policy = (struct ExpirePolicy *) calloc(1, sizeof(struct ExpirePolicy));
+ if (!*policy)
+ return -1;
+ if (which < 0 || which > 3)
+ return -2;
+
sprintf(cmd, "GPEX %s", proto[which]);
ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
if (ret / 100 == 2) {
/* SPEX */
/* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */
/* policy is 0 = inherit, 1 = no purge, 2 = by count, 3 = by age (days) */
-int CtdlIPCSetMessageExpirationPolicy(CtdlIPC *ipc, int which,
- struct ExpirePolicy *policy, char *cret)
+int CtdlIPCSetMessageExpirationPolicy(CtdlIPC * ipc, int which, struct ExpirePolicy *policy, char *cret)
{
char aaa[38];
char *whichvals[] = { "room", "floor", "site", "mailboxes" };
- if (!cret) return -2;
- if (which < 0 || which > 3) return -2;
- if (!policy) return -2;
- if (policy->expire_mode < 0 || policy->expire_mode > 3) return -2;
- if (policy->expire_mode >= 2 && policy->expire_value < 1) return -2;
+ if (!cret)
+ return -2;
+ if (which < 0 || which > 3)
+ return -2;
+ if (!policy)
+ return -2;
+ if (policy->expire_mode < 0 || policy->expire_mode > 3)
+ return -2;
+ if (policy->expire_mode >= 2 && policy->expire_value < 1)
+ return -2;
- sprintf(aaa, "SPEX %s|%d|%d", whichvals[which],
- policy->expire_mode, policy->expire_value);
+ sprintf(aaa, "SPEX %s|%d|%d", whichvals[which], policy->expire_mode, policy->expire_value);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}
/* CONF GET */
-int CtdlIPCGetSystemConfig(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCGetSystemConfig(CtdlIPC * ipc, char **listing, char *cret)
{
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
- return CtdlIPCGenericCommand(ipc, "CONF GET", NULL, 0,
- listing, &bytes, cret);
+ return CtdlIPCGenericCommand(ipc, "CONF GET", NULL, 0, listing, &bytes, cret);
}
/* CONF SET */
-int CtdlIPCSetSystemConfig(CtdlIPC *ipc, const char *listing, char *cret)
+int CtdlIPCSetSystemConfig(CtdlIPC * ipc, const char *listing, char *cret)
{
- if (!cret) return -2;
- if (!listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
- return CtdlIPCGenericCommand(ipc, "CONF SET", listing, strlen(listing),
- NULL, NULL, cret);
+ return CtdlIPCGenericCommand(ipc, "CONF SET", listing, strlen(listing), NULL, NULL, cret);
}
/* CONF GETSYS */
-int CtdlIPCGetSystemConfigByType(CtdlIPC *ipc, const char *mimetype, char **listing, char *cret)
+int CtdlIPCGetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, char **listing, char *cret)
{
int ret;
char *aaa;
size_t bytes;
- if (!cret) return -2;
- if (!mimetype) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!mimetype)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
aaa = malloc(strlen(mimetype) + 13);
- if (!aaa) return -1;
+ if (!aaa)
+ return -1;
sprintf(aaa, "CONF GETSYS|%s", mimetype);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, listing, &bytes, cret);
free(aaa);
/* CONF PUTSYS */
-int CtdlIPCSetSystemConfigByType(CtdlIPC *ipc, const char *mimetype, const char *listing, char *cret)
+int CtdlIPCSetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, const char *listing, char *cret)
{
int ret;
char *aaa;
- if (!cret) return -2;
- if (!mimetype) return -2;
- if (!listing) return -2;
+ if (!cret)
+ return -2;
+ if (!mimetype)
+ return -2;
+ if (!listing)
+ return -2;
aaa = malloc(strlen(mimetype) + 13);
- if (!aaa) return -1;
+ if (!aaa)
+ return -1;
sprintf(aaa, "CONF PUTSYS|%s", mimetype);
ret = CtdlIPCGenericCommand(ipc, aaa, listing, strlen(listing), NULL, NULL, cret);
free(aaa);
/* GNET */
-int CtdlIPCGetRoomNetworkConfig(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCGetRoomNetworkConfig(CtdlIPC * ipc, char **listing, char *cret)
{
size_t bytes;
- if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
+ if (*listing)
+ return -2;
return CtdlIPCGenericCommand(ipc, "GNET", NULL, 0, listing, &bytes, cret);
}
/* SNET */
-int CtdlIPCSetRoomNetworkConfig(CtdlIPC *ipc, const char *listing, char *cret)
+int CtdlIPCSetRoomNetworkConfig(CtdlIPC * ipc, const char *listing, char *cret)
{
- if (!cret) return -2;
- if (!listing) return -2;
+ if (!cret)
+ return -2;
+ if (!listing)
+ return -2;
return CtdlIPCGenericCommand(ipc, "SNET", listing, strlen(listing), NULL, NULL, cret);
}
/* REQT */
-int CtdlIPCRequestClientLogout(CtdlIPC *ipc, int session, char *cret)
+int CtdlIPCRequestClientLogout(CtdlIPC * ipc, int session, char *cret)
{
char aaa[64];
- if (!cret) return -2;
- if (session < 0) return -2;
+ if (!cret)
+ return -2;
+ if (session < 0)
+ return -2;
sprintf(aaa, "REQT %d", session);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* SEEN */
-int CtdlIPCSetMessageSeen(CtdlIPC *ipc, long msgnum, int seen, char *cret)
+int CtdlIPCSetMessageSeen(CtdlIPC * ipc, long msgnum, int seen, char *cret)
{
char aaa[27];
- if (!cret) return -2;
- if (msgnum < 0) return -2;
+ if (!cret)
+ return -2;
+ if (msgnum < 0)
+ return -2;
sprintf(aaa, "SEEN %ld|%d", msgnum, seen ? 1 : 0);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* STLS */
-int CtdlIPCStartEncryption(CtdlIPC *ipc, char *cret)
+int CtdlIPCStartEncryption(CtdlIPC * ipc, char *cret)
{
int a;
int r;
}
/* Pointless flag waving */
#if SSLEAY_VERSION_NUMBER >= 0x0922
- SSL_set_session_id_context(temp_ssl, (const unsigned char*) "Citadel SID", 14);
+ SSL_set_session_id_context(temp_ssl, (const unsigned char *) "Citadel SID", 14);
#endif
/* Associate network connection with SSL object */
ipc->ssl = temp_ssl;
error_printf("Encrypting with %s cipher %s\n",
- SSL_CIPHER_get_version(SSL_get_current_cipher(ipc->ssl)),
- SSL_CIPHER_get_name(SSL_get_current_cipher(ipc->ssl))
- );
+ SSL_CIPHER_get_version(SSL_get_current_cipher(ipc->ssl)), SSL_CIPHER_get_name(SSL_get_current_cipher(ipc->ssl))
+ );
return r;
#else
return 0;
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_OPENSSL */
}
#ifdef HAVE_OPENSSL
-static void endtls(SSL *ssl)
+static void endtls(SSL * ssl)
{
if (ssl) {
SSL_shutdown(ssl);
/* QDIR */
-int CtdlIPCDirectoryLookup(CtdlIPC *ipc, const char *address, char *cret)
+int CtdlIPCDirectoryLookup(CtdlIPC * ipc, const char *address, char *cret)
{
int ret;
char *aaa;
- if (!address) return -2;
- if (!cret) return -2;
+ if (!address)
+ return -2;
+ if (!cret)
+ return -2;
- aaa = (char *)malloc(strlen(address) + 6);
- if (!aaa) return -1;
+ aaa = (char *) malloc(strlen(address) + 6);
+ if (!aaa)
+ return -1;
sprintf(aaa, "QDIR %s", address);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
/* IPGM */
-int CtdlIPCInternalProgram(CtdlIPC *ipc, int secret, char *cret)
+int CtdlIPCInternalProgram(CtdlIPC * ipc, int secret, char *cret)
{
char aaa[30];
- if (!cret) return -2;
+ if (!cret)
+ return -2;
sprintf(aaa, "IPGM %d", secret);
return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}
/* Read a listing from the server up to 000. Append to dest if it exists */
-char *CtdlIPCReadListing(CtdlIPC *ipc, char *dest)
+char *CtdlIPCReadListing(CtdlIPC * ipc, char *dest)
{
size_t length = 0;
size_t linelength;
while (CtdlIPC_getline(ipc, aaa), strcmp(aaa, "000")) {
linelength = strlen(aaa);
- ret = (char *)realloc(ret, (size_t)(length + linelength + 2));
+ ret = (char *) realloc(ret, (size_t) (length + linelength + 2));
if (ret) {
strcpy(&ret[length], aaa);
length += linelength;
}
}
- return(ret);
+ return (ret);
}
/* Send a listing to the server; generate the ending 000. */
-int CtdlIPCSendListing(CtdlIPC *ipc, const char *listing)
+int CtdlIPCSendListing(CtdlIPC * ipc, const char *listing)
{
char *text;
- text = (char *)malloc(strlen(listing) + 6);
+ text = (char *) malloc(strlen(listing) + 6);
if (text) {
strcpy(text, listing);
while (text[strlen(text) - 1] == '\n')
/* Partial read of file from server */
-size_t CtdlIPCPartialRead(CtdlIPC *ipc, void **buf, size_t offset, size_t bytes, char *cret)
+size_t CtdlIPCPartialRead(CtdlIPC * ipc, void **buf, size_t offset, size_t bytes, char *cret)
{
size_t len = 0;
char aaa[SIZ];
- if (!buf) return 0;
- if (!cret) return 0;
- if (bytes < 1) return 0;
+ if (!buf)
+ return 0;
+ if (!cret)
+ return 0;
+ if (bytes < 1)
+ return 0;
CtdlIPC_lock(ipc);
- sprintf(aaa, "READ %d|%d", (int)offset, (int)bytes);
+ sprintf(aaa, "READ %d|%d", (int) offset, (int) bytes);
CtdlIPC_putline(ipc, aaa);
CtdlIPC_getline(ipc, aaa);
if (aaa[0] != '6')
strcpy(cret, &aaa[4]);
else {
len = extract_long(&aaa[4], 0);
- *buf = (void *)realloc(*buf, (size_t)(offset + len));
+ *buf = (void *) realloc(*buf, (size_t) (offset + len));
if (*buf) {
/* I know what I'm doing */
- serv_read(ipc, ((char *)(*buf) + offset), len);
+ serv_read(ipc, ((char *) (*buf) + offset), len);
} else {
/* We have to read regardless */
serv_read(ipc, aaa, len);
/* CLOS */
-int CtdlIPCEndDownload(CtdlIPC *ipc, char *cret)
+int CtdlIPCEndDownload(CtdlIPC * ipc, char *cret)
{
int ret;
- if (!cret) return -2;
- if (!ipc->downloading) return -2;
+ if (!cret)
+ return -2;
+ if (!ipc->downloading)
+ return -2;
ret = CtdlIPCGenericCommand(ipc, "CLOS", NULL, 0, NULL, NULL, cret);
if (ret / 100 == 2)
/* MSGP */
-int CtdlIPCSpecifyPreferredFormats(CtdlIPC *ipc, char *cret, char *formats) {
+int CtdlIPCSpecifyPreferredFormats(CtdlIPC * ipc, char *cret, char *formats)
+{
int ret;
char cmd[SIZ];
-
+
snprintf(cmd, sizeof cmd, "MSGP %s", formats);
ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
return ret;
/* READ */
-int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
- void (*progress_gauge_callback)
- (CtdlIPC*, unsigned long, unsigned long),
- 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)
{
size_t len;
- if (!cret) return -1;
- if (!buf) return -1;
- if (*buf) return -1;
- if (!ipc->downloading) return -1;
+ if (!cret)
+ return -1;
+ if (!buf)
+ return -1;
+ if (*buf)
+ return -1;
+ if (!ipc->downloading)
+ return -1;
len = resume;
if (progress_gauge_callback)
}
/* READ - pipelined */
-int CtdlIPCHighSpeedReadDownload(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)
{
size_t len;
- int calls; /* How many calls in the pipeline */
- int i; /* iterator */
+ int calls; /* How many calls in the pipeline */
+ int i; /* iterator */
char aaa[4096];
- if (!cret) return -1;
- if (!buf) return -1;
- if (*buf) return -1;
- if (!ipc->downloading) return -1;
+ if (!cret)
+ return -1;
+ if (!buf)
+ return -1;
+ if (*buf)
+ return -1;
+ if (!ipc->downloading)
+ return -1;
- *buf = (void *)realloc(*buf, bytes - resume);
- if (!*buf) return -1;
+ *buf = (void *) realloc(*buf, bytes - resume);
+ if (!*buf)
+ return -1;
len = 0;
CtdlIPC_lock(ipc);
/* How many calls will be in the pipeline? */
calls = (bytes - resume) / 4096;
- if ((bytes - resume) % 4096) calls++;
+ if ((bytes - resume) % 4096)
+ calls++;
/* Send all requests at once */
for (i = 0; i < calls; i++) {
- sprintf(aaa, "READ %d|4096", (int)(i * 4096 + resume) );
+ sprintf(aaa, "READ %d|4096", (int) (i * 4096 + resume));
CtdlIPC_putline(ipc, aaa);
}
else {
len = extract_long(&aaa[4], 0);
/* I know what I'm doing */
- serv_read(ipc, ((char *)(*buf) + (i * 4096)), len);
+ serv_read(ipc, ((char *) (*buf) + (i * 4096)), len);
}
if (progress_gauge_callback)
progress_gauge_callback(ipc, i * 4096 + len, bytes);
/* UCLS */
-int CtdlIPCEndUpload(CtdlIPC *ipc, int discard, char *cret)
+int CtdlIPCEndUpload(CtdlIPC * ipc, int discard, char *cret)
{
int ret;
char cmd[8];
- if (!cret) return -1;
- if (!ipc->uploading) return -1;
+ if (!cret)
+ return -1;
+ if (!ipc->uploading)
+ return -1;
sprintf(cmd, "UCLS %d", discard ? 0 : 1);
ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
/* WRIT */
-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 ret = -1;
size_t offset = 0;
FILE *fd = uploadFP;
int ferr;
- if (!cret) return -1;
+ if (!cret)
+ return -1;
fseek(fd, 0L, SEEK_END);
bytes = ftell(fd);
/* Read some data in */
to_write = fread(buf, 1, 4096, fd);
if (!to_write) {
- if (feof(fd) || ferror(fd)) break;
+ if (feof(fd) || ferror(fd))
+ break;
}
- sprintf(aaa, "WRIT %d", (int)to_write);
+ sprintf(aaa, "WRIT %d", (int) to_write);
CtdlIPC_putline(ipc, aaa);
CtdlIPC_getline(ipc, aaa);
strcpy(cret, &aaa[4]);
ret = atoi(aaa);
if (aaa[0] == '7') {
to_write = extract_long(&aaa[4], 0);
-
+
serv_write(ipc, buf, to_write);
offset += to_write;
if (progress_gauge_callback)
progress_gauge_callback(ipc, offset, bytes);
/* Detect short reads and back up if needed */
/* offset will never be negative anyway */
- fseek(fd, (signed)offset, SEEK_SET);
+ fseek(fd, (signed) offset, SEEK_SET);
} else {
break;
}
* protocol_response as described above. Some commands send additional
* data in this string.
*/
-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 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)
{
char buf[SIZ];
int ret;
- if (!command) return -2;
- if (!proto_response) return -2;
+ if (!command)
+ return -2;
+ if (!proto_response)
+ return -2;
CtdlIPC_lock(ipc);
CtdlIPC_putline(ipc, command);
ret = atoi(proto_response);
strcpy(proto_response, &proto_response[4]);
switch (ret / 100) {
- default: /* Unknown, punt */
- case 2: /* OK */
- case 3: /* MORE_DATA */
- case 5: /* ERROR */
+ default: /* Unknown, punt */
+ case 2: /* OK */
+ case 3: /* MORE_DATA */
+ case 5: /* ERROR */
/* Don't need to do anything */
break;
- case 1: /* LISTING_FOLLOWS */
+ case 1: /* LISTING_FOLLOWS */
if (to_receive && !*to_receive && bytes_to_receive) {
*to_receive = CtdlIPCReadListing(ipc, NULL);
- } else { /* Drain */
- while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) ;
+ } else { /* Drain */
+ while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000"));
ret = -ret;
}
break;
- case 4: /* SEND_LISTING */
+ case 4: /* SEND_LISTING */
if (to_send) {
CtdlIPCSendListing(ipc, to_send);
} else {
ret = -ret;
}
break;
- case 6: /* BINARY_FOLLOWS */
+ case 6: /* BINARY_FOLLOWS */
if (to_receive && !*to_receive && bytes_to_receive) {
- *bytes_to_receive =
- extract_long(proto_response, 0);
+ *bytes_to_receive = extract_long(proto_response, 0);
*to_receive = (char *)
- malloc((size_t)*bytes_to_receive);
+ malloc((size_t) * bytes_to_receive);
if (!*to_receive) {
ret = -1;
} else {
- serv_read(ipc, *to_receive,
- *bytes_to_receive);
+ serv_read(ipc, *to_receive, *bytes_to_receive);
}
} else {
/* Drain */
ret = -ret;
}
break;
- case 7: /* SEND_BINARY */
+ case 7: /* SEND_BINARY */
if (to_send && bytes_to_send) {
serv_write(ipc, to_send, bytes_to_send);
} else if (bytes_to_send) {
}
serv_write(ipc, buf, fake);
ret = -ret;
- } /* else who knows? DANGER WILL ROBINSON */
+ } /* else who knows? DANGER WILL ROBINSON */
break;
- case 8: /* START_CHAT_MODE */
+ case 8: /* START_CHAT_MODE */
if (!strncasecmp(command, "CHAT", 4)) {
/* Don't call chatmode with generic! */
CtdlIPC_putline(ipc, "/quit");
CtdlIPC_putline(ipc, "000");
ret = -ret;
}
- if (to_receive && !*to_receive
- && bytes_to_receive) {
+ if (to_receive && !*to_receive && bytes_to_receive) {
*to_receive = CtdlIPCReadListing(ipc, NULL);
- } else { /* Drain */
- while (CtdlIPC_getline(ipc, buf),
- strcmp(buf, "000")) ;
+ } else { /* Drain */
+ while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000"));
ret = -ret;
}
}
break;
- case 9: /* ASYNC_MSG */
+ case 9: /* ASYNC_MSG */
/* CtdlIPCDoAsync(ret, proto_response); */
free(CtdlIPCReadListing(ipc, NULL)); /* STUB FIXME */
break;
int sock = (-1);
if ((host == NULL) || IsEmptyStr(host)) {
- service = DEFAULT_HOST ;
+ service = DEFAULT_HOST;
}
if ((service == NULL) || IsEmptyStr(service)) {
- service = DEFAULT_PORT ;
+ service = DEFAULT_PORT;
}
memset(&hints, 0x00, sizeof(hints));
* Handle numeric IPv4 and IPv6 addresses
*/
rc = inet_pton(AF_INET, host, &serveraddr);
- if (rc == 1) { /* dotted quad */
+ if (rc == 1) { /* dotted quad */
hints.ai_family = AF_INET;
hints.ai_flags |= AI_NUMERICHOST;
- }
- else {
+ } else {
rc = inet_pton(AF_INET6, host, &serveraddr);
- if (rc == 1) { /* IPv6 address */
+ if (rc == 1) { /* IPv6 address */
hints.ai_family = AF_INET6;
hints.ai_flags |= AI_NUMERICHOST;
}
rc = getaddrinfo(host, service, &hints, &res);
if (rc != 0) {
- return(-1);
+ return (-1);
}
/*
*/
for (ai = res; ai != NULL; ai = ai->ai_next) {
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (sock < 0) return(-1);
+ if (sock < 0)
+ return (-1);
rc = connect(sock, ai->ai_addr, ai->ai_addrlen);
if (rc >= 0) {
- return(sock); /* Connected! */
- }
- else {
- close(sock); /* Failed. Close the socket to avoid fd leak! */
+ return (sock); /* Connected! */
+ } else {
+ close(sock); /* Failed. Close the socket to avoid fd leak! */
}
}
- return(-1);
+ return (-1);
}
/*
* input binary data from socket
*/
-static void serv_read(CtdlIPC *ipc, char *buf, unsigned int bytes)
+static void serv_read(CtdlIPC * ipc, char *buf, unsigned int bytes)
{
unsigned int len, rlen;
/*
* send binary to server
*/
-void serv_write(CtdlIPC *ipc, const char *buf, unsigned int nbytes)
+void serv_write(CtdlIPC * ipc, const char *buf, unsigned int nbytes)
{
unsigned int bytes_written = 0;
int retval;
}
#endif
while (bytes_written < nbytes) {
- retval = write(ipc->sock, &buf[bytes_written],
- nbytes - bytes_written);
+ retval = write(ipc->sock, &buf[bytes_written], nbytes - bytes_written);
if (retval < 1) {
connection_died(ipc, 0);
return;
/*
* input binary data from encrypted connection
*/
-static void serv_read_ssl(CtdlIPC* ipc, char *buf, unsigned int bytes)
+static void serv_read_ssl(CtdlIPC * ipc, char *buf, unsigned int bytes)
{
int len, rlen;
char junk[1];
long errval;
errval = SSL_get_error(ipc->ssl, rlen);
- if (errval == SSL_ERROR_WANT_READ ||
- errval == SSL_ERROR_WANT_WRITE) {
+ if (errval == SSL_ERROR_WANT_READ || errval == SSL_ERROR_WANT_WRITE) {
sleep(1);
continue;
}
return;
}
***/
- error_printf("SSL_read in serv_read: %s\n",
- ERR_reason_error_string(ERR_peek_error()));
+ error_printf("SSL_read in serv_read: %s\n", ERR_reason_error_string(ERR_peek_error()));
connection_died(ipc, 1);
return;
}
/*
* send binary to server encrypted
*/
-static void serv_write_ssl(CtdlIPC *ipc, const char *buf, unsigned int nbytes)
+static void serv_write_ssl(CtdlIPC * ipc, const char *buf, unsigned int nbytes)
{
unsigned int bytes_written = 0;
int retval;
ERR_print_errors_fp(stderr);
}
}
- retval = SSL_write(ipc->ssl, &buf[bytes_written],
- nbytes - bytes_written);
+ retval = SSL_write(ipc->ssl, &buf[bytes_written], nbytes - bytes_written);
if (retval < 1) {
long errval;
errval = SSL_get_error(ipc->ssl, retval);
- if (errval == SSL_ERROR_WANT_READ ||
- errval == SSL_ERROR_WANT_WRITE) {
+ if (errval == SSL_ERROR_WANT_READ || errval == SSL_ERROR_WANT_WRITE) {
sleep(1);
continue;
}
- if (errval == SSL_ERROR_ZERO_RETURN ||
- errval == SSL_ERROR_SSL) {
- serv_write(ipc, &buf[bytes_written],
- nbytes - bytes_written);
+ if (errval == SSL_ERROR_ZERO_RETURN || errval == SSL_ERROR_SSL) {
+ serv_write(ipc, &buf[bytes_written], nbytes - bytes_written);
return;
}
- error_printf("SSL_write in serv_write: %s\n",
- ERR_reason_error_string(ERR_peek_error()));
+ error_printf("SSL_write in serv_write: %s\n", ERR_reason_error_string(ERR_peek_error()));
connection_died(ipc, 1);
return;
}
int a;
const SSL_METHOD *ssl_method;
DH *dh;
-
+
/* already done init */
if (ssl_ctx) {
return;
DH_free(dh);
}
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_OPENSSL */
-int
-ReadNetworkChunk(CtdlIPC* ipc)
+int ReadNetworkChunk(CtdlIPC * ipc)
{
fd_set read_fd;
int ret = 0;
tv.tv_usec = 1000;
/*tries = 0; */
n = 0;
- while (1)
- {
- errno=0;
+ while (1) {
+ errno = 0;
FD_ZERO(&read_fd);
FD_SET(ipc->sock, &read_fd);
- ret = select(ipc->sock+1, &read_fd, NULL, NULL, &tv);
-
+ ret = select(ipc->sock + 1, &read_fd, NULL, NULL, &tv);
+
if (ret > 0) {
-
+
*(ipc->BufPtr) = '\0';
- n = recv(ipc->sock, ipc->BufPtr, ipc->BufSize - (ipc->BufPtr - ipc->Buf) - 1, 0);
+ n = recv(ipc->sock, ipc->BufPtr, ipc->BufSize - (ipc->BufPtr - ipc->Buf) - 1, 0);
if (n > 0) {
- ipc->BufPtr[n]='\0';
+ ipc->BufPtr[n] = '\0';
ipc->BufUsed += n;
return n;
- }
- else
+ } else
return n;
- }
- else if (ret < 0) {
+ } else if (ret < 0) {
if (!(errno == EINTR || errno == EAGAIN))
- error_printf( "\nselect failed: %d %s\n", err, strerror(err));
+ error_printf("\nselect failed: %d %s\n", err, strerror(err));
return -1;
- }/*
- else {
- tries ++;
- if (tries >= 10)
- n = read(ipc->sock, ipc->BufPtr, ipc->BufSize - (ipc->BufPtr - ipc->Buf) - 1);
- if (n > 0) {
- ipc->BufPtr[n]='\0';
- ipc->BufUsed += n;
- return n;
- }
- else {
- connection_died(ipc, 0);
- return -1;
- }
- }*/
+ } /*
+ else {
+ tries ++;
+ if (tries >= 10)
+ n = read(ipc->sock, ipc->BufPtr, ipc->BufSize - (ipc->BufPtr - ipc->Buf) - 1);
+ if (n > 0) {
+ ipc->BufPtr[n]='\0';
+ ipc->BufUsed += n;
+ return n;
+ }
+ else {
+ connection_died(ipc, 0);
+ return -1;
+ }
+ } */
}
}
*/
#ifdef CHUNKED_READ
-static void CtdlIPC_getline(CtdlIPC* ipc, char *buf)
+static void CtdlIPC_getline(CtdlIPC * ipc, char *buf)
{
int i, ntries;
char *aptr, *bptr, *aeptr, *beptr;
-// error_printf("---\n");
+// error_printf("---\n");
beptr = buf + SIZ;
#if defined(HAVE_OPENSSL)
- if (ipc->ssl) {
-
+ if (ipc->ssl) {
+
/* Read one character at a time. */
- for (i = 0;; i++) {
- serv_read(ipc, &buf[i], 1);
- if (buf[i] == '\n' || i == (SIZ-1))
- break;
- }
-
+ for (i = 0;; i++) {
+ serv_read(ipc, &buf[i], 1);
+ if (buf[i] == '\n' || i == (SIZ - 1))
+ break;
+ }
+
/* If we got a long line, discard characters until the newline. */
- if (i == (SIZ-1))
- while (buf[i] != '\n')
- serv_read(ipc, &buf[i], 1);
-
+ if (i == (SIZ - 1))
+ while (buf[i] != '\n')
+ serv_read(ipc, &buf[i], 1);
+
/* Strip the trailing newline (and carriage return, if present) */
- if (i>=0 && buf[i] == 10) buf[i--] = 0;
- if (i>=0 && buf[i] == 13) buf[i--] = 0;
- }
- else
+ if (i >= 0 && buf[i] == 10)
+ buf[i--] = 0;
+ if (i >= 0 && buf[i] == 13)
+ buf[i--] = 0;
+ } else
#endif
{
- if (ipc->Buf == NULL)
- {
+ if (ipc->Buf == NULL) {
ipc->BufSize = SIZ;
- ipc->Buf = (char*) malloc(ipc->BufSize + 10);
+ ipc->Buf = (char *) malloc(ipc->BufSize + 10);
*(ipc->Buf) = '\0';
ipc->BufPtr = ipc->Buf;
}
ntries = 0;
-// while ((ipc->BufUsed == 0)||(ntries++ > 10))
+// while ((ipc->BufUsed == 0)||(ntries++ > 10))
if (ipc->BufUsed == 0)
ReadNetworkChunk(ipc);
-//// if (ipc->BufUsed != 0) while (1)
+//// if (ipc->BufUsed != 0) while (1)
bptr = buf;
- while (1)
- {
+ while (1) {
aptr = ipc->BufPtr;
aeptr = ipc->Buf + ipc->BufSize;
- while ((aptr < aeptr) &&
- (bptr < beptr) &&
- (*aptr != '\0') &&
- (*aptr != '\n'))
+ while ((aptr < aeptr) && (bptr < beptr) && (*aptr != '\0') && (*aptr != '\n'))
*(bptr++) = *(aptr++);
- if ((*aptr == '\n') && (aptr < aeptr))
- {
+ if ((*aptr == '\n') && (aptr < aeptr)) {
/* Terminate it right, remove the line breaks */
while ((aptr < aeptr) && ((*aptr == '\n') || (*aptr == '\r')))
- aptr ++;
- while ((aptr < aeptr ) && (*(aptr + 1) == '\0') )
- aptr ++;
+ aptr++;
+ while ((aptr < aeptr) && (*(aptr + 1) == '\0'))
+ aptr++;
*(bptr++) = '\0';
-// fprintf(stderr, "parsing %d %d %d - %d %d %d %s\n", ipc->BufPtr - ipc->Buf, aptr - ipc->BufPtr, ipc->BufUsed , *aptr, *(aptr-1), *(aptr+1), buf);
- if ((bptr > buf + 1) && (*(bptr-1) == '\r'))
+// fprintf(stderr, "parsing %d %d %d - %d %d %d %s\n", ipc->BufPtr - ipc->Buf, aptr - ipc->BufPtr, ipc->BufUsed , *aptr, *(aptr-1), *(aptr+1), buf);
+ if ((bptr > buf + 1) && (*(bptr - 1) == '\r'))
*(--bptr) = '\0';
-
+
/* is there more in the buffer we need to read later? */
- if (ipc->Buf + ipc->BufUsed > aptr)
- {
+ if (ipc->Buf + ipc->BufUsed > aptr) {
ipc->BufPtr = aptr;
- }
- else
- {
+ } else {
ipc->BufUsed = 0;
ipc->BufPtr = ipc->Buf;
}
-// error_printf("----bla6\n");
+// error_printf("----bla6\n");
return;
-
- }/* should we move our read stuf to the bufferstart so we have more space at the end? */
- else if ((ipc->BufPtr != ipc->Buf) &&
- (ipc->BufUsed > (ipc->BufSize - (ipc->BufSize / 4))))
- {
+
+ } /* should we move our read stuf to the bufferstart so we have more space at the end? */
+ else if ((ipc->BufPtr != ipc->Buf) && (ipc->BufUsed > (ipc->BufSize - (ipc->BufSize / 4)))) {
size_t NewBufSize = ipc->BufSize * 2;
int delta = (ipc->BufPtr - ipc->Buf);
char *NewBuf;
/* if the line would end after our buffer, we should use a bigger buffer. */
- NewBuf = (char *)malloc (NewBufSize + 10);
- memcpy (NewBuf, ipc->BufPtr, ipc->BufUsed - delta);
+ NewBuf = (char *) malloc(NewBufSize + 10);
+ memcpy(NewBuf, ipc->BufPtr, ipc->BufUsed - delta);
free(ipc->Buf);
ipc->Buf = ipc->BufPtr = NewBuf;
ipc->BufUsed -= delta;
ipc->BufSize = NewBufSize;
}
- if (ReadNetworkChunk(ipc) <0)
- {
-// error_printf("----bla\n");
+ if (ReadNetworkChunk(ipc) < 0) {
+// error_printf("----bla\n");
return;
}
}
-/// error_printf("----bl45761%s\nipc->BufUsed");
+/// error_printf("----bl45761%s\nipc->BufUsed");
}
-// error_printf("----bla1\n");
+// error_printf("----bla1\n");
}
-#else /* CHUNKED_READ */
+#else /* CHUNKED_READ */
-static void CtdlIPC_getline(CtdlIPC* ipc, char *buf)
+static void CtdlIPC_getline(CtdlIPC * ipc, char *buf)
{
int i;
/* Read one character at a time. */
for (i = 0;; i++) {
serv_read(ipc, &buf[i], 1);
- if (buf[i] == '\n' || i == (SIZ-1))
+ if (buf[i] == '\n' || i == (SIZ - 1))
break;
}
/* If we got a long line, discard characters until the newline. */
- if (i == (SIZ-1))
+ if (i == (SIZ - 1))
while (buf[i] != '\n')
serv_read(ipc, &buf[i], 1);
/* Strip the trailing newline (and carriage return, if present) */
- if (i>=0 && buf[i] == 10) buf[i--] = 0;
- if (i>=0 && buf[i] == 13) buf[i--] = 0;
+ if (i >= 0 && buf[i] == 10)
+ buf[i--] = 0;
+ if (i >= 0 && buf[i] == 13)
+ buf[i--] = 0;
}
-#endif /* CHUNKED_READ */
+#endif /* CHUNKED_READ */
-void CtdlIPC_chat_recv(CtdlIPC* ipc, char* buf)
+void CtdlIPC_chat_recv(CtdlIPC * ipc, char *buf)
{
CtdlIPC_getline(ipc, buf);
}
/*
* send line to server - implemented in terms of serv_write()
*/
-static void CtdlIPC_putline(CtdlIPC *ipc, const char *buf)
+static void CtdlIPC_putline(CtdlIPC * ipc, const char *buf)
{
char *cmd = NULL;
int len;
ipc->last_command_sent = time(NULL);
}
-void CtdlIPC_chat_send(CtdlIPC* ipc, const char* buf)
+void CtdlIPC_chat_send(CtdlIPC * ipc, const char *buf)
{
CtdlIPC_putline(ipc, buf);
}
/*
* attach to server
*/
-CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf)
+CtdlIPC *CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf)
{
int a;
char cithost[SIZ];
char citport[SIZ];
char sockpath[SIZ];
- CtdlIPC* ipc;
+ CtdlIPC *ipc;
ipc = malloc(sizeof(struct _CtdlIPC));
if (!ipc) {
ipc->ssl = NULL;
CtdlIPC_init_OpenSSL();
#endif
- ipc->sock = -1; /* Not connected */
- ipc->isLocal = 0; /* Not local, of course! */
+ ipc->sock = -1; /* Not connected */
+ ipc->isLocal = 0; /* Not local, of course! */
ipc->downloading = 0;
ipc->uploading = 0;
ipc->last_command_sent = 0L;
} else if (a == 2) {
strcpy(citport, argv[a]);
} else {
- error_printf("%s: usage: ",argv[0]);
- error_printf("%s [host] [port] ",argv[0]);
+ error_printf("%s: usage: ", argv[0]);
+ error_printf("%s [host] [port] ", argv[0]);
free(ipc);
errno = EINVAL;
return 0;
- }
+ }
}
if ((!strcmp(cithost, "localhost")) || (!strcmp(cithost, "127.0.0.1"))) {
if (!strcmp(cithost, UDS)) {
if (!strcasecmp(citport, DEFAULT_PORT)) {
snprintf(sockpath, sizeof sockpath, "%s", file_citadel_socket);
- }
- else {
+ } else {
snprintf(sockpath, sizeof sockpath, "%s/%s", citport, "citadel.socket");
}
printf("[%s]\n", sockpath);
free(ipc);
return 0;
}
- if (hostbuf != NULL) strcpy(hostbuf, cithost);
- if (portbuf != NULL) strcpy(portbuf, sockpath);
+ if (hostbuf != NULL)
+ strcpy(hostbuf, cithost);
+ if (portbuf != NULL)
+ strcpy(portbuf, sockpath);
strcpy(ipc->ip_hostname, "");
strcpy(ipc->ip_address, "");
return ipc;
ipc->ip_hostname[0] = 0;
ipc->ip_address[0] = 0;
- getpeername(ipc->sock, (struct sockaddr *)&clientaddr, &addrlen);
- getnameinfo((struct sockaddr *)&clientaddr, addrlen,
- ipc->ip_hostname, sizeof ipc->ip_hostname, NULL, 0, 0
- );
- getnameinfo((struct sockaddr *)&clientaddr, addrlen,
- ipc->ip_address, sizeof ipc->ip_address, NULL, 0, NI_NUMERICHOST
- );
+ getpeername(ipc->sock, (struct sockaddr *) &clientaddr, &addrlen);
+ getnameinfo((struct sockaddr *) &clientaddr, addrlen, ipc->ip_hostname, sizeof ipc->ip_hostname, NULL, 0, 0);
+ getnameinfo((struct sockaddr *) &clientaddr, addrlen, ipc->ip_address, sizeof ipc->ip_address, NULL, 0, NI_NUMERICHOST);
/* stuff other things elsewhere */
- if (hostbuf != NULL) strcpy(hostbuf, cithost);
- if (portbuf != NULL) strcpy(portbuf, citport);
+ if (hostbuf != NULL)
+ strcpy(hostbuf, cithost);
+ if (portbuf != NULL)
+ strcpy(portbuf, citport);
return ipc;
}
/*
* Disconnect and delete the IPC class (destructor)
*/
-void CtdlIPC_delete(CtdlIPC* ipc)
+void CtdlIPC_delete(CtdlIPC * ipc)
{
#ifdef HAVE_OPENSSL
if (ipc->ssl) {
ipc->sock = -1;
}
if (ipc->Buf != NULL)
- free (ipc->Buf);
+ free(ipc->Buf);
ipc->Buf = NULL;
ipc->BufPtr = NULL;
free(ipc);
* Disconnect and delete the IPC class (destructor)
* Also NULLs out the pointer
*/
-void CtdlIPC_delete_ptr(CtdlIPC** pipc)
+void CtdlIPC_delete_ptr(CtdlIPC ** pipc)
{
CtdlIPC_delete(*pipc);
*pipc = NULL;
* FIXME: This is only used in chat mode; eliminate it when chat mode gets
* rewritten...
*/
-int CtdlIPC_getsockfd(CtdlIPC* ipc)
+int CtdlIPC_getsockfd(CtdlIPC * ipc)
{
return ipc->sock;
}
* FIXME: This is only used in chat mode; eliminate it when chat mode gets
* rewritten...
*/
-char CtdlIPC_get(CtdlIPC* ipc)
+char CtdlIPC_get(CtdlIPC * ipc)
{
char buf[2];
char ch;
extern char temp[];
char last_paged[SIZ] = "";
-void chatmode(CtdlIPC *ipc)
+void chatmode(CtdlIPC * ipc)
{
char wbuf[SIZ];
char buf[SIZ];
strcpy(buf, "");
strcpy(wbuf, "");
- strcpy(last_user, "");
+ strcpy(last_user, "");
color(BRIGHT_YELLOW);
scr_printf("\n");
scr_printf("> ");
snprintf(buf, sizeof buf, "RCHT poll|%d", seq);
CtdlIPC_chat_send(ipc, buf);
CtdlIPC_chat_recv(ipc, response);
-
+
if (response[0] == '1') {
seq = extract_int(&response[4], 0);
extract_token(c_user, &response[4], 2, '|', sizeof c_user);
/*
* send an instant message
*/
-void page_user(CtdlIPC *ipc)
+void page_user(CtdlIPC * ipc)
{
char buf[SIZ], touser[SIZ], msg[SIZ];
FILE *pagefp;
}
-void quiet_mode(CtdlIPC *ipc)
+void quiet_mode(CtdlIPC * ipc)
{
static int quiet = 0;
char cret[SIZ];
r = CtdlIPCEnableInstantMessageReceipt(ipc, !quiet, cret);
if (r / 100 == 2) {
quiet = !quiet;
- scr_printf("Quiet mode %sabled (%sother users may page you)\n",
- (quiet) ? "en" : "dis",
- (quiet) ? "no " : "");
+ scr_printf("Quiet mode %sabled (%sother users may page you)\n", (quiet) ? "en" : "dis", (quiet) ? "no " : "");
} else {
scr_printf("Unable to change quiet mode: %s\n", cret);
}
}
-void stealth_mode(CtdlIPC *ipc)
+void stealth_mode(CtdlIPC * ipc)
{
static int stealth = 0;
char cret[SIZ];
if (r / 100 == 2) {
stealth = !stealth;
scr_printf("Stealth mode %sabled (you are %s)\n",
- (stealth) ? "en" : "dis",
- (stealth) ? "invisible" : "listed as online");
+ (stealth) ? "en" : "dis", (stealth) ? "invisible" : "listed as online");
} else {
scr_printf("Unable to change stealth mode: %s\n", cret);
}
#define PWFILENAME "%s/.citadel.passwords"
-void determine_pwfilename(char *pwfile, size_t n) {
+void determine_pwfilename(char *pwfile, size_t n)
+{
struct passwd *p;
p = getpwuid(getuid());
- if (p == NULL) strcpy(pwfile, "");
+ if (p == NULL)
+ strcpy(pwfile, "");
snprintf(pwfile, n, PWFILENAME, p->pw_dir);
}
* Check the password file for a host/port match; if found, stuff the user
* name and password into the user/pass buffers
*/
-void get_stored_password(
- char *host,
- char *port,
- char *username,
- char *password) {
+void get_stored_password(char *host, char *port, char *username, char *password)
+{
char pwfile[PATH_MAX];
FILE *fp;
strcpy(password, "");
determine_pwfilename(pwfile, sizeof pwfile);
- if (IsEmptyStr(pwfile)) return;
+ if (IsEmptyStr(pwfile))
+ return;
fp = fopen(pwfile, "r");
- if (fp == NULL) return;
+ if (fp == NULL)
+ return;
while (fgets(buf64, sizeof buf64, fp) != NULL) {
CtdlDecodeBase64(buf, buf64, sizeof(buf64));
extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
/*
* Set (or clear) stored passwords.
*/
-void set_stored_password(
- char *host,
- char *port,
- char *username,
- char *password) {
+void set_stored_password(char *host, char *port, char *username, char *password)
+{
char pwfile[PATH_MAX];
FILE *fp, *oldfp;
char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
determine_pwfilename(pwfile, sizeof pwfile);
- if (IsEmptyStr(pwfile)) return;
+ if (IsEmptyStr(pwfile))
+ return;
oldfp = fopen(pwfile, "r");
- if (oldfp == NULL) oldfp = fopen("/dev/null", "r");
+ if (oldfp == NULL)
+ oldfp = fopen("/dev/null", "r");
unlink(pwfile);
fp = fopen(pwfile, "w");
- if (fp == NULL) fp = fopen("/dev/null", "w");
+ if (fp == NULL)
+ fp = fopen("/dev/null", "w");
while (fgets(buf64, sizeof buf64, oldfp) != NULL) {
CtdlDecodeBase64(buf, buf64, sizeof(buf64));
extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
extract_token(ubuf, buf, 2, '|', sizeof ubuf);
extract_token(pbuf, buf, 3, '|', sizeof pbuf);
- if ( (strcasecmp(hostbuf, host))
- || (strcasecmp(portbuf, port)) ) {
- snprintf(buf, sizeof buf, "%s|%s|%s|%s|",
- hostbuf, portbuf, ubuf, pbuf);
+ if ((strcasecmp(hostbuf, host))
+ || (strcasecmp(portbuf, port))) {
+ snprintf(buf, sizeof buf, "%s|%s|%s|%s|", hostbuf, portbuf, ubuf, pbuf);
CtdlEncodeBase64(buf64, buf, strlen(buf), 0);
fprintf(fp, "%s\n", buf64);
}
}
if (!IsEmptyStr(username)) {
- snprintf(buf, sizeof buf, "%s|%s|%s|%s|",
- host, port, username, password);
+ snprintf(buf, sizeof buf, "%s|%s|%s|%s|", host, port, username, password);
CtdlEncodeBase64(buf64, buf, strlen(buf), 0);
fprintf(fp, "%s\n", buf64);
}
/*
* Set the password if the user wants to, clear it otherwise
*/
-void offer_to_remember_password(CtdlIPC *ipc,
- char *host,
- char *port,
- char *username,
- char *password) {
+void offer_to_remember_password(CtdlIPC * ipc, char *host, char *port, char *username, char *password)
+{
if (rc_remember_passwords) {
if (boolprompt("Remember username/password for this site", 0)) {
set_stored_password(host, port, username, password);
- }
- else {
+ } else {
set_stored_password(host, port, "", "");
}
}
char *helptexts[] = {
-" Citadel Help Menu\n"
-" \n"
-" ? Help. (Typing a '?' will give you a menu almost anywhere)\n"
-" A Abandon this room where you stopped reading, goto next room.\n"
-" C Chat (multiuser chat, where available)\n"
-" D Prints directory, if there is one in the current room.\n"
-" E Enter a message.\n"
-" F Read all messages in the room, forward.\n"
-" G Goto next room which has UNREAD messages.\n"
-" H Help. Same as '?'\n"
-" I Reads the Information file for this room.\n"
-" K List of Known rooms.\n"
-" L Reads the last five messages in the room.\n"
-" N Reads all new messages in the room.\n"
-" O Reads all old messages, backwards.\n"
-" P Page another user (send an instant message)\n"
-" R Reads all messages in the room, in reverse order.\n"
-" S Skips current room without making its messages old.\n"
-" T Terminate (logout)\n"
-" U Ungoto (returns to the last room you were in)\n"
-" W Displays who is currently logged in.\n"
-" X Toggle eXpert mode (menus and help blurbs on/off)\n"
-" Z Zap (forget) room. (Removes the room from your list)\n"
-" + - Goto next, previous room on current floor.\n"
-" > < Goto next, previous floor.\n"
-" * Enter any locally installed 'doors'.\n"
-" \n"
-" In addition, there are dot commands. You hit the . (dot), then press the\n"
-"first letter of each word of the command. As you hit the letters, the words\n"
-"pop onto your screen. Exceptions: after you hit .Help or .Goto, the remainder\n"
-"of the command is a help file name or room name.\n"
-" \n"
-" *** USE .<H>elp ? for additional help *** \n"
-
-,
-
-"The following commands are available only to Admins. A subset of these\n"
-"commands are available to room aides when they are currently in the room\n"
-"they are room aide for.\n"
-"\n"
-" <.> <A>dmin <K>ill this room (Delete the current room)\n"
-" <.> <A>dmin <E>dit this room (Edit the current room's parameters)\n"
-" <.> <A>dmin <W>ho knows room (List users with access to this room)\n"
-" <.> <A>dmin edit <U>ser (Change user's access level, password, etc.)\n"
-" <.> <A>dmin <V>alidate new users (Process new user registrations)\n"
-" <.> <A>dmin enter <I>nfo file (Create/change this room's banner)\n"
-" <.> <A>dmin <R>oom <I>nvite user (Grant access to an invitation-only room)\n"
-" <.> <A>dmin <R>oom <K>ick out user (Revoke access to an invitation-only room)\n"
-" <.> <A>dmin <F>ile <D>elete (Delete a file from the room's directory)\n"
-" <.> <A>dmin <F>ile <S>end over net (Transmit a file to another node)\n"
-" <.> <A>dmin <F>ile <M>ove (Move a file to another room's directory)\n"
-" <.> <A>dmin <M>essage edit: (Edit system banners)\n"
-" <.> <A>dmin <P>ost (Post a message on behalf of another user)\n"
-" <.> <A>dmin <S>ystem configuration <G>eneral (Edit global site config)\n"
-" <.> <A>dmin <S>ystem configuration <I>nternet (Edit Internet domains)\n"
-" <.> <A>dmin <S>ystem configuration check <M>essage base (Internal checks)\n"
-" <.> <A>dmin <S>ystem configuration <N>etwork (Netting with other Citadels)\n"
-" <.> <A>dmin <S>ystem configuration network <F>ilter list\n"
-" <.> <A>dmin <T>erminate server <N>ow (Shut down Citadel server now)\n"
-" <.> <A>dmin <T>erminate server <S>cheduled (Shut down Citadel server later)\n"
-" <.> <A>dmin mailing <L>ist recipients (For mailing list rooms)\n"
-" <.> <A>dmin mailing list <D>igest recipients (For mailing list rooms)\n"
-" <.> <A>dmin <N>etwork room sharing (Replication with other Citadels)\n"
-" \n"
-" In addition, the <M>ove and <D>elete commands are available at the\n"
-"message prompt.\n"
-
-,
-
-" Floors\n"
-" ------\n"
-" Floors in Citadel are used to group rooms into related subject areas,\n"
-"just as rooms are used to group messages into manageable groups.\n"
-" \n"
-" You, as a user, do NOT have to use floors. If you choose not to, you suffer\n"
-"no penalty; you will not lose access to any rooms. You may use .EC or ;C (the\n"
-"latter is easier to use) to decide if you want to use floors. Feel free to\n"
-"experiment.\n"
-" \n"
-" Floor options are accessed two ways. First, if you are in floor mode, the\n"
-"<G>oto and <S>kip commands take you to the next room with new messages on the\n"
-"current floor; if there are none left, then the system will automatically\n"
-"switch floors (and let you know) and put you in the first room with new messages\n"
-"on that level. (Notice that your pattern of basic use of Citadel therefore\n"
-"doesn't really change.)\n"
-" \n"
-" Direct access to floor options is via the use of a ';' command.\n"
-"The following commands are currently available (more can be\n"
-"added if needed):\n"
-" \n"
-" <;C>onfigure\n"
-" This command toggles your floor mode.\n"
-" \n"
-" <;G>oto FLOORNAME\n"
-" This command causes the system to take you to the named floor.\n"
-" \n"
-" <;K>nown rooms on floors\n"
-" List all rooms on all floors. This is a very readable way to get a list of\n"
-"all rooms on the system.\n"
-" \n"
-" <;S>kip FLOORNAME\n"
-" This command causes the system to mark all rooms on the current floor as\n"
-"Skipped and takes you to the floor that you specify.\n"
-" \n"
-" <;Z>Forget floor\n"
-" This command causes you to forget all the rooms currently on the current\n"
-"floor. Unfortunately, it doesn't apply to rooms that are subsequently created\n"
-"or moved to this floor. (Sorry.)\n"
-" \n"
-" Feel free to experiment, you can't hurt yourself or the system with the\n"
-"floor stuff unless you ZForget a floor by accident.\n"
-
-,
-
-" New User's Introduction to the site\n"
-" \n"
-" This is an introduction to the Citadel BBS concept. It is intended\n"
-"for new users so that they can more easily become acquainted to using\n"
-"Citadel when accessing it in the form of a text-based BBS. Of\n"
-"course, old users might learn something new each time they read\n"
-"through it.\n"
-" \n"
-" Full help for the BBS commands can be obtained by typing <.H>elp SUMMARY\n"
-" \n"
-" The CITADEL BBS room concept\n"
-" ----------------------------\n"
-" The term BBS stands for 'Bulletin Board System'. The analogy is\n"
-"appropriate: one posts messages so that others may read them. In\n"
-"order to organize the posts, people can post in different areas of the\n"
-"BBS, called rooms.\n"
-" In order to post in a certain room, you need to be 'in' that room.\n"
-"Your current prompt is usually the room that you are in, followed the\n"
-"greater-than-sign, such as:\n"
-" \n"
-" Lobby>\n"
-" \n"
-" The easiest way to traverse the room structure is with the 'Goto'\n"
-"command, on the 'G' key. Pressing 'G' will take you to the next room\n"
-"in the 'march list' (see below) that has new messages in it. You can\n"
-"read these new messages with the 'N' key.\n"
-" Once you've 'Gotoed' every room in the system (or all of the ones\n"
-"you choose to read) you return to the 'Lobby,' the first and last room\n"
-"in the system. If new messages get posted to rooms you've already\n"
-"read during your session you will be brought BACK to those rooms so\n"
-"you can read them.\n"
-" \n"
-" March List\n"
-" ----------\n"
-" All the room names are stored in a march list, which is just a\n"
-"list containing all the room names. When you <G>oto or <S>kip a\n"
-"room, you are placed in the next room in your march list THAT HAS NEW\n"
-"MESSAGES. If you have no new messages in any of the rooms on your\n"
-"march list, you will keep going to the Lobby>. You can choose not to\n"
-"read certain rooms (that don't interest you) by 'Z'apping them. When\n"
-"you <Z>ap a room, you are merely deleting it from your march list (but\n"
-"not from anybody else's).\n"
-" \n"
-" You can use the <.G>oto (note the period before the G. You can also use\n"
-"<J>ump on some systems) to go to any room in the\n"
-"system. You don't have to type in the complete name of a room to\n"
-"'jump' to it; you merely need to type in enough to distinguish it from\n"
-"the other rooms. Left-aligned matches carry a heavier weight, so if you\n"
-"typed (for example) '.Goto TECH', you might be taken to a room called\n"
-"'Tech Area>' even if it found a room called 'Biotech/Ethics>' first.\n"
-" \n"
-" To return to a room you have previously <Z>apped, use the <.G>oto command\n"
-"to enter it, and it will be re-inserted into your march list. In the case\n"
-"of returning to Zapped rooms, you must type the room name in its entirety.\n"
-"REMEMBER, rooms with no new messages will not show on your\n"
-"march list! You must <.G>oto to a room with no new messages.\n"
-"Incidentally, you cannot change the order of the rooms on your march list.\n"
-"It's the same for everybody.\n"
-" \n"
-" Special rooms\n"
-" -------------\n"
-" There are two special rooms on a Citadel that you should know about.\n"
-" \n"
-" The first is the Lobby>. It's used for system announcements and other\n"
-"such administrativia. You cannot <Z>ap the Lobby>. Each time you first\n"
-"login, you will be placed in the Lobby>.\n"
-" \n"
-" The second is Mail>. In Mail>, when you post a messages, you are\n"
-"prompted to enter the screen name of the person who you want to send the\n"
-"message to. Only the person who you send the message to can read the\n"
-"message. NO ONE else can read it, not even the admins. Mail> is the\n"
-"first room on the march list, and is un-<Z>appable, so you can be sure\n"
-"that the person will get the message.\n"
-" \n"
-" System admins\n"
-" -------------\n"
-" These people, along with the room admins, keep the site running smoothly.\n"
-"\n"
-" Among the many things that admins do are: create rooms, delete\n"
-"rooms, set access levels, invite users, check registration, grant\n"
-"room admin status, and countless other things. They have access to the\n"
-"Aide> room, a special room only for admins.\n"
-" \n"
-" If you enter a mail message to 'Sysop' it will be placed in the\n"
-"Aide> room so that the next admin online will read it and deal with it.\n"
-"Admins cannot <Z>ap rooms. All the rooms are always on each admin's\n"
-"march list. Admins can read *any* and *every* room, but they *CAN* *NOT*\n"
-"read other users' Mail!\n"
-" \n"
-" Room admins\n"
-" -----------\n"
-" Room admins are granted special privileges in specific rooms.\n"
-"They are *NOT* true system admins; their power extends only over the\n"
-"rooms that they control, and they answer to the system admins.\n"
-" \n"
-" A room admin's job is to keep the topic of the their room on track,\n"
-"with nudges in the right direction now and then. A room admin can also\n"
-"move an off topic post to another room, or delete a post, if he/she\n"
-"feels it is necessary. \n"
-" \n"
-" Currently, very few rooms have room admins. Most rooms do not need\n"
-"their own specific room admin. Being a room admin requires a certain\n"
-"amount of trust, due to the additional privileges granted.\n"
-" \n"
-" Citadel messages\n"
-" ----------------\n"
-" Most of the time, the BBS code does not print a lot of messages\n"
-"to your screen. This is a great benefit once you become familiar\n"
-"with the system, because you do not have endless menus and screens\n"
-"to navigate through. nevertheless, there are some messages which you\n"
-"might see from time to time.\n"
-" \n"
-" 'There were messages posted while you were entering.'\n"
-" \n"
-" This is also known as 'simulposting.' When you start entering a \n"
-"message, the system knows where you last left off. When you save\n"
-"your message, the system checks to see if any messages were entered\n"
-"while you were typing. This is so that you know whether you need\n"
-"to go back and re-read the last few messages. This message may appear\n"
-"in any room.\n"
-" \n"
-" '*** You have new mail'\n"
-" \n"
-" This message is essentially the same as the above message, but can\n"
-"appear at any time. It simply means that new mail has arrived for you while\n"
-"you are logged in. Simply go to the Mail> room to read it.\n"
-" \n"
-" Who list\n"
-" --------\n"
-" The <W>ho command shows you the names of all users who are currently\n"
-"online. It also shows you the name of the room they are currently in. If\n"
-"they are in any type of private room, however, the room name will simply\n"
-"display as '<private room>'. Along with this information is displayed the\n"
-"name of the host computer the user is logged in from.\n"
-
-,
-
-"To send mail on this system, go to the Mail> room (using the command .G Mail)\n"
-"and press E to enter a message. You will be prompted with:\n"
-" \n"
-" Enter Recipient:\n"
-" \n"
-" At this point you may enter the name of another user on the system. Private\n"
-"mail is only readable by the sender and recipient. There is no need to delete\n"
-"mail after it is read; it will scroll out automatically.\n"
-" \n"
-" To send mail to another user on the Citadel network, simply type the\n"
-"user's name, followed by @ and then the system name. For example,\n"
-" \n"
-" Enter Recipient: Joe Schmoe @ citadrool\n"
-" \n"
-" If your account is enabled for Internet mail, you can also send email to\n"
-"anyone on the Internet here. Simply enter their address at the prompt:\n"
-" \n"
-" Enter Recipient: ajc@herring.fishnet.com\n"
-
-,
-
-" Welcome to the network. Messages entered in a network room will appear in\n"
-"that room on all other systems carrying it (The name of the room, however,\n"
-"may be different on other systems).\n"
-
-,
-
-" Citadel is the premier 'online community' (i.e. Bulletin Board System)\n"
-"software. It runs on all POSIX-compliant systems, including Linux. It is an\n"
-"advanced client/server application, and is being actively maintained.\n"
-" \n"
-" For more info, visit UNCENSORED! BBS at uncensored.citadel.org\n"
-
-,
-
-"Extended commands are available using the period ( . ) key. To use\n"
-"a dot command, press the . key, and then enter the first letter of\n"
-"each word in the command. The words will appear as you enter the keys.\n"
-"You can also backspace over partially entered commands. The following\n"
-"commands are available:\n"
-"\n"
-" <.> <H>elp: Displays help files. Type .H followed by a help file\n"
-" name. You are now reading <.H>elp SUMMARY\n"
-" \n"
-" <.> <G>oto: Jumps directly to the room you specify. You can also\n"
-" type a partial room name, just enough to make it unique,\n"
-" and it'll find the room you're looking for. As with the\n"
-" regular <G>oto command, messages in the current room will\n"
-" be marked as read.\n"
-" \n"
-" <.> <S>kip, goto: This is similar to <.G>oto, except it doesn't mark\n"
-" messages in the current room as read.\n"
-" \n"
-" <.> list <Z>apped rooms Shows all rooms you've <Z>apped (forgotten)\n"
-"\n"
-" \n"
-" Terminate (logoff) commands:\n"
-" \n"
-" <.> <T>erminate and <Q>uit Log off and disconnect.\n"
-" <.> <T>erminate and <S>tay online Log in as a different user.\n"
-" \n"
-" \n"
-" Read commands:\n"
-"\n"
-" <.> <R>ead <N>ew messages Same as <N>ew\n"
-" <.> <R>ead <O>ld msgs reverse Same as <O>ld\n"
-" <.> <R>ead <L>ast five msgs Same as <L>ast5\n"
-" <.> read <L>ast: Allows you to specify how many\n"
-" messages you wish to read.\n"
-"\n"
-" <.> <R>ead <U>ser listing: Lists all users on the system if\n"
-" you just hit enter, otherwise\n"
-" you can specify a partial match\n"
-"\n"
-" <.> <R>ead <T>extfile formatted File 'download' commands.\n"
-" <.> <R>ead file using <X>modem \n"
-" <.> <R>ead file using <Y>modem \n"
-" <.> <R>ead file using <Z>modem \n"
-" <.> <R>ead <F>ile unformatted \n"
-" <.> <R>ead <D>irectory \n"
-"\n"
-" <.> <R>ead <I>nfo file Read the room info file.\n"
-" <.> <R>ead <B>io Read other users' 'bio' files.\n"
-" <.> <R>ead <C>onfiguration Display your 'preferences'.\n"
-" <.> <R>ead <S>ystem info Display system statistics.\n"
-"\n"
-" \n"
-" Enter commands:\n"
-"\n"
-" <.> <E>nter <M>essage Post a message in this room.\n"
-" <.> <E>nter message with <E>ditor Post using a full-screen editor.\n"
-" <.> <E>nter <A>SCII message Post 'raw' (use this when 'pasting'\n"
-" a message from your clipboard).\n"
-"\n"
-" <.> <E>nter <P>assword Change your password.\n"
-" <.> <E>nter <C>onfiguration Change your 'preferences'.\n"
-" <.> <E>nter a new <R>oom Create a new room.\n"
-" <.> <E>nter re<G>istration Register (name, address, etc.)\n"
-" <.> <E>nter <B>io Enter/change your 'bio' file.\n"
-"\n"
-" <.> <E>nter <T>extfile File 'upload' commands.\n"
-" <.> <E>nter file using <X>modem \n"
-" <.> <E>nter file using <Y>modem \n"
-" <.> <E>nter file using <Z>modem \n"
-" \n"
-" \n"
-" Wholist commands:\n"
-" \n"
-" <.> <W>holist <L>ong Same as <W>ho is online, but displays\n"
-" more detailed information.\n"
-" <.> <W>holist <R>oomname Masquerade your room name (other users\n"
-" see the name you enter rather than the\n"
-" actual name of the room you're in)\n"
-" <.> <W>holist <H>ostname Masquerade your host name\n"
-" <.> <E>nter <U>sername Masquerade your user name (Admins only)\n"
-" <.> <W>holist <S>tealth mode Enter/exit 'stealth mode' (when in stealth\n"
-" mode you are invisible on the wholist)\n"
-" \n"
-" \n"
-" Floor commands (if using floor mode)\n"
-" ;<C>onfigure floor mode - turn floor mode on or off\n"
-" ;<G>oto floor: - jump to a specific floor\n"
-" ;<K>nown rooms - list all rooms on all floors\n"
-" ;<S>kip to floor: - skip current floor, jump to another\n"
-" ;<Z>ap floor - zap (forget) all rooms on this floor\n"
-" \n"
-" \n"
-" Administrative commands: \n"
-" \n"
-" <.> <A>dmin <K>ill this room \n"
-" <.> <A>dmin <E>dit this room \n"
-" <.> <A>dmin <W>ho knows room \n"
-" <.> <A>dmin edit <U>ser \n"
-" <.> <A>dmin <V>alidate new users \n"
-" <.> <A>dmin enter <I>nfo file \n"
-" <.> <A>dmin <R>oom <I>nvite user \n"
-" <.> <A>dmin <R>oom <K>ick out user \n"
-" <.> <A>dmin <F>ile <D>elete \n"
-" <.> <A>dmin <F>ile <S>end over net \n"
-" <.> <A>dmin <F>ile <M>ove \n"
-" <.> <A>dmin <M>essage edit: \n"
-" <.> <A>dmin <P>ost \n"
-" <.> <A>dmin <S>ystem configuration \n"
-" <.> <A>dmin <T>erminate server <N>ow\n"
-" <.> <A>dmin <T>erminate server <S>cheduled\n"
-
+ " Citadel Help Menu\n"
+ " \n"
+ " ? Help. (Typing a '?' will give you a menu almost anywhere)\n"
+ " A Abandon this room where you stopped reading, goto next room.\n"
+ " C Chat (multiuser chat, where available)\n"
+ " D Prints directory, if there is one in the current room.\n"
+ " E Enter a message.\n"
+ " F Read all messages in the room, forward.\n"
+ " G Goto next room which has UNREAD messages.\n"
+ " H Help. Same as '?'\n"
+ " I Reads the Information file for this room.\n"
+ " K List of Known rooms.\n"
+ " L Reads the last five messages in the room.\n"
+ " N Reads all new messages in the room.\n"
+ " O Reads all old messages, backwards.\n"
+ " P Page another user (send an instant message)\n"
+ " R Reads all messages in the room, in reverse order.\n"
+ " S Skips current room without making its messages old.\n"
+ " T Terminate (logout)\n"
+ " U Ungoto (returns to the last room you were in)\n"
+ " W Displays who is currently logged in.\n"
+ " X Toggle eXpert mode (menus and help blurbs on/off)\n"
+ " Z Zap (forget) room. (Removes the room from your list)\n"
+ " + - Goto next, previous room on current floor.\n"
+ " > < Goto next, previous floor.\n"
+ " * Enter any locally installed 'doors'.\n"
+ " \n"
+ " In addition, there are dot commands. You hit the . (dot), then press the\n"
+ "first letter of each word of the command. As you hit the letters, the words\n"
+ "pop onto your screen. Exceptions: after you hit .Help or .Goto, the remainder\n"
+ "of the command is a help file name or room name.\n" " \n" " *** USE .<H>elp ? for additional help *** \n",
+
+ "The following commands are available only to Admins. A subset of these\n"
+ "commands are available to room aides when they are currently in the room\n"
+ "they are room aide for.\n"
+ "\n"
+ " <.> <A>dmin <K>ill this room (Delete the current room)\n"
+ " <.> <A>dmin <E>dit this room (Edit the current room's parameters)\n"
+ " <.> <A>dmin <W>ho knows room (List users with access to this room)\n"
+ " <.> <A>dmin edit <U>ser (Change user's access level, password, etc.)\n"
+ " <.> <A>dmin <V>alidate new users (Process new user registrations)\n"
+ " <.> <A>dmin enter <I>nfo file (Create/change this room's banner)\n"
+ " <.> <A>dmin <R>oom <I>nvite user (Grant access to an invitation-only room)\n"
+ " <.> <A>dmin <R>oom <K>ick out user (Revoke access to an invitation-only room)\n"
+ " <.> <A>dmin <F>ile <D>elete (Delete a file from the room's directory)\n"
+ " <.> <A>dmin <F>ile <S>end over net (Transmit a file to another node)\n"
+ " <.> <A>dmin <F>ile <M>ove (Move a file to another room's directory)\n"
+ " <.> <A>dmin <M>essage edit: (Edit system banners)\n"
+ " <.> <A>dmin <P>ost (Post a message on behalf of another user)\n"
+ " <.> <A>dmin <S>ystem configuration <G>eneral (Edit global site config)\n"
+ " <.> <A>dmin <S>ystem configuration <I>nternet (Edit Internet domains)\n"
+ " <.> <A>dmin <S>ystem configuration check <M>essage base (Internal checks)\n"
+ " <.> <A>dmin <S>ystem configuration <N>etwork (Netting with other Citadels)\n"
+ " <.> <A>dmin <S>ystem configuration network <F>ilter list\n"
+ " <.> <A>dmin <T>erminate server <N>ow (Shut down Citadel server now)\n"
+ " <.> <A>dmin <T>erminate server <S>cheduled (Shut down Citadel server later)\n"
+ " <.> <A>dmin mailing <L>ist recipients (For mailing list rooms)\n"
+ " <.> <A>dmin mailing list <D>igest recipients (For mailing list rooms)\n"
+ " <.> <A>dmin <N>etwork room sharing (Replication with other Citadels)\n"
+ " \n" " In addition, the <M>ove and <D>elete commands are available at the\n" "message prompt.\n",
+
+ " Floors\n"
+ " ------\n"
+ " Floors in Citadel are used to group rooms into related subject areas,\n"
+ "just as rooms are used to group messages into manageable groups.\n"
+ " \n"
+ " You, as a user, do NOT have to use floors. If you choose not to, you suffer\n"
+ "no penalty; you will not lose access to any rooms. You may use .EC or ;C (the\n"
+ "latter is easier to use) to decide if you want to use floors. Feel free to\n"
+ "experiment.\n"
+ " \n"
+ " Floor options are accessed two ways. First, if you are in floor mode, the\n"
+ "<G>oto and <S>kip commands take you to the next room with new messages on the\n"
+ "current floor; if there are none left, then the system will automatically\n"
+ "switch floors (and let you know) and put you in the first room with new messages\n"
+ "on that level. (Notice that your pattern of basic use of Citadel therefore\n"
+ "doesn't really change.)\n"
+ " \n"
+ " Direct access to floor options is via the use of a ';' command.\n"
+ "The following commands are currently available (more can be\n"
+ "added if needed):\n"
+ " \n"
+ " <;C>onfigure\n"
+ " This command toggles your floor mode.\n"
+ " \n"
+ " <;G>oto FLOORNAME\n"
+ " This command causes the system to take you to the named floor.\n"
+ " \n"
+ " <;K>nown rooms on floors\n"
+ " List all rooms on all floors. This is a very readable way to get a list of\n"
+ "all rooms on the system.\n"
+ " \n"
+ " <;S>kip FLOORNAME\n"
+ " This command causes the system to mark all rooms on the current floor as\n"
+ "Skipped and takes you to the floor that you specify.\n"
+ " \n"
+ " <;Z>Forget floor\n"
+ " This command causes you to forget all the rooms currently on the current\n"
+ "floor. Unfortunately, it doesn't apply to rooms that are subsequently created\n"
+ "or moved to this floor. (Sorry.)\n"
+ " \n"
+ " Feel free to experiment, you can't hurt yourself or the system with the\n"
+ "floor stuff unless you ZForget a floor by accident.\n",
+
+ " New User's Introduction to the site\n"
+ " \n"
+ " This is an introduction to the Citadel BBS concept. It is intended\n"
+ "for new users so that they can more easily become acquainted to using\n"
+ "Citadel when accessing it in the form of a text-based BBS. Of\n"
+ "course, old users might learn something new each time they read\n"
+ "through it.\n"
+ " \n"
+ " Full help for the BBS commands can be obtained by typing <.H>elp SUMMARY\n"
+ " \n"
+ " The CITADEL BBS room concept\n"
+ " ----------------------------\n"
+ " The term BBS stands for 'Bulletin Board System'. The analogy is\n"
+ "appropriate: one posts messages so that others may read them. In\n"
+ "order to organize the posts, people can post in different areas of the\n"
+ "BBS, called rooms.\n"
+ " In order to post in a certain room, you need to be 'in' that room.\n"
+ "Your current prompt is usually the room that you are in, followed the\n"
+ "greater-than-sign, such as:\n"
+ " \n"
+ " Lobby>\n"
+ " \n"
+ " The easiest way to traverse the room structure is with the 'Goto'\n"
+ "command, on the 'G' key. Pressing 'G' will take you to the next room\n"
+ "in the 'march list' (see below) that has new messages in it. You can\n"
+ "read these new messages with the 'N' key.\n"
+ " Once you've 'Gotoed' every room in the system (or all of the ones\n"
+ "you choose to read) you return to the 'Lobby,' the first and last room\n"
+ "in the system. If new messages get posted to rooms you've already\n"
+ "read during your session you will be brought BACK to those rooms so\n"
+ "you can read them.\n"
+ " \n"
+ " March List\n"
+ " ----------\n"
+ " All the room names are stored in a march list, which is just a\n"
+ "list containing all the room names. When you <G>oto or <S>kip a\n"
+ "room, you are placed in the next room in your march list THAT HAS NEW\n"
+ "MESSAGES. If you have no new messages in any of the rooms on your\n"
+ "march list, you will keep going to the Lobby>. You can choose not to\n"
+ "read certain rooms (that don't interest you) by 'Z'apping them. When\n"
+ "you <Z>ap a room, you are merely deleting it from your march list (but\n"
+ "not from anybody else's).\n"
+ " \n"
+ " You can use the <.G>oto (note the period before the G. You can also use\n"
+ "<J>ump on some systems) to go to any room in the\n"
+ "system. You don't have to type in the complete name of a room to\n"
+ "'jump' to it; you merely need to type in enough to distinguish it from\n"
+ "the other rooms. Left-aligned matches carry a heavier weight, so if you\n"
+ "typed (for example) '.Goto TECH', you might be taken to a room called\n"
+ "'Tech Area>' even if it found a room called 'Biotech/Ethics>' first.\n"
+ " \n"
+ " To return to a room you have previously <Z>apped, use the <.G>oto command\n"
+ "to enter it, and it will be re-inserted into your march list. In the case\n"
+ "of returning to Zapped rooms, you must type the room name in its entirety.\n"
+ "REMEMBER, rooms with no new messages will not show on your\n"
+ "march list! You must <.G>oto to a room with no new messages.\n"
+ "Incidentally, you cannot change the order of the rooms on your march list.\n"
+ "It's the same for everybody.\n"
+ " \n"
+ " Special rooms\n"
+ " -------------\n"
+ " There are two special rooms on a Citadel that you should know about.\n"
+ " \n"
+ " The first is the Lobby>. It's used for system announcements and other\n"
+ "such administrativia. You cannot <Z>ap the Lobby>. Each time you first\n"
+ "login, you will be placed in the Lobby>.\n"
+ " \n"
+ " The second is Mail>. In Mail>, when you post a messages, you are\n"
+ "prompted to enter the screen name of the person who you want to send the\n"
+ "message to. Only the person who you send the message to can read the\n"
+ "message. NO ONE else can read it, not even the admins. Mail> is the\n"
+ "first room on the march list, and is un-<Z>appable, so you can be sure\n"
+ "that the person will get the message.\n"
+ " \n"
+ " System admins\n"
+ " -------------\n"
+ " These people, along with the room admins, keep the site running smoothly.\n"
+ "\n"
+ " Among the many things that admins do are: create rooms, delete\n"
+ "rooms, set access levels, invite users, check registration, grant\n"
+ "room admin status, and countless other things. They have access to the\n"
+ "Aide> room, a special room only for admins.\n"
+ " \n"
+ " If you enter a mail message to 'Sysop' it will be placed in the\n"
+ "Aide> room so that the next admin online will read it and deal with it.\n"
+ "Admins cannot <Z>ap rooms. All the rooms are always on each admin's\n"
+ "march list. Admins can read *any* and *every* room, but they *CAN* *NOT*\n"
+ "read other users' Mail!\n"
+ " \n"
+ " Room admins\n"
+ " -----------\n"
+ " Room admins are granted special privileges in specific rooms.\n"
+ "They are *NOT* true system admins; their power extends only over the\n"
+ "rooms that they control, and they answer to the system admins.\n"
+ " \n"
+ " A room admin's job is to keep the topic of the their room on track,\n"
+ "with nudges in the right direction now and then. A room admin can also\n"
+ "move an off topic post to another room, or delete a post, if he/she\n"
+ "feels it is necessary. \n"
+ " \n"
+ " Currently, very few rooms have room admins. Most rooms do not need\n"
+ "their own specific room admin. Being a room admin requires a certain\n"
+ "amount of trust, due to the additional privileges granted.\n"
+ " \n"
+ " Citadel messages\n"
+ " ----------------\n"
+ " Most of the time, the BBS code does not print a lot of messages\n"
+ "to your screen. This is a great benefit once you become familiar\n"
+ "with the system, because you do not have endless menus and screens\n"
+ "to navigate through. nevertheless, there are some messages which you\n"
+ "might see from time to time.\n"
+ " \n"
+ " 'There were messages posted while you were entering.'\n"
+ " \n"
+ " This is also known as 'simulposting.' When you start entering a \n"
+ "message, the system knows where you last left off. When you save\n"
+ "your message, the system checks to see if any messages were entered\n"
+ "while you were typing. This is so that you know whether you need\n"
+ "to go back and re-read the last few messages. This message may appear\n"
+ "in any room.\n"
+ " \n"
+ " '*** You have new mail'\n"
+ " \n"
+ " This message is essentially the same as the above message, but can\n"
+ "appear at any time. It simply means that new mail has arrived for you while\n"
+ "you are logged in. Simply go to the Mail> room to read it.\n"
+ " \n"
+ " Who list\n"
+ " --------\n"
+ " The <W>ho command shows you the names of all users who are currently\n"
+ "online. It also shows you the name of the room they are currently in. If\n"
+ "they are in any type of private room, however, the room name will simply\n"
+ "display as '<private room>'. Along with this information is displayed the\n"
+ "name of the host computer the user is logged in from.\n",
+
+ "To send mail on this system, go to the Mail> room (using the command .G Mail)\n"
+ "and press E to enter a message. You will be prompted with:\n"
+ " \n"
+ " Enter Recipient:\n"
+ " \n"
+ " At this point you may enter the name of another user on the system. Private\n"
+ "mail is only readable by the sender and recipient. There is no need to delete\n"
+ "mail after it is read; it will scroll out automatically.\n"
+ " \n"
+ " To send mail to another user on the Citadel network, simply type the\n"
+ "user's name, followed by @ and then the system name. For example,\n"
+ " \n"
+ " Enter Recipient: Joe Schmoe @ citadrool\n"
+ " \n"
+ " If your account is enabled for Internet mail, you can also send email to\n"
+ "anyone on the Internet here. Simply enter their address at the prompt:\n"
+ " \n" " Enter Recipient: ajc@herring.fishnet.com\n",
+
+ " Welcome to the network. Messages entered in a network room will appear in\n"
+ "that room on all other systems carrying it (The name of the room, however,\n" "may be different on other systems).\n",
+
+ " Citadel is the premier 'online community' (i.e. Bulletin Board System)\n"
+ "software. It runs on all POSIX-compliant systems, including Linux. It is an\n"
+ "advanced client/server application, and is being actively maintained.\n"
+ " \n" " For more info, visit UNCENSORED! BBS at uncensored.citadel.org\n",
+
+ "Extended commands are available using the period ( . ) key. To use\n"
+ "a dot command, press the . key, and then enter the first letter of\n"
+ "each word in the command. The words will appear as you enter the keys.\n"
+ "You can also backspace over partially entered commands. The following\n"
+ "commands are available:\n"
+ "\n"
+ " <.> <H>elp: Displays help files. Type .H followed by a help file\n"
+ " name. You are now reading <.H>elp SUMMARY\n"
+ " \n"
+ " <.> <G>oto: Jumps directly to the room you specify. You can also\n"
+ " type a partial room name, just enough to make it unique,\n"
+ " and it'll find the room you're looking for. As with the\n"
+ " regular <G>oto command, messages in the current room will\n"
+ " be marked as read.\n"
+ " \n"
+ " <.> <S>kip, goto: This is similar to <.G>oto, except it doesn't mark\n"
+ " messages in the current room as read.\n"
+ " \n"
+ " <.> list <Z>apped rooms Shows all rooms you've <Z>apped (forgotten)\n"
+ "\n"
+ " \n"
+ " Terminate (logoff) commands:\n"
+ " \n"
+ " <.> <T>erminate and <Q>uit Log off and disconnect.\n"
+ " <.> <T>erminate and <S>tay online Log in as a different user.\n"
+ " \n"
+ " \n"
+ " Read commands:\n"
+ "\n"
+ " <.> <R>ead <N>ew messages Same as <N>ew\n"
+ " <.> <R>ead <O>ld msgs reverse Same as <O>ld\n"
+ " <.> <R>ead <L>ast five msgs Same as <L>ast5\n"
+ " <.> read <L>ast: Allows you to specify how many\n"
+ " messages you wish to read.\n"
+ "\n"
+ " <.> <R>ead <U>ser listing: Lists all users on the system if\n"
+ " you just hit enter, otherwise\n"
+ " you can specify a partial match\n"
+ "\n"
+ " <.> <R>ead <T>extfile formatted File 'download' commands.\n"
+ " <.> <R>ead file using <X>modem \n"
+ " <.> <R>ead file using <Y>modem \n"
+ " <.> <R>ead file using <Z>modem \n"
+ " <.> <R>ead <F>ile unformatted \n"
+ " <.> <R>ead <D>irectory \n"
+ "\n"
+ " <.> <R>ead <I>nfo file Read the room info file.\n"
+ " <.> <R>ead <B>io Read other users' 'bio' files.\n"
+ " <.> <R>ead <C>onfiguration Display your 'preferences'.\n"
+ " <.> <R>ead <S>ystem info Display system statistics.\n"
+ "\n"
+ " \n"
+ " Enter commands:\n"
+ "\n"
+ " <.> <E>nter <M>essage Post a message in this room.\n"
+ " <.> <E>nter message with <E>ditor Post using a full-screen editor.\n"
+ " <.> <E>nter <A>SCII message Post 'raw' (use this when 'pasting'\n"
+ " a message from your clipboard).\n"
+ "\n"
+ " <.> <E>nter <P>assword Change your password.\n"
+ " <.> <E>nter <C>onfiguration Change your 'preferences'.\n"
+ " <.> <E>nter a new <R>oom Create a new room.\n"
+ " <.> <E>nter re<G>istration Register (name, address, etc.)\n"
+ " <.> <E>nter <B>io Enter/change your 'bio' file.\n"
+ "\n"
+ " <.> <E>nter <T>extfile File 'upload' commands.\n"
+ " <.> <E>nter file using <X>modem \n"
+ " <.> <E>nter file using <Y>modem \n"
+ " <.> <E>nter file using <Z>modem \n"
+ " \n"
+ " \n"
+ " Wholist commands:\n"
+ " \n"
+ " <.> <W>holist <L>ong Same as <W>ho is online, but displays\n"
+ " more detailed information.\n"
+ " <.> <W>holist <R>oomname Masquerade your room name (other users\n"
+ " see the name you enter rather than the\n"
+ " actual name of the room you're in)\n"
+ " <.> <W>holist <H>ostname Masquerade your host name\n"
+ " <.> <E>nter <U>sername Masquerade your user name (Admins only)\n"
+ " <.> <W>holist <S>tealth mode Enter/exit 'stealth mode' (when in stealth\n"
+ " mode you are invisible on the wholist)\n"
+ " \n"
+ " \n"
+ " Floor commands (if using floor mode)\n"
+ " ;<C>onfigure floor mode - turn floor mode on or off\n"
+ " ;<G>oto floor: - jump to a specific floor\n"
+ " ;<K>nown rooms - list all rooms on all floors\n"
+ " ;<S>kip to floor: - skip current floor, jump to another\n"
+ " ;<Z>ap floor - zap (forget) all rooms on this floor\n"
+ " \n"
+ " \n"
+ " Administrative commands: \n"
+ " \n"
+ " <.> <A>dmin <K>ill this room \n"
+ " <.> <A>dmin <E>dit this room \n"
+ " <.> <A>dmin <W>ho knows room \n"
+ " <.> <A>dmin edit <U>ser \n"
+ " <.> <A>dmin <V>alidate new users \n"
+ " <.> <A>dmin enter <I>nfo file \n"
+ " <.> <A>dmin <R>oom <I>nvite user \n"
+ " <.> <A>dmin <R>oom <K>ick out user \n"
+ " <.> <A>dmin <F>ile <D>elete \n"
+ " <.> <A>dmin <F>ile <S>end over net \n"
+ " <.> <A>dmin <F>ile <M>ove \n"
+ " <.> <A>dmin <M>essage edit: \n"
+ " <.> <A>dmin <P>ost \n"
+ " <.> <A>dmin <S>ystem configuration \n"
+ " <.> <A>dmin <T>erminate server <N>ow\n" " <.> <A>dmin <T>erminate server <S>cheduled\n"
};
int rc_ansi_color;
int rc_color_use_bg;
int rc_prompt_control = 0;
-time_t rc_idle_threshold = (time_t)900;
+time_t rc_idle_threshold = (time_t) 900;
char rc_url_cmd[SIZ];
char rc_open_cmd[SIZ];
char rc_gotmail_cmd[SIZ];
/* these variables are local to this module */
char keepalives_enabled = KA_YES; /* send NOOPs to server when idle */
-int ok_to_interrupt = 0; /* print instant msgs asynchronously */
-time_t AnsiDetect; /* when did we send the detect code? */
-int enable_color = 0; /* nonzero for ANSI color */
+int ok_to_interrupt = 0; /* print instant msgs asynchronously */
+time_t AnsiDetect; /* when did we send the detect code? */
+int enable_color = 0; /* nonzero for ANSI color */
/*
* If an interesting key has been pressed, return its value, otherwise 0
*/
-char was_a_key_pressed(void) {
+char was_a_key_pressed(void)
+{
fd_set rfds;
struct timeval tv;
int the_character;
FD_SET(0, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
- retval = select(1, &rfds, NULL, NULL, &tv);
+ retval = select(1, &rfds, NULL, NULL, &tv);
/* Careful! Disable keepalives during keyboard polling; we're probably
* in the middle of a data transfer from the server, in which case
set_keepalives(KA_NO);
the_character = inkey();
set_keepalives(KA_YES);
- }
- else {
+ } else {
the_character = 0;
}
- return(the_character);
+ return (the_character);
}
color(BRIGHT_RED);
scr_printf("\r---");
}
-
+
while (instant_msgs != 0) {
r = CtdlIPCGetInstantMessage(ipc_for_signal_handlers, &listing, buf);
if (r / 100 != 1)
return;
-
+
instant_msgs = extract_int(buf, 0);
timestamp = extract_long(buf, 1);
flags = extract_int(buf, 2);
extract_token(sender, buf, 3, '|', sizeof sender);
extract_token(node, buf, 4, '|', sizeof node);
strcpy(last_paged, sender);
-
+
localtime_r(×tamp, &stamp);
/* If the page is a Logoff Request, honor it. */
termn8 = 1;
return;
}
-
+
if (!IsEmptyStr(rc_exp_cmd)) {
outpipe = popen(rc_exp_cmd, "w");
if (outpipe != NULL) {
/* Header derived from flags */
if (flags & 2)
- fprintf(outpipe,
- "Please log off now, as requested ");
+ fprintf(outpipe, "Please log off now, as requested ");
else if (flags & 1)
fprintf(outpipe, "Broadcast message ");
else if (flags & 4)
fprintf(outpipe, "Message ");
/* Timestamp. Can this be improved? */
if (stamp.tm_hour == 0 || stamp.tm_hour == 12)
- fprintf(outpipe, "at 12:%02d%cm",
- stamp.tm_min,
- stamp.tm_hour ? 'p' : 'a');
- else if (stamp.tm_hour > 12) /* pm */
- fprintf(outpipe, "at %d:%02dpm",
- stamp.tm_hour - 12,
- stamp.tm_min);
- else /* am */
- fprintf(outpipe, "at %d:%02dam",
- stamp.tm_hour, stamp.tm_min);
+ fprintf(outpipe, "at 12:%02d%cm", stamp.tm_min, stamp.tm_hour ? 'p' : 'a');
+ else if (stamp.tm_hour > 12) /* pm */
+ fprintf(outpipe, "at %d:%02dpm", stamp.tm_hour - 12, stamp.tm_min);
+ else /* am */
+ fprintf(outpipe, "at %d:%02dam", stamp.tm_hour, stamp.tm_min);
fprintf(outpipe, " from %s", sender);
if (strncmp(ipc_for_signal_handlers->ServInfo.nodename, node, 32))
fprintf(outpipe, " @%s", node);
scr_printf("Chat request ");
else
scr_printf("Message ");
-
+
/* Timestamp. Can this be improved? */
- if (stamp.tm_hour == 0 || stamp.tm_hour == 12)/* 12am/12pm */
- scr_printf("at 12:%02d%cm", stamp.tm_min,
- stamp.tm_hour ? 'p' : 'a');
- else if (stamp.tm_hour > 12) /* pm */
- scr_printf("at %d:%02dpm",
- stamp.tm_hour - 12, stamp.tm_min);
- else /* am */
+ if (stamp.tm_hour == 0 || stamp.tm_hour == 12) /* 12am/12pm */
+ scr_printf("at 12:%02d%cm", stamp.tm_min, stamp.tm_hour ? 'p' : 'a');
+ else if (stamp.tm_hour > 12) /* pm */
+ scr_printf("at %d:%02dpm", stamp.tm_hour - 12, stamp.tm_min);
+ else /* am */
scr_printf("at %d:%02dam", stamp.tm_hour, stamp.tm_min);
-
+
/* Sender */
scr_printf(" from %s", sender);
-
+
/* Remote node, if any */
if (strncmp(ipc_for_signal_handlers->ServInfo.nodename, node, 32))
scr_printf(" @%s", node);
-
+
scr_printf(":\n");
fmout(screenwidth, NULL, listing, NULL, 0);
free(listing);
*/
static time_t idlet = 0;
-static void really_do_keepalive(void) {
+static void really_do_keepalive(void)
+{
time(&idlet);
if (ok_to_interrupt == 1) {
scr_printf("\r%64s\r", "");
print_instant();
- scr_printf("%s%c ", room_name,
- room_prompt(room_flags));
+ scr_printf("%s%c ", room_name, room_prompt(room_flags));
scr_flush();
}
}
/* If half keepalives are enabled, send a QNOP to the server (if the
* server supports it) and then do nothing.
*/
- if ( (keepalives_enabled == KA_HALF)
- && (ipc_for_signal_handlers->ServInfo.supports_qnop > 0) ) {
+ if ((keepalives_enabled == KA_HALF)
+ && (ipc_for_signal_handlers->ServInfo.supports_qnop > 0)) {
CtdlIPC_chat_send(ipc_for_signal_handlers, "QNOP");
}
}
time_t now;
time(&now);
- if ((now - idlet) < ((long) S_KEEPALIVE))
- {
+ if ((now - idlet) < ((long) S_KEEPALIVE)) {
return;
}
while (num_stars--) {
scr_putc('*');
}
- }
- else {
+ } else {
scr_printf("%s", string);
}
- while(1) {
+ while (1) {
ch = inkey();
- if ((ch == 8) && (pos > 0)) { /* backspace */
+ if ((ch == 8) && (pos > 0)) { /* backspace */
--pos;
- scr_putc(8); scr_putc(32); scr_putc(8);
+ scr_putc(8);
+ scr_putc(32);
+ scr_putc(8);
}
- else if ((ch == 8) && (pos == 0) && (bs)) { /* backspace out of the prompt */
- return(-1);
+ else if ((ch == 8) && (pos == 0) && (bs)) { /* backspace out of the prompt */
+ return (-1);
}
- else if ((ch == 23) && (pos > 0)) { /* Ctrl-W deletes a word */
+ else if ((ch == 23) && (pos > 0)) { /* Ctrl-W deletes a word */
while ((pos > 0) && !isspace(string[pos])) {
--pos;
- scr_putc(8); scr_putc(32); scr_putc(8);
+ scr_putc(8);
+ scr_putc(32);
+ scr_putc(8);
}
- while ((pos > 0) && !isspace(string[pos-1])) {
+ while ((pos > 0) && !isspace(string[pos - 1])) {
--pos;
- scr_putc(8); scr_putc(32); scr_putc(8);
+ scr_putc(8);
+ scr_putc(32);
+ scr_putc(8);
}
}
- else if (ch == 10) { /* return */
+ else if (ch == 10) { /* return */
string[pos] = 0;
scr_printf("\n");
- return(pos);
+ return (pos);
}
- else if (isprint(ch)) { /* payload characters */
+ else if (isprint(ch)) { /* payload characters */
scr_putc((noshow ? '*' : ch));
string[pos] = ch;
++pos;
color(DIM_WHITE);
scr_printf(": ");
color(BRIGHT_CYAN);
- ctdl_getline(str, abs(len), (len<0), 0);
+ ctdl_getline(str, abs(len), (len < 0), 0);
color(DIM_WHITE);
}
snprintf(buf, sizeof buf, "%d", i);
strprompt(prompt, buf, 15);
i = atoi(buf);
- for (p=0; !IsEmptyStr(&buf[p]); ++p) {
- if ( (!isdigit(buf[p]))
- && ( (buf[p]!='-') || (p!=0) ) )
+ for (p = 0; !IsEmptyStr(&buf[p]); ++p) {
+ if ((!isdigit(buf[p]))
+ && ((buf[p] != '-') || (p != 0)))
i = imin - 1;
}
if (i < imin)
color(BRIGHT_MAGENTA);
scr_printf("%s", prompt);
color(DIM_MAGENTA);
- ctdl_getline(str, abs(len), (len<0), 0);
+ ctdl_getline(str, abs(len), (len < 0), 0);
color(DIM_WHITE);
}
#ifdef HAVE_OPENSSL
else if (!strcasecmp(&buf[8], "no")) {
rc_encrypt = RC_NO;
- }
- else if (!strcasecmp(&buf[8], "default")) {
+ } else if (!strcasecmp(&buf[8], "default")) {
rc_encrypt = RC_DEFAULT;
}
#endif
if (strbuf[a] == '&') {
/* dont echo these non mnemonic command keys */
- int noecho = strbuf[a+1] == '<' || strbuf[a+1] == '>' || strbuf[a+1] == '+' || strbuf[a+1] == '-';
+ int noecho = strbuf[a + 1] == '<' || strbuf[a + 1] == '>' || strbuf[a + 1] == '+' || strbuf[a + 1] == '-';
if (mode == 0) {
strcpy(&exp[a], &exp[a + 1 + noecho]);
* This function returns an integer command number. If the command prompts
* for a string then it is placed in the supplied buffer.
*/
-int getcmd(CtdlIPC *ipc, char *argbuf)
+int getcmd(CtdlIPC * ipc, char *argbuf)
{
char cmdbuf[5];
int cmdspaces[5];
if (cptr->c_cmdnum == this_lazy_cmd) {
for (a = 0; a < 5; ++a)
if (cptr->c_keys[a][0] != 0)
- scr_printf("%s ", cmd_expand(
- cptr->c_keys[a], 0));
+ scr_printf("%s ", cmd_expand(cptr->c_keys[a], 0));
scr_printf("\n");
return (this_lazy_cmd);
}
if (cmdmatch(cmdbuf, cptr, cmdpos + 1)) {
scr_printf("%s", cmd_expand(cptr->c_keys[cmdpos], 0));
- cmdspaces[cmdpos] = strlen(
- cmd_expand(cptr->c_keys[cmdpos], 0));
+ cmdspaces[cmdpos] = strlen(cmd_expand(cptr->c_keys[cmdpos], 0));
if (cmdpos < 4)
if ((cptr->c_keys[cmdpos + 1]) != 0)
scr_putc(' ');
for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
if (cmdmatch(cmdbuf, cptr, cmdpos)) {
for (a = 0; a < 5; ++a) {
- keyopt(cmd_expand(cptr->c_keys[a], 1));
- scr_printf(" ");
+ keyopt(cmd_expand(cptr->c_keys[a], 1));
+ scr_printf(" ");
}
scr_printf("\n");
}
}
- sigcaught = 0;
+ sigcaught = 0;
scr_printf("\n%s%c ", room_name, room_prompt(room_flags));
got = 0;
for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
if ((got == 0) && (cmdmatch(cmdbuf, cptr, cmdpos))) {
for (a = 0; a < cmdpos; ++a) {
- scr_printf("%s ",
- cmd_expand(cptr->c_keys[a], 0));
+ scr_printf("%s ", cmd_expand(cptr->c_keys[a], 0));
}
got = 1;
}
/*
* display_help() - help text viewer
*/
-void display_help(CtdlIPC *ipc, char *name)
+void display_help(CtdlIPC * ipc, char *name)
{
int i;
- int num_helps = sizeof(helpnames) / sizeof(char *) ;
+ int num_helps = sizeof(helpnames) / sizeof(char *);
- for (i=0; i<num_helps; ++i) {
+ for (i = 0; i < num_helps; ++i) {
if (!strcasecmp(name, helpnames[i])) {
fmout(screenwidth, NULL, helptexts[i], NULL, 0);
return;
}
scr_printf("'%s' not found. Enter one of:\n", name);
- for (i=0; i<num_helps; ++i) {
+ for (i = 0; i < num_helps; ++i) {
scr_printf(" %s\n", helpnames[i]);
}
}
/*
* fmout() - Citadel text formatter and paginator
*/
-int fmout(
- int width, /* screen width to use */
- FILE *fpin, /* file to read from, or NULL to format given text */
- char *text, /* text to be formatted (when fpin is NULL */
- FILE *fpout, /* file to write to, or NULL to write to screen */
- int subst) /* nonzero if we should use hypertext mode */
-{
+int fmout(int width, /* screen width to use */
+ FILE * fpin, /* file to read from, or NULL to format given text */
+ char *text, /* text to be formatted (when fpin is NULL */
+ FILE * fpout, /* file to write to, or NULL to write to screen */
+ int subst) { /* nonzero if we should use hypertext mode */
char *buffer = NULL; /* The current message */
char *word = NULL; /* What we are about to actually print */
char *e; /* Pointer to position in text */
size_t i; /* Generic counter */
/* Space for a single word, which can be at most screenwidth */
- word = (char *)calloc(1, width);
+ word = (char *) calloc(1, width);
if (!word) {
- scr_printf("Can't alloc memory to print message: %s!\n",
- strerror(errno));
+ scr_printf("Can't alloc memory to print message: %s!\n", strerror(errno));
logoff(NULL, 3);
}
if (fpin) {
buffer = load_message_from_file(fpin);
if (!buffer) {
- scr_printf("Can't print message: %s!\n",
- strerror(errno));
+ scr_printf("Can't print message: %s!\n", strerror(errno));
logoff(NULL, 3);
}
} else {
scr_printf("\n");
}
column = 0;
- } else if (old != ' ') {/* Don't print two spaces */
+ } else if (old != ' ') { /* Don't print two spaces */
if (fpout) {
fprintf(fpout, " ");
} else {
/* Are we looking at a nonprintable?
* (This section is now commented out because we could be displaying
* a character set like UTF-8 or ISO-8859-1.)
- if ( (*e < 32) || (*e > 126) ) {
- e++;
- continue;
- } */
+ if ( (*e < 32) || (*e > 126) ) {
+ e++;
+ continue;
+ } */
/* Or are we looking at a space? */
if (*e == ' ') {
/* Break up really long words */
/* TODO: auto-hyphenation someday? */
- if (i >= width)
+ if (i >= width)
i = width - 1;
strncpy(word, e, i);
word[i] = 0;
if (colornum == ORIGINAL_PAIR)
printf("\033[0;39;49m");
else
- printf("\033[%d;3%d;4%dm",
- (colornum & 8) ? 1 : 0,
- (colornum & 7),
- rc_color_use_bg);
+ printf("\033[%d;3%d;4%dm", (colornum & 8) ? 1 : 0, (colornum & 7), rc_color_use_bg);
}
}
void cls(int colornum)
{
if (enable_color) {
- printf("\033[4%dm\033[2J\033[H\033[0m",
- colornum ? colornum : rc_color_use_bg);
+ printf("\033[4%dm\033[2J\033[H\033[0m", colornum ? colornum : rc_color_use_bg);
}
}
abuf[strlen(abuf) + 1] = 0;
rv = read(0, &abuf[strlen(abuf)], 1);
if (rv < 0) {
- scr_printf("failed to read after select: %s",
- strerror(errno));
+ scr_printf("failed to read after select: %s", strerror(errno));
break;
}
}
/*
* Display key options (highlight hotkeys inside angle brackets)
*/
-void keyopt(char *buf) {
+void keyopt(char *buf)
+{
int i;
color(DIM_WHITE);
- for (i=0; !IsEmptyStr(&buf[i]); ++i) {
- if (buf[i]=='<') {
+ for (i = 0; !IsEmptyStr(&buf[i]); ++i) {
+ if (buf[i] == '<') {
scr_printf("%c", buf[i]);
color(BRIGHT_MAGENTA);
} else {
- if (buf[i]=='>'&& buf[i+1] != '>') {
+ if (buf[i] == '>' && buf[i + 1] != '>') {
color(DIM_WHITE);
}
scr_printf("%c", buf[i]);
/*
* Present a key-menu line choice type of thing
*/
-char keymenu(char *menuprompt, char *menustring) {
+char keymenu(char *menuprompt, char *menustring)
+{
int i, c, a;
int choices;
int do_prompt = 0;
choices = num_tokens(menustring, '|');
- if (menuprompt != NULL) do_prompt = 1;
- if ((menuprompt != NULL) && (IsEmptyStr(menuprompt))) do_prompt = 0;
+ if (menuprompt != NULL)
+ do_prompt = 1;
+ if ((menuprompt != NULL) && (IsEmptyStr(menuprompt)))
+ do_prompt = 0;
while (1) {
if (display_prompt) {
if (do_prompt) {
scr_printf("%s ", menuprompt);
- }
- else {
- for (i=0; i<choices; ++i) {
+ } else {
+ for (i = 0; i < choices; ++i) {
extract_token(buf, menustring, i, '|', sizeof buf);
keyopt(buf);
scr_printf(" ");
display_prompt = 0;
}
ch = lkey();
-
- if ( (do_prompt) && (ch=='?') ) {
+
+ if ((do_prompt) && (ch == '?')) {
scr_printf("\rOne of... ");
scr_printf(" \n");
- for (i=0; i<choices; ++i) {
+ for (i = 0; i < choices; ++i) {
extract_token(buf, menustring, i, '|', sizeof buf);
scr_printf(" ");
keyopt(buf);
display_prompt = 1;
}
- for (i=0; i<choices; ++i) {
+ for (i = 0; i < choices; ++i) {
extract_token(buf, menustring, i, '|', sizeof buf);
- for (c=1; !IsEmptyStr(&buf[c]); ++c) {
- if ( (ch == tolower(buf[c]))
- && (buf[c-1]=='<')
- && (buf[c+1]=='>') ) {
- for (a=0; !IsEmptyStr(&buf[a]); ++a) {
- if ( (a!=(c-1)) && (a!=(c+1))) {
+ for (c = 1; !IsEmptyStr(&buf[c]); ++c) {
+ if ((ch == tolower(buf[c]))
+ && (buf[c - 1] == '<')
+ && (buf[c + 1] == '>')) {
+ for (a = 0; !IsEmptyStr(&buf[a]); ++a) {
+ if ((a != (c - 1)) && (a != (c + 1))) {
scr_putc(buf[a]);
}
}
/* Note that some of these functions may not work with multiple instances. */
-static void (*deathHook)(void) = NULL;
-int (*error_printf)(char *s, ...) = (int (*)(char *, ...))printf;
+static void (*deathHook) (void) = NULL;
+int (*error_printf) (char *s, ...) = (int (*)(char *, ...)) printf;
-void setIPCDeathHook(void (*hook)(void)) {
+void setIPCDeathHook(void (*hook) (void))
+{
deathHook = hook;
}
-void setIPCErrorPrintf(int (*func)(char *s, ...)) {
+void setIPCErrorPrintf(int (*func) (char *s, ...))
+{
error_printf = func;
}
-void connection_died(CtdlIPC* ipc, int using_ssl) {
+void connection_died(CtdlIPC * ipc, int using_ssl)
+{
if (deathHook != NULL) {
deathHook();
}
fflush(stdout);
shutdown(ipc->sock, 2);
ipc->sock = -1;
- exit(1);
+ exit(1);
}
*/
void byteReverse(unsigned char *buf, unsigned longs)
{
- uint32_t t;
- do {
- t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- *(uint32_t *) buf = t;
- buf += 4;
- } while (--longs);
+ uint32_t t;
+ do {
+ t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]);
+ *(uint32_t *) buf = t;
+ buf += 4;
+ } while (--longs);
}
#endif
#endif
*/
void MD5Init(struct MD5Context *ctx)
{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
}
/*
*/
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
{
- uint32_t t;
+ uint32_t t;
- /* Update bitcount */
+ /* Update bitcount */
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
- /* Handle any leading odd-sized chunks */
+ /* Handle any leading odd-sized chunks */
- if (t) {
- unsigned char *p = (unsigned char *) ctx->in + t;
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
- t = 64 - t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
+ t = 64 - t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, ctx->in);
+ buf += t;
+ len -= t;
}
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memcpy(ctx->in, buf, len);
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy(ctx->in, buf, len);
}
/*
*/
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
{
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ((unsigned char*)ctx->in) + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- ((uint32_t *) ctx->in)[14] = ctx->bits[0];
- ((uint32_t *) ctx->in)[15] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- byteReverse((unsigned char *) ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ((unsigned char *) ctx->in) + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count - 8);
+ }
+ byteReverse(ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+ ((uint32_t *) ctx->in)[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ byteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
*/
void MD5Transform(uint32_t buf[4], uint32_t const in[16])
{
- register uint32_t a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
-#ifdef __PUREC__ /* PureC Weirdness... (GG) */
- MD5STEP(F1(b,c,d), a, b, c, d, in[0] + 0xd76aa478L, 7);
- MD5STEP(F1(a,b,c), d, a, b, c, in[1] + 0xe8c7b756L, 12);
- MD5STEP(F1(d,a,b), c, d, a, b, in[2] + 0x242070dbL, 17);
- MD5STEP(F1(c,d,a), b, c, d, a, in[3] + 0xc1bdceeeL, 22);
- MD5STEP(F1(b,c,d), a, b, c, d, in[4] + 0xf57c0fafL, 7);
- MD5STEP(F1(a,b,c), d, a, b, c, in[5] + 0x4787c62aL, 12);
- MD5STEP(F1(d,a,b), c, d, a, b, in[6] + 0xa8304613L, 17);
- MD5STEP(F1(c,d,a), b, c, d, a, in[7] + 0xfd469501L, 22);
- MD5STEP(F1(b,c,d), a, b, c, d, in[8] + 0x698098d8L, 7);
- MD5STEP(F1(a,b,c), d, a, b, c, in[9] + 0x8b44f7afL, 12);
- MD5STEP(F1(d,a,b), c, d, a, b, in[10] + 0xffff5bb1L, 17);
- MD5STEP(F1(c,d,a), b, c, d, a, in[11] + 0x895cd7beL, 22);
- MD5STEP(F1(b,c,d), a, b, c, d, in[12] + 0x6b901122L, 7);
- MD5STEP(F1(a,b,c), d, a, b, c, in[13] + 0xfd987193L, 12);
- MD5STEP(F1(d,a,b), c, d, a, b, in[14] + 0xa679438eL, 17);
- MD5STEP(F1(c,d,a), b, c, d, a, in[15] + 0x49b40821L, 22);
-
- MD5STEP(F2(b,c,d), a, b, c, d, in[1] + 0xf61e2562L, 5);
- MD5STEP(F2(a,b,c), d, a, b, c, in[6] + 0xc040b340L, 9);
- MD5STEP(F2(d,a,b), c, d, a, b, in[11] + 0x265e5a51L, 14);
- MD5STEP(F2(c,d,a), b, c, d, a, in[0] + 0xe9b6c7aaL, 20);
- MD5STEP(F2(b,c,d), a, b, c, d, in[5] + 0xd62f105dL, 5);
- MD5STEP(F2(a,b,c), d, a, b, c, in[10] + 0x02441453L, 9);
- MD5STEP(F2(d,a,b), c, d, a, b, in[15] + 0xd8a1e681L, 14);
- MD5STEP(F2(c,d,a), b, c, d, a, in[4] + 0xe7d3fbc8L, 20);
- MD5STEP(F2(b,c,d), a, b, c, d, in[9] + 0x21e1cde6L, 5);
- MD5STEP(F2(a,b,c), d, a, b, c, in[14] + 0xc33707d6L, 9);
- MD5STEP(F2(d,a,b), c, d, a, b, in[3] + 0xf4d50d87L, 14);
- MD5STEP(F2(c,d,a), b, c, d, a, in[8] + 0x455a14edL, 20);
- MD5STEP(F2(b,c,d), a, b, c, d, in[13] + 0xa9e3e905L, 5);
- MD5STEP(F2(a,b,c), d, a, b, c, in[2] + 0xfcefa3f8L, 9);
- MD5STEP(F2(d,a,b), c, d, a, b, in[7] + 0x676f02d9L, 14);
- MD5STEP(F2(c,d,a), b, c, d, a, in[12] + 0x8d2a4c8aL, 20);
-
- MD5STEP(F3(b,c,d), a, b, c, d, in[5] + 0xfffa3942L, 4);
- MD5STEP(F3(a,b,c), d, a, b, c, in[8] + 0x8771f681L, 11);
- MD5STEP(F3(d,a,b), c, d, a, b, in[11] + 0x6d9d6122L, 16);
- MD5STEP(F3(c,d,a), b, c, d, a, in[14] + 0xfde5380cL, 23);
- MD5STEP(F3(b,c,d), a, b, c, d, in[1] + 0xa4beea44L, 4);
- MD5STEP(F3(a,b,c), d, a, b, c, in[4] + 0x4bdecfa9L, 11);
- MD5STEP(F3(d,a,b), c, d, a, b, in[7] + 0xf6bb4b60L, 16);
- MD5STEP(F3(c,d,a), b, c, d, a, in[10] + 0xbebfbc70L, 23);
- MD5STEP(F3(b,c,d), a, b, c, d, in[13] + 0x289b7ec6L, 4);
- MD5STEP(F3(a,b,c), d, a, b, c, in[0] + 0xeaa127faL, 11);
- MD5STEP(F3(d,a,b), c, d, a, b, in[3] + 0xd4ef3085L, 16);
- MD5STEP(F3(c,d,a), b, c, d, a, in[6] + 0x04881d05L, 23);
- MD5STEP(F3(b,c,d), a, b, c, d, in[9] + 0xd9d4d039L, 4);
- MD5STEP(F3(a,b,c), d, a, b, c, in[12] + 0xe6db99e5L, 11);
- MD5STEP(F3(d,a,b), c, d, a, b, in[15] + 0x1fa27cf8L, 16);
- MD5STEP(F3(c,d,a), b, c, d, a, in[2] + 0xc4ac5665L, 23);
-
- MD5STEP(F4(b,c,d), a, b, c, d, in[0] + 0xf4292244L, 6);
- MD5STEP(F4(a,b,c), d, a, b, c, in[7] + 0x432aff97L, 10);
- MD5STEP(F4(d,a,b), c, d, a, b, in[14] + 0xab9423a7L, 15);
- MD5STEP(F4(c,d,a), b, c, d, a, in[5] + 0xfc93a039L, 21);
- MD5STEP(F4(b,c,d), a, b, c, d, in[12] + 0x655b59c3L, 6);
- MD5STEP(F4(a,b,c), d, a, b, c, in[3] + 0x8f0ccc92L, 10);
- MD5STEP(F4(d,a,b), c, d, a, b, in[10] + 0xffeff47dL, 15);
- MD5STEP(F4(c,d,a), b, c, d, a, in[1] + 0x85845dd1L, 21);
- MD5STEP(F4(b,c,d), a, b, c, d, in[8] + 0x6fa87e4fL, 6);
- MD5STEP(F4(a,b,c), d, a, b, c, in[15] + 0xfe2ce6e0L, 10);
- MD5STEP(F4(d,a,b), c, d, a, b, in[6] + 0xa3014314L, 15);
- MD5STEP(F4(c,d,a), b, c, d, a, in[13] + 0x4e0811a1L, 21);
- MD5STEP(F4(b,c,d), a, b, c, d, in[4] + 0xf7537e82L, 6);
- MD5STEP(F4(a,b,c), d, a, b, c, in[11] + 0xbd3af235L, 10);
- MD5STEP(F4(d,a,b), c, d, a, b, in[2] + 0x2ad7d2bbL, 15);
- MD5STEP(F4(c,d,a), b, c, d, a, in[9] + 0xeb86d391L, 21);
+ register uint32_t a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+#ifdef __PUREC__ /* PureC Weirdness... (GG) */
+ MD5STEP(F1(b, c, d), a, b, c, d, in[0] + 0xd76aa478L, 7);
+ MD5STEP(F1(a, b, c), d, a, b, c, in[1] + 0xe8c7b756L, 12);
+ MD5STEP(F1(d, a, b), c, d, a, b, in[2] + 0x242070dbL, 17);
+ MD5STEP(F1(c, d, a), b, c, d, a, in[3] + 0xc1bdceeeL, 22);
+ MD5STEP(F1(b, c, d), a, b, c, d, in[4] + 0xf57c0fafL, 7);
+ MD5STEP(F1(a, b, c), d, a, b, c, in[5] + 0x4787c62aL, 12);
+ MD5STEP(F1(d, a, b), c, d, a, b, in[6] + 0xa8304613L, 17);
+ MD5STEP(F1(c, d, a), b, c, d, a, in[7] + 0xfd469501L, 22);
+ MD5STEP(F1(b, c, d), a, b, c, d, in[8] + 0x698098d8L, 7);
+ MD5STEP(F1(a, b, c), d, a, b, c, in[9] + 0x8b44f7afL, 12);
+ MD5STEP(F1(d, a, b), c, d, a, b, in[10] + 0xffff5bb1L, 17);
+ MD5STEP(F1(c, d, a), b, c, d, a, in[11] + 0x895cd7beL, 22);
+ MD5STEP(F1(b, c, d), a, b, c, d, in[12] + 0x6b901122L, 7);
+ MD5STEP(F1(a, b, c), d, a, b, c, in[13] + 0xfd987193L, 12);
+ MD5STEP(F1(d, a, b), c, d, a, b, in[14] + 0xa679438eL, 17);
+ MD5STEP(F1(c, d, a), b, c, d, a, in[15] + 0x49b40821L, 22);
+
+ MD5STEP(F2(b, c, d), a, b, c, d, in[1] + 0xf61e2562L, 5);
+ MD5STEP(F2(a, b, c), d, a, b, c, in[6] + 0xc040b340L, 9);
+ MD5STEP(F2(d, a, b), c, d, a, b, in[11] + 0x265e5a51L, 14);
+ MD5STEP(F2(c, d, a), b, c, d, a, in[0] + 0xe9b6c7aaL, 20);
+ MD5STEP(F2(b, c, d), a, b, c, d, in[5] + 0xd62f105dL, 5);
+ MD5STEP(F2(a, b, c), d, a, b, c, in[10] + 0x02441453L, 9);
+ MD5STEP(F2(d, a, b), c, d, a, b, in[15] + 0xd8a1e681L, 14);
+ MD5STEP(F2(c, d, a), b, c, d, a, in[4] + 0xe7d3fbc8L, 20);
+ MD5STEP(F2(b, c, d), a, b, c, d, in[9] + 0x21e1cde6L, 5);
+ MD5STEP(F2(a, b, c), d, a, b, c, in[14] + 0xc33707d6L, 9);
+ MD5STEP(F2(d, a, b), c, d, a, b, in[3] + 0xf4d50d87L, 14);
+ MD5STEP(F2(c, d, a), b, c, d, a, in[8] + 0x455a14edL, 20);
+ MD5STEP(F2(b, c, d), a, b, c, d, in[13] + 0xa9e3e905L, 5);
+ MD5STEP(F2(a, b, c), d, a, b, c, in[2] + 0xfcefa3f8L, 9);
+ MD5STEP(F2(d, a, b), c, d, a, b, in[7] + 0x676f02d9L, 14);
+ MD5STEP(F2(c, d, a), b, c, d, a, in[12] + 0x8d2a4c8aL, 20);
+
+ MD5STEP(F3(b, c, d), a, b, c, d, in[5] + 0xfffa3942L, 4);
+ MD5STEP(F3(a, b, c), d, a, b, c, in[8] + 0x8771f681L, 11);
+ MD5STEP(F3(d, a, b), c, d, a, b, in[11] + 0x6d9d6122L, 16);
+ MD5STEP(F3(c, d, a), b, c, d, a, in[14] + 0xfde5380cL, 23);
+ MD5STEP(F3(b, c, d), a, b, c, d, in[1] + 0xa4beea44L, 4);
+ MD5STEP(F3(a, b, c), d, a, b, c, in[4] + 0x4bdecfa9L, 11);
+ MD5STEP(F3(d, a, b), c, d, a, b, in[7] + 0xf6bb4b60L, 16);
+ MD5STEP(F3(c, d, a), b, c, d, a, in[10] + 0xbebfbc70L, 23);
+ MD5STEP(F3(b, c, d), a, b, c, d, in[13] + 0x289b7ec6L, 4);
+ MD5STEP(F3(a, b, c), d, a, b, c, in[0] + 0xeaa127faL, 11);
+ MD5STEP(F3(d, a, b), c, d, a, b, in[3] + 0xd4ef3085L, 16);
+ MD5STEP(F3(c, d, a), b, c, d, a, in[6] + 0x04881d05L, 23);
+ MD5STEP(F3(b, c, d), a, b, c, d, in[9] + 0xd9d4d039L, 4);
+ MD5STEP(F3(a, b, c), d, a, b, c, in[12] + 0xe6db99e5L, 11);
+ MD5STEP(F3(d, a, b), c, d, a, b, in[15] + 0x1fa27cf8L, 16);
+ MD5STEP(F3(c, d, a), b, c, d, a, in[2] + 0xc4ac5665L, 23);
+
+ MD5STEP(F4(b, c, d), a, b, c, d, in[0] + 0xf4292244L, 6);
+ MD5STEP(F4(a, b, c), d, a, b, c, in[7] + 0x432aff97L, 10);
+ MD5STEP(F4(d, a, b), c, d, a, b, in[14] + 0xab9423a7L, 15);
+ MD5STEP(F4(c, d, a), b, c, d, a, in[5] + 0xfc93a039L, 21);
+ MD5STEP(F4(b, c, d), a, b, c, d, in[12] + 0x655b59c3L, 6);
+ MD5STEP(F4(a, b, c), d, a, b, c, in[3] + 0x8f0ccc92L, 10);
+ MD5STEP(F4(d, a, b), c, d, a, b, in[10] + 0xffeff47dL, 15);
+ MD5STEP(F4(c, d, a), b, c, d, a, in[1] + 0x85845dd1L, 21);
+ MD5STEP(F4(b, c, d), a, b, c, d, in[8] + 0x6fa87e4fL, 6);
+ MD5STEP(F4(a, b, c), d, a, b, c, in[15] + 0xfe2ce6e0L, 10);
+ MD5STEP(F4(d, a, b), c, d, a, b, in[6] + 0xa3014314L, 15);
+ MD5STEP(F4(c, d, a), b, c, d, a, in[13] + 0x4e0811a1L, 21);
+ MD5STEP(F4(b, c, d), a, b, c, d, in[4] + 0xf7537e82L, 6);
+ MD5STEP(F4(a, b, c), d, a, b, c, in[11] + 0xbd3af235L, 10);
+ MD5STEP(F4(d, a, b), c, d, a, b, in[2] + 0x2ad7d2bbL, 15);
+ MD5STEP(F4(c, d, a), b, c, d, a, in[9] + 0xeb86d391L, 21);
#else
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
#endif
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
/*
char *make_apop_string(char *realpass, char *nonce, char *buffer, size_t n)
{
- struct MD5Context ctx;
- u_char rawdigest[MD5_DIGEST_LEN];
- int i;
-
- MD5Init(&ctx);
- MD5Update(&ctx, (u_char*)nonce, strlen(nonce));
- MD5Update(&ctx, (u_char*)realpass, strlen(realpass));
- MD5Final(rawdigest, &ctx);
- for (i=0; i<MD5_DIGEST_LEN; i++)
- {
- snprintf(&buffer[i*2], n - i*2, "%02X", (unsigned char) (rawdigest[i] & 0xff));
- buffer[i*2] = tolower(buffer[i*2]);
- buffer[(i*2)+1] = tolower(buffer[(i*2)+1]);
- }
- return buffer;
+ struct MD5Context ctx;
+ u_char rawdigest[MD5_DIGEST_LEN];
+ int i;
+
+ MD5Init(&ctx);
+ MD5Update(&ctx, (u_char *) nonce, strlen(nonce));
+ MD5Update(&ctx, (u_char *) realpass, strlen(realpass));
+ MD5Final(rawdigest, &ctx);
+ for (i = 0; i < MD5_DIGEST_LEN; i++) {
+ snprintf(&buffer[i * 2], n - i * 2, "%02X", (unsigned char) (rawdigest[i] & 0xff));
+ buffer[i * 2] = tolower(buffer[i * 2]);
+ buffer[(i * 2) + 1] = tolower(buffer[(i * 2) + 1]);
+ }
+ return buffer;
}
void stty_ctdl(int cmd);
int haschar(const char *st, int ch);
int file_checksum(char *filename);
-void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
+void progress(CtdlIPC * ipc, unsigned long curr, unsigned long cmax);
unsigned long *msg_arr = NULL;
int msg_arr_size = 0;
int num_urls = 0;
char urls[MAXURLS][SIZ];
char imagecmd[SIZ];
-int has_images = 0; /* Current msg has images */
+int has_images = 0; /* Current msg has images */
struct parts *last_message_parts = NULL; /* Parts from last msg */
/*
* begin editing of an opened file pointed to by fp
*/
-void citedit(FILE *fp)
+void citedit(FILE * fp)
{
int a, prev, finished, b, last_space;
int appending = 0;
for (b = 0; b < strlen(wordbuf); ++b)
if (wordbuf[b] == 32) {
wordbuf[b] = 0;
- add_word(textlist,
- wordbuf);
- strcpy(wordbuf,
- &wordbuf[b + 1]);
+ add_word(textlist, wordbuf);
+ strcpy(wordbuf, &wordbuf[b + 1]);
b = 0;
}
add_word(textlist, wordbuf);
for (b = 0; b < strlen(wordbuf); ++b)
if (wordbuf[b] == 32) {
wordbuf[b] = 0;
- add_word(textlist,
- wordbuf);
- strcpy(wordbuf,
- &wordbuf[b + 1]);
+ add_word(textlist, wordbuf);
+ strcpy(wordbuf, &wordbuf[b + 1]);
b = 0;
}
for (b = 0; b < strlen(wordbuf); ++b) {
if (rv < 0)
scr_printf("failed to set message buffer: %s\n", strerror(errno));
-
+
/* and deallocate the memory we used */
while (textlist != NULL) {
ptr = textlist->next;
* This is a mini RFC2047 decoder.
* It only handles strings encoded from UTF-8 as Quoted-printable.
*/
-void mini_2047_decode(char *s) {
- if (!s) return;
+void mini_2047_decode(char *s)
+{
+ if (!s)
+ return;
char *qstart = strstr(s, "=?UTF-8?Q?");
- if (!qstart) return;
+ if (!qstart)
+ return;
char *qend = strstr(s, "?=");
- if (!qend) return;
+ if (!qend)
+ return;
- if (qend <= qstart) return;
+ if (qend <= qstart)
+ return;
strcpy(qstart, &qstart[10]);
qend -= 10;
if (p[0] == '_') {
p[0] = ' ';
}
-
+
++p;
}
/*
* Read a message from the server
*/
-int read_message(CtdlIPC *ipc,
- long num, /* message number */
- int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
- FILE *dest) /* Destination file, NULL for screen */
-{
+int read_message(CtdlIPC * ipc, long num, /* message number */
+ int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
+ FILE * dest)
+{ /* Destination file, NULL for screen */
char buf[SIZ];
char now[256];
int format_type = 0;
int fr = 0;
int nhdr = 0;
struct ctdlipcmessage *message = NULL;
- int r; /* IPC response code */
+ int r; /* IPC response code */
char *converted_text = NULL;
char *lineptr;
char *nextline;
return (0);
}
- if (dest)
- {
+ if (dest) {
fprintf(dest, "\n ");
- }
- else
- {
+ } else {
scr_printf("\n");
- if (pagin != 2)
- {
+ if (pagin != 2) {
scr_printf(" ");
}
}
- if (pagin == 1 && !dest)
- {
+ if (pagin == 1 && !dest) {
color(BRIGHT_CYAN);
}
/* View headers only */
if (pagin == 2) {
scr_printf("nhdr=%s\nfrom=%s\ntype=%d\nmsgn=%s\n",
- message->nhdr ? "yes" : "no",
- message->author, message->type,
- message->msgid);
+ message->nhdr ? "yes" : "no", message->author, message->type, message->msgid);
if (!IsEmptyStr(message->subject)) {
scr_printf("subj=%s\n", message->subject);
}
if (!IsEmptyStr(message->email)) {
scr_printf("rfca=%s\n", message->email);
}
- scr_printf("room=%s\ntime=%s",
- message->room,
- asctime(localtime(&message->time))
- );
+ scr_printf("room=%s\ntime=%s", message->room, asctime(localtime(&message->time))
+ );
if (!IsEmptyStr(message->recipient)) {
scr_printf("rcpt=%s\n", message->recipient);
}
for (ptr = message->attachments; ptr; ptr = ptr->next) {
scr_printf("part=%s|%s|%s|%s|%s|%ld\n",
- ptr->name, ptr->filename, ptr->number,
- ptr->disposition, ptr->mimetype,
- ptr->length
- );
+ ptr->name, ptr->filename, ptr->number, ptr->disposition, ptr->mimetype, ptr->length);
}
}
scr_printf("\n");
scr_printf("<");
color(BRIGHT_BLUE);
scr_printf("%s", message->email);
- color(DIM_WHITE);
+ color(DIM_WHITE);
scr_printf("> ");
}
}
}
}
}
-
+
if (dest) {
fprintf(dest, "\n");
} else {
if ((message->email != NULL) && (!IsEmptyStr(message->email))) {
if (!IsEmptyStr(message->author)) {
snprintf(reply_to, sizeof reply_to, "%s <%s>", message->author, message->email);
- }
- else {
+ } else {
safestrncpy(reply_to, message->email, sizeof reply_to);
}
}
safestrncpy(reply_inreplyto, message->msgid, sizeof reply_inreplyto);
}
- if (message->references != NULL) if (!IsEmptyStr(message->references)) {
- safestrncpy(reply_references, message->references, sizeof reply_references);
- }
+ if (message->references != NULL)
+ if (!IsEmptyStr(message->references)) {
+ safestrncpy(reply_references, message->references, sizeof reply_references);
+ }
if (message->subject != NULL) {
safestrncpy(reply_subject, message->subject, sizeof reply_subject);
"ftp://"
};
int p = 0;
- num_urls = 0; /* Start with a clean slate */
- for (p=0; p<(sizeof urlprefixes / sizeof(char *)); ++p) {
+ num_urls = 0; /* Start with a clean slate */
+ for (p = 0; p < (sizeof urlprefixes / sizeof(char *)); ++p) {
searchptr = message->text;
- while ( (searchptr != NULL) && (num_urls < MAXURLS) ) {
+ while ((searchptr != NULL) && (num_urls < MAXURLS)) {
searchptr = strstr(searchptr, urlprefixes[p]);
if (searchptr != NULL) {
safestrncpy(urls[num_urls], searchptr, sizeof(urls[num_urls]));
for (i = 0; i < strlen(urls[num_urls]); i++) {
ch = urls[num_urls][i];
- if (ch == '>' || ch == '\"' || ch == ')' ||
- ch == ' ' || ch == '\n') {
+ if (ch == '>' || ch == '\"' || ch == ')' || ch == ' ' || ch == '\n') {
urls[num_urls][i] = 0;
break;
}
if (nextline != NULL) {
*nextline = 0;
++nextline;
- if (*nextline == 0) nextline = NULL;
+ if (*nextline == 0)
+ nextline = NULL;
}
if (sigcaught == 0) {
linelen = strlen(lineptr);
- if (linelen && (lineptr[linelen-1] == '\r')) {
+ if (linelen && (lineptr[linelen - 1] == '\r')) {
lineptr[--linelen] = 0;
}
if (dest) {
scr_printf("%s\n", lineptr);
}
}
- if (lineptr[0] == 0) final_line_is_blank = 1;
- else final_line_is_blank = 0;
+ if (lineptr[0] == 0)
+ final_line_is_blank = 1;
+ else
+ final_line_is_blank = 0;
lineptr = nextline;
} while (nextline);
fr = sigcaught;
if (!final_line_is_blank) {
if (dest) {
fprintf(dest, "\n");
- }
- else {
+ } else {
scr_printf("\n");
- fr = sigcaught;
+ fr = sigcaught;
}
}
/* Enumerate any attachments */
- if ( (pagin == 1) && (message->attachments) ) {
+ if ((pagin == 1) && (message->attachments)) {
struct parts *ptr;
for (ptr = message->attachments; ptr; ptr = ptr->next) {
- if ( (!strcasecmp(ptr->disposition, "attachment"))
- || (!strcasecmp(ptr->disposition, "inline"))
- || (!strcasecmp(ptr->disposition, ""))
- ) {
- if ( (strcasecmp(ptr->number, message->mime_chosen))
- && (!IsEmptyStr(ptr->mimetype))
- ) {
+ if ((!strcasecmp(ptr->disposition, "attachment"))
+ || (!strcasecmp(ptr->disposition, "inline"))
+ || (!strcasecmp(ptr->disposition, ""))
+ ) {
+ if ((strcasecmp(ptr->number, message->mime_chosen))
+ && (!IsEmptyStr(ptr->mimetype))
+ ) {
color(DIM_WHITE);
scr_printf("Part ");
color(BRIGHT_MAGENTA);
long msglen = 0L;
int rv;
- newprompt("Enter text to be replaced: ", srch_str, (sizeof(srch_str)-1) );
+ newprompt("Enter text to be replaced: ", srch_str, (sizeof(srch_str) - 1));
if (IsEmptyStr(srch_str)) {
return;
}
- newprompt("Enter text to replace it with: ", rplc_str, (sizeof(rplc_str)-1) );
+ newprompt("Enter text to replace it with: ", rplc_str, (sizeof(rplc_str) - 1));
fp = fopen(filename, "r+");
if (fp == NULL) {
rv = fwrite((char *) buf, 128, 1, fp);
if (rv < 0) {
scr_printf("failed to replace string: %s\n", strerror(errno));
- break; /*whoopsi! */
+ break; /*whoopsi! */
}
strcpy(buf, &buf[128]);
wpos = ftell(fp);
/*
* Function to begin composing a new message
*/
-int client_make_message(CtdlIPC *ipc,
- char *filename, /* temporary file name */
+int client_make_message(CtdlIPC * ipc, char *filename, /* temporary file name */
char *recipient, /* NULL if it's not mail */
- int is_anonymous,
- int format_type,
- int mode,
- char *subject, /* buffer to store subject line */
- int subject_required
-) {
+ int is_anonymous, int format_type, int mode, char *subject, /* buffer to store subject line */
+ int subject_required)
+{
FILE *fp;
int a, b, e_ex_code;
long beg;
char header[SIZ];
int cksum = 0;
- if ( (mode == 2) && (IsEmptyStr(editor_path)) ) {
+ if ((mode == 2) && (IsEmptyStr(editor_path))) {
scr_printf("*** No editor available; using built-in editor.\n");
mode = 0;
}
if (room_flags & QR_ANONONLY && !recipient) {
snprintf(header, sizeof header, " ****");
- }
- else {
- snprintf(header, sizeof header,
- " %s from %s",
- datestr,
- (is_anonymous ? "[anonymous]" : fullname)
- );
+ } else {
+ snprintf(header, sizeof header, " %s from %s", datestr, (is_anonymous ? "[anonymous]" : fullname)
+ );
if (!IsEmptyStr(recipient)) {
size_t tmp = strlen(header);
- snprintf(&header[tmp], sizeof header - tmp,
- " to %s", recipient);
+ snprintf(&header[tmp], sizeof header - tmp, " to %s", recipient);
}
}
scr_printf("%s\n", header);
- if (subject != NULL) if (!IsEmptyStr(subject)) {
- scr_printf("Subject: %s\n", subject);
- }
-
- if ( (subject_required) && (IsEmptyStr(subject)) ) {
+ if (subject != NULL)
+ if (!IsEmptyStr(subject)) {
+ scr_printf("Subject: %s\n", subject);
+ }
+
+ if ((subject_required) && (IsEmptyStr(subject))) {
newprompt("Subject: ", subject, 70);
}
fmout(screenwidth, fp, NULL, NULL, 0);
beg = ftell(fp);
if (beg < 0)
- scr_printf("failed to get stream position %s\n",
- strerror(errno));
+ scr_printf("failed to get stream position %s\n", strerror(errno));
fclose(fp);
} else {
fp = fopen(filename, "w");
if (fp == NULL) {
- scr_printf("*** Error opening temp file!\n %s: %s\n",
- filename, strerror(errno)
- );
- return(1);
+ scr_printf("*** Error opening temp file!\n %s: %s\n", filename, strerror(errno)
+ );
+ return (1);
}
fclose(fp);
}
}
-ME1: switch (mode) {
+ ME1:switch (mode) {
case 0:
fp = fopen(filename, "r+");
if (fp == NULL) {
- scr_printf("*** Error opening temp file!\n %s: %s\n",
- filename, strerror(errno)
- );
- return(1);
+ scr_printf("*** Error opening temp file!\n %s: %s\n", filename, strerror(errno)
+ );
+ return (1);
}
citedit(fp);
fclose(fp);
case 1:
fp = fopen(filename, "a");
if (fp == NULL) {
- scr_printf("*** Error opening temp file!\n"
- " %s: %s\n",
- filename, strerror(errno));
- return(1);
+ scr_printf("*** Error opening temp file!\n" " %s: %s\n", filename, strerror(errno));
+ return (1);
}
do {
a = inkey();
break;
case 2:
- default: /* allow 2+ modes */
+ default: /* allow 2+ modes */
e_ex_code = 1; /* start with a failed exit code */
stty_ctdl(SB_RESTORE);
editor_pid = fork();
break;
}
-MECR: if (mode >= 2) {
+ MECR:if (mode >= 2) {
if (file_checksum(filename) == cksum) {
scr_printf("*** Aborted message.\n");
e_ex_code = 1;
}
b = keymenu("Entry command (? for options)",
- "<A>bort|"
- "<C>ontinue|"
- "<S>ave message|"
- "<P>rint formatted|"
- "add s<U>bject|"
- "<R>eplace string|"
- "<H>old message"
- );
-
- if (b == 'a') goto MEABT;
- if (b == 'c') goto ME1;
- if (b == 's') goto MEFIN;
+ "<A>bort|"
+ "<C>ontinue|" "<S>ave message|" "<P>rint formatted|" "add s<U>bject|" "<R>eplace string|" "<H>old message");
+
+ if (b == 'a')
+ goto MEABT;
+ if (b == 'c')
+ goto ME1;
+ if (b == 's')
+ goto MEFIN;
if (b == 'p') {
scr_printf(" %s from %s", datestr, fullname);
if (!IsEmptyStr(recipient)) {
scr_printf(" to %s", recipient);
}
scr_printf("\n");
- if (subject != NULL) if (!IsEmptyStr(subject)) {
- scr_printf("Subject: %s\n", subject);
- }
+ if (subject != NULL)
+ if (!IsEmptyStr(subject)) {
+ scr_printf("Subject: %s\n", subject);
+ }
fp = fopen(filename, "r");
if (fp != NULL) {
fmout(screenwidth, fp, NULL, NULL, 0);
beg = ftell(fp);
if (beg < 0)
- scr_printf("failed to get stream position %s\n",
- strerror(errno));
+ scr_printf("failed to get stream position %s\n", strerror(errno));
fclose(fp);
}
goto MECR;
goto MECR;
}
-MEFIN: return (0);
+ MEFIN:return (0);
-MEABT: scr_printf("Are you sure? ");
+ MEABT:scr_printf("Are you sure? ");
if (yesno() == 0) {
goto ME1;
}
-MEABT2: unlink(filename);
+ MEABT2:unlink(filename);
return (2);
}
/*
* Make sure there's room in msg_arr[] for at least one more.
*/
-void check_msg_arr_size(void) {
+void check_msg_arr_size(void)
+{
if ((num_msgs + 1) > msg_arr_size) {
msg_arr_size += 512;
- msg_arr = realloc(msg_arr,
- ((sizeof(long)) * msg_arr_size) );
+ msg_arr = realloc(msg_arr, ((sizeof(long)) * msg_arr_size));
}
}
* break_big_lines() - break up lines that are >1024 characters
* otherwise the server will truncate
*/
-void break_big_lines(char *msg) {
+void break_big_lines(char *msg)
+{
char *ptr;
char *break_here;
* entmsg() - edit and create a message
* returns 0 if message was saved
*/
-int entmsg(CtdlIPC *ipc,
- int is_reply, /* nonzero if this was a <R>eply command */
- int c, /* mode */
- int masquerade /* prompt for a non-default display name? */
-) {
+int entmsg(CtdlIPC * ipc, int is_reply, /* nonzero if this was a <R>eply command */
+ int c, /* mode */
+ int masquerade /* prompt for a non-default display name? */
+ )
+{
char buf[SIZ];
int a, b;
int need_recp = 0;
if (!entmsg_ok) {
scr_printf("You may not enter messages in this type of room.\n");
- return(1);
+ return (1);
}
if (c > 0) {
mode = 1;
- }
- else {
+ } else {
mode = 0;
}
strcpy(message.author, "");
strcpy(message.subject, "");
strcpy(message.references, "");
- message.text = ""; /* point to "", changes later */
+ message.text = ""; /* point to "", changes later */
message.anonymous = 0;
message.type = mode;
if (is_reply) {
if (!IsEmptyStr(reply_subject)) {
- if (!strncasecmp(reply_subject,
- "Re: ", 3)) {
+ if (!strncasecmp(reply_subject, "Re: ", 3)) {
strcpy(message.subject, reply_subject);
- }
- else {
- snprintf(message.subject,
- sizeof message.subject,
- "Re: %s",
- reply_subject);
+ } else {
+ snprintf(message.subject, sizeof message.subject, "Re: %s", reply_subject);
}
}
*/
int rrtok = num_tokens(reply_references, '|');
int rrlen = strlen(reply_references);
- if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+ if (((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10)) {
remove_token(reply_references, 1, '|');
}
snprintf(message.references, sizeof message.references, "%s%s%s",
- reply_references,
- (IsEmptyStr(reply_references) ? "" : "|"),
- reply_inreplyto
- );
+ reply_references, (IsEmptyStr(reply_references) ? "" : "|"), reply_inreplyto);
}
r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf);
if (is_reply) {
strcpy(buf, reply_to);
} else {
- newprompt("Enter recipient: ", buf, SIZ-100);
+ newprompt("Enter recipient: ", buf, SIZ - 100);
if (IsEmptyStr(buf)) {
return (1);
}
/* If it's mail, we've got to check the validity of the recipient... */
if (!IsEmptyStr(message.recipient)) {
- r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf);
+ r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf);
if (r / 100 != 2) {
scr_printf("%s\n", buf);
return (1);
}
/* Learn the number of the newest message in in the room, so we can
- * tell upon saving whether someone else has posted too.
- */
+ * tell upon saving whether someone else has posted too.
+ */
num_msgs = 0;
r = CtdlIPCGetMessages(ipc, LastMessages, 1, NULL, &msgarr, buf);
if (r / 100 != 1) {
scr_printf("%s\n", buf);
} else {
- for (num_msgs = 0; msgarr[num_msgs]; num_msgs++)
- ;
+ for (num_msgs = 0; msgarr[num_msgs]; num_msgs++);
}
/* Now compose the message... */
- if (client_make_message(ipc, temp, message.recipient,
- message.anonymous, 0, c, message.subject, subject_required) != 0) {
- if (msgarr) free(msgarr);
+ if (client_make_message(ipc, temp, message.recipient, message.anonymous, 0, c, message.subject, subject_required) != 0) {
+ if (msgarr)
+ free(msgarr);
return (2);
}
fp = fopen(temp, "r");
if (!fp || !(message.text = load_message_from_file(fp))) {
- scr_printf("*** Internal error while trying to save message!\n"
- "%s: %s\n",
- temp, strerror(errno));
+ scr_printf("*** Internal error while trying to save message!\n" "%s: %s\n", temp, strerror(errno));
unlink(temp);
- return(errno);
+ return (errno);
}
- if (fp) fclose(fp);
+ if (fp)
+ fclose(fp);
/* Break lines that are >1024 characters, otherwise the server
* will truncate them.
/* Yes, unlink it now, so it doesn't stick around if we crash */
unlink(temp);
- if (num_msgs >= 1) highmsg = msgarr[num_msgs - 1];
+ if (num_msgs >= 1)
+ highmsg = msgarr[num_msgs - 1];
- if (msgarr) free(msgarr);
+ if (msgarr)
+ free(msgarr);
msgarr = NULL;
r = CtdlIPCGetMessages(ipc, NewMessages, 0, NULL, &msgarr, buf);
if (r / 100 != 1) {
scr_printf("%s\n", buf);
} else {
- for (num_msgs = 0; msgarr[num_msgs]; num_msgs++)
- ;
+ for (num_msgs = 0; msgarr[num_msgs]; num_msgs++);
}
/* get new highest message number in room to set lrp for goto... */
++b;
}
}
- if (msgarr) free(msgarr);
+ if (msgarr)
+ free(msgarr);
msgarr = NULL;
/* In the Mail> room, this algorithm always counts one message
}
if (b == 1) {
- scr_printf("*** 1 additional message has been entered "
- "in this room by another user.\n");
+ scr_printf("*** 1 additional message has been entered " "in this room by another user.\n");
+ } else if (b > 1) {
+ scr_printf("*** %d additional messages have been entered " "in this room by other users.\n", b);
}
- else if (b > 1) {
- scr_printf("*** %d additional messages have been entered "
- "in this room by other users.\n", b);
- }
- free(message.text);
+ free(message.text);
- return(0);
+ return (0);
}
/*
/*
* List the URL's which were embedded in the previous message
*/
-void list_urls(CtdlIPC *ipc)
+void list_urls(CtdlIPC * ipc)
{
int i;
char cmd[SIZ];
snprintf(cmd, sizeof cmd, rc_url_cmd, urls[i - 1]);
rv = system(cmd);
- if (rv != 0)
+ if (rv != 0)
scr_printf("failed to '%s' by %d\n", cmd, rv);
scr_printf("\n");
}
waitpid(childpid, &retcode, 0);
return retcode;
}
-
+
return -1;
}
/*
* View an image attached to a message
*/
-void image_view(CtdlIPC *ipc, unsigned long msg)
+void image_view(CtdlIPC * ipc, unsigned long msg)
{
struct parts *ptr = last_message_parts;
char part[SIZ];
/* Run through available parts */
for (ptr = last_message_parts; ptr; ptr = ptr->next) {
if ((!strcasecmp(ptr->disposition, "attachment")
- || !strcasecmp(ptr->disposition, "inline"))
- && !strncmp(ptr->mimetype, "image/", 6)) {
+ || !strcasecmp(ptr->disposition, "inline"))
+ && !strncmp(ptr->mimetype, "image/", 6)) {
found++;
if (found == 1) {
strcpy(part, ptr->number);
while (found > 0) {
if (found > 1)
- strprompt("View which part (0 when done)", part, SIZ-1);
+ strprompt("View which part (0 when done)", part, SIZ - 1);
found = -found;
for (ptr = last_message_parts; ptr; ptr = ptr->next) {
if ((!strcasecmp(ptr->disposition, "attachment")
- || !strcasecmp(ptr->disposition, "inline"))
- && !strncmp(ptr->mimetype, "image/", 6)
- && !strcasecmp(ptr->number, part)) {
+ || !strcasecmp(ptr->disposition, "inline"))
+ && !strncmp(ptr->mimetype, "image/", 6)
+ && !strcasecmp(ptr->number, part)) {
char tmp[PATH_MAX];
char buf[SIZ];
- void *file = NULL; /* The downloaded file */
+ void *file = NULL; /* The downloaded file */
int r;
-
+
/* view image */
found = -found;
r = CtdlIPCAttachmentDownload(ipc, msg, ptr->number, &file, progress, buf);
scr_printf("%s\n", buf);
} else {
size_t len;
-
- len = (size_t)extract_long(buf, 0);
+
+ len = (size_t) extract_long(buf, 0);
progress(ipc, len, len);
scr_flush();
CtdlMakeTempFileName(tmp, sizeof tmp);
break;
}
}
-
+
/*
* Read the messages in the current room
*/
-void readmsgs(CtdlIPC *ipc,
- enum MessageList c, /* see listing in citadel_ipc.h */
- enum MessageDirection rdir, /* 1=Forward (-1)=Reverse */
- int q /* Number of msgs to read (if c==3) */
-) {
+void readmsgs(CtdlIPC * ipc, enum MessageList c, /* see listing in citadel_ipc.h */
+ enum MessageDirection rdir, /* 1=Forward (-1)=Reverse */
+ int q /* Number of msgs to read (if c==3) */
+ )
+{
int a, e, f, g, start;
int savedpos;
int hold_sw = 0;
char filename[PATH_MAX];
char save_to[PATH_MAX];
void *attachment = NULL; /* Downloaded attachment */
- FILE *dest = NULL; /* Alternate destination other than screen */
- int r; /* IPC response code */
- static int att_seq = 0; /* Attachment download sequence number */
- int rv = 0; /* silence the stupid warn_unused_result warnings */
+ FILE *dest = NULL; /* Alternate destination other than screen */
+ int r; /* IPC response code */
+ static int att_seq = 0; /* Attachment download sequence number */
+ int rv = 0; /* silence the stupid warn_unused_result warnings */
CtdlMakeTempFileName(prtfile, sizeof prtfile);
if (r / 100 != 1) {
scr_printf("%s\n", cmd);
} else {
- for (num_msgs = 0; msg_arr[num_msgs]; num_msgs++)
- ;
+ for (num_msgs = 0; msg_arr[num_msgs]; num_msgs++);
}
if (num_msgs == 0) { /* TODO look at this later */
- if (c == LastMessages) return;
+ if (c == LastMessages)
+ return;
scr_printf("*** There are no ");
- if (c == NewMessages) scr_printf("new ");
- if (c == OldMessages) scr_printf("old ");
+ if (c == NewMessages)
+ scr_printf("new ");
+ if (c == OldMessages)
+ scr_printf("old ");
scr_printf("messages in this room.\n");
return;
}
return;
}
-RAGAIN: pagin = ((arcflag == 0)
+ RAGAIN:pagin = ((arcflag == 0)
&& (quotflag == 0)
&& (userflags & US_PAGINATOR)) ? 1 : 0;
if ((quotflag) || (arcflag)) {
screenwidth = hold_sw;
}
-RMSGREAD:
+ RMSGREAD:
highest_msg_read = msg_arr[a];
if (quotflag) {
fclose(dest);
if (e == SIGQUIT)
return;
if (((userflags & US_NOPROMPT) || (e == SIGINT))
- && (((room_flags & QR_MAILBOX) == 0)
+ && (((room_flags & QR_MAILBOX) == 0)
|| (rc_force_mail_prompts == 0))) {
e = 'n';
} else {
/* space key same as <N> */ if (e == 32)
e = 'n';
/* del/move for aides only */
- if ( (!is_room_aide)
- && ((room_flags & QR_MAILBOX) == 0)
- && ((room_flags2 & QR2_COLLABDEL) == 0)
- ) {
+ if ((!is_room_aide)
+ && ((room_flags & QR_MAILBOX) == 0)
+ && ((room_flags2 & QR2_COLLABDEL) == 0)
+ ) {
if ((e == 'd') || (e == 'm'))
e = 0;
}
if ((e == 'p') && (IsEmptyStr(printcmd)))
e = 0;
/* can't file if not allowed */
- if ((e == 'f')
- && (rc_allow_attachments == 0))
+ if ((e == 'f')
+ && (rc_allow_attachments == 0))
e = 0;
/* link only if browser avail*/
- if ((e == 'u')
- && (IsEmptyStr(rc_url_cmd)))
+ if ((e == 'u')
+ && (IsEmptyStr(rc_url_cmd)))
e = 0;
if ((e == 'i')
- && (IsEmptyStr(imagecmd) || !has_images))
+ && (IsEmptyStr(imagecmd) || !has_images))
e = 0;
} while ((e != 'a') && (e != 'n') && (e != 's')
&& (e != 'd') && (e != 'm') && (e != 'p')
&& (e != 'q') && (e != 'b') && (e != 'h')
&& (e != 'r') && (e != 'f') && (e != '?')
&& (e != 'u') && (e != 'c') && (e != 'y')
- && (e != 'i') && (e != 'o') );
+ && (e != 'i') && (e != 'o'));
switch (e) {
case 's':
scr_printf("Stop");
else
scr_printf("\n");
}
-DONE_QUOTING: switch (e) {
+ DONE_QUOTING:switch (e) {
case '?':
scr_printf("Options available here:\n"
- " ? Help (prints this message)\n"
- " S Stop reading immediately\n"
- " A Again (repeats last message)\n"
- " N Next (continue with next message)\n"
- " Y My Next (continue with next message you authored)\n"
- " B Back (go back to previous message)\n");
- if ( (is_room_aide)
- || (room_flags & QR_MAILBOX)
- || (room_flags2 & QR2_COLLABDEL)
- ) {
- scr_printf(" D Delete this message\n"
- " M Move message to another room\n");
+ " ? Help (prints this message)\n"
+ " S Stop reading immediately\n"
+ " A Again (repeats last message)\n"
+ " N Next (continue with next message)\n"
+ " Y My Next (continue with next message you authored)\n"
+ " B Back (go back to previous message)\n");
+ if ((is_room_aide)
+ || (room_flags & QR_MAILBOX)
+ || (room_flags2 & QR2_COLLABDEL)
+ ) {
+ scr_printf(" D Delete this message\n" " M Move message to another room\n");
}
scr_printf(" C Copy message to another room\n");
if (!IsEmptyStr(printcmd))
scr_printf(" P Print this message\n");
- scr_printf(
- " Q Reply to this message, quoting portions of it\n"
- " H Headers (display message headers only)\n");
+ scr_printf(" Q Reply to this message, quoting portions of it\n"
+ " H Headers (display message headers only)\n");
if (is_mail)
scr_printf(" R Reply to this message\n");
if (rc_allow_attachments) {
break;
case 'm':
case 'c':
- newprompt("Enter target room: ",
- targ, ROOMNAMELEN - 1);
+ newprompt("Enter target room: ", targ, ROOMNAMELEN - 1);
if (!IsEmptyStr(targ)) {
- r = CtdlIPCMoveMessage(ipc, (e == 'c' ? 1 : 0),
- msg_arr[a], targ, cmd);
+ r = CtdlIPCMoveMessage(ipc, (e == 'c' ? 1 : 0), msg_arr[a], targ, cmd);
scr_printf("%s\n", cmd);
if (r / 100 == 2)
msg_arr[a] = 0L;
case 'o':
case 'f':
newprompt("Which section? ", filename, ((sizeof filename) - 1));
- r = CtdlIPCAttachmentDownload(ipc, msg_arr[a],
- filename, &attachment, progress, cmd);
+ r = CtdlIPCAttachmentDownload(ipc, msg_arr[a], filename, &attachment, progress, cmd);
if (r / 100 != 2) {
scr_printf("%s\n", cmd);
} else {
if (IsEmptyStr(filename)) {
strcpy(filename, reply_subject);
}
- if (e == 'o') { /* open attachment */
+ if (e == 'o') { /* open attachment */
mkdir(tempdir, 0700);
- snprintf(save_to, sizeof save_to, "%s/%04x.%s",
- tempdir,
- ++att_seq,
- filename);
+ snprintf(save_to, sizeof save_to, "%s/%04x.%s", tempdir, ++att_seq, filename);
save_buffer(attachment, extract_unsigned_long(cmd, 0), save_to);
snprintf(cmd, sizeof cmd, rc_open_cmd, save_to);
rv = system(cmd);
if (rv != 0)
scr_printf("failed to save %s Reason %d\n", cmd, rv);
- }
- else { /* save attachment to disk */
+ } else { /* save attachment to disk */
destination_directory(save_to, filename);
save_buffer(attachment, extract_unsigned_long(cmd, 0), save_to);
}
case 'i':
image_view(ipc, msg_arr[a]);
goto RMSGREAD;
- case 'y':
- { /* hack hack hack */
- /* find the next message by me, stay here if we find nothing */
- int finda;
- int lasta = a;
- for (finda = (a + rdir); ((finda < num_msgs) && (finda >= 0)); finda += rdir)
- {
- /* This is repetitively dumb, but that's what computers are for.
- We have to load up messages until we find one by us */
- char buf[SIZ];
- int founda = 0;
- struct ctdlipcmessage *msg = NULL;
-
- /* read the header so we can get 'from=' */
- r = CtdlIPCGetSingleMessage(ipc, msg_arr[finda], 1, 0, &msg, buf);
- if (!strncasecmp(msg->author, fullname, sizeof(fullname))) {
- a = lasta; /* meesa current */
- founda = 1;
- }
+ case 'y':
+ { /* hack hack hack */
+ /* find the next message by me, stay here if we find nothing */
+ int finda;
+ int lasta = a;
+ for (finda = (a + rdir); ((finda < num_msgs) && (finda >= 0)); finda += rdir) {
+ /* This is repetitively dumb, but that's what computers are for.
+ We have to load up messages until we find one by us */
+ char buf[SIZ];
+ int founda = 0;
+ struct ctdlipcmessage *msg = NULL;
+
+ /* read the header so we can get 'from=' */
+ r = CtdlIPCGetSingleMessage(ipc, msg_arr[finda], 1, 0, &msg, buf);
+ if (!strncasecmp(msg->author, fullname, sizeof(fullname))) {
+ a = lasta; /* meesa current */
+ founda = 1;
+ }
- free(msg);
+ free(msg);
- if (founda)
- break; /* for */
- lasta = finda; /* keep one behind or we skip on the reentrance to the for */
- } /* for */
- } /* case 'y' */
- } /* switch */
+ if (founda)
+ break; /* for */
+ lasta = finda; /* keep one behind or we skip on the reentrance to the for */
+ } /* for */
+ } /* case 'y' */
+ } /* switch */
} /* end for loop */
} /* end read routine */
/*
* View and edit a system message
*/
-void edit_system_message(CtdlIPC *ipc, char *which_message)
+void edit_system_message(CtdlIPC * ipc, char *which_message)
{
char desc[SIZ];
char read_cmd[SIZ];
* Loads the contents of a file into memory. Caller must free the allocated
* memory.
*/
-char *load_message_from_file(FILE *src)
+char *load_message_from_file(FILE * src)
{
size_t i;
size_t got = 0;
i = ftell(src);
rewind(src);
- dest = (char *)calloc(1, i + 1);
+ dest = (char *) calloc(1, i + 1);
if (!dest)
return NULL;
void stty_ctdl(int cmd);
-void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto);
-void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
+void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto);
+void progress(CtdlIPC * ipc, unsigned long curr, unsigned long cmax);
int pattern(char *search, char *patn);
int file_checksum(char *filename);
int nukedir(char *dirname);
extern char floorlist[128][SIZ];
-void load_floorlist(CtdlIPC *ipc)
+void load_floorlist(CtdlIPC * ipc)
{
int a;
char buf[SIZ];
scr_printf("%s", rmname);
if (f & QR_DIRECTORY) {
scr_printf("] ");
- }
- else {
+ } else {
scr_printf("> ");
}
c = c + strlen(rmname) + 3;
for (mptr = listing; mptr != NULL; mptr = mptr->next) {
list_it = 1;
- if ( (new_only == LISTRMS_NEW_ONLY)
- && ((mptr->march_access & UA_HASNEWMSGS) == 0))
+ if ((new_only == LISTRMS_NEW_ONLY)
+ && ((mptr->march_access & UA_HASNEWMSGS) == 0))
list_it = 0;
- if ( (new_only == LISTRMS_OLD_ONLY)
- && ((mptr->march_access & UA_HASNEWMSGS) != 0))
+ if ((new_only == LISTRMS_OLD_ONLY)
+ && ((mptr->march_access & UA_HASNEWMSGS) != 0))
list_it = 0;
- if ( (floor_only >= 0)
- && (mptr->march_floor != floor_only))
+ if ((floor_only >= 0)
+ && (mptr->march_floor != floor_only))
list_it = 0;
if (flags && (mptr->march_flags & flags) == 0)
- list_it = 0;
+ list_it = 0;
- if (match && (pattern(mptr->march_name, match) == -1))
+ if (match && (pattern(mptr->march_name, match) == -1))
list_it = 0;
if (list_it) {
rp->rlorder = mptr->march_order;
rp->lnext = NULL;
rp->rnext = NULL;
-
+
rs = rl;
if (rl == NULL) {
rl = rp;
* List known rooms. kn_floor_mode should be set to 0 for a 'flat' listing,
* 1 to list rooms on the current floor, or 2 to list rooms on all floors.
*/
-void knrooms(CtdlIPC *ipc, int kn_floor_mode)
+void knrooms(CtdlIPC * ipc, int kn_floor_mode)
{
int a;
struct march *listing = NULL;
struct march *mptr;
- int r; /* IPC response code */
+ int r; /* IPC response code */
char buf[SIZ];
if (kn_floor_mode == 1) {
color(BRIGHT_CYAN);
- scr_printf("\n Rooms with unread messages on %s:\n",
- floorlist[(int) curr_floor]);
+ scr_printf("\n Rooms with unread messages on %s:\n", floorlist[(int) curr_floor]);
listrms(listing, LISTRMS_NEW_ONLY, curr_floor, 0, NULL);
color(BRIGHT_CYAN);
- scr_printf("\n\n Rooms with no new messages on %s:\n",
- floorlist[(int) curr_floor]);
+ scr_printf("\n\n Rooms with no new messages on %s:\n", floorlist[(int) curr_floor]);
listrms(listing, LISTRMS_OLD_ONLY, curr_floor, 0, NULL);
color(BRIGHT_CYAN);
scr_printf("\n\n Other floors:\n");
for (a = 0; a < 128; ++a) {
if (floorlist[a][0] != 0) {
color(BRIGHT_CYAN);
- scr_printf("\n Rooms on %s:\n",
- floorlist[a]);
+ scr_printf("\n Rooms on %s:\n", floorlist[a]);
listrms(listing, LISTRMS_ALL, a, 0, NULL);
scr_printf("\n");
}
}
-void listzrooms(CtdlIPC *ipc)
+void listzrooms(CtdlIPC * ipc)
{ /* list public forgotten rooms */
struct march *listing = NULL;
struct march *mptr;
- int r; /* IPC response code */
+ int r; /* IPC response code */
char buf[SIZ];
color(DIM_WHITE);
}
-void dotknown(CtdlIPC *ipc, int what, char *match)
+void dotknown(CtdlIPC * ipc, int what, char *match)
{ /* list rooms according to attribute */
struct march *listing = NULL;
struct march *mptr;
- int r; /* IPC response code */
+ int r; /* IPC response code */
char buf[SIZ];
/* Ask the server for a room list */
color(BRIGHT_CYAN);
switch (what) {
- case 0:
- scr_printf("\n Anonymous rooms:\n");
- listrms(listing, LISTRMS_ALL, -1, QR_ANONONLY|QR_ANONOPT, NULL);
- scr_printf("\n");
+ case 0:
+ scr_printf("\n Anonymous rooms:\n");
+ listrms(listing, LISTRMS_ALL, -1, QR_ANONONLY | QR_ANONOPT, NULL);
+ scr_printf("\n");
break;
- case 1:
- scr_printf("\n Directory rooms:\n");
- listrms(listing, LISTRMS_ALL, -1, QR_DIRECTORY, NULL);
- scr_printf("\n");
+ case 1:
+ scr_printf("\n Directory rooms:\n");
+ listrms(listing, LISTRMS_ALL, -1, QR_DIRECTORY, NULL);
+ scr_printf("\n");
break;
- case 2:
- scr_printf("\n Matching \"%s\" rooms:\n", match);
- listrms(listing, LISTRMS_ALL, -1, 0, match);
- scr_printf("\n");
+ case 2:
+ scr_printf("\n Matching \"%s\" rooms:\n", match);
+ listrms(listing, LISTRMS_ALL, -1, 0, match);
+ scr_printf("\n");
break;
- case 3:
- scr_printf("\n Preferred only rooms:\n");
- listrms(listing, LISTRMS_ALL, -1, QR_PREFONLY, NULL);
- scr_printf("\n");
+ case 3:
+ scr_printf("\n Preferred only rooms:\n");
+ listrms(listing, LISTRMS_ALL, -1, QR_PREFONLY, NULL);
+ scr_printf("\n");
break;
- case 4:
- scr_printf("\n Private rooms:\n");
- listrms(listing, LISTRMS_ALL, -1, QR_PRIVATE, NULL);
- scr_printf("\n");
+ case 4:
+ scr_printf("\n Private rooms:\n");
+ listrms(listing, LISTRMS_ALL, -1, QR_PRIVATE, NULL);
+ scr_printf("\n");
break;
- case 5:
- scr_printf("\n Read only rooms:\n");
- listrms(listing, LISTRMS_ALL, -1, QR_READONLY, NULL);
- scr_printf("\n");
+ case 5:
+ scr_printf("\n Read only rooms:\n");
+ listrms(listing, LISTRMS_ALL, -1, QR_READONLY, NULL);
+ scr_printf("\n");
break;
}
}
-int set_room_attr(CtdlIPC *ipc, unsigned int ibuf, char *prompt, unsigned int sbit)
+int set_room_attr(CtdlIPC * ipc, unsigned int ibuf, char *prompt, unsigned int sbit)
{
int a;
* The supplied argument is the 'default' floor number.
* This function returns the selected floor number.
*/
-int select_floor(CtdlIPC *ipc, int rfloor)
+int select_floor(CtdlIPC * ipc, int rfloor)
{
int a, newfloor;
char floorstr[SIZ];
do {
newfloor = (-1);
- safestrncpy(floorstr, floorlist[rfloor],
- sizeof floorstr);
+ safestrncpy(floorstr, floorlist[rfloor], sizeof floorstr);
strprompt("Which floor", floorstr, 255);
for (a = 0; a < 128; ++a) {
- if (!strcasecmp
- (floorstr, &floorlist[a][0]))
+ if (!strcasecmp(floorstr, &floorlist[a][0]))
newfloor = a;
if ((newfloor < 0)
- &&
- (!strncasecmp
- (floorstr, &floorlist[a][0],
- strlen(floorstr))))
+ && (!strncasecmp(floorstr, &floorlist[a][0], strlen(floorstr))))
newfloor = a;
if ((newfloor < 0)
&& (pattern(&floorlist[a][0], floorstr)
scr_printf("\n One of:\n");
for (a = 0; a < 128; ++a) {
if (floorlist[a][0] != 0) {
- scr_printf("%s\n",
- &floorlist[a][0]);
+ scr_printf("%s\n", &floorlist[a][0]);
}
}
}
}
else {
- scr_printf("Floor selection bypassed because you have "
- "floor mode disabled.\n");
+ scr_printf("Floor selection bypassed because you have " "floor mode disabled.\n");
}
return (rfloor);
/*
* .<A>ide <E>dit room
*/
-void editthisroom(CtdlIPC *ipc)
+void editthisroom(CtdlIPC * ipc)
{
int rbump = 0;
char room_admin_name[USERNAME_SIZE];
char buf[SIZ];
struct ctdlroom *attr = NULL;
struct ExpirePolicy *eptr = NULL;
- int r; /* IPC response code */
+ int r; /* IPC response code */
/* Fetch the existing room config */
r = CtdlIPCGetRoomAttributes(ipc, &attr, buf);
/* Now interact with the user. */
- strprompt("Room name", attr->QRname, ROOMNAMELEN-1);
+ strprompt("Room name", attr->QRname, ROOMNAMELEN - 1);
attr->QRfloor = select_floor(ipc, attr->QRfloor);
attr->QRflags = set_room_attr(ipc, attr->QRflags, "Private room", QR_PRIVATE);
if (attr->QRflags & QR_PRIVATE) {
attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Hidden room (accessible to anyone who knows the room name)",
- QR_GUESSNAME);
+ "Hidden room (accessible to anyone who knows the room name)", QR_GUESSNAME);
}
/* if it's public, clear the privacy classes */
/* if it's private, choose the privacy classes */
if ((attr->QRflags & QR_PRIVATE)
&& ((attr->QRflags & QR_GUESSNAME) == 0)) {
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Accessible by entering a password",
- QR_PASSWORDED);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Accessible by entering a password", QR_PASSWORDED);
}
if ((attr->QRflags & QR_PRIVATE)
&& ((attr->QRflags & QR_PASSWORDED) == QR_PASSWORDED)) {
rbump = boolprompt("Cause current users to forget room", 0);
}
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Preferred users only", QR_PREFONLY);
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Read-only room", QR_READONLY);
- attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
- "Allow message deletion by anyone who can post",
- QR2_COLLABDEL);
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Permanent room", QR_PERMANENT);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Preferred users only", QR_PREFONLY);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Read-only room", QR_READONLY);
+ attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "Allow message deletion by anyone who can post", QR2_COLLABDEL);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Permanent room", QR_PERMANENT);
attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
- "Subject Required (Force "
- "users to specify a message "
- "subject)", QR2_SUBJECTREQ);
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Directory room", QR_DIRECTORY);
+ "Subject Required (Force " "users to specify a message " "subject)", QR2_SUBJECTREQ);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Directory room", QR_DIRECTORY);
if (attr->QRflags & QR_DIRECTORY) {
strprompt("Directory name", attr->QRdirname, 14);
- attr->QRflags =
- set_room_attr(ipc, attr->QRflags,
- "Uploading allowed", QR_UPLOAD);
- attr->QRflags =
- set_room_attr(ipc, attr->QRflags, "Downloading allowed",
- QR_DOWNLOAD);
- attr->QRflags =
- set_room_attr(ipc, attr->QRflags,
- "Visible directory", QR_VISDIR);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Uploading allowed", QR_UPLOAD);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Downloading allowed", QR_DOWNLOAD);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Visible directory", QR_VISDIR);
}
+ attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "Self-service list subscribe/unsubscribe", QR2_SELFLIST);
attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
- "Self-service list subscribe/unsubscribe",
- QR2_SELFLIST);
- attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
- "public posting to this room via room_roomname@yourcitadel.org",
- QR2_SMTP_PUBLIC);
- attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
- "moderated mailinglist",
- QR2_MODERATED);
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Automatically make all messages anonymous",
- QR_ANONONLY);
+ "public posting to this room via room_roomname@yourcitadel.org", QR2_SMTP_PUBLIC);
+ attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "moderated mailinglist", QR2_MODERATED);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Automatically make all messages anonymous", QR_ANONONLY);
if ((attr->QRflags & QR_ANONONLY) == 0) {
- attr->QRflags = set_room_attr(ipc, attr->QRflags,
- "Ask users whether to make messages anonymous",
- QR_ANONOPT);
+ attr->QRflags = set_room_attr(ipc, attr->QRflags, "Ask users whether to make messages anonymous", QR_ANONOPT);
}
attr->QRorder = intprompt("Listing order", attr->QRorder, 0, 127);
strprompt("Message expire policy (? for list)", buf, 1);
if (buf[0] == '?') {
scr_printf("\n"
- "0. Use the default for this floor\n"
- "1. Never automatically expire messages\n"
- "2. Expire by message count\n"
- "3. Expire by message age\n");
+ "0. Use the default for this floor\n"
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n" "3. Expire by message age\n");
}
} while ((buf[0] < 48) || (buf[0] > 51));
attr->QRep.expire_mode = buf[0] - 48;
free(attr);
if (r / 100 == 2)
dotgoto(ipc, buf, 2, 0);
- }
- else free(attr);
+ } else
+ free(attr);
}
/*
* un-goto the previous room, or a specified room
*/
-void dotungoto(CtdlIPC *ipc, char *towhere)
- {
- /* Find this 'towhere' room in the list ungoto from this room to
- that at the messagepointer position in that room in our ungoto list.
- I suppose I could be a real dick and just ungoto that many places
- in our list. */
- int found = -1;
- int lp;
+void dotungoto(CtdlIPC * ipc, char *towhere)
+{
+ /* Find this 'towhere' room in the list ungoto from this room to
+ that at the messagepointer position in that room in our ungoto list.
+ I suppose I could be a real dick and just ungoto that many places
+ in our list. */
+ int found = -1;
+ int lp;
char buf[SIZ];
struct ctdlipcroom *rret = NULL; /* ignored */
int r;
- if (uglistsize == 0)
- {
+ if (uglistsize == 0) {
scr_printf("No rooms to ungoto.\n");
return;
- }
- if (towhere == NULL)
- {
+ }
+ if (towhere == NULL) {
scr_printf("Must specify a room to ungoto.\n");
return;
- }
- if (IsEmptyStr(towhere))
- {
+ }
+ if (IsEmptyStr(towhere)) {
scr_printf("Must specify a room to ungoto.\n");
return;
- }
- for (lp = uglistsize-1; lp >= 0; lp--)
- {
- if (strcasecmp(towhere, uglist[lp]) == 0)
- {
- found = lp;
- break;
- }
- }
- if (found == -1)
- {
+ }
+ for (lp = uglistsize - 1; lp >= 0; lp--) {
+ if (strcasecmp(towhere, uglist[lp]) == 0) {
+ found = lp;
+ break;
+ }
+ }
+ if (found == -1) {
scr_printf("Room: %s not in ungoto list.\n", towhere);
- return;
- }
+ return;
+ }
r = CtdlIPCGotoRoom(ipc, uglist[found], "", &rret, buf);
- if (rret) free(rret); /* ignored */
+ if (rret)
+ free(rret); /* ignored */
if (r / 100 != 2) {
scr_printf("%s\n", buf);
return;
scr_printf("%s\n", buf);
}
safestrncpy(buf, uglist[found], sizeof(buf));
- /* we queue ungoto information here, because we're not really
- ungotoing, we're really going to a random spot in some arbitrary
- room list. */
+ /* we queue ungoto information here, because we're not really
+ ungotoing, we're really going to a random spot in some arbitrary
+ room list. */
dotgoto(ipc, buf, 0, 0);
- }
+}
-void ungoto(CtdlIPC *ipc)
+void ungoto(CtdlIPC * ipc)
{
char buf[SIZ];
struct ctdlipcroom *rret = NULL; /* ignored */
if (uglistsize == 0)
return;
- r = CtdlIPCGotoRoom(ipc, uglist[uglistsize-1], "", &rret, buf);
- if (rret) free(rret); /* ignored */
+ r = CtdlIPCGotoRoom(ipc, uglist[uglistsize - 1], "", &rret, buf);
+ if (rret)
+ free(rret); /* ignored */
if (r / 100 != 2) {
scr_printf("%s\n", buf);
return;
}
- r = CtdlIPCSetLastRead(ipc, uglistlsn[uglistsize-1] ? uglistlsn[uglistsize-1] : 1, buf);
+ r = CtdlIPCSetLastRead(ipc, uglistlsn[uglistsize - 1] ? uglistlsn[uglistsize - 1] : 1, buf);
if (r / 100 != 2) {
scr_printf("%s\n", buf);
}
- safestrncpy(buf, uglist[uglistsize-1], sizeof(buf));
+ safestrncpy(buf, uglist[uglistsize - 1], sizeof(buf));
uglistsize--;
free(uglist[uglistsize]);
/* Don't queue ungoto info or we end up in a loop */
return 0;
}
do {
- block = fwrite((char *)file + bytes_written, 1,
- filelen - bytes_written, fp);
+ block = fwrite((char *) file + bytes_written, 1, filelen - bytes_written, fp);
bytes_written += block;
} while (errno == EINTR && bytes_written < filelen);
fclose(fp);
if (bytes_written < filelen) {
- scr_printf("Trouble saving '%s': %s\n", pathname,
- strerror(errno));
+ scr_printf("Trouble saving '%s': %s\n", pathname, strerror(errno));
return 0;
}
return 1;
if (IsEmptyStr(save_dir)) {
if (getenv("HOME") == NULL) {
strcpy(save_dir, ".");
- }
- else {
+ } else {
sprintf(save_dir, "%s/Desktop", getenv("HOME"));
if (access(save_dir, W_OK) != 0) {
sprintf(save_dir, "%s", getenv("HOME"));
strcpy(save_dir, dest);
if (strrchr(save_dir, '/') != NULL) {
strcpy(strrchr(save_dir, '/'), "");
- }
- else {
+ } else {
strcpy(save_dir, ".");
}
}
* function determines which protocol to use.
* proto - 0 = paginate, 1 = xmodem, 2 = raw, 3 = ymodem, 4 = zmodem, 5 = save
*/
-void download(CtdlIPC *ipc, int proto)
+void download(CtdlIPC * ipc, int proto)
{
char buf[SIZ];
char filename[PATH_MAX];
scr_printf("%s\n", buf);
return;
}
- save_buffer(file, (size_t)extract_long(buf, 0), tempname);
+ save_buffer(file, (size_t) extract_long(buf, 0), tempname);
free(file);
return;
}
tpipe = fopen(tempname, "wb");
if (fwrite(file, filelen, 1, tpipe) < filelen) {
/* FIXME: restart syscall on EINTR
- broken = 1;*/
+ broken = 1; */
}
fclose(tpipe);
- if (file) free(file);
+ if (file)
+ free(file);
if (proto == 0) {
/* FIXME: display internally instead */
snprintf(transmit_cmd, sizeof transmit_cmd,
- "SHELL=/dev/null; export SHELL; TERM=dumb; export TERM; exec more -d <%s",
- tempname);
- }
- else if (proto == 1)
+ "SHELL=/dev/null; export SHELL; TERM=dumb; export TERM; exec more -d <%s", tempname);
+ } else if (proto == 1)
snprintf(transmit_cmd, sizeof transmit_cmd, "exec sx %s", tempname);
else if (proto == 3)
snprintf(transmit_cmd, sizeof transmit_cmd, "exec sb %s", tempname);
/* clean up the temporary directory */
nukedir(tempdir);
- ctdl_beep(); /* Beep beep! */
+ ctdl_beep(); /* Beep beep! */
}
/*
* read directory of this room
*/
-void roomdir(CtdlIPC *ipc)
+void roomdir(CtdlIPC * ipc)
{
char flnm[256];
char flsz[32];
if (strlen(flnm) <= 14)
scr_printf("%-14s %8s %s [%s]\n", flnm, flsz, comment, mimetype);
else
- scr_printf("%s\n%14s %8s %s [%s]\n", flnm, "", flsz,
- comment, mimetype);
+ scr_printf("%s\n%14s %8s %s [%s]\n", flnm, "", flsz, comment, mimetype);
}
- if (listing) free(listing);
+ if (listing)
+ free(listing);
}
/*
* add a user to a private room
*/
-void invite(CtdlIPC *ipc)
+void invite(CtdlIPC * ipc)
{
char username[USERNAME_SIZE];
char buf[SIZ];
/*
* kick a user out of a room
*/
-void kickout(CtdlIPC *ipc)
+void kickout(CtdlIPC * ipc)
{
char username[USERNAME_SIZE];
char buf[SIZ];
/*
* aide command: kill the current room
*/
-void killroom(CtdlIPC *ipc)
+void killroom(CtdlIPC * ipc)
{
char aaa[100];
int r;
dotgoto(ipc, "_BASEROOM_", 0, 0);
}
-void forget(CtdlIPC *ipc)
+void forget(CtdlIPC * ipc)
{ /* forget the current room */
char buf[SIZ];
/*
* create a new room
*/
-void entroom(CtdlIPC *ipc)
+void entroom(CtdlIPC * ipc)
{
char buf[SIZ];
char new_room_name[ROOMNAMELEN];
char new_room_pass[10];
int new_room_floor;
int a, b;
- int r; /* IPC response code */
+ int r; /* IPC response code */
/* Check permission to create room */
r = CtdlIPCCreateRoom(ipc, 0, "", 1, "", 0, buf);
IFNEXPERT formout(ipc, "roomaccess");
do {
scr_printf("<?>Help\n"
- "<1>Public room (shown to all users by default)\n"
- "<2>Hidden room (accessible to anyone who knows the room name)\n"
- "<3>Passworded room (hidden, plus requires a password to enter)\n"
- "<4>Invitation-only room (requires access to be granted by an Admin)\n"
- "<5>Personal room (accessible to you only)\n"
- "Enter room type: "
- );
+ "<1>Public room (shown to all users by default)\n"
+ "<2>Hidden room (accessible to anyone who knows the room name)\n"
+ "<3>Passworded room (hidden, plus requires a password to enter)\n"
+ "<4>Invitation-only room (requires access to be granted by an Admin)\n"
+ "<5>Personal room (accessible to you only)\n" "Enter room type: ");
do {
b = inkey();
} while (((b < '1') || (b > '5')) && (b != '?'));
formout(ipc, "roomaccess");
}
} while ((b < '1') || (b > '5'));
- b -= '0'; /* Portable */
+ b -= '0'; /* Portable */
scr_printf("%d\n", b);
new_room_type = b - 1;
if (new_room_type == 2) {
return;
}
- r = CtdlIPCCreateRoom(ipc, 1, new_room_name, new_room_type,
- new_room_pass, new_room_floor, buf);
+ r = CtdlIPCCreateRoom(ipc, 1, new_room_name, new_room_type, new_room_pass, new_room_floor, buf);
if (r / 100 != 2) {
scr_printf("%s\n", buf);
return;
-void readinfo(CtdlIPC *ipc)
+void readinfo(CtdlIPC * ipc)
{ /* read info file for current room */
char buf[SIZ];
char room_admin_name[64];
/*
* <W>ho knows room...
*/
-void whoknows(CtdlIPC *ipc)
+void whoknows(CtdlIPC * ipc)
{
char buf[256];
char *listing = NULL;
}
-void do_edit(CtdlIPC *ipc,
- char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
+void do_edit(CtdlIPC * ipc, char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
{
FILE *fp;
char cmd[SIZ];
}
-void enterinfo(CtdlIPC *ipc)
+void enterinfo(CtdlIPC * ipc)
{ /* edit info file for current room */
do_edit(ipc, "the Info file for this room", "RINF", "EINF 0", "EINF 1");
}
-void enter_bio(CtdlIPC *ipc)
+void enter_bio(CtdlIPC * ipc)
{
char cmd[SIZ];
snprintf(cmd, sizeof cmd, "RBIO %s", fullname);
/*
* create a new floor
*/
-void create_floor(CtdlIPC *ipc)
+void create_floor(CtdlIPC * ipc)
{
char buf[SIZ];
char newfloorname[SIZ];
load_floorlist(ipc);
r = CtdlIPCCreateFloor(ipc, 0, "", buf);
- if ( (r / 100 != 2) && (r != ERROR + ILLEGAL_VALUE) ) {
+ if ((r / 100 != 2) && (r != ERROR + ILLEGAL_VALUE)) {
scr_printf("%s\n", buf);
return;
}
newprompt("Name for new floor: ", newfloorname, 255);
- if (!*newfloorname) return;
+ if (!*newfloorname)
+ return;
r = CtdlIPCCreateFloor(ipc, 1, newfloorname, buf);
if (r / 100 == 2) {
scr_printf("Floor has been created.\n");
/*
* edit the current floor
*/
-void edit_floor(CtdlIPC *ipc)
+void edit_floor(CtdlIPC * ipc)
{
char buf[SIZ];
struct ExpirePolicy *ep = NULL;
CtdlIPCGetMessageExpirationPolicy(ipc, 1, &ep, buf);
/* Interact with the user */
- scr_printf("You are editing the floor called \"%s\"\n",
- &floorlist[(int) curr_floor][0] );
+ scr_printf("You are editing the floor called \"%s\"\n", &floorlist[(int) curr_floor][0]);
strprompt("Floor name", &floorlist[(int) curr_floor][0], 255);
/* Angels and demons dancing in my head... */
do {
snprintf(buf, sizeof buf, "%d", ep->expire_mode);
- strprompt
- ("Floor default message expire policy (? for list)",
- buf, 1);
+ strprompt("Floor default message expire policy (? for list)", buf, 1);
if (buf[0] == '?') {
scr_printf("\n"
- "0. Use the system default\n"
- "1. Never automatically expire messages\n"
- "2. Expire by message count\n"
- "3. Expire by message age\n");
+ "0. Use the system default\n"
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n" "3. Expire by message age\n");
}
} while ((buf[0] < '0') || (buf[0] > '3'));
ep->expire_mode = buf[0] - '0';
/* Save it */
CtdlIPCSetMessageExpirationPolicy(ipc, 1, ep, buf);
- CtdlIPCEditFloor(ipc, curr_floor, &floorlist[(int)curr_floor][0], buf);
+ CtdlIPCEditFloor(ipc, curr_floor, &floorlist[(int) curr_floor][0], buf);
scr_printf("%s\n", buf);
load_floorlist(ipc);
}
/*
* kill the current floor
*/
-void kill_floor(CtdlIPC *ipc)
+void kill_floor(CtdlIPC * ipc)
{
int floornum_to_delete, a;
char buf[SIZ];
extern int rc_prompt_control;
/* Destructive backspace */
-void back(int spaces) {
+void back(int spaces)
+{
int a;
- for (a=0; a<spaces; ++a) {
+ for (a = 0; a < spaces; ++a) {
scr_putc(8);
scr_putc(32);
scr_putc(8);
/*
* Edit a user's Internet email addresses
*/
-void edit_user_internet_email_addresses(CtdlIPC *ipc, char *who)
+void edit_user_internet_email_addresses(CtdlIPC * ipc, char *who)
{
char buf[SIZ];
char *resp = NULL;
remove_token(emailaddrs, 0, '\n');
if (!IsEmptyStr(buf)) {
++num_recs;
- if (num_recs == 1) recs = malloc(sizeof(char *));
- else recs = realloc(recs, (sizeof(char *)) * num_recs);
- recs[num_recs-1] = malloc(strlen(buf) + 1);
- strcpy(recs[num_recs-1], buf);
+ if (num_recs == 1)
+ recs = malloc(sizeof(char *));
+ else
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ recs[num_recs - 1] = malloc(strlen(buf) + 1);
+ strcpy(recs[num_recs - 1], buf);
}
}
}
scr_printf(" Internet email addresses for %s\n", who);
color(DIM_WHITE);
scr_printf("--- --------------------------------------------------\n");
- for (i=0; i<num_recs; ++i) {
+ for (i = 0; i < num_recs; ++i) {
color(DIM_WHITE);
- scr_printf("%3d ", i+1);
+ scr_printf("%3d ", i + 1);
color(BRIGHT_CYAN);
scr_printf("%s\n", recs[i]);
color(DIM_WHITE);
}
ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
- switch(ch) {
- case 'a':
- newprompt("Enter new email address: ", buf, 50);
- striplt(buf);
- if (!IsEmptyStr(buf)) {
- // FIXME validate the email address (format, our own domain, addr does not belong to another user)
- ++num_recs;
- if (num_recs == 1) {
- recs = malloc(sizeof(char *));
- }
- else {
- recs = realloc(recs, (sizeof(char *)) * num_recs);
- }
- recs[num_recs-1] = strdup(buf);
- }
- modified = 1;
- break;
- case 'd':
- i = intprompt("Delete which address", 1, 1, num_recs) - 1;
- free(recs[i]);
- --num_recs;
- for (j=i; j<num_recs; ++j) {
- recs[j] = recs[j+1];
- }
- modified = 1;
- break;
- case 's':
- r = 1;
- for (i = 0; i < num_recs; i++)
- r += 1 + strlen(recs[i]);
- resp = (char *)calloc(1, r);
- if (!resp) {
- scr_printf("Can't save config - out of memory!\n");
- logoff(ipc, 1);
+ switch (ch) {
+ case 'a':
+ newprompt("Enter new email address: ", buf, 50);
+ striplt(buf);
+ if (!IsEmptyStr(buf)) {
+ // FIXME validate the email address (format, our own domain, addr does not belong to another user)
+ ++num_recs;
+ if (num_recs == 1) {
+ recs = malloc(sizeof(char *));
+ } else {
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
}
- if (num_recs) for (i = 0; i < num_recs; i++) {
+ recs[num_recs - 1] = strdup(buf);
+ }
+ modified = 1;
+ break;
+ case 'd':
+ i = intprompt("Delete which address", 1, 1, num_recs) - 1;
+ free(recs[i]);
+ --num_recs;
+ for (j = i; j < num_recs; ++j) {
+ recs[j] = recs[j + 1];
+ }
+ modified = 1;
+ break;
+ case 's':
+ r = 1;
+ for (i = 0; i < num_recs; i++)
+ r += 1 + strlen(recs[i]);
+ resp = (char *) calloc(1, r);
+ if (!resp) {
+ scr_printf("Can't save config - out of memory!\n");
+ logoff(ipc, 1);
+ }
+ if (num_recs)
+ for (i = 0; i < num_recs; i++) {
strcat(resp, recs[i]);
strcat(resp, "\n");
}
- r = CtdlIPCAideSetEmailAddresses(ipc, who, resp, buf);
- if (r / 100 != 4) {
- scr_printf("%s\n", buf);
- } else {
- scr_printf("Saved %d addresses.\n", num_recs);
- modified = 0;
- quitting = 1;
- }
- free(resp);
- break;
- case 'q':
- quitting = !modified || boolprompt("Quit without saving", 0);
- break;
- default:
- break;
+ r = CtdlIPCAideSetEmailAddresses(ipc, who, resp, buf);
+ if (r / 100 != 4) {
+ scr_printf("%s\n", buf);
+ } else {
+ scr_printf("Saved %d addresses.\n", num_recs);
+ modified = 0;
+ quitting = 1;
+ }
+ free(resp);
+ break;
+ case 'q':
+ quitting = !modified || boolprompt("Quit without saving", 0);
+ break;
+ default:
+ break;
}
} while (!quitting);
if (recs != NULL) {
- for (i=0; i<num_recs; ++i) free(recs[i]);
+ for (i = 0; i < num_recs; ++i)
+ free(recs[i]);
free(recs);
}
}
/*
* Edit or delete a user (cmd=25 to edit/create, 96 to delete)
*/
-void edituser(CtdlIPC *ipc, int cmd)
+void edituser(CtdlIPC * ipc, int cmd)
{
char buf[SIZ];
char who[USERNAME_SIZE];
char newname[USERNAME_SIZE];
struct ctdluser *user = NULL;
int newnow = 0;
- int r; /* IPC response code */
+ int r; /* IPC response code */
int change_name = 0;
strcpy(newname, "");
return;
}
- if (cmd == 25) { // user edit
+ if (cmd == 25) { // user edit
/* val_user(ipc, user->fullname, 0); we used to display the vCard here but there's really no need */
change_name = 1;
while (change_name == 1) {
if (boolprompt("Change name", 0)) {
- strprompt("New name", newname, USERNAME_SIZE-1);
+ strprompt("New name", newname, USERNAME_SIZE - 1);
r = CtdlIPCRenameUser(ipc, user->fullname, newname, buf);
if (r / 100 != 2) {
scr_printf("%s\n", buf);
- }
- else {
+ } else {
strcpy(user->fullname, newname);
change_name = 0;
}
- }
- else {
+ } else {
change_name = 0;
}
}
if (newnow || boolprompt("Change password", 0)) {
strprompt("Password", user->password, -19);
}
-
+
user->axlevel = intprompt("Access level", user->axlevel, 0, 6);
if (boolprompt("Permission to send Internet mail", (user->flags & US_INTERNET))) {
user->flags |= US_INTERNET;
- }
- else {
+ } else {
user->flags &= ~US_INTERNET;
}
if (boolprompt("Ask user to register again", !(user->flags & US_REGIS))) {
user->flags &= ~US_REGIS;
- }
- else {
+ } else {
user->flags |= US_REGIS;
}
user->timescalled = intprompt("Times called", user->timescalled, 0, INT_MAX);
user->posted = intprompt("Messages posted", user->posted, 0, INT_MAX);
- user->lastcall = boolprompt("Set last login to now", 0) ? time(NULL) : user->lastcall;
+ user->lastcall = boolprompt("Set last login to now", 0) ? time(NULL) : user->lastcall;
user->USuserpurge = intprompt("Purge time (in days, 0 for system default", user->USuserpurge, 0, INT_MAX);
}
* yes or no. Yes=1 and No=0, unless 'backwards' is set to a nonzero value
* in which case No=1 and Yes=0.
*/
-int set_attr(CtdlIPC *ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards)
+int set_attr(CtdlIPC * ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards)
{
int a;
int temp;
color(BRIGHT_MAGENTA);
if (backwards) {
- scr_printf("%3s", ((temp&sbit) ? "No":"Yes"));
- }
- else {
- scr_printf("%3s", ((temp&sbit) ? "Yes":"No"));
+ scr_printf("%3s", ((temp & sbit) ? "No" : "Yes"));
+ } else {
+ scr_printf("%3s", ((temp & sbit) ? "Yes" : "No"));
}
color(DIM_MAGENTA);
scr_printf("]? ");
color(BRIGHT_CYAN);
a = (temp & sbit);
- if (a != 0) a = 1;
- if (backwards) a = 1 - a;
+ if (a != 0)
+ a = 1;
+ if (backwards)
+ a = 1 - a;
a = yesno_d(a);
- if (backwards) a = 1 - a;
+ if (backwards)
+ a = 1 - a;
color(DIM_WHITE);
- temp = (temp|sbit);
- if (!a) temp = (temp^sbit);
- return(temp);
+ temp = (temp | sbit);
+ if (!a)
+ temp = (temp ^ sbit);
+ return (temp);
}
/*
* modes are: 0 - .EC command, 1 - .EC for new user,
* 2 - toggle Xpert mode 3 - toggle floor mode
*/
-void enter_config(CtdlIPC *ipc, int mode)
+void enter_config(CtdlIPC * ipc, int mode)
{
char buf[SIZ];
struct ctdluser *user = NULL;
- int r; /* IPC response code */
+ int r; /* IPC response code */
r = CtdlIPCGetConfig(ipc, &user, buf);
if (r / 100 != 2) {
if (mode == 0 || mode == 1) {
- user->flags = set_attr(ipc, user->flags,
- "Are you an experienced Citadel user",
- US_EXPERT, 0);
+ user->flags = set_attr(ipc, user->flags, "Are you an experienced Citadel user", US_EXPERT, 0);
if ((user->flags & US_EXPERT) == 0 && mode == 1) {
free(user);
return;
}
- user->flags = set_attr(
- ipc,
- user->flags,
- "Print last old message on New message request",
- US_LASTOLD,
- 0
- );
-
- user->flags = set_attr(
- ipc,
- user->flags,
- "Prompt after each message",
- US_NOPROMPT,
- 1
- );
+ user->flags = set_attr(ipc, user->flags, "Print last old message on New message request", US_LASTOLD, 0);
+
+ user->flags = set_attr(ipc, user->flags, "Prompt after each message", US_NOPROMPT, 1);
if ((user->flags & US_NOPROMPT) == 0) {
- user->flags = set_attr(
- ipc,
- user->flags,
- "Use 'disappearing' prompts",
- US_DISAPPEAR,
- 0
- );
+ user->flags = set_attr(ipc, user->flags, "Use 'disappearing' prompts", US_DISAPPEAR, 0);
}
- user->flags = set_attr(
- ipc,
- user->flags,
- "Pause after each screenful of text",
- US_PAGINATOR,
- 0
- );
+ user->flags = set_attr(ipc, user->flags, "Pause after each screenful of text", US_PAGINATOR, 0);
if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR)) {
- user->flags = set_attr(
- ipc,
- user->flags,
- "<N>ext and <S>top work at paginator prompt",
- US_PROMPTCTL,
- 0
- );
+ user->flags = set_attr(ipc, user->flags, "<N>ext and <S>top work at paginator prompt", US_PROMPTCTL, 0);
}
if (rc_floor_mode == RC_DEFAULT) {
- user->flags = set_attr(
- ipc,
- user->flags,
- "View rooms by floor",
- US_FLOORS,
- 0
- );
+ user->flags = set_attr(ipc, user->flags, "View rooms by floor", US_FLOORS, 0);
}
if (rc_ansi_color == 3) {
- user->flags = set_attr(
- ipc,
- user->flags,
- "Enable color support",
- US_COLOR,
- 0
- );
+ user->flags = set_attr(ipc, user->flags, "Enable color support", US_COLOR, 0);
}
- if ((user->flags & US_EXPERT) == 0) {
+ if ((user->flags & US_EXPERT) == 0) {
formout(ipc, "unlisted");
}
- user->flags = set_attr(
- ipc,
- user->flags,
- "Be unlisted in userlog",
- US_UNLISTED,
- 0
- );
+ user->flags = set_attr(ipc, user->flags, "Be unlisted in userlog", US_UNLISTED, 0);
if (!IsEmptyStr(editor_path)) {
- user->flags = set_attr(
- ipc,
- user->flags,
- "Always enter messages with the full-screen editor",
- US_EXTEDIT,
- 0
- );
+ user->flags = set_attr(ipc,
+ user->flags, "Always enter messages with the full-screen editor", US_EXTEDIT, 0);
}
}
}
r = CtdlIPCSetConfig(ipc, user, buf);
- if (r / 100 != 2) scr_printf("%s\n", buf);
+ if (r / 100 != 2)
+ scr_printf("%s\n", buf);
userflags = user->flags;
free(user);
}
* getstring() - get a line of text from a file
* ignores lines beginning with "#"
*/
-int getstring(FILE *fp, char *string)
+int getstring(FILE * fp, char *string)
{
- int a,c;
+ int a, c;
do {
- strcpy(string,"");
- a=0;
+ strcpy(string, "");
+ a = 0;
do {
- c=getc(fp);
- if (c<0) {
- string[a]=0;
- return(-1);
+ c = getc(fp);
+ if (c < 0) {
+ string[a] = 0;
+ return (-1);
}
- string[a++]=c;
- } while(c!=10);
- string[a-1]=0;
- } while(string[0]=='#');
- return(strlen(string));
+ string[a++] = c;
+ } while (c != 10);
+ string[a - 1] = 0;
+ } while (string[0] == '#');
+ return (strlen(string));
}
/* Searches for patn in search string */
-int pattern(char *search, char *patn) {
- int a,b,len;
-
+int pattern(char *search, char *patn)
+{
+ int a, b, len;
+
len = strlen(patn);
- for (a=0; !IsEmptyStr(&search[a]); ++a) {
- b=strncasecmp(&search[a],patn,len);
- if (b==0) return(b);
+ for (a = 0; !IsEmptyStr(&search[a]); ++a) {
+ b = strncasecmp(&search[a], patn, len);
+ if (b == 0)
+ return (b);
}
- return(-1);
+ return (-1);
}
{
int a;
- if (IsEmptyStr(string)) return;
+ if (IsEmptyStr(string))
+ return;
/* Convert non-printable characters to blanks */
- for (a=0; !IsEmptyStr(&string[a]); ++a) {
- if (string[a]<32) string[a]=32;
- if (string[a]>126) string[a]=32;
+ for (a = 0; !IsEmptyStr(&string[a]); ++a) {
+ if (string[a] < 32)
+ string[a] = 32;
+ if (string[a] > 126)
+ string[a] = 32;
}
/* Remove leading and trailing blanks */
- while(string[0]<33) strcpy(string,&string[1]);
- while(string[strlen(string)-1]<33) string[strlen(string)-1]=0;
+ while (string[0] < 33)
+ strcpy(string, &string[1]);
+ while (string[strlen(string) - 1] < 33)
+ string[strlen(string) - 1] = 0;
/* Remove double blanks */
- for (a=0; a<strlen(string); ++a) {
- if ((string[a]==32)&&(string[a+1]==32)) {
- strcpy(&string[a],&string[a+1]);
- a=0;
+ for (a = 0; a < strlen(string); ++a) {
+ if ((string[a] == 32) && (string[a + 1] == 32)) {
+ strcpy(&string[a], &string[a + 1]);
+ a = 0;
}
}
/* remove characters which would interfere with the network */
- for (a=0; a<strlen(string); ++a) {
- if (string[a]=='!') strcpy(&string[a],&string[a+1]);
- if (string[a]=='@') strcpy(&string[a],&string[a+1]);
- if (string[a]=='_') strcpy(&string[a],&string[a+1]);
- if (string[a]==',') strcpy(&string[a],&string[a+1]);
- if (string[a]=='%') strcpy(&string[a],&string[a+1]);
- if (string[a]=='|') strcpy(&string[a],&string[a+1]);
+ for (a = 0; a < strlen(string); ++a) {
+ if (string[a] == '!')
+ strcpy(&string[a], &string[a + 1]);
+ if (string[a] == '@')
+ strcpy(&string[a], &string[a + 1]);
+ if (string[a] == '_')
+ strcpy(&string[a], &string[a + 1]);
+ if (string[a] == ',')
+ strcpy(&string[a], &string[a + 1]);
+ if (string[a] == '%')
+ strcpy(&string[a], &string[a + 1]);
+ if (string[a] == '|')
+ strcpy(&string[a], &string[a + 1]);
}
}
-void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax)
+void progress(CtdlIPC * ipc, unsigned long curr, unsigned long cmax)
{
- static char dots[] =
- "**************************************************";
+ static char dots[] = "**************************************************";
char dots_printed[51];
char fmt[42];
unsigned long a;
if (curr >= cmax) {
- scr_printf("\r%79s\r","");
+ scr_printf("\r%79s\r", "");
} else {
/* a will be range 0-50 rather than 0-100 */
- a=(curr * 50) / cmax;
+ a = (curr * 50) / cmax;
sprintf(fmt, "[%%s%%%lds] %%3ld%%%% %%10ld/%%10ld\r", 50 - a);
strncpy(dots_printed, dots, a);
dots_printed[a] = 0;
- scr_printf(fmt, dots_printed, "",
- curr * 100 / cmax, curr, cmax);
+ scr_printf(fmt, dots_printed, "", curr * 100 / cmax, curr, cmax);
scr_flush();
}
}
* NOT the same locate_host() in locate_host.c. This one just does a
* 'who am i' to try to discover where the user is...
*/
-void locate_host(CtdlIPC* ipc, char *hbuf)
+void locate_host(CtdlIPC * ipc, char *hbuf)
{
- FILE *who = (FILE *)popen("who am i","r");
- if (who==NULL) {
+ FILE *who = (FILE *) popen("who am i", "r");
+ if (who == NULL) {
strcpy(hbuf, ipc->ServInfo.fqdn);
- return;
+ return;
}
fgets(hbuf, SIZ, who);
pclose(who);
- stripallbut(hbuf, '(' , ')' );
+ stripallbut(hbuf, '(', ')');
}
/*
* miscellaneous server commands (testing, etc.)
*/
-void misc_server_cmd(CtdlIPC *ipc, char *cmd) {
+void misc_server_cmd(CtdlIPC * ipc, char *cmd)
+{
char buf[SIZ];
CtdlIPC_chat_send(ipc, cmd);
CtdlIPC_chat_recv(ipc, buf);
- scr_printf("%s\n",buf);
- if (buf[0]=='1') {
+ scr_printf("%s\n", buf);
+ if (buf[0] == '1') {
set_keepalives(KA_HALF);
- while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf,"000")) {
- scr_printf("%s\n",buf);
+ while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf, "000")) {
+ scr_printf("%s\n", buf);
}
set_keepalives(KA_YES);
return;
}
- if (buf[0]=='4') {
+ if (buf[0] == '4') {
do {
- newprompt("> ",buf,255);
+ newprompt("> ", buf, 255);
CtdlIPC_chat_send(ipc, buf);
- } while(strcmp(buf,"000"));
+ } while (strcmp(buf, "000"));
return;
}
}
int ch;
FILE *fp;
- fp = fopen(filename,"r");
- if (fp == NULL) return(0);
+ fp = fopen(filename, "r");
+ if (fp == NULL)
+ return (0);
/* yes, this algorithm may allow cksum to overflow, but that's ok
* as long as it overflows consistently, which it will.
*/
- while (ch=getc(fp), ch>=0) {
+ while (ch = getc(fp), ch >= 0) {
cksum = (cksum + ch);
}
fclose(fp);
- return(cksum);
+ return (cksum);
}
/*
dp = opendir(dirname);
if (dp == NULL) {
- return(errno);
+ return (errno);
}
while (d = readdir(dp), d != NULL) {
- snprintf(filename, sizeof filename, "%s/%s",
- dirname, d->d_name);
+ snprintf(filename, sizeof filename, "%s/%s", dirname, d->d_name);
unlink(filename);
}
closedir(dp);
- return(rmdir(dirname));
+ return (rmdir(dirname));
}
/*
* Register with name and address
*/
-void entregis(CtdlIPC *ipc)
+void entregis(CtdlIPC * ipc)
{
char buf[SIZ];
char holdemail[SIZ];
char *reg = NULL;
int ok = 0;
- int r; /* IPC response code */
+ int r; /* IPC response code */
strcpy(tmpname, "");
strcpy(tmpaddr, "");
striplt(diruser);
striplt(dirnode);
if ((strcasecmp(diruser, fullname))
- || (strcasecmp(dirnode, ipc->ServInfo.nodename))) {
- scr_printf(
- "\nYou can't use %s as your address.\n",
- tmpemail);
- scr_printf(
- "It is already in use by %s @ %s.\n",
- diruser, dirnode);
+ || (strcasecmp(dirnode, ipc->ServInfo.nodename))) {
+ scr_printf("\nYou can't use %s as your address.\n", tmpemail);
+ scr_printf("It is already in use by %s @ %s.\n", diruser, dirnode);
ok = 0;
safestrncpy(tmpemail, holdemail, sizeof tmpemail);
}
} while (ok == 0);
/* now send the registration info back to the server */
- reg = (char *)realloc(reg, SIZ);
+ reg = (char *) realloc(reg, SIZ);
if (reg) {
sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- tmpname, tmpaddr, tmpcity, tmpstate,
- tmpzip, tmpphone, tmpemail, tmpcountry);
+ tmpname, tmpaddr, tmpcity, tmpstate, tmpzip, tmpphone, tmpemail, tmpcountry);
r = CtdlIPCSetRegistration(ipc, reg, buf);
if (r / 100 != 4)
scr_printf("%s\n", buf);
/*
* make all messages old in current room
*/
-void updatels(CtdlIPC *ipc)
+void updatels(CtdlIPC * ipc)
{
char buf[256];
- int r; /* IPC response code */
+ int r; /* IPC response code */
- r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ? maxmsgnum : highest_msg_read, buf);
+ r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ? maxmsgnum : highest_msg_read, buf);
if (r / 100 != 2)
scr_printf("%s\n", buf);
/*
* only make messages old in this room that have been read
*/
-void updatelsa(CtdlIPC *ipc)
+void updatelsa(CtdlIPC * ipc)
{
char buf[256];
- int r; /* IPC response code */
+ int r; /* IPC response code */
r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
if (r / 100 != 2)
/*
* client-based uploads (for users with their own clientware)
*/
-void cli_upload(CtdlIPC *ipc)
+void cli_upload(CtdlIPC * ipc)
{
char flnm[PATH_MAX];
char desc[151];
char buf[256];
char tbuf[256];
- int r; /* IPC response code */
+ int r; /* IPC response code */
int a;
int fd;
/* basename of filename */
strcpy(tbuf, flnm);
if (haschar(tbuf, '/'))
- extract_token(tbuf, flnm,
- num_tokens(tbuf, '/') - 1,
- '/', sizeof tbuf
- );
+ extract_token(tbuf, flnm, num_tokens(tbuf, '/') - 1, '/', sizeof tbuf);
/* filename.1, filename.2, etc */
if (a > 0) {
sprintf(&tbuf[strlen(tbuf)], ".%d", a);
break;
++a;
}
- if (a > 0) scr_printf("Saved as '%s'\n", tbuf);
+ if (a > 0)
+ scr_printf("Saved as '%s'\n", tbuf);
}
/*
* Function used for various image upload commands
*/
-void cli_image_upload(CtdlIPC *ipc, char *keyname)
+void cli_image_upload(CtdlIPC * ipc, char *keyname)
{
char flnm[PATH_MAX];
char buf[256];
/*
* protocol-based uploads (Xmodem, Ymodem, Zmodem)
*/
-void upload(CtdlIPC *ipc, int c)
+void upload(CtdlIPC * ipc, int c)
{ /* c = upload mode */
char flnm[PATH_MAX];
char desc[151];
/* create a temporary directory... */
if (mkdir(tempdir, 0700) != 0) {
- scr_printf("*** Could not create temporary directory %s: %s\n",
- tempdir, strerror(errno));
+ scr_printf("*** Could not create temporary directory %s: %s\n", tempdir, strerror(errno));
return;
}
/* now do the transfer ... in a separate process */
if (xfer_pid == 0) {
rv = chdir(tempdir);
if (rv < 0) {
- scr_printf("failed to change into %s Reason %s\nAborting now.\n",
- tempdir,
- strerror(errno));
+ scr_printf("failed to change into %s Reason %s\nAborting now.\n", tempdir, strerror(errno));
nukedir(tempdir);
return;
}
if (lsfp != NULL) {
while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
flnm[strlen(flnm) - 1] = 0; /* chop newline */
- snprintf(buf, sizeof buf,
- "Enter a short description of '%s':\n: ",
- flnm);
+ snprintf(buf, sizeof buf, "Enter a short description of '%s':\n: ", flnm);
newprompt(buf, desc, 150);
snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
/*
* validate a user (returns 0 for successful validation, nonzero if quitting)
*/
-int val_user(CtdlIPC *ipc, char *user, int do_validate)
+int val_user(CtdlIPC * ipc, char *user, int do_validate)
{
int a;
char cmd[256];
char *resp = NULL;
int ax = 0;
char answer[2];
- int r; /* IPC response code */
+ int r; /* IPC response code */
scr_printf("\n");
r = CtdlIPCGetUserRegistration(ipc, user, &resp, cmd);
if (a == 1)
scr_printf("User #%s - %s ", buf, cmd);
if (a == 2)
- scr_printf("PW: %s\n", (IsEmptyStr(buf) ? "<NOT SET>" : "<SET>") );
+ scr_printf("PW: %s\n", (IsEmptyStr(buf) ? "<NOT SET>" : "<SET>"));
if (a == 3)
scr_printf("%s\n", buf);
if (a == 4)
} else {
scr_printf("%s\n%s\n", user, &cmd[4]);
}
- if (resp) free(resp);
+ if (resp)
+ free(resp);
if (do_validate) {
/* now set the access level */
- while(1) {
+ while (1) {
sprintf(answer, "%d", ax);
- strprompt("New access level (? for help, q to quit)",
- answer, 1);
+ strprompt("New access level (? for help, q to quit)", answer, 1);
if ((answer[0] >= '0') && (answer[0] <= '6')) {
ax = atoi(answer);
r = CtdlIPCValidateUser(ipc, user, ax, cmd);
if (r / 100 != 2)
- scr_printf("%s\n\n", cmd);
- return(0);
+ scr_printf("%s\n\n", cmd);
+ return (0);
}
if (tolower(answer[0]) == 'q') {
scr_printf("*** Aborted.\n\n");
- return(1);
+ return (1);
}
if (answer[0] == '?') {
scr_printf("Available access levels:\n");
- for (a=0; a<7; ++a) {
- scr_printf("%d - %s\n",
- a, axdefs[a]);
+ for (a = 0; a < 7; ++a) {
+ scr_printf("%d - %s\n", a, axdefs[a]);
}
}
}
}
- return(0);
+ return (0);
}
/*
* Validate new users
*/
-void validate(CtdlIPC *ipc)
+void validate(CtdlIPC * ipc)
{
char cmd[256];
char buf[256];
int finished = 0;
- int r; /* IPC response code */
+ int r; /* IPC response code */
do {
r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
scr_printf("%s\n", cmd);
if (r / 100 == 3) {
extract_token(buf, cmd, 0, '|', sizeof buf);
- if (val_user(ipc, buf, 1) != 0) finished = 1;
+ if (val_user(ipc, buf, 1) != 0)
+ finished = 1;
}
} while (finished == 0);
}
/*
* <.A>ide <F>ile <D>elete command
*/
-void deletefile(CtdlIPC *ipc)
+void deletefile(CtdlIPC * ipc)
{
char filename[32];
char buf[256];
/*
* <.A>ide <F>ile <M>ove command
*/
-void movefile(CtdlIPC *ipc)
+void movefile(CtdlIPC * ipc)
{
char filename[64];
char newroom[ROOMNAMELEN];
/*
* list of users who have filled out a bio
*/
-void list_bio(CtdlIPC *ipc)
+void list_bio(CtdlIPC * ipc)
{
char buf[256];
char *resp = NULL;
pos = pos + strlen(buf) + 2;
}
scr_printf("%c%c \n\n", 8, 8);
- if (resp) free(resp);
+ if (resp)
+ free(resp);
}
/*
* read bio
*/
-void read_bio(CtdlIPC *ipc)
+void read_bio(CtdlIPC * ipc)
{
char who[256];
char buf[256];
remove_token(resp, 0, '\n');
scr_printf("%s\n", buf);
}
- if (resp) free(resp);
+ if (resp)
+ free(resp);
}
/*
* Beep.
*/
-void ctdl_beep(void) {
+void ctdl_beep(void)
+{
putc(7, stdout);
}
-
+
va_end(ap);
len = strlen(outbuf);
- for (i=0; i<len; ++i) {
+ for (i = 0; i < len; ++i) {
scr_putc(outbuf[i]);
}
return retval;
scr_flush();
buf = '\0';
- if (!read (0, &buf, 1))
+ if (!read(0, &buf, 1))
logoff(NULL, 3);
lines_printed = 0;
/*
* Issue the paginator prompt (more / hit any key to continue)
*/
-void hit_any_key(void) {
+void hit_any_key(void)
+{
int a, b;
color(COLOR_PUSH);
color(DIM_RED);
scr_printf("%s\r", moreprompt);
color(COLOR_POP);
- b=inkey();
- for (a=0; a<screenwidth; ++a) {
+ b = inkey();
+ for (a = 0; a < screenwidth; ++a) {
scr_putc(' ');
}
scr_printf("\r");
- if ( (rc_prompt_control == 1) || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL)) ) {
+ if ((rc_prompt_control == 1) || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL))) {
if (b == 'q' || b == 'Q' || b == 's' || b == 'S') {
b = STOP_KEY;
}
}
}
- if (b==NEXT_KEY) sigcaught = SIGINT;
- if (b==STOP_KEY) sigcaught = SIGQUIT;
+ if (b == NEXT_KEY)
+ sigcaught = SIGINT;
+ if (b == STOP_KEY)
+ sigcaught = SIGQUIT;
}
do {
scr_putc(' ');
} while ((cols_printed % 8) != 0);
- return(c);
+ return (c);
}
/* Output the character... */
if (c == '\n') {
++lines_printed;
cols_printed = 0;
- }
- else if (c == '\r') {
+ } else if (c == '\r') {
cols_printed = 0;
- }
- else if (isprint(c)) {
+ } else if (isprint(c)) {
++cols_printed;
if ((screenwidth > 0) && (cols_printed > screenwidth)) {
++lines_printed;
/* How many lines output before stopping for the paginator?
* Depends on whether we are displaying a status line.
*/
- int height_offset = ( ((enable_color) && (screenwidth > 0) && (enable_status_line)) ? (3) : (2) ) ;
+ int height_offset = (((enable_color) && (screenwidth > 0) && (enable_status_line)) ? (3) : (2));
/* Ok, go check it. Stop and display the paginator prompt if necessary. */
- if ((screenheight > 0) && (lines_printed > (screenheight-height_offset))) {
+ if ((screenheight > 0) && (lines_printed > (screenheight - height_offset))) {
lines_printed = 0;
hit_any_key();
lines_printed = 0;
/*
* Display a 3270-style "wait" indicator at the bottom of the screen
*/
-void scr_wait_indicator(int state) {
+void scr_wait_indicator(int state)
+{
int sp = (screenwidth - 2);
- if (!enable_status_line) return;
+ if (!enable_status_line)
+ return;
if (screenwidth > 0) {
switch (state) {
- default:
- case 0: /* Idle */
- status_line[sp] = ' ';
- break;
- case 1: /* Waiting */
- status_line[sp] = 'X';
- break;
- case 2: /* Receiving */
- status_line[sp] = '<';
- break;
- case 3: /* Sending */
- status_line[sp] = '>';
- break;
+ default:
+ case 0: /* Idle */
+ status_line[sp] = ' ';
+ break;
+ case 1: /* Waiting */
+ status_line[sp] = 'X';
+ break;
+ case 2: /* Receiving */
+ status_line[sp] = '<';
+ break;
+ case 3: /* Sending */
+ status_line[sp] = '>';
+ break;
}
scr_flush();
}
}
-
/*
* General system configuration command
*/
-void do_system_configuration(CtdlIPC *ipc)
+void do_system_configuration(CtdlIPC * ipc)
{
/* NUM_CONFIGS is now defined in citadel.h */
r = CtdlIPCGetSystemConfig(ipc, &resp, buf);
if (r / 100 == 1) {
server_configs = num_tokens(resp, '\n');
- for (a=0; a<server_configs; ++a) {
+ for (a = 0; a < server_configs; ++a) {
if (a < NUM_CONFIGS) {
extract_token(&sc[a][0], resp, a, '\n', sizeof sc[a]);
}
}
}
- if (resp) free(resp);
+ if (resp)
+ free(resp);
resp = NULL;
/* Fetch the expire policy (this will silently fail on old servers,
* resulting in "default" policy)
strprompt("Initial access level for new users", &sc[6][0], 1);
strprompt("Access level required to create rooms", &sc[19][0], 1);
snprintf(sc[67], sizeof sc[67], "%d", (boolprompt("Allow anonymous guest logins", atoi(&sc[67][0]))));
- snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
- "Automatically give room admin privs to a user who creates a private room",
- atoi(&sc[4][0]))));
+ snprintf(sc[4], sizeof sc[4], "%d", (boolprompt("Automatically give room admin privs to a user who creates a private room",
+ atoi(&sc[4][0]))));
- snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
- "Automatically move problem user messages to twit room",
- atoi(&sc[8][0]))));
+ snprintf(sc[8], sizeof sc[8], "%d", (boolprompt("Automatically move problem user messages to twit room", atoi(&sc[8][0]))));
strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
- snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
- "Restrict Internet mail to only those with that privilege",
- atoi(&sc[11][0]))));
- snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
- "Allow admins to Zap (forget) rooms",
- atoi(&sc[26][0]))));
+ snprintf(sc[11], sizeof sc[11], "%d", (boolprompt("Restrict Internet mail to only those with that privilege",
+ atoi(&sc[11][0]))));
+ snprintf(sc[26], sizeof sc[26], "%d", (boolprompt("Allow admins to Zap (forget) rooms", atoi(&sc[26][0]))));
if (!IsEmptyStr(&sc[18][0])) {
logpages = 1;
- }
- else {
+ } else {
logpages = 0;
}
logpages = boolprompt("Log all instant messages", logpages);
if (logpages) {
strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
- }
- else {
+ } else {
sc[18][0] = 0;
}
* change while the server is running.
*
* snprintf(sc[52], sizeof sc[52], "%d", (boolprompt(
- * "Use system authentication",
- * atoi(&sc[52][0]))));
+ * "Use system authentication",
+ * atoi(&sc[52][0]))));
*/
/* Server tuning */
strprompt("Maximum message length", &sc[20][0], 20);
strprompt("Minimum number of worker threads", &sc[21][0], 3);
strprompt("Maximum number of worker threads", &sc[22][0], 3);
- snprintf(sc[43], sizeof sc[43], "%d", (boolprompt(
- "Automatically delete committed database logs",
- atoi(&sc[43][0]))));
+ snprintf(sc[43], sizeof sc[43], "%d", (boolprompt("Automatically delete committed database logs", atoi(&sc[43][0]))));
strprompt("Server IP address (* for 'any')", &sc[37][0], 15);
strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
a = (a ? 0 : 1);
snprintf(sc[25], sizeof sc[25], "%d", a);
- snprintf(sc[66], sizeof sc[66], "%d", (boolprompt(
- "Flag messages as spam instead of rejecting",
- atoi(&sc[66][0]))));
+ snprintf(sc[66], sizeof sc[66], "%d", (boolprompt("Flag messages as spam instead of rejecting", atoi(&sc[66][0]))));
/* This logic flips the question around, because it's one of those
* situations where 0=yes and 1=no
a = (a ? 0 : 1);
snprintf(sc[61], sizeof sc[61], "%d", a);
- snprintf(sc[45], sizeof sc[45], "%d", (boolprompt(
- "Allow unauthenticated SMTP clients to spoof my domains",
- atoi(&sc[45][0]))));
- snprintf(sc[57], sizeof sc[57], "%d", (boolprompt(
- "Perform RBL checks at greeting instead of after RCPT",
- atoi(&sc[57][0]))));
+ snprintf(sc[45], sizeof sc[45], "%d", (boolprompt("Allow unauthenticated SMTP clients to spoof my domains",
+ atoi(&sc[45][0]))));
+ snprintf(sc[57], sizeof sc[57], "%d", (boolprompt("Perform RBL checks at greeting instead of after RCPT",
+ atoi(&sc[57][0]))));
/* LDAP settings */
if (ipc->ServInfo.supports_ldap) {
strprompt("Base DN", &sc[34][0], 255);
strprompt("Bind DN (or blank for anonymous bind)", &sc[35][0], 255);
strprompt("Password for bind DN (or blank for anonymous bind)", &sc[36][0], 255);
- }
- else {
+ } else {
strcpy(&sc[32][0], "");
}
}
/* Angels and demons dancing in my head... */
do {
snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_mode);
- strprompt("System default message expire policy (? for list)",
- buf, 1);
+ strprompt("System default message expire policy (? for list)", buf, 1);
if (buf[0] == '?') {
scr_printf("\n"
- "1. Never automatically expire messages\n"
- "2. Expire by message count\n"
- "3. Expire by message age\n");
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n" "3. Expire by message age\n");
}
} while ((buf[0] < '1') || (buf[0] > '3'));
site_expirepolicy->expire_mode = buf[0] - '0';
/* Media messiahs preying on my fears... */
do {
snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_mode);
- strprompt("Mailbox default message expire policy (? for list)",
- buf, 1);
+ strprompt("Mailbox default message expire policy (? for list)", buf, 1);
if (buf[0] == '?') {
scr_printf("\n"
- "0. Go with the system default\n"
- "1. Never automatically expire messages\n"
- "2. Expire by message count\n"
- "3. Expire by message age\n");
+ "0. Go with the system default\n"
+ "1. Never automatically expire messages\n"
+ "2. Expire by message count\n" "3. Expire by message age\n");
}
} while ((buf[0] < '0') || (buf[0] > '3'));
mbx_expirepolicy->expire_mode = buf[0] - '0';
strprompt("Default frequency to run POP3 collection (in seconds)", &sc[64][0], 5);
strprompt("Fastest frequency to run POP3 collection (in seconds)", &sc[65][0], 5);
strprompt("Hour to run purges (0-23)", &sc[31][0], 2);
- snprintf(sc[42], sizeof sc[42], "%d", (boolprompt(
- "Enable full text search index (warning: resource intensive)",
- atoi(&sc[42][0]))));
-
- snprintf(sc[46], sizeof sc[46], "%d", (boolprompt(
- "Perform journaling of email messages",
- atoi(&sc[46][0]))));
- snprintf(sc[47], sizeof sc[47], "%d", (boolprompt(
- "Perform journaling of non-email messages",
- atoi(&sc[47][0]))));
- if ( (atoi(&sc[46][0])) || (atoi(&sc[47][0])) ) {
- strprompt("Email destination of journalized messages",
- &sc[48][0], 127);
+ snprintf(sc[42], sizeof sc[42], "%d", (boolprompt("Enable full text search index (warning: resource intensive)",
+ atoi(&sc[42][0]))));
+
+ snprintf(sc[46], sizeof sc[46], "%d", (boolprompt("Perform journaling of email messages", atoi(&sc[46][0]))));
+ snprintf(sc[47], sizeof sc[47], "%d", (boolprompt("Perform journaling of non-email messages", atoi(&sc[47][0]))));
+ if ((atoi(&sc[46][0])) || (atoi(&sc[47][0]))) {
+ strprompt("Email destination of journalized messages", &sc[48][0], 127);
}
/* No more Funambol */
/* External pager stuff */
int yes_pager = 0;
- if (strlen(sc[60]) > 0) yes_pager = 1;
+ if (strlen(sc[60]) > 0)
+ yes_pager = 1;
yes_pager = boolprompt("Configure an external pager tool", yes_pager);
if (yes_pager) {
strprompt("External pager tool", &sc[60][0], 255);
- }
- else {
+ } else {
sc[60][0] = 0;
}
/* Master user account */
int yes_muacct = 0;
- if (strlen(sc[58]) > 0) yes_muacct = 1;
+ if (strlen(sc[58]) > 0)
+ yes_muacct = 1;
yes_muacct = boolprompt("Enable a 'master user' account", yes_muacct);
if (yes_muacct) {
strprompt("Master user name", &sc[58][0], 31);
strprompt("Master user password", &sc[59][0], -31);
- }
- else {
+ } else {
strcpy(&sc[58][0], "");
strcpy(&sc[59][0], "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}
for (a = 0; a < NUM_CONFIGS; a++) {
r += 1 + strlen(sc[a]);
}
- resp = (char *)calloc(1, r);
+ resp = (char *) calloc(1, r);
if (!resp) {
scr_printf("Can't save config - out of memory!\n");
logoff(ipc, 1);
}
}
- if (site_expirepolicy) free(site_expirepolicy);
- if (mbx_expirepolicy) free(mbx_expirepolicy);
+ if (site_expirepolicy)
+ free(site_expirepolicy);
+ if (mbx_expirepolicy)
+ free(mbx_expirepolicy);
}
/*
* support function for do_internet_configuration()
*/
-void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
+void get_inet_rec_type(CtdlIPC * ipc, char *buf)
+{
int sel;
keyopt(" <1> localhost (Alias for this computer)\n");
keyopt(" <6> masq domains (Domains as which users are allowed to masquerade)\n");
keyopt(" <7> ClamAV (Address of ClamAV clamd server)\n");
sel = intprompt("Which one", 1, 1, 8);
- switch(sel) {
- case 1: strcpy(buf, "localhost");
- return;
- case 2: strcpy(buf, "smarthost");
- return;
- case 3: strcpy(buf, "fallbackhost");
- return;
- case 4: strcpy(buf, "spamassassin");
- return;
- case 5: strcpy(buf, "rbl");
- return;
- case 6: strcpy(buf, "masqdomain");
- return;
- case 7: strcpy(buf, "clamav");
- return;
+ switch (sel) {
+ case 1:
+ strcpy(buf, "localhost");
+ return;
+ case 2:
+ strcpy(buf, "smarthost");
+ return;
+ case 3:
+ strcpy(buf, "fallbackhost");
+ return;
+ case 4:
+ strcpy(buf, "spamassassin");
+ return;
+ case 5:
+ strcpy(buf, "rbl");
+ return;
+ case 6:
+ strcpy(buf, "masqdomain");
+ return;
+ case 7:
+ strcpy(buf, "clamav");
+ return;
}
}
/*
* Internet mail configuration
*/
-void do_internet_configuration(CtdlIPC *ipc)
+void do_internet_configuration(CtdlIPC * ipc)
{
char buf[256];
char *resp = NULL;
int quitting = 0;
int modified = 0;
int r;
-
+
r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
if (r / 100 == 1) {
while (!IsEmptyStr(resp)) {
}
++num_recs;
- if (num_recs == 1) recs = malloc(sizeof(char *));
- else recs = realloc(recs, (sizeof(char *)) * num_recs);
- recs[num_recs-1] = malloc(strlen(buf) + 1);
- strcpy(recs[num_recs-1], buf);
+ if (num_recs == 1)
+ recs = malloc(sizeof(char *));
+ else
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ recs[num_recs - 1] = malloc(strlen(buf) + 1);
+ strcpy(recs[num_recs - 1], buf);
}
}
- if (resp) free(resp);
+ if (resp)
+ free(resp);
do {
scr_printf("\n");
scr_printf("### Host or domain Record type \n");
color(DIM_WHITE);
scr_printf("--- -------------------------------------------------- --------------------\n");
- for (i=0; i<num_recs; ++i) {
- color(DIM_WHITE);
- scr_printf("%3d ", i+1);
- extract_token(buf, recs[i], 0, '|', sizeof buf);
- color(BRIGHT_CYAN);
- scr_printf("%-50s ", buf);
- extract_token(buf, recs[i], 1, '|', sizeof buf);
- color(BRIGHT_MAGENTA);
- scr_printf("%-20s\n", buf);
- color(DIM_WHITE);
+ for (i = 0; i < num_recs; ++i) {
+ color(DIM_WHITE);
+ scr_printf("%3d ", i + 1);
+ extract_token(buf, recs[i], 0, '|', sizeof buf);
+ color(BRIGHT_CYAN);
+ scr_printf("%-50s ", buf);
+ extract_token(buf, recs[i], 1, '|', sizeof buf);
+ color(BRIGHT_MAGENTA);
+ scr_printf("%-20s\n", buf);
+ color(DIM_WHITE);
}
ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
- switch(ch) {
- case 'a':
- newprompt("Enter host name: ", buf, 50);
- striplt(buf);
- if (!IsEmptyStr(buf)) {
- ++num_recs;
- if (num_recs == 1) {
- recs = malloc(sizeof(char *));
- }
- else {
- recs = realloc(recs, (sizeof(char *)) * num_recs);
- }
- strcat(buf, "|");
- get_inet_rec_type(ipc, &buf[strlen(buf)]);
- recs[num_recs-1] = strdup(buf);
- }
- modified = 1;
- break;
- case 'd':
- i = intprompt("Delete which one", 1, 1, num_recs) - 1;
- free(recs[i]);
- --num_recs;
- for (j=i; j<num_recs; ++j) {
- recs[j] = recs[j+1];
- }
- modified = 1;
- break;
- case 's':
- r = 1;
- for (i = 0; i < num_recs; i++)
- r += 1 + strlen(recs[i]);
- resp = (char *)calloc(1, r);
- if (!resp) {
- scr_printf("Can't save config - out of memory!\n");
- logoff(ipc, 1);
+ switch (ch) {
+ case 'a':
+ newprompt("Enter host name: ", buf, 50);
+ striplt(buf);
+ if (!IsEmptyStr(buf)) {
+ ++num_recs;
+ if (num_recs == 1) {
+ recs = malloc(sizeof(char *));
+ } else {
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
}
- if (num_recs) for (i = 0; i < num_recs; i++) {
+ strcat(buf, "|");
+ get_inet_rec_type(ipc, &buf[strlen(buf)]);
+ recs[num_recs - 1] = strdup(buf);
+ }
+ modified = 1;
+ break;
+ case 'd':
+ i = intprompt("Delete which one", 1, 1, num_recs) - 1;
+ free(recs[i]);
+ --num_recs;
+ for (j = i; j < num_recs; ++j) {
+ recs[j] = recs[j + 1];
+ }
+ modified = 1;
+ break;
+ case 's':
+ r = 1;
+ for (i = 0; i < num_recs; i++)
+ r += 1 + strlen(recs[i]);
+ resp = (char *) calloc(1, r);
+ if (!resp) {
+ scr_printf("Can't save config - out of memory!\n");
+ logoff(ipc, 1);
+ }
+ if (num_recs)
+ for (i = 0; i < num_recs; i++) {
strcat(resp, recs[i]);
strcat(resp, "\n");
}
- r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
- if (r / 100 != 4) {
- scr_printf("%s\n", buf);
- } else {
- scr_printf("Wrote %d records.\n", num_recs);
- modified = 0;
- }
- free(resp);
- break;
- case 'q':
- quitting = !modified || boolprompt(
- "Quit without saving", 0);
- break;
- default:
- break;
+ r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
+ if (r / 100 != 4) {
+ scr_printf("%s\n", buf);
+ } else {
+ scr_printf("Wrote %d records.\n", num_recs);
+ modified = 0;
+ }
+ free(resp);
+ break;
+ case 'q':
+ quitting = !modified || boolprompt("Quit without saving", 0);
+ break;
+ default:
+ break;
}
} while (!quitting);
if (recs != NULL) {
- for (i=0; i<num_recs; ++i) free(recs[i]);
+ for (i = 0; i < num_recs; ++i)
+ free(recs[i]);
free(recs);
}
}
/*
* Edit network configuration for room sharing, mailing lists, etc.
*/
-void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
+void network_config_management(CtdlIPC * ipc, char *entrytype, char *comment)
{
char filename[PATH_MAX];
char changefile[PATH_MAX];
fprintf(tempfp, "# Configuration for room: %s\n", room_name);
fprintf(tempfp, "# %s\n", comment);
- fprintf(tempfp, "# Specify one per line.\n"
- "\n\n");
+ fprintf(tempfp, "# Specify one per line.\n" "\n\n");
r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
if (r / 100 == 1) {
- while(listing && !IsEmptyStr(listing)) {
+ while (listing && !IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
extract_token(instr, buf, 0, '|', sizeof instr);
if (!strcasecmp(instr, entrytype)) {
tokens = num_tokens(buf, '|');
- for (i=1; i<tokens; ++i) {
+ for (i = 1; i < tokens; ++i) {
extract_token(addr, buf, i, '|', sizeof addr);
fprintf(tempfp, "%s", addr);
- if (i < (tokens-1)) {
+ if (i < (tokens - 1)) {
fprintf(tempfp, "|");
}
}
}
fclose(tempfp);
- e_ex_code = 1; /* start with a failed exit code */
+ e_ex_code = 1; /* start with a failed exit code */
stty_ctdl(SB_RESTORE);
editor_pid = fork();
cksum = file_checksum(filename);
e_ex_code = 0;
b = ka_wait(&e_ex_code);
} while ((b != editor_pid) && (b >= 0));
- editor_pid = (-1);
- stty_ctdl(0);
+ editor_pid = (-1);
+ stty_ctdl(0);
}
if (file_checksum(filename) == cksum) {
e_ex_code = 1;
}
- if (e_ex_code == 0) { /* Save changes */
+ if (e_ex_code == 0) { /* Save changes */
changefp = fopen(changefile, "w");
/* Load all netconfig entries that are *not* of the type we are editing */
r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
if (r / 100 == 1) {
- while(listing && !IsEmptyStr(listing)) {
+ while (listing && !IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
extract_token(instr, buf, 0, '|', sizeof instr);
/* ...and merge that with the data we just edited */
tempfp = fopen(filename, "r");
while (fgets(buf, sizeof buf, tempfp) != NULL) {
- for (i=0; i<strlen(buf); ++i) {
- if (buf[i] == '#') buf[i] = 0;
+ for (i = 0; i < strlen(buf); ++i) {
+ if (buf[i] == '#')
+ buf[i] = 0;
}
striplt(buf);
if (!IsEmptyStr(buf)) {
}
}
- unlink(filename); /* Delete the temporary files */
+ unlink(filename); /* Delete the temporary files */
unlink(changefile);
}
/*
* POP3 aggregation client configuration
*/
-void do_pop3client_configuration(CtdlIPC *ipc)
+void do_pop3client_configuration(CtdlIPC * ipc)
{
char buf[SIZ];
int num_recs = 0;
r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
if (r / 100 == 1) {
- while(listing && !IsEmptyStr(listing)) {
+ while (listing && !IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
extract_token(instr, buf, 0, '|', sizeof instr);
if (!strcasecmp(instr, "pop3client")) {
++num_recs;
- if (num_recs == 1) recs = malloc(sizeof(char *));
- else recs = realloc(recs, (sizeof(char *)) * num_recs);
- recs[num_recs-1] = malloc(SIZ);
- strcpy(recs[num_recs-1], buf);
+ if (num_recs == 1)
+ recs = malloc(sizeof(char *));
+ else
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ recs[num_recs - 1] = malloc(SIZ);
+ strcpy(recs[num_recs - 1], buf);
}
}
do {
scr_printf("\n");
color(BRIGHT_WHITE);
- scr_printf( "### "
- " Remote POP3 host "
- " User name "
- "Keep on server? "
- "\n");
- color(DIM_WHITE);
- scr_printf( "--- "
- "---------------------------- "
- "---------------------------- "
- "--------------- "
- "\n");
- for (i=0; i<num_recs; ++i) {
- color(DIM_WHITE);
- scr_printf("%3d ", i+1);
-
- extract_token(buf, recs[i], 1, '|', sizeof buf);
- color(BRIGHT_CYAN);
- scr_printf("%-28s ", buf);
-
- extract_token(buf, recs[i], 2, '|', sizeof buf);
- color(BRIGHT_MAGENTA);
- scr_printf("%-28s ", buf);
-
- color(BRIGHT_CYAN);
- scr_printf("%-15s\n", (extract_int(recs[i], 4) ? "Yes" : "No") );
+ scr_printf("### " " Remote POP3 host " " User name " "Keep on server? " "\n");
color(DIM_WHITE);
+ scr_printf("--- " "---------------------------- " "---------------------------- " "--------------- " "\n");
+ for (i = 0; i < num_recs; ++i) {
+ color(DIM_WHITE);
+ scr_printf("%3d ", i + 1);
+
+ extract_token(buf, recs[i], 1, '|', sizeof buf);
+ color(BRIGHT_CYAN);
+ scr_printf("%-28s ", buf);
+
+ extract_token(buf, recs[i], 2, '|', sizeof buf);
+ color(BRIGHT_MAGENTA);
+ scr_printf("%-28s ", buf);
+
+ color(BRIGHT_CYAN);
+ scr_printf("%-15s\n", (extract_int(recs[i], 4) ? "Yes" : "No"));
+ color(DIM_WHITE);
}
ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
- switch(ch) {
- case 'a':
- ++num_recs;
- if (num_recs == 1) {
- recs = malloc(sizeof(char *));
- }
- else {
- recs = realloc(recs, (sizeof(char *)) * num_recs);
- }
- strcpy(buf, "pop3client|");
- newprompt("Enter host name: ", &buf[strlen(buf)], 28);
- strcat(buf, "|");
- newprompt("Enter user name: ", &buf[strlen(buf)], 28);
- strcat(buf, "|");
- newprompt("Enter password : ", &buf[strlen(buf)], 16);
- strcat(buf, "|");
- scr_printf("Keep messages on server instead of deleting them? ");
- sprintf(&buf[strlen(buf)], "%d", yesno());
- strcat(buf, "|");
- recs[num_recs-1] = strdup(buf);
- modified = 1;
- break;
- case 'd':
- i = intprompt("Delete which one",
- 1, 1, num_recs) - 1;
- free(recs[i]);
- --num_recs;
- for (j=i; j<num_recs; ++j)
- recs[j] = recs[j+1];
- modified = 1;
- break;
- case 's':
- r = 1;
+ switch (ch) {
+ case 'a':
+ ++num_recs;
+ if (num_recs == 1) {
+ recs = malloc(sizeof(char *));
+ } else {
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ }
+ strcpy(buf, "pop3client|");
+ newprompt("Enter host name: ", &buf[strlen(buf)], 28);
+ strcat(buf, "|");
+ newprompt("Enter user name: ", &buf[strlen(buf)], 28);
+ strcat(buf, "|");
+ newprompt("Enter password : ", &buf[strlen(buf)], 16);
+ strcat(buf, "|");
+ scr_printf("Keep messages on server instead of deleting them? ");
+ sprintf(&buf[strlen(buf)], "%d", yesno());
+ strcat(buf, "|");
+ recs[num_recs - 1] = strdup(buf);
+ modified = 1;
+ break;
+ case 'd':
+ i = intprompt("Delete which one", 1, 1, num_recs) - 1;
+ free(recs[i]);
+ --num_recs;
+ for (j = i; j < num_recs; ++j)
+ recs[j] = recs[j + 1];
+ modified = 1;
+ break;
+ case 's':
+ r = 1;
+ for (i = 0; i < num_recs; ++i) {
+ r += 1 + strlen(recs[i]);
+ }
+ listing = (char *) calloc(1, r);
+ if (!listing) {
+ scr_printf("Can't save config - out of memory!\n");
+ logoff(ipc, 1);
+ }
+ if (num_recs)
for (i = 0; i < num_recs; ++i) {
- r += 1 + strlen(recs[i]);
- }
- listing = (char*) calloc(1, r);
- if (!listing) {
- scr_printf("Can't save config - out of memory!\n");
- logoff(ipc, 1);
- }
- if (num_recs) for (i = 0; i < num_recs; ++i) {
strcat(listing, recs[i]);
strcat(listing, "\n");
}
- /* Retrieve all the *other* records for merging */
- r = CtdlIPCGetRoomNetworkConfig(ipc, &other_listing, buf);
- if (r / 100 == 1) {
- for (i=0; i<num_tokens(other_listing, '\n'); ++i) {
- extract_token(buf, other_listing, i, '\n', sizeof buf);
- if (strncasecmp(buf, "pop3client|", 11)) {
- listing = realloc(listing, strlen(listing) +
- strlen(buf) + 10);
- strcat(listing, buf);
- strcat(listing, "\n");
- }
+ /* Retrieve all the *other* records for merging */
+ r = CtdlIPCGetRoomNetworkConfig(ipc, &other_listing, buf);
+ if (r / 100 == 1) {
+ for (i = 0; i < num_tokens(other_listing, '\n'); ++i) {
+ extract_token(buf, other_listing, i, '\n', sizeof buf);
+ if (strncasecmp(buf, "pop3client|", 11)) {
+ listing = realloc(listing, strlen(listing) + strlen(buf) + 10);
+ strcat(listing, buf);
+ strcat(listing, "\n");
}
}
- free(other_listing);
- r = CtdlIPCSetRoomNetworkConfig(ipc, listing, buf);
- free(listing);
- listing = NULL;
+ }
+ free(other_listing);
+ r = CtdlIPCSetRoomNetworkConfig(ipc, listing, buf);
+ free(listing);
+ listing = NULL;
- if (r / 100 != 4) {
- scr_printf("%s\n", buf);
- } else {
- scr_printf("Wrote %d records.\n", num_recs);
- modified = 0;
- }
- quitting = 1;
- break;
- case 'q':
- quitting = !modified || boolprompt(
- "Quit without saving", 0);
- break;
- default:
- break;
+ if (r / 100 != 4) {
+ scr_printf("%s\n", buf);
+ } else {
+ scr_printf("Wrote %d records.\n", num_recs);
+ modified = 0;
+ }
+ quitting = 1;
+ break;
+ case 'q':
+ quitting = !modified || boolprompt("Quit without saving", 0);
+ break;
+ default:
+ break;
}
} while (!quitting);
if (recs != NULL) {
- for (i=0; i<num_recs; ++i) free(recs[i]);
+ for (i = 0; i < num_recs; ++i)
+ free(recs[i]);
free(recs);
}
}
/*
* RSS feed retrieval client configuration
*/
-void do_rssclient_configuration(CtdlIPC *ipc)
+void do_rssclient_configuration(CtdlIPC * ipc)
{
char buf[SIZ];
int num_recs = 0;
r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf);
if (r / 100 == 1) {
- while(listing && !IsEmptyStr(listing)) {
+ while (listing && !IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
extract_token(instr, buf, 0, '|', sizeof instr);
if (!strcasecmp(instr, "rssclient")) {
++num_recs;
- if (num_recs == 1) recs = malloc(sizeof(char *));
- else recs = realloc(recs, (sizeof(char *)) * num_recs);
- recs[num_recs-1] = malloc(SIZ);
- strcpy(recs[num_recs-1], buf);
+ if (num_recs == 1)
+ recs = malloc(sizeof(char *));
+ else
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ recs[num_recs - 1] = malloc(SIZ);
+ strcpy(recs[num_recs - 1], buf);
}
}
color(BRIGHT_WHITE);
scr_printf("### Feed URL\n");
color(DIM_WHITE);
- scr_printf("--- "
- "---------------------------------------------------------------------------"
- "\n");
-
- for (i=0; i<num_recs; ++i) {
- color(DIM_WHITE);
- scr_printf("%3d ", i+1);
+ scr_printf("--- " "---------------------------------------------------------------------------" "\n");
- extract_token(buf, recs[i], 1, '|', sizeof buf);
- color(BRIGHT_CYAN);
- scr_printf("%-75s\n", buf);
+ for (i = 0; i < num_recs; ++i) {
+ color(DIM_WHITE);
+ scr_printf("%3d ", i + 1);
- color(DIM_WHITE);
+ extract_token(buf, recs[i], 1, '|', sizeof buf);
+ color(BRIGHT_CYAN);
+ scr_printf("%-75s\n", buf);
+
+ color(DIM_WHITE);
}
ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
- switch(ch) {
- case 'a':
- ++num_recs;
- if (num_recs == 1) {
- recs = malloc(sizeof(char *));
- }
- else {
- recs = realloc(recs, (sizeof(char *)) * num_recs);
- }
- strcpy(buf, "rssclient|");
- newprompt("Enter feed URL: ", &buf[strlen(buf)], 75);
- strcat(buf, "|");
- recs[num_recs-1] = strdup(buf);
- modified = 1;
- break;
- case 'd':
- i = intprompt("Delete which one", 1, 1, num_recs) - 1;
- free(recs[i]);
- --num_recs;
- for (j=i; j<num_recs; ++j)
- recs[j] = recs[j+1];
- modified = 1;
- break;
- case 's':
- r = 1;
+ switch (ch) {
+ case 'a':
+ ++num_recs;
+ if (num_recs == 1) {
+ recs = malloc(sizeof(char *));
+ } else {
+ recs = realloc(recs, (sizeof(char *)) * num_recs);
+ }
+ strcpy(buf, "rssclient|");
+ newprompt("Enter feed URL: ", &buf[strlen(buf)], 75);
+ strcat(buf, "|");
+ recs[num_recs - 1] = strdup(buf);
+ modified = 1;
+ break;
+ case 'd':
+ i = intprompt("Delete which one", 1, 1, num_recs) - 1;
+ free(recs[i]);
+ --num_recs;
+ for (j = i; j < num_recs; ++j)
+ recs[j] = recs[j + 1];
+ modified = 1;
+ break;
+ case 's':
+ r = 1;
+ for (i = 0; i < num_recs; ++i) {
+ r += 1 + strlen(recs[i]);
+ }
+ listing = (char *) calloc(1, r);
+ if (!listing) {
+ scr_printf("Can't save config - out of memory!\n");
+ logoff(ipc, 1);
+ }
+ if (num_recs)
for (i = 0; i < num_recs; ++i) {
- r += 1 + strlen(recs[i]);
- }
- listing = (char*) calloc(1, r);
- if (!listing) {
- scr_printf("Can't save config - out of memory!\n");
- logoff(ipc, 1);
- }
- if (num_recs) for (i = 0; i < num_recs; ++i) {
strcat(listing, recs[i]);
strcat(listing, "\n");
}
- /* Retrieve all the *other* records for merging */
- r = CtdlIPCGetRoomNetworkConfig(ipc, &other_listing, buf);
- if (r / 100 == 1) {
- for (i=0; i<num_tokens(other_listing, '\n'); ++i) {
- extract_token(buf, other_listing, i, '\n', sizeof buf);
- if (strncasecmp(buf, "rssclient|", 10)) {
- listing = realloc(listing, strlen(listing) +
- strlen(buf) + 10);
- strcat(listing, buf);
- strcat(listing, "\n");
- }
+ /* Retrieve all the *other* records for merging */
+ r = CtdlIPCGetRoomNetworkConfig(ipc, &other_listing, buf);
+ if (r / 100 == 1) {
+ for (i = 0; i < num_tokens(other_listing, '\n'); ++i) {
+ extract_token(buf, other_listing, i, '\n', sizeof buf);
+ if (strncasecmp(buf, "rssclient|", 10)) {
+ listing = realloc(listing, strlen(listing) + strlen(buf) + 10);
+ strcat(listing, buf);
+ strcat(listing, "\n");
}
}
- free(other_listing);
- r = CtdlIPCSetRoomNetworkConfig(ipc, listing, buf);
- free(listing);
- listing = NULL;
+ }
+ free(other_listing);
+ r = CtdlIPCSetRoomNetworkConfig(ipc, listing, buf);
+ free(listing);
+ listing = NULL;
- if (r / 100 != 4) {
- scr_printf("%s\n", buf);
- } else {
- scr_printf("Wrote %d records.\n", num_recs);
- modified = 0;
- }
- quitting = 1;
- break;
- case 'q':
- quitting = !modified || boolprompt(
- "Quit without saving", 0);
- break;
- default:
- break;
+ if (r / 100 != 4) {
+ scr_printf("%s\n", buf);
+ } else {
+ scr_printf("Wrote %d records.\n", num_recs);
+ modified = 0;
+ }
+ quitting = 1;
+ break;
+ case 'q':
+ quitting = !modified || boolprompt("Quit without saving", 0);
+ break;
+ default:
+ break;
}
} while (!quitting);
if (recs != NULL) {
- for (i=0; i<num_recs; ++i) free(recs[i]);
+ for (i = 0; i < num_recs; ++i)
+ free(recs[i]);
free(recs);
}
}
-
-