Mailing list header changes (fuck you Google)
[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 {
13         char buf[1024];
14         char *t = NULL;
15
16         sock_puts(server_socket, "RWHO");
17         sock_getln(server_socket, buf, sizeof buf);
18         printf("%s\n", &buf[4]);
19         if (buf[0] != '1') {
20                 return (cmdret_error);
21         }
22
23         printf("Session         User name               Room                  From host\n");
24         printf("------- ------------------------- ------------------- ------------------------\n");
25
26         while (sock_getln(server_socket, buf, sizeof buf), strcmp(buf, "000")) {
27
28 //7872|Dampfklon| |p5DE44943.dip.t-dialin.net||1330016445|CHEK|.||||1
29
30                 t = strtok(buf, "|");   /* session number */
31                 printf("%-7d ", atoi(t));
32
33                 t = strtok(NULL, "|");
34                 printf("%-26s", t);     /* user name */
35
36                 t = strtok(NULL, "|");  /* room name */
37                 printf("%-19s ", t);
38
39                 t = strtok(NULL, "|");  /* from host */
40                 printf("%-24s\n", t);
41         }
42
43         return (cmdret_ok);
44 }