Server hacks to allow non-ASCII characters to be carried in
authorArt Cancro <ajc@citadel.org>
Tue, 28 Feb 2006 04:09:00 +0000 (04:09 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 28 Feb 2006 04:09:00 +0000 (04:09 +0000)
instant messages and displayed in certain types of text messages.
This allows UTF-8 and ISO-8859-1 instant messages in WebCit, for
example.

citadel/commands.c
citadel/messages.c
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_chat.c

index 7fdd065781ceb06ae5e15487aa2ad4ba678b8cda..17d3150d40e9f9a81b04a15bc580991a01bbc28c 100644 (file)
@@ -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++;
index 5dd4a02c861e4087b08f6a24f2bbf0bb578ef470..18cebfcdf78deb3b2c96d8a3b2627d0e77e2c2b2 100644 (file)
@@ -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");
index 94784f48ed12d99e5066081e6df85f79573191fe..186391bcdd6f3ed083df467239328b7affd61f59 100644 (file)
@@ -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
index a4f43002e4337e1f9d0f41ed06bc440cf7db26ca..b5ba483f0eab43651a45f67b82ab14aa2e3ef245 100644 (file)
@@ -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);
index ce6f7324b08e7a1a8c2ec5d122368ee8cb4c6758..7bdc4894ef55a2d95624050b0c20e4b79050e1cb 100644 (file)
@@ -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])    /* <bc> */
+               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  <bc>
+ * send instant messages
  */
 void cmd_sexp(char *argbuf)
 {
        int message_sent = 0;
        char x_user[USERNAME_SIZE];
        char x_msg[1024];
-       char *lun;              /* <bc> */
+       char *lun;
        char *x_big_msgbuf = NULL;
 
        if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {