summaryrefslogtreecommitdiffstats
path: root/util/userlist.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /util/userlist.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/userlist.c')
-rw-r--r--util/userlist.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/util/userlist.c b/util/userlist.c
new file mode 100644
index 00000000..9a142926
--- /dev/null
+++ b/util/userlist.c
@@ -0,0 +1,48 @@
+/* $id:$ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include "config.h"
+#include "pttstruct.h"
+
+struct utmpfile_t *u;
+
+int main(int argc, char **argv) {
+ int i, shm, counter;
+
+ shm = shmget(UTMPSHM_KEY, USHM_SIZE, SHM_R | SHM_W);
+ if(shm == -1) {
+ perror("shmget");
+ exit(0);
+ }
+
+ u = shmat(shm, NULL, 0);
+ if(u == (struct utmpfile_t *)-1) {
+ perror("shmat");
+ exit(0);
+ }
+
+ if(argc > 1) {
+ for(i = 1; i < argc; i++)
+ u->uinfo[atoi(argv[i])].pid = 0;
+ } else {
+ for(i = counter = 0; i < USHM_SIZE; i++)
+ if(u->uinfo[i].pid) {
+ userinfo_t *f;
+
+ f = &u->uinfo[i];
+ printf(
+ "%4d(%d) p[%d] i[%d] u[%s] n[%s] f[%s] m[%d] d[%d] t[%ld]\n",
+ ++counter, i, f->pager, f->invisible, f->userid,
+ f->username, f->from, f->mode, f->mind, f->lastact);
+ }
+ printf("\nTotal: %d(%d)\n", counter, u->number);
+ if(counter != u->number) {
+ u->number = counter;
+ printf("adjust user number!\n");
+ }
+ }
+ return 0;
+}