From 2cd5cf763302ab3aeaff98e84cf2df7ee48a7272 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 31 Aug 2008 15:37:29 +0000 Subject: [PATCH] * clean some memleaks * prune static who code * add summary wholist templates --- webcit/messages.c | 1 + webcit/paging.c | 3 +- webcit/static/t/who.html | 4 +++ webcit/static/t/wholiststatic.html | 4 --- webcit/static/t/wholistsummarysection.html | 9 ++++++ webcit/static/t/whosection.html | 2 +- webcit/static/t/whosimplesection.html | 2 +- webcit/static/t/whosummarysection.html | 20 ++++++++++++ webcit/summary.c | 4 +-- webcit/webcit.c | 4 --- webcit/webcit.h | 2 +- webcit/who.c | 36 ++++++++++++---------- 12 files changed, 60 insertions(+), 31 deletions(-) create mode 100644 webcit/static/t/wholistsummarysection.html create mode 100644 webcit/static/t/whosummarysection.html diff --git a/webcit/messages.c b/webcit/messages.c index fb2ccc8b2..087ecea65 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -3203,6 +3203,7 @@ void post_message(void) ChrPtr(Wikipage), ChrPtr(my_email_addr), ChrPtr(references)); + FreeStrBuf(&references); lprintf(9, "%s\n", CmdBuf); serv_puts(ChrPtr(CmdBuf)); diff --git a/webcit/paging.c b/webcit/paging.c index e2dd90bb4..b36375d87 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -35,6 +35,7 @@ void display_page(void) wprintf("
\n"); wprintf("\n", WC->nonce); + wprintf("\n"); wprintf(" diff --git a/webcit/static/t/whosimplesection.html b/webcit/static/t/whosimplesection.html index fe72e61b1..dee4e3e19 100644 --- a/webcit/static/t/whosimplesection.html +++ b/webcit/static/t/whosimplesection.html @@ -1 +1 @@ -
  • activeuserinactiveuser">">
  • +
  • activeuserinactiveuser">">
  • diff --git a/webcit/static/t/whosummarysection.html b/webcit/static/t/whosummarysection.html new file mode 100644 index 000000000..79ef5f4c1 --- /dev/null +++ b/webcit/static/t/whosummarysection.html @@ -0,0 +1,20 @@ + + + + + + + diff --git a/webcit/summary.c b/webcit/summary.c index ce67551c5..9f673649b 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -216,7 +216,7 @@ void summary_inner_div(void) { wprintf(_("Who's online now")); wprintf("
    "); wprintf("
    "); - who_inner_div(); + do_template("wholistsummarysection", NULL); wprintf("
    "); wprintf(""); @@ -280,7 +280,7 @@ void summary(void) { " { method: 'get', frequency: 120 } ); " " new Ajax.PeriodicalUpdater('calendar_inner', 'calendar_inner_html', " " { method: 'get', frequency: 90 } ); " - " new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html', " + " new Ajax.PeriodicalUpdater('do_template', 'template=wholistsummarysection', " " { method: 'get', frequency: 30 } ); " " \n" ); diff --git a/webcit/webcit.c b/webcit/webcit.c index a0cc93a60..ebaf0c82e 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -956,13 +956,11 @@ void mimepart(const char *msgnum, const char *partnum, int force_download) char buf[256]; off_t bytes; char content_type[256]; - char *content = NULL; serv_printf("OPNA %s|%s", msgnum, partnum); serv_getln(buf, sizeof buf); if (buf[0] == '2') { bytes = extract_long(&buf[4], 0); - content = malloc(bytes + 2); if (force_download) { strcpy(content_type, "application/octet-stream"); } @@ -982,7 +980,6 @@ void mimepart(const char *msgnum, const char *partnum, int force_download) wprintf(_("An error occurred while retrieving this part: %s\n"), &buf[4]); end_burst(); } - } @@ -1011,7 +1008,6 @@ char *load_mimepart(long msgnum, char *partnum) else { return(NULL); } - } diff --git a/webcit/webcit.h b/webcit/webcit.h index aa9e11b54..c71fa59cc 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -558,7 +558,6 @@ void _fmout(StrBuf *Targt, char *align); void pullquote_fmout(void); void wDumpContent(int); - /* These may return NULL if not foud */ #define sbstr(a) SBstr(a, sizeof(a) - 1) const StrBuf *SBSTR(const char *key); @@ -677,6 +676,7 @@ void SVPUTBuf(const char *keyname, int keylen, StrBuf *Buf, int ref); void DoTemplate(const char *templatename, long len, void *Context, StrBuf *Target); #define do_template(a, b) DoTemplate(a, sizeof(a) -1, b, NULL); +void url_do_template(void); int lingering_close(int fd); diff --git a/webcit/who.c b/webcit/who.c index 0cffbebde..a57a3f20b 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -111,19 +111,18 @@ int GetWholistSection(HashList *List, time_t now) /* * Display inner div of Wholist - */ + * / void who_inner_div(void) { UserStateStruct *User; void *VUser; char buf[SIZ]; - struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */ + struct wcsession *WCC = WC; HashList *List; HashPos *it; const char *UserName; long len; time_t now; int bg = 0; - wprintf("
    \n"); @@ -93,7 +94,7 @@ void page_user(void) } } - who(); + url_do_template(); } diff --git a/webcit/static/t/who.html b/webcit/static/t/who.html index 3dcf42088..98c168989 100644 --- a/webcit/static/t/who.html +++ b/webcit/static/t/who.html @@ -23,5 +23,9 @@ return confirm('');
    + diff --git a/webcit/static/t/wholiststatic.html b/webcit/static/t/wholiststatic.html index a79eb07f2..8b72cac6e 100644 --- a/webcit/static/t/wholiststatic.html +++ b/webcit/static/t/wholiststatic.html @@ -15,8 +15,4 @@ (p) - diff --git a/webcit/static/t/wholistsummarysection.html b/webcit/static/t/wholistsummarysection.html new file mode 100644 index 000000000..fd0c05aa9 --- /dev/null +++ b/webcit/static/t/wholistsummarysection.html @@ -0,0 +1,9 @@ + + + + + + + + +
    diff --git a/webcit/static/t/whosection.html b/webcit/static/t/whosection.html index b28f86910..9a9f0f7c4 100644 --- a/webcit/static/t/whosection.html +++ b/webcit/static/t/whosection.html @@ -1,7 +1,7 @@
    - + ()
    "> + (p) + + (<?_(s )" border="0" /> + (<?_()" border="0" /> + + +"> +[] + + + +
    +
    " "\n"); wprintf("\n"); @@ -165,7 +164,7 @@ void who_inner_div(void) { } wprintf(""); - /* (link to page this user) */ + / * (link to page this user) * / wprintf(""); - /* (idle flag) */ + / * (idle flag) * / wprintf("\n\n\t\n\t
    UserName); wprintf("\">" @@ -175,7 +174,7 @@ void who_inner_div(void) { " border=\"0\" /> "); wprintf(""); if (User->Idle) { wprintf(" " @@ -196,7 +195,7 @@ void who_inner_div(void) { } wprintf(""); - /* username (link to user bio/photo page) */ + / * username (link to user bio/photo page) * / wprintf("UserName); wprintf("\">"); @@ -205,7 +204,7 @@ void who_inner_div(void) { wprintf(" [%d] ", User->SessionCount); wprintf(""); - /* room */ + / * room * / wprintf(""); StrEscPuts(User->Room); if (StrLength(User->RealRoom) > 0) { @@ -215,7 +214,7 @@ void who_inner_div(void) { } wprintf(""); - /* hostname */ + / * hostname * / StrEscPuts(User->Host); if (StrLength(User->RealHost) > 0) { wprintf("
    "); @@ -228,13 +227,13 @@ void who_inner_div(void) { } wprintf("
    "); DeleteHash(&List); - } +*/ /* * Display a list of users currently logged in to the system - */ + * / void who(void) { char title[256]; @@ -279,13 +278,13 @@ void who(void) ); wprintf("\n"); - /* + / * * JavaScript to make the ajax refresh happen: * See http://www.sergiopereira.com/articles/prototype.js.html for info on Ajax.PeriodicalUpdater * It wants: 1. The div being updated * 2. The URL of the update source * 3. Other flags (such as the HTTP method and the refresh frequency) - */ + * / wprintf( "