From f64cb93dd34d9b1b129e6e367f067d943b2b7234 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 16 Jun 2003 04:39:45 +0000 Subject: [PATCH] * support.c: removed an unused variable * citadel.c: sort wholist by idle time (most recently active users first) --- citadel/ChangeLog | 5 +++++ citadel/citadel.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ citadel/support.c | 1 - 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index e97204972..07b6ebb54 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 607.1 2003/06/16 04:39:45 ajc + * support.c: removed an unused variable + * citadel.c: sort wholist by idle time (most recently active users first) + Revision 607.0 2003/06/10 04:15:39 ajc * THIS IS 6.07 @@ -4760,3 +4764,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.c b/citadel/citadel.c index 5b374218d..78a9ccb2a 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -773,6 +773,61 @@ void get_serv_info(CtdlIPC *ipc, char *supplied_hostname) +/* + * Record compare function for SortOnlineUsers() + */ +int idlecmp(const void *rec1, const void *rec2) { + time_t i1, i2; + + i1 = extract_long(rec1, 5); + i2 = extract_long(rec2, 5); + + if (i1 < i2) return(1); + if (i1 > i2) return(-1); + return(0); +} + + +/* + * Sort the list of online users by idle time. + * This function frees the supplied buffer, and returns a new one + * to the caller. The caller is responsible for freeing the returned buffer. + */ +char *SortOnlineUsers(char *listing) { + int rows; + char *sortbuf; + char *retbuf; + char buf[SIZ]; + int i; + + rows = num_tokens(listing, '\n'); + sortbuf = malloc(rows * SIZ); + if (sortbuf == NULL) return(listing); + retbuf = malloc(rows * SIZ); + if (retbuf == NULL) { + free(sortbuf); + return(listing); + } + + /* Copy the list into a fixed-record-size array for sorting */ + for (i=0; i 0) { int isidle = 0; diff --git a/citadel/support.c b/citadel/support.c index 855c9ad4c..f7f17f7f8 100644 --- a/citadel/support.c +++ b/citadel/support.c @@ -112,7 +112,6 @@ void mesg_locate(char *targ, size_t n, const char *searchfor, int a; char buf[SIZ]; struct stat test; - FILE *ls; for (a=0; a