4 * Command-line user list utility.
13 #if TIME_WITH_SYS_TIME
14 # include <sys/time.h>
18 # include <sys/time.h>
24 #include <libcitadel.h>
27 #include "citadel_ipc.h"
28 #include "citadel_dirs.h"
35 void userlist(CtdlIPC
*ipc
) {
43 r
= CtdlIPCUserListing(ipc
, "", &listing
, buf
);
48 printf(" User Name Num L Last Visit Logins Messages\n");
49 printf("------------------------- ----- - ---------- ------ --------\n");
50 while (strlen(listing
) > 0) {
51 extract_token(buf
, listing
, 0, '\n', sizeof buf
);
52 remove_token(listing
, 0, '\n');
53 extract_token(fl
, buf
, 0, '|', sizeof fl
);
55 printf("%5ld %d ", extract_long(buf
,2),
57 lc
= extract_long(buf
,3);
58 localtime_r(&lc
, &tmbuf
);
59 printf("%02d/%02d/%04d ",
62 (tmbuf
.tm_year
+ 1900));
64 extract_long(buf
,4),extract_long(buf
,5));
70 int main(int argc
, char **argv
)
73 char hostbuf
[SIZ
], portbuf
[SIZ
];
77 char relhome
[PATH_MAX
]="";
78 char ctdldir
[PATH_MAX
]=CTDLDIR
;
80 calc_dirs_n_files(relh
, home
, relhome
, ctdldir
, 0);
82 ipc
= CtdlIPC_new(argc
, argv
, hostbuf
, portbuf
);
83 CtdlIPC_chat_recv(ipc
, buf
);
84 if ((buf
[0]!='2')&&(strncmp(buf
,"551",3))) {
85 fprintf(stderr
,"%s: %s\n",argv
[0],&buf
[4]);
98 * replacement strerror() for systems that don't have it
100 char *strerror(int e
)
104 snprintf(buf
, sizeof buf
, "errno = %d",e
);
113 void stty_ctdl(int cmd
) {