diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-06-07 05:35:23 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-06-07 05:35:23 +0800 |
commit | e8fc08b9800ba86163e5bf43469cdc9f4b478b13 (patch) | |
tree | eb2dcd75cad19ac57b7e9d9cc29c63a850d8ad86 /util/userlist.c | |
parent | c0a6419aeceaeb93d5d9ccde393236d67ff8c72f (diff) | |
download | pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.tar pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.tar.gz pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.tar.bz2 pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.tar.lz pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.tar.xz pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.tar.zst pttbbs-e8fc08b9800ba86163e5bf43469cdc9f4b478b13.zip |
only one shared memory
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@296 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/userlist.c')
-rw-r--r-- | util/userlist.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/util/userlist.c b/util/userlist.c index 9a142926..c8d53389 100644 --- a/util/userlist.c +++ b/util/userlist.c @@ -7,40 +7,39 @@ #include "config.h" #include "pttstruct.h" -struct utmpfile_t *u; +SHM_t *SHM; int main(int argc, char **argv) { int i, shm, counter; - shm = shmget(UTMPSHM_KEY, USHM_SIZE, SHM_R | SHM_W); + shm = shmget(SHM_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) { + if( (SHM = shmat(shm, NULL, 0)) < 0 ){ perror("shmat"); exit(0); } if(argc > 1) { for(i = 1; i < argc; i++) - u->uinfo[atoi(argv[i])].pid = 0; + SHM->uinfo[atoi(argv[i])].pid = 0; } else { for(i = counter = 0; i < USHM_SIZE; i++) - if(u->uinfo[i].pid) { + if(SHM->uinfo[i].pid) { userinfo_t *f; - f = &u->uinfo[i]; + f = &SHM->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("\nTotal: %d(%d)\n", counter, SHM->number); + if(counter != SHM->number) { + SHM->number = counter; printf("adjust user number!\n"); } } |