From: Art Cancro Date: Tue, 28 Feb 2006 04:09:00 +0000 (+0000) Subject: Server hacks to allow non-ASCII characters to be carried in X-Git-Tag: v7.86~4171 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=af23b68fd136d4815a6eaf5db0893a06bd252a7e Server hacks to allow non-ASCII characters to be carried in instant messages and displayed in certain types of text messages. This allows UTF-8 and ISO-8859-1 instant messages in WebCit, for example. --- diff --git a/citadel/commands.c b/citadel/commands.c index 7fdd06578..17d3150d4 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -495,15 +495,21 @@ int inkey(void) * (There's a hole in the bucket...) */ a = scr_getc(SCR_BLOCK); - if (a == 127) + if (a == 127) { a = 8; - if (a > 126) - a = 0; - if (a == 13) + } + if (a == 13) { a = 10; + } +/* not so fast there dude, we have to handle UTF-8 and ISO-8859-1... + if (a > 126) { + a = 0; + } if (((a != 23) && (a != 4) && (a != 10) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY)) - && ((a < 32) || (a > 126))) + && ((a < 32) || (a > 126))) { a = 0; + } + */ #ifndef DISABLE_CURSES #if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H) @@ -573,8 +579,9 @@ void getline(char *string, int lim) strcpy(string, ""); gl_string = string; async_ka_start(); - GLA:a = inkey(); - a = (a & 127); + +GLA: a = inkey(); + /* a = (a & 127); ** commented out because it isn't just an ASCII world anymore */ if ((a == 8 || a == 23) && (strlen(string) == 0)) goto GLA; if ((a != 10) && (a != 8) && (strlen(string) == lim)) @@ -1370,11 +1377,15 @@ int fmout( old = '\n'; continue; } - /* Are we looking at a nonprintable? */ + + /* 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; - } + } */ + /* Or are we looking at a space? */ if (*e == ' ') { e++; diff --git a/citadel/messages.c b/citadel/messages.c index 5dd4a02c8..18cebfcdf 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -260,12 +260,10 @@ void citedit(CtdlIPC *ipc, FILE * fp) if (a == 127) a = 8; - /******* new ***********/ - if ((a > 32) && (a < 127) && (prev == 13)) { + if ((a != 32) && (prev == 13)) { add_word(textlist, "\n"); scr_printf(" "); } - /***********************/ if ((a == 32) && (prev == 13)) { add_word(textlist, "\n"); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 94784f48e..186391bcd 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -751,7 +751,6 @@ void do_help_subst(char *buffer) * to the client. The client software may reformat it again. */ void memfmout( - int width, /* screen width to use */ char *mptr, /* where are we going to get our text from? */ char subst, /* nonzero if we should do substitutions */ char *nl) /* string to terminate lines with */ @@ -762,6 +761,7 @@ void memfmout( cit_uint8_t ch; char aaa[140]; char buffer[SIZ]; + static int width = 80; strcpy(aaa, ""); old = 255; @@ -789,15 +789,13 @@ void memfmout( old = real; real = ch; - if (((ch == 13) || (ch == 10)) && (old != 13) && (old != 10)) + if (((ch == 13) || (ch == 10)) && (old != 13) && (old != 10)) { ch = 32; + } if (((old == 13) || (old == 10)) && (isspace(real))) { cprintf("%s", nl); c = 1; } - if (ch > 126) - continue; - if (ch > 32) { if (((strlen(aaa) + c) > (width - 5)) && (strlen(aaa) > (width - 5))) { cprintf("%s%s", nl, aaa); @@ -1682,7 +1680,7 @@ START_TEXT: if (mode == MT_MIME) { cprintf("Content-type: text/x-citadel-variformat\n\n"); } - memfmout(80, mptr, 0, nl); + memfmout(mptr, 0, nl); } /* If the message on disk is format 4 (MIME), we've gotta hand it diff --git a/citadel/msgbase.h b/citadel/msgbase.h index a4f43002e..b5ba483f0 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -78,7 +78,7 @@ void cmd_msgs (char *cmdbuf); void cmd_isme (char *cmdbuf); void help_subst (char *strbuf, char *source, char *dest); void do_help_subst (char *buffer); -void memfmout (int width, char *mptr, char subst, char *nl); +void memfmout (char *mptr, char subst, char *nl); void output_mime_parts(char *); void cmd_msg0 (char *cmdbuf); void cmd_msg2 (char *cmdbuf); diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index ce6f7324b..7bdc4894e 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -456,7 +456,7 @@ void cmd_pexp(char *argbuf) cprintf("Message "); cprintf("from %s:\n", ptr->sender); if (ptr->text != NULL) - memfmout(80, ptr->text, 0, "\n"); + memfmout(ptr->text, 0, "\n"); holdptr = ptr->next; if (ptr->text != NULL) free(ptr->text); @@ -486,15 +486,18 @@ void cmd_gexp(char *argbuf) { cprintf("%d %d|%ld|%d|%s|%s\n", LISTING_FOLLOWS, ((ptr->next != NULL) ? 1 : 0), /* more msgs? */ - (long)ptr->timestamp, /* time sent */ + (long)ptr->timestamp, /* time sent */ ptr->flags, /* flags */ ptr->sender, /* sender of msg */ - config.c_nodename); /* static for now */ + config.c_nodename /* static for now */ + ); + if (ptr->text != NULL) { - memfmout(80, ptr->text, 0, "\n"); + memfmout(ptr->text, 0, "\n"); if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n"); free(ptr->text); - } + } + cprintf("000\n"); free(ptr); } @@ -554,7 +557,6 @@ void add_xmsg_to_context(struct CitContext *ccptr, int send_instant_message(char *lun, char *x_user, char *x_msg) { int message_sent = 0; /* number of successful sends */ - struct CitContext *ccptr; struct ExpressMessage *newmsg; char *un; @@ -570,16 +572,18 @@ int send_instant_message(char *lun, char *x_user, char *x_msg) if (strlen(x_msg) > 0) { msglen = strlen(x_msg) + 4; do_send = 1; - } + } /* find the target user's context and append the message */ begin_critical_section(S_SESSION_TABLE); for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) { - if (ccptr->fake_username[0]) /* */ + if (ccptr->fake_username[0]) { un = ccptr->fake_username; - else + } + else { un = ccptr->user.fullname; + } if ( ((!strcasecmp(un, x_user)) || (!strcasecmp(x_user, "broadcast"))) @@ -662,14 +666,14 @@ int send_instant_message(char *lun, char *x_user, char *x_msg) } /* - * send instant messages + * send instant messages */ void cmd_sexp(char *argbuf) { int message_sent = 0; char x_user[USERNAME_SIZE]; char x_msg[1024]; - char *lun; /* */ + char *lun; char *x_big_msgbuf = NULL; if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {