Done with doxygenizing
[citadel.git] / webcit / notes.c
1 /*
2  * $Id$
3  */
4 /**
5  * \defgroup StickyNotes Functions which handle "sticky notes"
6  *
7  */
8 /*@{*/
9 #include "webcit.h"
10 #include "webserver.h"
11
12 /**
13  * \brief display sticky notes
14  * \param msgnum the citadel mesage number
15  */
16 void display_note(long msgnum) {
17         char buf[SIZ];
18         char notetext[SIZ];
19         char display_notetext[SIZ];
20         int in_text = 0;
21         int i;
22
23         wprintf("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">\n");
24
25         serv_printf("MSG0 %ld", msgnum);
26         serv_getln(buf, sizeof buf);
27         if (buf[0] != '1') {
28                 wprintf("%s<br />\n", &buf[4]);
29                 return;
30         }
31
32         strcpy(notetext, "");
33         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
34
35                 /** Fill the buffer to at least 256 characters */
36                 if ( (in_text) && (strlen(notetext) < 256) ) {
37                         strcat(notetext, buf);
38                 }
39
40                 if ( (!in_text) && (!strcasecmp(buf, "text")) ) {
41                         in_text = 1;
42                 }
43         }
44
45         /** Now sanitize the buffer, and shorten it to just a small snippet */
46         for (i=0; i<strlen(notetext); ++i) {
47                 if (isspace(notetext[i])) notetext[i] = ' ';
48         }
49         strcpy(&notetext[72], "...");
50
51         /** Make it HTML-happy and print it. */
52         stresc(display_notetext, notetext, 1, 1);
53         wprintf("%s<br />\n", display_notetext);
54 }
55
56
57 /*@}*/