/*
+ * $Id$
+ *
* Citadel/UX message support routines
* see copyright.txt for copyright information
- * $Id$
*/
#include "sysdep.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
-#include <time.h>
#include <signal.h>
#include <errno.h>
#include <limits.h>
#include <sys/wait.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <stdarg.h>
#include "citadel.h"
#include "messages.h"
};
void sttybbs(int cmd);
-int struncmp(char *lstr, char *rstr, int len);
int fmout(int width, FILE *fp, char pagin, int height, int starting_lp, char subst);
int haschar(char *st, int ch);
int checkpagin(int lp, int pagin, int height);
extern int editor_pid;
-int lines_printed;
-
void ka_sigcatch(int signum) {
char buf[256];
alarm(S_KEEPALIVE);
add_word(textlist,"\n");
add_newline(textlist);
add_word(textlist,"");
- }
}
+ }
else {
wordbuf[strlen(wordbuf)+1] = 0;
wordbuf[strlen(wordbuf)] = a;
- }
+ }
if (strlen(wordbuf)+3 > screenwidth) {
add_word(textlist,wordbuf);
strcpy(wordbuf,"");
- }
- prev = a;
}
+ prev = a;
+ }
/* get text */
finished = 0;
if (a==10) a=13;
if (a==9) a=32;
if (a==127) a=8;
+
+
+ /******* new ***********/
+ if ((a>32)&&(a<127)&&(prev==13)) {
+ add_word(textlist,"\n");
+ printf(" ");
+ }
+ /***********************/
+
if ((a==32)&&(prev==13)) {
add_word(textlist,"\n");
add_newline(textlist);
- }
+ }
+
if (a==8) {
if (strlen(wordbuf)>0) {
wordbuf[strlen(wordbuf)-1] = 0;
putc(8,stdout);
putc(32,stdout);
putc(8,stdout);
- }
}
+ }
else if (a==13) {
printf("\n");
if (strlen(wordbuf)==0) finished = 1;
add_word(textlist,wordbuf);
strcpy(wordbuf,&wordbuf[b+1]);
b=0;
- }
+ }
add_word(textlist,wordbuf);
strcpy(wordbuf,"");
- }
}
+ }
else {
putc(a,stdout);
wordbuf[strlen(wordbuf)+1] = 0;
wordbuf[strlen(wordbuf)] = a;
- }
+ }
if ((strlen(wordbuf)+3) > screenwidth) {
last_space = (-1);
for (b=0; b<strlen(wordbuf); ++b)
add_word(textlist,wordbuf);
strcpy(wordbuf,&wordbuf[b+1]);
b=0;
- }
+ }
for (b=0; b<strlen(wordbuf); ++b) {
putc(8,stdout);
putc(32,stdout);
putc(8,stdout);
- }
- printf("\n%s",wordbuf);
}
+ printf("\n%s",wordbuf);
+ }
else {
add_word(textlist,wordbuf);
strcpy(wordbuf,"");
printf("\n");
- }
}
+ }
prev = a;
- } while (finished==0);
+ } while (finished==0);
async_ka_end();
/* write the buffer back to disk */
ptr=textlist->next;
free(textlist);
textlist=ptr;
- }
}
+}
int read_message(long int num, char pagin) /* Read a message from the server */
{
char buf[256];
char m_subject[256];
- char from[256];
- time_t now;
- struct tm *tm;
+ char from[256], node[256], rfca[256];
+ char now[256];
int format_type = 0;
int fr = 0;
int nhdr = 0;
- int have_rfca = 0;
sigcaught = 0;
sttybbs(1);
strcpy(m_subject,"");
strcpy(reply_to, "nobody ... xxxxx");
+ strcpy(from, "");
+ strcpy(node, "");
+ strcpy(rfca, "");
+
printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed,pagin,screenheight);
return(0);
}
- while(serv_gets(buf), struncmp(buf,"text",4)) {
- if (!struncmp(buf,"nhdr=yes",8)) nhdr=1;
- if (!struncmp(buf,"from=",5)) {
+ while(serv_gets(buf), strncasecmp(buf,"text",4)) {
+ if (!strncasecmp(buf,"nhdr=yes",8)) nhdr=1;
+ if (!strncasecmp(buf,"from=",5)) {
strcpy(from,&buf[5]);
}
if (nhdr==1) buf[0]='_';
- if (!struncmp(buf,"type=",5))
+ if (!strncasecmp(buf,"type=",5))
format_type=atoi(&buf[5]);
- if ((!struncmp(buf,"msgn=",5))&&(rc_display_message_numbers)) {
+ if ((!strncasecmp(buf,"msgn=",5))&&(rc_display_message_numbers)) {
color(DIM_WHITE);
printf("[");
color(BRIGHT_WHITE);
color(DIM_WHITE);
printf("] ");
}
- if (!struncmp(buf,"from=",5)) {
+ if (!strncasecmp(buf,"from=",5)) {
color(DIM_WHITE);
printf("from ");
color(BRIGHT_CYAN);
printf("%s ",&buf[5]);
}
- if (!struncmp(buf,"subj=",5))
+ if (!strncasecmp(buf,"subj=",5))
strcpy(m_subject,&buf[5]);
- if (!struncmp(buf,"rfca=",5)) {
- strcpy(reply_to, &buf[5]);
- have_rfca = 1;
+ if (!strncasecmp(buf,"rfca=",5)) {
+ safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
color(DIM_WHITE);
printf("<");
color(BRIGHT_BLUE);
color(DIM_WHITE);
printf("> ");
}
- if ((!struncmp(buf,"hnod=",5))
- && (strucmp(&buf[5],serv_info.serv_humannode))
- && (have_rfca == 0) ) {
+ if ((!strncasecmp(buf,"hnod=",5))
+ && (strcasecmp(&buf[5],serv_info.serv_humannode))
+ && (strlen(rfca) == 0) ) {
color(DIM_WHITE);
printf("(");
color(BRIGHT_WHITE);
color(DIM_WHITE);
printf(") ");
}
- if ((!struncmp(buf,"room=",5))
- && (strucmp(&buf[5],room_name))
- && (have_rfca == 0)) {
+ if ((!strncasecmp(buf,"room=",5))
+ && (strcasecmp(&buf[5],room_name))
+ && (strlen(rfca) == 0)) {
color(DIM_WHITE);
printf("in ");
color(BRIGHT_MAGENTA);
printf("%s> ",&buf[5]);
}
- if (!struncmp(buf,"node=",5)) {
+ if (!strncasecmp(buf,"node=",5)) {
+ safestrncpy(node, &buf[5], sizeof(buf) - 5);
if ( (room_flags&QR_NETWORK)
- || ((strucmp(&buf[5],serv_info.serv_nodename)
- &&(strucmp(&buf[5],serv_info.serv_fqdn)))) )
+ || ((strcasecmp(&buf[5],serv_info.serv_nodename)
+ &&(strcasecmp(&buf[5],serv_info.serv_fqdn)))) )
{
- if (have_rfca == 0) {
+ if (strlen(rfca) == 0) {
color(DIM_WHITE);
printf("@");
color(BRIGHT_YELLOW);
printf("%s ",&buf[5]);
}
}
- if (have_rfca == 0) {
- if ((!strucmp(&buf[5],serv_info.serv_nodename))
- ||(!strucmp(&buf[5],serv_info.serv_fqdn)))
- {
- strcpy(reply_to,from);
- }
- }
- else {
- sprintf(reply_to,"%s @ %s",from,&buf[5]);
- }
- }
+ }
- if (!struncmp(buf,"rcpt=",5)) {
+ if (!strncasecmp(buf,"rcpt=",5)) {
color(DIM_WHITE);
printf("to ");
color(BRIGHT_CYAN);
printf("%s ",&buf[5]);
}
- if (!struncmp(buf,"time=",5)) {
- now=atol(&buf[5]);
- tm=(struct tm *)localtime(&now);
- strcpy(buf,asctime(tm)); buf[strlen(buf)-1]=0;
- strcpy(&buf[16],&buf[19]);
- color(BRIGHT_MAGENTA);
- printf("%s ",&buf[4]);
+ if (!strncasecmp(buf,"time=",5)) {
+ fmt_date(now, atol(&buf[5]));
+ printf("%s ", now);
}
}
}
}
printf("\n");
+
+ if (strlen(rfca) > 0) {
+ strcpy(reply_to, rfca);
+ }
+ else {
+ snprintf(reply_to, sizeof(reply_to), "%s @ %s", from, node);
+ }
+
if (pagin == 1) color(BRIGHT_WHITE);
++lines_printed;
lines_printed = checkpagin(lines_printed,pagin,screenheight);
buf[strlen(buf)] = a;
if ( strlen(buf) >= strlen(srch_str) ) {
ptr=&buf[strlen(buf)-strlen(srch_str)];
- if (!struncmp(ptr,srch_str,strlen(srch_str))) {
+ if (!strncasecmp(ptr,srch_str,strlen(srch_str))) {
strcpy(ptr,rplc_str);
++substitutions;
}
{
FILE *fp;
int a,b,e_ex_code;
- time_t now;
long beg;
char datestr[64];
int cksum = 0;
mode=0;
}
- time(&now);
- strcpy(datestr,asctime(localtime(&now)));
- datestr[strlen(datestr)-1] = 0;
+ fmt_date(datestr, time(NULL));
if (room_flags & QR_ANONONLY) {
printf(" ****");
color(DIM_WHITE);
printf(") ");
- if (is_mail==1) keyopt("<R>eply ");
- keyopt("<B>ack <A>gain <Q>uote <N>ext <S>top ");
+ keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top ");
if (rc_url_cmd[0] && num_urls) keyopt("<U>RL View ");
keyopt("<?>Help/others -> ");
if ((e=='d')||(e=='m')||(e=='c')) e=0;
}
/* print only if available */ if ((e=='p')&&(strlen(printcmd)==0)) e=0;
-/* can't reply in public rms */ if ((e=='r')&&(is_mail!=1)) e=0;
/* can't file if not allowed */ if ((e=='f')&&(rc_allow_attachments==0)) e=0;
/* link only if browser avail*/ if ((e=='u')&&(strlen(rc_url_cmd)==0)) e=0;
} while((e!='a')&&(e!='n')&&(e!='s')