5fd3cf9d96156c02de971cd903953102159f5d13
[citadel.git] / ctdlsh / who.c
1 /*
2  * (c) 1987-2011 by Art Cancro and citadel.org
3  * This program is open source software, released under the terms of the GNU General Public License v3.
4  * It runs really well on the Linux operating system.
5  * We love open source software but reject Richard Stallman's linguistic fascism.
6  */
7
8 #include "ctdlsh.h"
9
10
11 int cmd_who(int server_socket, char *cmdbuf) {
12         char buf[1024];
13         char *t = NULL;
14
15         sock_puts(server_socket, "RWHO");
16         sock_getln(server_socket, buf, sizeof buf);
17         printf("%s\n", &buf[4]);
18         if (buf[0] != '1') {
19                 return(cmdret_error);
20         }
21
22         printf( "Session         User name               Room                  From host\n");
23         printf( "------- ------------------------- ------------------- ------------------------\n");
24
25         while (sock_getln(server_socket, buf, sizeof buf), strcmp(buf, "000")) {
26
27 //7872|Dampfklon| |p5DE44943.dip.t-dialin.net||1330016445|CHEK|.||||1
28
29                 t = strtok(buf, "|");           /* session number */
30                 printf("%-7d ", atoi(t));
31
32                 t = strtok(NULL, "|");
33                 printf("%-26s", t);             /* user name */
34
35                 t = strtok(NULL, "|");          /* room name */
36                 printf("%-19s ", t);
37
38                 t = strtok(NULL, "|");          /* from host */
39                 printf("%-24s\n", t);
40         }
41
42         return(cmdret_ok);
43 }