+ /* Combine multiple sessions for the same user */
+ if (condense) {
+ qsort(sortbuf, rows, SIZ, rwho_username_cmp);
+ if (rows > 1) for (i=1; i<rows; ++i) if (i>0) {
+ char u1[USERNAME_SIZE];
+ char u2[USERNAME_SIZE];
+ extract_token(u1, &sortbuf[(i-1)*SIZ], 1, '|', sizeof u1);
+ extract_token(u2, &sortbuf[i*SIZ], 1, '|', sizeof u2);
+ if (!strcasecmp(u1, u2)) {
+ memcpy(&sortbuf[i*SIZ], &sortbuf[(i+1)*SIZ], (rows-i-1)*SIZ);
+ --rows;
+ --i;
+ }
+ }
+
+ qsort(sortbuf, rows, SIZ, idlecmp); /* idle sort again */
+ }
+