Tree @upstream/7.37 (Download .tar.gz)
- autom4te.cache
- contrib
- docs
- help
- include
- messages
- modules
- network
- openldap
- techdoc
- .svnignore
- acinclude.m4
- aclocal.m4
- aidepost.c
- auth.c
- auth.h
- axdefs.h
- base64.c
- bootstrap
- buildpackages
- chkpw.c
- chkpwd.c
- citadel-slapd.conf
- citadel.c
- citadel.h
- citadel.nsi
- citadel.pam
- citadel.rc
- citadel_decls.h
- citadel_dirs.c
- citadel_dirs.h
- citadel_ipc.c
- citadel_ipc.h
- citmail.c
- citserver.c
- citserver.h
- client_chat.c
- client_chat.h
- client_passwords.c
- client_passwords.h
- clientsocket.c
- clientsocket.h
- commands.c
- commands.h
- config.c
- config.guess
- config.h
- config.sub
- configure
- configure.ac
- control.c
- control.h
- COPYING
- crc16.c
- crc16.h
- database.h
- database_cleanup.sh.in
- database_sleepycat.c
- domain.c
- domain.h
- ecrash.c
- ecrash.h
- euidindex.c
- euidindex.h
- file_ops.c
- file_ops.h
- genstamp.c
- genstamp.h
- getmail.c
- getutline.c
- housekeeping.c
- housekeeping.h
- ical_dezonify.c
- ical_dezonify.h
- imap_tools.h
- install-sh
- internet_addressing.c
- internet_addressing.h
- internetmail.h
- ipc_c_tcp.c
- ipcdef.h
- journaling.c
- journaling.h
- locate_host.c
- locate_host.h
- loginwrapper.sh
- Makefile.in
- md5.c
- md5.h
- messages.c
- messages.h
- migrate_aliases.sh
- missing
- mk_module_init.sh
- mk_svn_revision.sh
- mkinstalldirs
- msgbase.c
- msgbase.h
- msgform.c
- packageversion
- parsedate.c
- parsedate.h
- parsedate.y
- policy.c
- policy.h
- public_clients
- README.txt
- room_ops.c
- room_ops.h
- rooms.c
- rooms.h
- routines.c
- routines.h
- routines2.c
- routines2.h
- screen.c
- screen.h
- sendcommand.c
- sendwelcomemail.sh
- serv_extensions.c
- serv_extensions.h
- serv_network.h
- serv_sieve.h
- serv_vcard.h
- server.h
- server_main.c
- setup.c
- snprintf.c
- snprintf.h
- stress.c
- support.c
- support.h
- svn_revision.c
- svn_revision.h
- sysconfig.h
- sysdep.c
- sysdep.h.in
- sysdep_decls.h
- threads.c
- threads.h
- tuiconfig.c
- tuiconfig.h
- typesize.h
- user_ops.c
- user_ops.h
- userlist.c
- whobbs.c
userlist.c @upstream/7.37 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /* * $Id: userlist.c 5952 2008-01-17 20:29:27Z ajc $ * * Command-line user list utility. * */ #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <string.h> #if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else # if HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> # endif #endif #include <libcitadel.h> #include "citadel.h" #include <unistd.h> #include "citadel_ipc.h" #include "citadel_dirs.h" void logoff(int code) { exit(code); } void userlist(CtdlIPC *ipc) { char buf[SIZ]; char fl[SIZ]; struct tm tmbuf; time_t lc; char *listing = NULL; int r; r = CtdlIPCUserListing(ipc, "", &listing, buf); if (r / 100 != 1) { printf("%s\n", buf); return; } printf(" User Name Num L Last Visit Logins Messages\n"); printf("------------------------- ----- - ---------- ------ --------\n"); while (strlen(listing) > 0) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); extract_token(fl, buf, 0, '|', sizeof fl); printf("%-25s ",fl); printf("%5ld %d ", extract_long(buf,2), extract_int(buf,1)); lc = extract_long(buf,3); localtime_r(&lc, &tmbuf); printf("%02d/%02d/%04d ", (tmbuf.tm_mon+1), tmbuf.tm_mday, (tmbuf.tm_year + 1900)); printf("%6ld %8ld\n", extract_long(buf,4),extract_long(buf,5)); } printf("\n"); } int main(int argc, char **argv) { char buf[SIZ]; char hostbuf[SIZ], portbuf[SIZ]; CtdlIPC *ipc = NULL; int relh=0; int home=0; char relhome[PATH_MAX]=""; char ctdldir[PATH_MAX]=CTDLDIR; calc_dirs_n_files(relh, home, relhome, ctdldir, 0); ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf); CtdlIPC_chat_recv(ipc, buf); if ((buf[0]!='2')&&(strncmp(buf,"551",3))) { fprintf(stderr,"%s: %s\n",argv[0],&buf[4]); logoff(atoi(buf)); } userlist(ipc); CtdlIPCQuit(ipc); exit(0); } #ifndef HAVE_STRERROR /* * replacement strerror() for systems that don't have it */ char *strerror(int e) { static char buf[32]; snprintf(buf, sizeof buf, "errno = %d",e); return(buf); } #endif |