* New "notes" icon
[citadel.git] / webcit / notes.c
index 8fccbdcdffb4df1b0d17b43c0d6598e25961c560..2e6d7ce09e915e796879e1ee4ca2ebe693689a74 100644 (file)
 #include "webserver.h"
 
 void display_note(long msgnum) {
-       wprintf("<TABLE border=2><TR><TD>\n");
-       wprintf("FIXME note #%ld\n", msgnum);
-       wprintf("</TD></TR></TABLE\n");
+       char buf[SIZ];
+       char notetext[SIZ];
+       char display_notetext[SIZ];
+       int in_text = 0;
+       int i;
+
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/note.gif\">\n");
+
+       serv_printf("MSG0 %ld", msgnum);
+       serv_gets(buf);
+       if (buf[0] != '1') {
+               wprintf("%s<BR>\n", &buf[4]);
+               return;
+       }
+
+       strcpy(notetext, "");
+       while (serv_gets(buf), strcmp(buf, "000")) {
+
+               /* Fill the buffer to at least 256 characters */
+               if ( (in_text) && (strlen(notetext) < 256) ) {
+                       strcat(notetext, buf);
+               }
+
+               if ( (!in_text) && (!strcasecmp(buf, "text")) ) {
+                       in_text = 1;
+               }
+       }
+
+       /* Now sanitize the buffer, and shorten it to just a small snippet */
+       for (i=0; i<strlen(notetext); ++i) {
+               if (isspace(notetext[i])) notetext[i] = ' ';
+       }
+       strcpy(&notetext[72], "...");
+
+       /* Make it HTML-happy and print it. */
+       stresc(display_notetext, notetext, 1, 1);
+       wprintf("%s<BR>\n", display_notetext);
 }